Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Getting error Assertion failed.

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.

getting error as shown in attached image

Thank you very much in advance.

click to hide/show revision 2
retagged

updated 2015-04-08 10:42:49 -0600

berak gravatar image

Getting error Assertion failed.

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.

getting error as shown in attached image

Thank you very much in advance.

click to hide/show revision 3
No.3 Revision

updated 2015-04-08 10:43:27 -0600

berak gravatar image

Getting error Assertion failed.

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/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
  

include <opencv2 imgproc="" imgproc.hpp="">

include <iostream>

#include <iostream> using namespace cv; using namespace std;

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);

imshow("cam1",roi);

if (waitKey(30) >= 0) break; } return 0; } `

is there any suggestion to overcome this error.

getting error as shown in attached image

Thank you very much in advance.