OpenCV中文网站

 找回密码
 立即注册
搜索
热搜: 安装 配置
查看: 4790|回复: 3

emgu中保存视频的问题

[复制链接]
发表于 2010-3-10 10:38:01 | 显示全部楼层 |阅读模式
我只能将灰度图像保存成AVI文件,不能将彩色图像保存成AVI文件。当保存彩色图像时,抛出异常:
cvWriteFrame() needs images with depth = IPL_DEPTH_8U and nChannels = 1.

附程序: Capture camera = new Capture("E:\\music\\avril.avi");
            if (camera == null)
            {
                MessageBox.Show("can't find a camera", "error");
            }
            double fps= camera.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FPS);
            double cpHeight=camera.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT);
            double cpWidth = camera.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH);
            double fourcc=camera.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FOURCC);
            CvInvoke.cvNamedWindow("camera");
            Image<Bgr, byte> temp = camera.QueryFrame();
           
            VideoWriter video = new VideoWriter(&quot;video.avi&quot;,(int)fourcc,20, 800, 480,false);
            while (temp != null)
            {
                CvInvoke.cvShowImage(&quot;camera&quot;, temp.Ptr);
                temp = camera.QueryFrame();

                int c = CvInvoke.cvWaitKey(20);
                video.WriteFrame<Bgr,byte>(temp);//如果用Gray就不会报错,可以保存,现在这样出现上述错误
              

                if (c == 27) break;
            }


            video.Dispose();
            camera.Dispose();
            CvInvoke.cvDestroyWindow(&quot;camera&quot;);
回复

使用道具 举报

 楼主| 发表于 2010-3-10 10:39:35 | 显示全部楼层

emgu中保存视频的问题

我用的是EMGU.CV2.0的,网上也找不到同样的问题……希望各位大侠帮助
回复 支持 反对

使用道具 举报

发表于 2010-3-12 11:17:53 | 显示全部楼层

emgu中保存视频的问题

我也遇到了这样的问题。。
回复 支持 反对

使用道具 举报

发表于 2010-3-15 09:19:35 | 显示全部楼层

emgu中保存视频的问题

把你的代码:
VideoWriter video = new VideoWriter(&quot;video.avi&quot;,(int)fourcc,20, 800, 480,false);
改成:
VideoWriter video = new VideoWriter(&quot;video.avi&quot;,(int)fourcc,20, 800, 480,true);
应该就可以了。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|OpenCV中文网站

GMT+8, 2024-5-5 07:28 , Processed in 0.010659 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表