我需要在Mac os X 10.8上使用OpenCV从GIge相机保存灰度视频。我使用以下代码:

 namedWindow("My video",CV_WINDOW_AUTOSIZE);
 Size frameSize(659, 493);
 VideoWriter oVideoWriter ("MyVideo.avi",-1, 30, frameSize, false);

 While(1)
 {
 ...
     Mat Image=Mat(Size(GCamera.Frames[Index].Width,GCamera.Frames[Index].Height),CV_8UC1,GCamera.Frames[Index].ImageBuffer);

     oVideoWriter.write(Image);
 ...
 }

我收到此错误:

最佳答案

我是这样写的:

 VideoWriter oVideoWriter ("MyVideo.avi",CV_FOURCC('M','J','P','G'), 30, frameSize);

 While(1)
 {
     Mat Image=Mat(Size(GCamera.Frames[Index].Width,GCamera.Frames[Index].Height),CV_8UC1,GCamera.Frames[Index].ImageBuffer);
     Mat colorFrame;
     cvtColor(Image, colorFrame, CV_GRAY2BGR);
     oVideoWriter.write(colorFrame);
 }

关于c++ - 使用opencv创建灰度视频,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23066542/

10-12 20:26