capture image with webcam on ubuntu
I m very new to ubuntu and open cv..I( hav finishe installing opencv.. can anyone tell me the proper instructions to compile a program in ubuntu using opencv.. I tried out this code for image capture
include <iostream>
include <cxcore.h>
include <highgui.h>
int main(int argc, char* argv[]) { CvCapture* camera = 0; if (argc > 1) camera = cvCreateFileCapture(argv[1]); else { camera = cvCreateCameraCapture(-1); // Use the default camera
IplImage* frame = 0; IplImage img;
cvNamedWindow("window_name", 1);
while (cvGetWindowHandle("window_name")) { //Use while (true) if you are on Mac
frame = cvQueryFrame(&camera); //Be careful not to change the value or to free the "frame" variable
cvSaveImage("webcam.jpg", &frame);
cvShowImage("window_name", &frame);
keyPressed = cvWaitKey(2);
if (keyPressed == 27)
break;
}
cvReleaseCapture(&camera); return 0; }
And i m getting some errors for this like
camera1.cpp: In function ‘int main(int, char)’: camera1.cpp:19:32: error: cannot convert ‘CvCapture’ to ‘CvCapture’ for argument ‘1’ to ‘IplImage cvQueryFrame(CvCapture*)’ camera1.cpp:25:5: error: ‘keyPressed’ was not declared in this scope camera1.cpp:13:17: warning: unused variable ‘img’ [-Wunused-variable] camera1.cpp:33:1: error: expected ‘}’ at end of input
please tell me the basic steps and the errors above..
can you please reformat the question, so it's more readable ? edit it, highlight(select) the code part, and press the '0101001' button, same for the error msg. some important details, like * and & got lost