Difference between revisions of "Function:TrackFeatures"

From CUVI Wiki
(Created page with "__NOTOC__ CUVI Feature tracker tracks input features from frame 1 onto frame 2. The function is ideal for tracking selected number of features through an image sequence or a v...")
 
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
CUVI Feature tracker tracks input features from frame 1 onto frame 2. The function is ideal for tracking selected number of features through an image sequence or a video stream. This is a custom algorithm and does not use optical flows to estimate motion. Check out Motion Estimate section for more details on Optical Flow based motion tracking.
CUVI Feature tracker tracks input features from frame 1 onto frame 2. The function is ideal for tracking selected number of features through an image sequence or a video stream. This is a custom algorithm and does not use optical flows to estimate motion. Check out Motion Estimate section for more details on Optical Flow based motion tracking.
===Function===
====Function====
{|
{|
|style="font-size:150%;"|
|style="font-size:100%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
CuviStatus trackFeatures(CuviImage* previousImage,
CuviStatus trackFeatures(const CuviImage& previous,
                         CuviImage* nextImage,
                         const CuviImage& next,
                         CuviPointValue2D* inputFeatures,
                         CuviPointValue2D<Cuvi32f,Cuvi32f>* inputFeatures,
                         CuviPointValue2D** trackedFeatures,
                         CuviPointValue2D<Cuvi32f,Cuvi32f>*& trackedFeatures,
                         Cuvi32s featureCount,
                         const Cuvi32s featureCount,
                         CuviTrackingCriteria criteria,
                         CuviTrackingCriteria criteria,
                         CuviStream* stream = NULL);
                         const CuviStream& stream = CuviStream());
</syntaxhighlight>
</syntaxhighlight>
|}
|}


===Parameters===
====Parameters====
{|
|style="font-size:75%;"|
{|class="wikitable"
{|class="wikitable"
|-
|-
Line 22: Line 24:
! Description
! Description
|-
|-
| previousImage
| previous
| CuviImage*
| const CuviImage&
| The first image whose features are to be tracked
| The first image whose features are to be tracked
|-
|-
| nextImage
| next
| CuviImage*
| const CuviImage&
| Second image, in which to look for features of first image
| Second image, in which to look for features of first image
|-
|-
| inputFeatures
| inputFeatures
| CuviPointValue2D*
| CuviPointValue2D<Cuvi32f,Cuvi32f>*
| Feature of first image
| Feature of first image
|-
|-
| trackedFeatures
| trackedFeatures
| CuviPointValue2D**
| CuviPointValue2D<Cuvi32f,Cuvi32f>*&
| Output feature list containing the location of tracked features from first image onto second image
| Output feature list containing the location of tracked features from first image onto second image
|-
|-
| featureCount
| featureCount
| Cuvi32s
| const Cuvi32s
| Number of features to track
| Number of features to track
|-
|-
Line 47: Line 49:
|-
|-
| stream
| stream
| CuviStream*
| const CuviStream&
| GPU stream ID for execution
| GPU stream ID for execution
 
|}
|}
|}


 
====Image Type Support====
===Image Type Support===
{|
 
|style="font-size:75%;"|
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 62: Line 64:
| 8uC1
| 8uC1
| CuviPointValue2D
| CuviPointValue2D
|}
|}
|}


