VPI - Vision Programming Interface

3.2 Release

DCF tracker

Overview

This application tracks bounding boxes on an input video, draws them on each frame, and saves the result in a sequence of image files. You can define which backend will be used for processing.

It serves as simple example (or skeleton) of how the DCF Tracker algorithm can be implemented in a pipeline.

Note
The sample implements a simplistic tracking pipeline using poor tracking quality. For production-grade tracking quality, you must implement proper object lifetime management and bounding box refinement stages in the code section named "Custom target update".

Instructions

The command line parameters are:

./vpi_sample_19_dcf_tracker <backend> <input video> <input bboxes>

where

  • backend: either cuda or pva; it defines the backend that will perform the processing.
  • input video: input video file name, it accepts all video types that OpenCV's cv::VideoCapture accepts.
  • input bboxes: file with input bounding boxes and in what frame they appear. The file is composed of multiple lines with the following format:
      <target_id> <frame> <bbox_x> <bbox_y> <bbox_width> <bbox_height>

Here's one example:

  • C++
    ./vpi_sample_19_dcf_tracker cuda ../assets/pedestrians.mp4 ../assets/pedestrians_bboxes.txt

This is using the CUDA backend and one of the provided sample videos and bounding boxes. It'll render the tracked bounding boxes into a sequence of images that are then saved to disk.

Results

Simple Tracking Result
Note
Video output requires HTML5-capable browser that supports H.264 mp4 video decoding.

Source Code

For convenience, here's the code that is also installed in the samples directory.

