I have a yuv camera.
I convert yuv to bgr (because of opencv use bgr) but I get an exception:
Unhandled exception at 0x76c1a832 in test1.exe: Microsoft C++ exception: cv::Exception at memory location 0x00baee60..
How can I fix it?
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv2/opencv.hpp>
void main()
{
IplImage* image ;
CvCapture* capture=cvCaptureFromCAM(CV_CAP_ANY);
//cv::Mat input;
cv::Mat output;
cvNamedWindow("webcam",1);
cvGrabFrame( capture );
image = cvRetrieveFrame( capture );
cv::Mat input = cv::cvarrToMat(image);
cv::cvtColor(input,output,CV_YUV2BGR_YUY2);
imshow("webcam", output);
/*
while(1)
{
//get image from Camera
image = cvQueryFrame(capture);
//Iplimage to Mat
cv::Mat input = cv::cvarrToMat(image);
//YUV to RGB, CV_YUV2RGB_NV12 CV_YUV2BGR_NV12 CV_YUV2RGB_YV12 CV_YUV2BGR_YV12 CV_YUV2RGB_IYUV CV_YUV2BGR_IYUV CV_YUV2RGB_UYVY CV_YUV2BGR_UYVY
cv::cvtColor(input,output,CV_YUV2BGR_YUY2);
// Draw image
//cvShowImage("webcam", image);
imshow("webcam", output);
//key = cvWaitKey(30);
if(cvWaitKey(33)>=27)
break;
}
*/
cvReleaseCapture(&capture);
cvDestroyWindow("webcam");
}
try-catchblock to catch the exception and see what the problem is. It has a.what()method.