这是从 Opencv video frame giving me an error 的延续问题我想我关闭它,Im新的Stackoverflow。Opencv视频帧没有显示Sobel输出
我有下面的代码,我试图看到它的Sobel边缘图像。然而程序运行,但输出只是一个灰色的屏幕,如果我鼠标光标消失。 有没有人看到错误?或者是它使用
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);
//Create Sobel output
frame_copy1 = cvCreateImage(cvSize(frame->width,frame->height),IPL_DEPTH_16S,1);
cvSobel(frame_copy,frame_copy1,2,2,3);
cvShowImage("video:",frame_copy1);
cvWaitKey(33);}
cvReleaseCapture(&capture);
我认为他使用了正确的深度。如果输入为“IPL_DEPTH_8U”,则'cvSobel'预计输出类型为'IPL_DEPTH_16S',因为Sobel滤波的结果可能为负值。 – misha