Difference between revisions of "CUVI by Example"
From CUVI Wiki
Line 19: | Line 19: | ||
static const int requestedFeatures = 150; //Number of features to look for | static const int requestedFeatures = 150; //Number of features to look for | ||
static const float featureQuality = 0.006f; //Quality of a feature | static const float featureQuality = 0.006f; //Quality of a feature | ||
static const int featureMinDistance = | static const int featureMinDistance = 15; //Minimum distance between 2 features | ||
static const int blockSize = 3; //block size for computing Eigen Matrix | |||
static const float k = -2.0f; //k for Harris Corner detector | static const float k = -2.0f; //k for Harris Corner detector | ||
Line 87: | Line 88: | ||
} | } | ||
//Call any Feature Detector on first Frame( KLT | HARRIS | PETER ) | //Defining feature selection criteria from parameters | ||
cuvi::computerVision::goodFeaturesToTrack(gimg1,roi,features1,&feature_count, | CuviFeaturesCriteria feature_criteria = cuviFeaturesCriteria(CUVI_FEATURES_HARRIS, featureQuality, featureMinDistance, blockSize, k); | ||
//Call any Feature Detector on first Frame( KLT | HARRIS | PETER ) | |||
cuvi::computerVision::goodFeaturesToTrack(gimg1,roi,features1,&feature_count,feature_criteria); | |||
//Track Features Using of Frame#1 onto Frame#2 using KLT Tracker | |||
cuvi::trackFeatures(gimg1,gimg2,features1,features2,feature_count, | //Defining tracking criteria from tracking parameters | ||
CuviTrackingCriteria tracking_criteria = cuviTrackingCriteria(pyramidLevels, trackingWindow, iterations, residue); | |||
//Track Features Using of Frame#1 onto Frame#2 using KLT Tracker | |||
cuvi::trackFeatures(gimg1,gimg2,features1,features2,feature_count,tracking_criteria ); | |||
//At this point you can indetify whether the selected features in frame one moved in frame two or not | //At this point you can indetify whether the selected features in frame one moved in frame two or not | ||
for(int i=0; i<feature_count; i++) | for(int i=0; i<feature_count; i++){ | ||
//True only if the feature has moved from its location | |||
if(FeatureHasMoved(features1[i],features2[i],MovementThreshold)) | |||
//You can also plot the tracked features on the screen | |||
} | |||
}while(video_Frames) | }while(video_Frames) | ||
//Freeing GPU Memory | //Freeing GPU Memory |
Revision as of 19:29, 30 April 2012
CUVI library comes with all the image processing essentials that can be used to build countless applications. For example the Computer Vision module of CUVI can be used for motion and intrusion detection in a live video stream and tracking an object of interest throughout series of cameras installed in a premises. The processing pipeline for motion detection goes as follows:
- Read a frame from the camera stream
- Select Strong Features in that Frame using CUVI
- Read next frame
- Track features of first frame in the second frame using CUVI
- Set alarm if motion is detected
The CUVI functions used in this example are goodFeaturesToTrack() and trackFeatures(). For simplicity we have removed the I/O part on host side from the code
|