Language:
29 #include <opencv2/core.hpp>
30 #include <opencv2/features2d.hpp>
31 #include <opencv2/imgcodecs.hpp>
32 #include <opencv2/imgproc.hpp>
33 #include <opencv2/videoio.hpp>
34 #include <vpi/OpenCVInterop.hpp>
35 
36 #include <vpi/Array.h>
37 #include <vpi/Image.h>
38 #include <vpi/Pyramid.h>
39 #include <vpi/Status.h>
40 #include <vpi/Stream.h>
42 #include <vpi/algo/CropScaler.h>
43 #include <vpi/algo/DCFTracker.h>
44 
45 #include <cmath>
46 #include <cstdio>
47 #include <cstring>
48 #include <fstream>
49 #include <iostream>
50 #include <list>
51 #include <map>
52 #include <numeric>
53 #include <optional>
54 #include <sstream>
55 #include <vector>
56 
57 #define CHECK_STATUS(STMT) \
58  do \
59  { \
60  VPIStatus status = (STMT); \
61  if (status != VPI_SUCCESS) \
62  { \
63  char buffer[VPI_MAX_STATUS_MESSAGE_LENGTH]; \
64  vpiGetLastStatusMessage(buffer, sizeof(buffer)); \
65  std::ostringstream ss; \
66  ss << vpiStatusGetName(status) << ": " << buffer; \
67  throw std::runtime_error(ss.str()); \
68  } \
69  } while (0);
70 
71 namespace {
72 
73 // Information about the target track.
74 struct TrackInfo
75 {
76  int idTarget;
77  cv::Scalar color;
78  bool enabled; // whether target is lost or not.
79 };
80 
81 // idTarget -> info
82 using TargetTrackInfoMap = std::map<int, TrackInfo>;
83 
84 // Stores information about a detected target.
85 struct DetectedTargetInfo
86 {
87  int idTarget;
88 
90 
91  bool lostTrack() const
92  {
93  return bbox.width == 0 || bbox.height == 0;
94  }
95 };
96 
97 // idTarget -> info
98 using DetectedTargetInfoMap = std::multimap<int, DetectedTargetInfo>;
99 
100 VPIBackend ParseBackend(const std::string &str)
101 {
102  if (str == "cuda")
103  {
104  return VPI_BACKEND_CUDA;
105  }
106  else if (str == "pva")
107  {
108  return VPI_BACKEND_PVA;
109  }
110  else
111  {
112  throw std::runtime_error("Backend '" + str + "' not recognized, it must be either cuda or pva.");
113  }
114 }
115 
116 // Opens the video given by its file name.
117 cv::VideoCapture ParseVideo(const std::string &fname)
118 {
119  cv::VideoCapture video;
120  if (!video.open(fname))
121  {
122  throw std::runtime_error("Can't open '" + fname + "'");
123  }
124  return video;
125 }
126 
127 // Parse the target bounding boxes at the frame they show up.
128 DetectedTargetInfoMap ParseTargetInfoAtFrame(const std::string &fname)
129 {
130  std::ifstream in(fname);
131  if (!in)
132  {
133  throw std::runtime_error("Can't open '" + fname + "'");
134  }
135 
136  DetectedTargetInfoMap out;
137 
138  // For each bounding box,
139  int frame;
140  DetectedTargetInfo tinfo;
141  while (in >> tinfo.idTarget >> frame >> tinfo.bbox.left >> tinfo.bbox.top >> tinfo.bbox.width >> tinfo.bbox.height)
142  {
143  out.emplace(frame, tinfo);
144  }
145 
146  return out;
147 }
148 
149 // Returns random high-saturated colors.
150 cv::Scalar GetRandomColor(cv::RNG &rng)
151 {
152  std::vector<cv::Vec3b> color = {cv::Vec3b{(unsigned char)rng.uniform(0, 180), 255, 255}};
153  cvtColor(color, color, cv::COLOR_HSV2BGR);
154  return cv::Scalar(color[0][0], color[0][1], color[0][2], 255);
155 }
156 
157 // Adds to 'targets' the new targets found in frame 'idxFrame'.
158 bool AddNewTargetsFromFrame(int idxFrame, DetectedTargetInfoMap &tgtInfos, TargetTrackInfoMap &trackInfo,
159  VPIArrayData &targets)
160 {
161  // Tries to add the new target in the slot of an existing target
162  // whose tracking was lost. If these no such targets, will append to the
163  // end of the array.
164 
165  auto *pTarget = static_cast<VPIDCFTrackedBoundingBox *>(targets.buffer.aos.data);
166  const auto *tgtBegin = pTarget;
167 
168  static cv::RNG rng(1);
169 
170  // For all new targets in 'idxFrame',
171  auto tgtInfoRange = tgtInfos.equal_range(idxFrame);
172  for (auto it = tgtInfoRange.first; it != tgtInfoRange.second; ++it)
173  {
174  // If info indicates the target's track has finished,
175  if (it->second.lostTrack())
176  {
177  // skip it, we're only adding new targets here.
178  continue;
179  }
180 
181  // If the corresponding target is enabled (i.e. is being tracked)
182  auto itTrackInfo = trackInfo.find(it->second.idTarget);
183  if (itTrackInfo != trackInfo.end() && itTrackInfo->second.enabled)
184  {
185  // also skip it
186  continue;
187  }
188 
189  // @note: when an array is allocated, its content is filled with zeroes,
190  // up to its capacity. This implies that the state of the targets is lost.
191  static_assert(VPI_TRACKING_STATE_LOST == 0, "Unexpected value for lost state");
192 
193  // Search for the first target whose tracking was lost.
194  while (pTarget->state != VPI_TRACKING_STATE_LOST && pTarget < tgtBegin + targets.buffer.aos.capacity)
195  {
196  ++pTarget;
197  }
198 
199  assert(pTarget < tgtBegin + targets.buffer.aos.capacity);
200 
201  pTarget->bbox = it->second.bbox;
202  pTarget->state = VPI_TRACKING_STATE_NEW;
203  pTarget->seqIndex = 0;
204  // Reasonable defaults.
205  pTarget->filterLR = 0.075;
206  pTarget->filterChannelWeightsLR = 0.1;
207 
208  // Is it the first time we're seeing this target?
209  if (itTrackInfo == trackInfo.end())
210  {
211  // Create a track info for it.
212  TrackInfo tinfo;
213  tinfo.idTarget = it->second.idTarget;
214  tinfo.color = GetRandomColor(rng);
215  tinfo.enabled = true;
216  itTrackInfo = trackInfo.emplace(tinfo.idTarget, tinfo).first;
217  }
218  else
219  {
220  // It's now enabled.
221  itTrackInfo->second.enabled = true;
222  }
223 
224  pTarget->userData = &itTrackInfo->second;
225 
226  ++pTarget;
227  }
228 
229  // Update the array size only if we've appended targets to the end of the array.
230  *targets.buffer.aos.sizePointer = std::max<int32_t>(*targets.buffer.aos.sizePointer, pTarget - tgtBegin);
231 
232  assert(*targets.buffer.aos.sizePointer >= 0);
233 
234  return true;
235 }
236 
237 // Mark as lost the targets whose bounding box falls outside the frame area, or are deemed lost by the detector.
238 bool DetectTrackingLost(int idxFrame, DetectedTargetInfoMap &tgtInfos, VPIArrayData &targets, cv::Size frameSize)
239 {
240  auto tgtInfoRange = tgtInfos.equal_range(idxFrame);
241 
242  // This is a simplistic method that isn't reliable in a robust tracker.
243  // A robust method needs to be implemented by the user.
244 
245  bool atLeastOneLost = false;
246 
247  // For all targets, back to front so that we can easily reduce array size if needed.
248  for (auto *pBeginTarget = static_cast<VPIDCFTrackedBoundingBox *>(targets.buffer.aos.data),
249  *pTarget = pBeginTarget + *targets.buffer.aos.sizePointer - 1;
250  pTarget >= pBeginTarget; --pTarget)
251  {
252  bool trackingLost = false;
253 
254  // Is it a valid target but its bounding box isn't entirely inside the frame,
255  if (pTarget->state != VPI_TRACKING_STATE_LOST && (pTarget->bbox.left < 0 || pTarget->bbox.top < 0 ||
256  pTarget->bbox.left + pTarget->bbox.width > frameSize.width ||
257  pTarget->bbox.top + pTarget->bbox.height > frameSize.height))
258  {
259  // Consider its tracking to be lost.
260  trackingLost = true;
261  }
262  else
263  {
264  // Go through all target infos in current frame
265  for (auto itInfo = tgtInfoRange.first; itInfo != tgtInfoRange.second; ++itInfo)
266  {
267  // Is it the info of the current target, and the tracking is lost?
268  if (pTarget->state != VPI_TRACKING_STATE_LOST &&
269  static_cast<const TrackInfo *>(pTarget->userData)->idTarget == itInfo->second.idTarget &&
270  itInfo->second.lostTrack())
271  {
272  // Flag it,
273  trackingLost = true;
274  break;
275  }
276  }
277  }
278 
279  if (trackingLost)
280  {
281  atLeastOneLost = true;
282 
283  // Update the target state to reflect it.
284  pTarget->state = VPI_TRACKING_STATE_LOST;
285  static_cast<TrackInfo *>(pTarget->userData)->enabled = false;
286 
287  assert(*targets.buffer.aos.sizePointer >= 1);
288 
289  // If the target is at the end of the target array,
290  if (pTarget == pBeginTarget + *targets.buffer.aos.sizePointer - 1)
291  {
292  // We can reduce the array size to improve tracking processing times.
293  *targets.buffer.aos.sizePointer = -1;
294  }
295  }
296  }
297 
298  return atLeastOneLost;
299 }
300 
301 // Update target's bounding box with input from detector output.
302 bool RefineTracksAtFrame(int idxFrame, DetectedTargetInfoMap &tgtInfos, VPIArrayData &targets)
303 {
304  auto tgtInfoRange = tgtInfos.equal_range(idxFrame);
305 
306  bool atLeastOneUpdated = false;
307 
308  for (auto *pBeginTarget = static_cast<VPIDCFTrackedBoundingBox *>(targets.buffer.aos.data), *pTarget = pBeginTarget;
309  pTarget < pBeginTarget + *targets.buffer.aos.sizePointer; ++pTarget)
310  {
311  // If tracking is lost,
312  if (pTarget->state == VPI_TRACKING_STATE_LOST)
313  {
314  // there's nothing to refine.
315  continue;
316  }
317 
318  bool found = false;
319 
320  // For all targets in 'idxFrame',
321  for (auto itInfo = tgtInfoRange.first; itInfo != tgtInfoRange.second; ++itInfo)
322  {
323  // If info indicates the tracking is lost,
324  if (itInfo->second.lostTrack())
325  {
326  // skip it, we're only updating existing targets.
327  continue;
328  }
329 
330  if ((pTarget->state == VPI_TRACKING_STATE_TRACKED || pTarget->state == VPI_TRACKING_STATE_SHADOW_TRACKED) &&
331  static_cast<const TrackInfo *>(pTarget->userData)->idTarget == itInfo->second.idTarget)
332  {
333  pTarget->bbox = itInfo->second.bbox;
334  found = true;
335  break;
336  }
337  }
338 
339  if (found)
340  {
341  atLeastOneUpdated = true;
342  pTarget->state = VPI_TRACKING_STATE_TRACKED;
343  }
344  else if (pTarget->state == VPI_TRACKING_STATE_TRACKED)
345  {
346  pTarget->state = VPI_TRACKING_STATE_SHADOW_TRACKED;
347  }
348  }
349 
350  return atLeastOneUpdated;
351 }
352 
353 void DrawTargets(cv::Mat &frame, VPIArray targets)
354 {
355  VPIArrayData tgtData;
356  CHECK_STATUS(vpiArrayLockData(targets, VPI_LOCK_READ, VPI_ARRAY_BUFFER_HOST_AOS, &tgtData));
357 
358  auto *ptgt = static_cast<VPIDCFTrackedBoundingBox *>(tgtData.buffer.aos.data);
359  int numObjs = *tgtData.buffer.aos.sizePointer;
360 
361  for (int o = 0; o < numObjs; ++o, ++ptgt)
362  {
363  // Only draw objects that are not lost
364  if (ptgt->state == VPI_TRACKING_STATE_LOST)
365  {
366  continue;
367  }
368 
369  auto &tinfo = *static_cast<TrackInfo *>(ptgt->userData);
370 
371  rectangle(frame,
372  cv::Rect{(int)ptgt->bbox.left, (int)ptgt->bbox.top, (int)ptgt->bbox.width, (int)ptgt->bbox.height},
373  tinfo.color);
374  }
375 
376  CHECK_STATUS(vpiArrayUnlock(targets));
377 }
378 
379 void WriteToDisk(const cv::Mat &img, std::string name, int idx)
380 {
381  char buf[128];
382  snprintf(buf, sizeof(buf) - 1, "%s_%03d.jpg", name.c_str(), idx);
383  buf[sizeof(buf) - 1] = '\0';
384 
385  imwrite(buf, img);
386 }
387 
388 void PreprocessFrame(VPIStream stream, const cv::Mat &in, VPIImage &wrapper, VPIImage out)
389 {
390  // Pre-process current frame
391  if (wrapper == NULL)
392  {
393  CHECK_STATUS(vpiImageCreateWrapperOpenCVMat(in, 0, &wrapper));
394  }
395  else
396  {
397  CHECK_STATUS(vpiImageSetWrappedOpenCVMat(wrapper, in));
398  }
399 
400  CHECK_STATUS(vpiSubmitConvertImageFormat(stream, VPI_BACKEND_CUDA, wrapper, out, NULL));
401 }
402 
403 } // namespace
404 
405 int main(int argc, char *argv[])
406 {
407  VPIPayload cropScale = NULL;
408  VPIPayload dcf = NULL;
409  VPIStream stream = NULL;
410  VPIArray inTargets = NULL, outTargets = NULL;
411  VPIImage tgtPatches = NULL;
412  VPIImage frame = NULL;
413  VPIImage wrappedOCVFrame = NULL;
414 
415  int retval = 0;
416  try
417  {
418  // Command line argument processing
419  // --------------------------------
420  if (argc != 4)
421  {
422  throw std::runtime_error(std::string("Usage: ") + argv[0] + " <pva|cuda> <input_video> <bbox descr>");
423  }
424 
425  VPIBackend backend = ParseBackend(argv[1]);
426  cv::VideoCapture invid = ParseVideo(argv[2]);
427  DetectedTargetInfoMap targetInfoAtFrame = ParseTargetInfoAtFrame(argv[3]);
428 
429  TargetTrackInfoMap trackInfo;
430 
431  // Allocate all VPI resources needed
432  // ---------------------------------
433 
434  const int maxTrackedTargets = targetInfoAtFrame.size();
435 
436  // Create the CropScale payload
437  CHECK_STATUS(vpiCreateCropScaler(backend,
438  1, // max number of sequences (only processing one video)
439  maxTrackedTargets, &cropScale));
440 
441  // Configure and create the DCFTracker payload
442  VPIDCFTrackerCreationParams dcfInitParams;
443  CHECK_STATUS(vpiInitDCFTrackerCreationParams(&dcfInitParams));
444 
445  VPIPayload dcf;
446  CHECK_STATUS(vpiCreateDCFTracker(backend,
447  1, // max number of sequences
448  maxTrackedTargets, &dcfInitParams, &dcf));
449 
450  // Optionally user can retrieve the internal array that stores the channel weights and
451  // the maximum correlation response for each tracked target. These can be used, together
452  // with the correlation map, to decide whether tracking was lost or not.
453  // This is not being done in this sample, though.
454  /*
455  VPIArray channelWeights;
456  int32_t numFeatureChannels
457  CHECK_STATUS(vpiDCFTrackerGetChannelWeights(dcf, &channelWeights, &numFeatureChannels));
458  */
459 
460  // Create target arrays
461  VPIArray inTargets, outTargets;
462  CHECK_STATUS(vpiArrayCreate(maxTrackedTargets, VPI_ARRAY_TYPE_DCF_TRACKED_BOUNDING_BOX, 0, &inTargets));
463  CHECK_STATUS(vpiArrayCreate(maxTrackedTargets, VPI_ARRAY_TYPE_DCF_TRACKED_BOUNDING_BOX, 0, &outTargets));
464 
465  // Create image that stores the targets' patches
466  const int tgtPatchSize = dcfInitParams.featurePatchSize * dcfInitParams.hogCellSize;
467  const VPIImageFormat tgtPatchFormat = backend == VPI_BACKEND_PVA
469  : VPI_IMAGE_FORMAT_RGBA8; // use supported patch-format for backend
470 
471  CHECK_STATUS(vpiImageCreate(tgtPatchSize, tgtPatchSize * maxTrackedTargets, tgtPatchFormat, 0, &tgtPatches));
472 
473  // Create stream for processing
474  CHECK_STATUS(vpiStreamCreate(0, &stream));
475 
476  // Create the image that stores the input frame
477  CHECK_STATUS(vpiImageCreate(invid.get(cv::CAP_PROP_FRAME_WIDTH), invid.get(cv::CAP_PROP_FRAME_HEIGHT),
478  VPI_IMAGE_FORMAT_RGBA8, 0, &frame));
479 
480  // Target tracking
481  // ---------------
482 
483  int curFrame = 0;
484 
485  // Populate the targets array with targets found the first frame.
486  VPIArrayData tgtData;
487  CHECK_STATUS(vpiArrayLockData(inTargets, VPI_LOCK_READ_WRITE, VPI_ARRAY_BUFFER_HOST_AOS, &tgtData));
488  try
489  {
490  AddNewTargetsFromFrame(curFrame, targetInfoAtFrame, trackInfo, tgtData);
491  }
492  catch (...)
493  {
494  CHECK_STATUS(vpiArrayUnlock(inTargets));
495  throw;
496  }
497  CHECK_STATUS(vpiArrayUnlock(inTargets));
498 
499  // For each input frame,
500  cv::Mat cvFrame;
501  while (invid.read(cvFrame))
502  {
503  printf("Frame %d\n", curFrame);
504 
505  // Transform the opencv frame (cvFrame) into a suitable VPIImage (frame).
506  PreprocessFrame(stream, cvFrame, wrappedOCVFrame, frame);
507 
508  // Crop the targets from the current frame using their bbox from previous iteration,
509  // then rescale them into tgtPatches.
510  CHECK_STATUS(vpiSubmitCropScalerBatch(stream, 0, cropScale, &frame, 1, inTargets, tgtPatchSize,
511  tgtPatchSize, tgtPatches));
512 
513  // If we're in the first frame,
514  VPIArray targets;
515  if (curFrame == 0)
516  {
517  // The targets are simply the ones found.
518  targets = inTargets;
519  }
520  else
521  {
522  // Localize and refine current targets' bbox in the current frame.
523  CHECK_STATUS(vpiSubmitDCFTrackerLocalizeBatch(stream, 0, dcf, NULL, 0, // process all sequences
524  NULL, // feature masking window (not needed)
525  tgtPatches, inTargets, outTargets,
526  NULL, // outCorrelationResponses (not needed)
527  NULL, // outMaxCorrelationResponses (not needed)
528  NULL)); // algorithm knobs (use defaults)
529  targets = outTargets;
530 
531  // Custom target update
532  // --------------------
533 
534  // At this point some other additional processing can be done,
535  // such as target lifetime management and bounding box refinement.
536  // It typically uses information from 'outMaxCorrelationResponses',
537  // 'outCorrelationResponses' and/or 'channelWeights'.
538  // Since this processing is usually time consuming,
539  // it is usually performed once every few frames.
540 
541  // Since we're updating the target arrays on host, we need to synchronize the stream.
542  CHECK_STATUS(vpiStreamSync(stream));
543 
544  // Target patches must be updated if the corresponding target is new, or its bounding
545  // box was refined.
546  bool mustUpdateTargetPatches = false;
547 
548  VPIArrayData tgtData;
549  CHECK_STATUS(vpiArrayLockData(targets, VPI_LOCK_READ_WRITE, VPI_ARRAY_BUFFER_HOST_AOS, &tgtData));
550  try
551  {
552  // These functions update the target array based on the
553  // output of a object detector on the current frame. This
554  // detector is responsible for associating the detected
555  // objects with the corresponding existing target (if
556  // possible).
557  //
558  // Based on this information, the functions update the
559  // object lifetime (whether the object is new or tracking
560  // was lost), and also update its bounding box and state.
561  //
562  // For this sample application, the detection and
563  // reassociation is hardcoded in 'targetInfoAtFrame'. For
564  // production-level quality, a robust and generic solution
565  // needs to be implemented by the user.
566 
567  // Note: Target update implemented in three separate
568  // functions for exposition purposes only.
569 
570  // Detect whether a target tracking was lost and update tgtData accordingly.
571  DetectTrackingLost(curFrame, targetInfoAtFrame, tgtData, cv::Size{cvFrame.cols, cvFrame.rows});
572 
573  // Target bounding box refinement
574  mustUpdateTargetPatches |= RefineTracksAtFrame(curFrame, targetInfoAtFrame, tgtData);
575 
576  // Detect whether new targets are found in the current frame.
577  mustUpdateTargetPatches |= AddNewTargetsFromFrame(curFrame, targetInfoAtFrame, trackInfo, tgtData);
578  }
579  catch (...)
580  {
581  CHECK_STATUS(vpiArrayUnlock(targets));
582  throw;
583  }
584  CHECK_STATUS(vpiArrayUnlock(targets));
585 
586  if (mustUpdateTargetPatches)
587  {
588  // Crop+rescale updated targets and copy them into tgtPatches.
589  CHECK_STATUS(vpiSubmitCropScalerBatch(stream, 0, cropScale, &frame, 1, targets, tgtPatchSize,
590  tgtPatchSize, tgtPatches));
591  }
592  }
593 
594  // Update the targets' internal metadata given their new bounding box.
595  CHECK_STATUS(vpiSubmitDCFTrackerUpdateBatch(stream, 0, dcf, nullptr, 0, // process all sequences
596  NULL, // featureMaskingWindow (not needed)
597  NULL, // modelMaskingWindow (not needed)
598  tgtPatches, targets,
599  NULL)); // algorithm knobs (use defaults)
600 
601  // Wait for frame processing to finish
602  CHECK_STATUS(vpiStreamSync(stream));
603 
604  // Write frame to disk
605  DrawTargets(cvFrame, targets);
606  WriteToDisk(cvFrame, "frame", curFrame);
607 
608  // Ping-pong the target arrays:
609  // Updated targets in this iteration will be input to the next iteration (inTargets),
610  // while current input will store the updated targets.
611  std::swap(inTargets, targets);
612  ++curFrame;
613  }
614  }
615  catch (std::exception &e)
616  {
617  std::cerr << e.what() << std::endl;
618  retval = 1;
619  }
620 
621  // Destroy all VPI resources
622  // -------------------------
623 
624  vpiStreamDestroy(stream);
625 
626  vpiPayloadDestroy(cropScale);
627  vpiPayloadDestroy(dcf);
628  vpiArrayDestroy(inTargets);
629  vpiArrayDestroy(outTargets);
630  vpiImageDestroy(tgtPatches);
631  vpiImageDestroy(frame);
632  vpiImageDestroy(wrappedOCVFrame);
633 
634  return retval;
635 }
Functions and structures for dealing with VPI arrays.
Declares functions that handle image format conversion.
Declares functions that implement the Crop Scaler algorithm.
Declares functions that implement the DCF Tracker algorithm.
#define VPI_IMAGE_FORMAT_RGB8p
Planar RGB with unsigned 8-bit channels.
Definition: ImageFormat.h:333
#define VPI_IMAGE_FORMAT_RGBA8
Single plane with interleaved RGBA 8-bit channel.
Definition: ImageFormat.h:327
Functions and structures for dealing with VPI images.
Functions for handling OpenCV interoperability with VPI.
Functions and structures for dealing with VPI pyramids.
Declaration of VPI status codes handling functions.
Declares functions dealing with VPI streams.
@ VPI_TRACKING_STATE_LOST
Object isn't being tracked anymore.
Definition: Types.h:454
@ VPI_TRACKING_STATE_SHADOW_TRACKED
Object is being tracked with low confidence.
Definition: Types.h:480
@ VPI_TRACKING_STATE_TRACKED
Object is being tracked with high confidence.
Definition: Types.h:471
@ VPI_TRACKING_STATE_NEW
New object to be tracked.
Definition: Types.h:461
void * data
Points to the first element of the array.
Definition: Array.h:135
VPIArrayBuffer buffer
Stores the array contents.
Definition: Array.h:175
int32_t * sizePointer
Points to the number of elements in the array.
Definition: Array.h:122
VPIArrayBufferAOS aos
Array stored in array-of-structures layout.
Definition: Array.h:162
int32_t capacity
Maximum number of elements that the array can hold.
Definition: Array.h:126
VPIStatus vpiArrayUnlock(VPIArray array)
Releases the lock on array object.
VPIStatus vpiArrayLockData(VPIArray array, VPILockMode mode, VPIArrayBufferType bufType, VPIArrayData *data)
Acquires the lock on an array object and returns the array contents.
void vpiArrayDestroy(VPIArray array)
Destroy an array instance.
VPIStatus vpiArrayCreate(int32_t capacity, VPIArrayType type, uint64_t flags, VPIArray *array)
Create an empty array instance.
struct VPIArrayImpl * VPIArray
A handle to an array.
Definition: Types.h:232
@ VPI_ARRAY_TYPE_DCF_TRACKED_BOUNDING_BOX
VPIDCFTrackedBoundingBox element.
Definition: ArrayType.h:86
@ VPI_ARRAY_BUFFER_HOST_AOS
Host-accessible array-of-structures.
Definition: Array.h:146
Stores information about array characteristics and contents.
Definition: Array.h:168
VPIStatus vpiSubmitConvertImageFormat(VPIStream stream, uint64_t backend, VPIImage input, VPIImage output, const VPIConvertImageFormatParams *params)
Converts the image contents to the desired format, with optional scaling and offset.
VPIStatus vpiCreateCropScaler(uint64_t backends, int maxFrames, int maxObjects, VPIPayload *payload)
Creates payload instance for the Crop Scale algorithm.
VPIStatus vpiSubmitCropScalerBatch(VPIStream stream, uint64_t backend, VPIPayload payload, VPIImage *frameList, int32_t numFrames, VPIArray objects, int32_t patchWidth, int32_t patchHeight, VPIImage outPatches)
Crops rectangular regions from the input frames and rescale them all to the same dimensions.
int32_t hogCellSize
Cell size for features from Histogram of Oriented Gradients.
Definition: DCFTracker.h:210
int32_t featurePatchSize
Size of an object feature patch.
Definition: DCFTracker.h:205
VPIStatus vpiSubmitDCFTrackerLocalizeBatch(VPIStream stream, uint64_t backend, VPIPayload payload, const int32_t *enabledSequences, int32_t numSequences, VPIImage featureMaskingWindow, VPIImage inPatches, VPIArray inObjects, VPIArray outObjects, VPIImage outCorrelationResponses, VPIArray outMaxCorrelationResponses, const VPIDCFTrackerParams *params)
Localizes each tracked object in the input image patches using the Discriminative Correlation Filter ...
VPIStatus vpiSubmitDCFTrackerUpdateBatch(VPIStream stream, uint64_t backend, VPIPayload payload, const int32_t *enabledSequences, int32_t numSequences, VPIImage featureMaskingWindow, VPIImage modelMaskingWindow, VPIImage inPatches, VPIArray trackedObjects, const VPIDCFTrackerParams *params)
Update internal object tracking information based on its state and its corresponding input image patc...
VPIStatus vpiCreateDCFTracker(uint64_t backends, int32_t maxNumSequences, int32_t maxNumObjects, const VPIDCFTrackerCreationParams *params, VPIPayload *payload)
Creates payload for DCF Tracker.
VPIStatus vpiInitDCFTrackerCreationParams(VPIDCFTrackerCreationParams *params)
Initialize VPIDCFTrackerCreationParams with default values.
Stores information about an object tracked by DCF Tracker.
Definition: Types.h:516
Creation parameters of DCF Tracker.
Definition: DCFTracker.h:192
uint64_t VPIImageFormat
Pre-defined image formats.
Definition: ImageFormat.h:94
void vpiImageDestroy(VPIImage img)
Destroy an image instance.
struct VPIImageImpl * VPIImage
A handle to an image.
Definition: Types.h:256
VPIStatus vpiImageCreate(int32_t width, int32_t height, VPIImageFormat fmt, uint64_t flags, VPIImage *img)
Create an empty image instance with the specified flags.
VPIStatus vpiImageCreateWrapperOpenCVMat(const cv::Mat &mat, VPIImageFormat fmt, uint64_t flags, VPIImage *img)
Wraps a cv::Mat in an VPIImage with the given image format.
VPIStatus vpiImageSetWrappedOpenCVMat(VPIImage img, const cv::Mat &mat)
Redefines the wrapped cv::Mat of an existing VPIImage wrapper.
struct VPIPayloadImpl * VPIPayload
A handle to an algorithm payload.
Definition: Types.h:268
void vpiPayloadDestroy(VPIPayload payload)
Deallocates the payload object and all associated resources.
struct VPIStreamImpl * VPIStream
A handle to a stream.
Definition: Types.h:250
VPIStatus vpiStreamSync(VPIStream stream)
Blocks the calling thread until all submitted commands in this stream queue are done (queue is empty)...
VPIBackend
VPI Backend types.
Definition: Types.h:91
void vpiStreamDestroy(VPIStream stream)
Destroy a stream instance and deallocate all HW resources.
VPIStatus vpiStreamCreate(uint64_t flags, VPIStream *stream)
Create a stream instance.
@ VPI_BACKEND_CUDA
CUDA backend.
Definition: Types.h:93
@ VPI_BACKEND_PVA
PVA backend.
Definition: Types.h:94
float height
Bounding box height.
Definition: Types.h:440
float width
Bounding box width.
Definition: Types.h:439
@ VPI_LOCK_READ_WRITE
Lock memory for reading and writing.
Definition: Types.h:631
@ VPI_LOCK_READ
Lock memory only for reading.
Definition: Types.h:617
Stores an axis-aligned 32-bit floating point 2D bounding box.
Definition: Types.h:436