hello,
I am trying to communicate with simple camera of my laptop, but some time this code work fine and some time I am getting error.
`#include <opencv2 highgui="" highgui.hpp="">
include <opencv2 imgproc="" imgproc.hpp="">
include <iostream>
using namespace cv; using namespace std;
int main() { VideoCapture stream1(0); //0 is the id of video device.0 if you have only one camera. stream1.set(CV_CAP_PROP_FRAME_WIDTH, 640); stream1.set(CV_CAP_PROP_FRAME_HEIGHT, 480); if (!stream1.isOpened()) { //check if video device has been initialised cout << "cannot open camera"; }
//unconditional loop while (true) { Mat cameraFrame; stream1.read(cameraFrame); imshow("cam", cameraFrame); Mat roi = cameraFrame( Rect(150,50,150,250) ); imshow("cam1",roi);
if (waitKey(30) >= 0) break; } return 0; } ` is there any suggestion to overcome this error.
Thank you very much in advance.