====Samples====
[[File:Frame0.jpg|none|frame]]
<br/>
[[File:Frame1.jpg|none|frame|]]
<br/>


 
====Code Example====
===Samples===
{|
{|
|-
|style="font-size:100%;"|
|[[File:Frame0.jpg|frame]]
<syntaxhighlight lang="cpp">
|[[File:Frame1.jpg|frame|]]
|}




//Image size
CuviSize size = cuviSize(img1->width,img1->height);


===Example===
//Create two 8-bit Grays-scale CuviImage objects
{|
CuviImage gimg1 = cuvi::io::loadImage(path, CUVI_LOAD_IMAGE_GRAYSCALE);
|style="font-size:150%;"|
CuviImage gimg2 = cuvi::io::loadImage(path, CUVI_LOAD_IMAGE_GRAYSCALE);
<syntaxhighlight lang="cpp">


//Create an 8-bit Grays-scale CuviImage
CuviPointValue2D* features1, *features2;
CuviImage *gpu_image = new CuviImage(size,img->depth,img->nChannels);


//Populate the Image
//selection and tracking criteria
gpu_image->upload(img->imageData,img->widthStep);
CuviFeaturesCriteria fc(CUVI_FEATURES_HARRIS,0.006f,22);
CuviTrackingCriteria tc(2,CuviSize(12,12),15,10.0f);


CuviPointValue2D *features;
//ROI for selection
CuviRect roi(0,0,gimg1.width(),gimg1.height());


//Desired number of features
int featureCount = 50;
int featureCount = 100;


//Selecting complete image for the process
//Select Features
CuviROI roi = cuviROI(0,0,img->width,img->height);
cuvi::computerVision::goodFeaturesToTrack(gimg1,roi,features1,featureCount,fc);


//Setting Feature selection parameters
//Track the selected features from first frame onto second frame
CuviFeaturesCriteria criteria = cuviFeaturesCriteria(CUVI_FEATURES_HARRIS_PETER,0.006f,15,3,-2.0f);
cuvi::computerVision::trackFeatures(gimg1,gimg2,features1,features2,featureCount,tc);


//Calling GoodFeaturesToTrack
cuvi::computerVision::goodFeaturesToTrack(&gimg,roi,&features,&featureCount,criteria);


</syntaxhighlight>
</syntaxhighlight>
|}
|}

Latest revision as of 14:19, 18 October 2022

CUVI Feature tracker tracks input features from frame 1 onto frame 2. The function is ideal for tracking selected number of features through an image sequence or a video stream. This is a custom algorithm and does not use optical flows to estimate motion. Check out Motion Estimate section for more details on Optical Flow based motion tracking.

Function

CuviStatus trackFeatures(const CuviImage& previous,
                         const CuviImage& next,
                         CuviPointValue2D<Cuvi32f,Cuvi32f>* inputFeatures,
                         CuviPointValue2D<Cuvi32f,Cuvi32f>*& trackedFeatures,
                         const Cuvi32s featureCount,
                         CuviTrackingCriteria criteria,
                         const CuviStream& stream = CuviStream());

Parameters

Name Type Description
previous const CuviImage& The first image whose features are to be tracked
next const CuviImage& Second image, in which to look for features of first image
inputFeatures CuviPointValue2D<Cuvi32f,Cuvi32f>* Feature of first image
trackedFeatures CuviPointValue2D<Cuvi32f,Cuvi32f>*& Output feature list containing the location of tracked features from first image onto second image
featureCount const Cuvi32s Number of features to track
criteria CuviFeaturesCriteria A structure containing various parameters that affect feature tracking behavior
stream const CuviStream& GPU stream ID for execution

Image Type Support

Input Output
8uC1 CuviPointValue2D

Samples

Frame0.jpg


Frame1.jpg


Code Example

//Image size
CuviSize size = cuviSize(img1->width,img1->height);

//Create two 8-bit Grays-scale CuviImage objects
CuviImage gimg1 = cuvi::io::loadImage(path, CUVI_LOAD_IMAGE_GRAYSCALE);
CuviImage gimg2 = cuvi::io::loadImage(path, CUVI_LOAD_IMAGE_GRAYSCALE);

CuviPointValue2D* features1, *features2;

//selection and tracking criteria
CuviFeaturesCriteria fc(CUVI_FEATURES_HARRIS,0.006f,22);
CuviTrackingCriteria tc(2,CuviSize(12,12),15,10.0f);

//ROI for selection
CuviRect roi(0,0,gimg1.width(),gimg1.height());

int featureCount = 50;

//Select Features
cuvi::computerVision::goodFeaturesToTrack(gimg1,roi,features1,featureCount,fc);

//Track the selected features from first frame onto second frame
cuvi::computerVision::trackFeatures(gimg1,gimg2,features1,features2,featureCount,tc);