试图对视频上的帧执行灰度转换,但当我到达cvCvtColor时不断获取As thesis失败错误。 有没有人看到我的错误在哪里?Opencv视频帧给我一个错误
IplImage *frame, *frame_copy = 0;
// capture frames from video
CvCapture *capture = cvCaptureFromFile("lightinbox1.avi");
//Allows Access to video propertys
cvQueryFrame(capture);
//Get the number of frames
int nframe=(int) cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_COUNT);
//Name window
cvNamedWindow("video:", 1);
//start loop
for(int i=0;i<nframe;i++){
//prepare capture frame extraction
cvGrabFrame(capture);
cout<<"We are on frame "<<i<<"\n";
//Get this frame
frame = cvRetrieveFrame(capture);
con2txt(frame);
frame_copy = cvCreateImage(cvSize(frame->width,frame->height),IPL_DEPTH_8U,frame->nChannels);
//show and destroy frame
cvCvtColor(frame,frame,CV_RGB2GRAY);
cvShowImage("video:",frame);
cvWaitKey(33);}
cvReleaseCapture(&capture);
}
那是伟大的,但为什么当我添加frame_copy1 = cvCreateImage(cvSize(帧 - >宽度,帧 - >高),IPL_DEPTH_16S, 1); cvSobel(frame_copy,frame_copy1,2,2,3); cvShowImage( “视频”,frame_copy1);它是否显示我一个空白屏幕 – user1016950
这是另一个问题,我建议你在新线程中提问。但我怀疑它与图像的深度有关,产生的图像被存储在'IPL_DEPTH_16S'上,但原始图像可能是'IPL_DEPTH_8U'。 – karlphillip