Skip to content

Instantly share code, notes, and snippets.

@jayrambhia
Created September 19, 2012 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayrambhia/3750683 to your computer and use it in GitHub Desktop.
Save jayrambhia/3750683 to your computer and use it in GitHub Desktop.
compiling opencv_webcam.cpp
opencv_webcam.cpp: In function ‘int main()’:
opencv_webcam.cpp:8:9: error: ‘cap’ was not declared in this scope
opencv_webcam.cpp:11:9: error: ‘k’ was not declared in this scope
opencv_webcam.cpp:11:23: error: ‘waitkey’ was not declared in this scope
opencv_webcam.cpp:12:9: error: expected ‘;’ before ‘if’
Output file => opencv_webcam
compiling opencv_webcam.cpp
opencv_webcam.cpp: In function ‘int main()’:
opencv_webcam.cpp:8:9: error: ‘cap’ was not declared in this scope
opencv_webcam.cpp:11:9: error: ‘k’ was not declared in this scope
opencv_webcam.cpp:11:23: error: ‘waitkey’ was not declared in this scope
opencv_webcam.cpp:12:9: error: expected ‘;’ before ‘if’
Output file => opencv_webcam
#include<opencv2/highgui/highgui.hpp>
using namespace cv;
int main()
{
while(1)
{
cap = VideoCapture(0);
Mat img = cap.read();
imshow("image",img);
k = waitkey(10)
if k == 27:
break;
}
return 0;
}
#include<opencv2/highgui/highgui.hpp>
using namespace cv;
int main()
{
int k;
VideoCapture cap = VideoCapture(0);
while(1)
{
Mat img;
cap >> img;
imshow("image",img);
k = waitKey(10);
if (k == 27)
{
break;
}
}
return 0;
}
//This works perfectly well
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment