Skip to main content

Posts

Showing posts with the label video

SURF keypoints using a camera

#include <stdlib.h> #include <stdio.h> #include <math.h> #include <string.h> #include <opencv2/objdetect/objdetect.hpp> #include <opencv2/features2d/features2d.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/calib3d/calib3d.hpp> #include <opencv2/imgproc/imgproc_c.h> #include <opencv2/video/tracking.hpp> #include <iostream> #include <vector> using namespace std; int main(int argc, char** argv) { CvMemStorage* storage = cvCreateMemStorage(0); cvNamedWindow("Object", 1); int key = 0; static CvScalar colors[] = { {{0,0,255}}, {{0,128,255}}, {{0,255,255}}, {{0,255,0}}, {{255,128,0}}, {{255,255,0}}, {{255,0,0}}, {{255,0,255}}, {{255,255,255}} }; CvCapture* capture = cvCreateCameraCapture(0); CvMat* prevgray = 0, *image = 0, *gray =0; while( key != 'q' ) { int firstFrame = gray == 0; IplImage* frame = cvQueryFrame(captur...

Load a Video in OpenCV

#include <stdlib.h> #include <stdio.h> #include <math.h> #include <string.h> #include<opencv2\opencv.hpp> #include <opencv2\highgui\highgui.hpp> int main(int argc, char *argv[]) { IplImage *frame; int key = 'a'; /* supply the AVI file to play */ if(argc<2){ printf("Usage: main <video-file-name>.avi\n\7"); exit(0); } /* load the AVI file */ CvCapture *capture = cvCaptureFromAVI( argv[1] ); /* always check */ if( !capture ) return 1; /* get fps, needed to set the delay */ int fps = ( int )cvGetCaptureProperty( capture, CV_CAP_PROP_FPS ); /* display video */ cvNamedWindow( "video", 0 ); while( key != 'q' ) { /* get a frame */ frame = cvQueryFrame( capture ); /* always check */ if( !frame ) break; /* display frame */ cvShowImage( "video", frame ); /* quit if user press 'q' */ cvWaitKey( 1000 / fps ); } /* free memory */ cvReleaseCapture( &capture ...