Skip to main content

Posts

Showing posts with the label images

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...

SURF using Image and Camera

Im reusing the SURF implementation in the samples, what ive added is the camera, so im matching an image.jpg to a frame captured from the 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; void help() { printf( "This program demonstrated the use of the SURF Detector and Descriptor using\n" "either FLANN (fast approx nearst neighbor classification) or brute force matching\n" "on planar objects.\n" "Call:\n" "./find_obj...

Loading an Image 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* img = 0; int height,width,step,channels; uchar *data; int i,j,k; char* change_im(char*); char *im = ""; if(argc<2){ printf("Usage: main <image-file-name>\n\7"); im = "aresh.jpg"; //decalre DEFAULT } else { im = argv[1]; } // load an image img=cvLoadImage(im); if(!img){ printf("Could not load image file: %s\n",im); exit(0); } // get the image data height = img->height; width = img->width; step = img->widthStep; channels = img->nChannels; data = (uchar *)img->imageData; printf("Processing a %dx%d image with %d channels\n",height,width,channels); // create a window cvNamedWindow("mainWin", CV_WINDOW_AUTO...