我会避免将视频摄像机拍摄的每一帧转换成cvtColor(frame, image, CV_RGB2GRAY);
是否仍然设置VideoCapture为直接进入灰度?
例:
VideoCapture cap(0);
cap.set(CV_CAP_PROP_FRAME_WIDTH,420);
cap.set(CV_CAP_PROP_FRAME_HEIGHT,340);
cap.set(CV_CAP_GREYSCALE,1); //< ???
Run Code Online (Sandbox Code Playgroud)
如果您的相机支持YUV420,那么您可以选择Y频道:http: //en.wikipedia.org/wiki/YUV
如何做到这一点在这里得到了很好的解释: 访问OpenCV中的每个单独的通道
警告:Y通道可能不是您使用split()获得的第一个Mat,因此您应该单独执行所有这些的imshow()并选择看起来像"真实"灰色图像的那个.其他人只会出于对比,所以这很明显.对我来说这是第二个垫子.
通常,任何相机都应该能够进行YUV420,因为直接以RGB格式发送帧速度较慢,因此几乎所有相机都使用YUV.:)
这是不可能的。以下是所有代码的列表:
CV_CAP_PROP_POS_MSEC - position in milliseconds from the file beginning
CV_CAP_PROP_POS_FRAMES - position in frames (only for video files)
CV_CAP_PROP_POS_AVI_RATIO - position in relative units (0 - start of the file, 1 - end of the file)
CV_CAP_PROP_FRAME_WIDTH - width of frames in the video stream (only for cameras)
CV_CAP_PROP_FRAME_HEIGHT - height of frames in the video stream (only for cameras)
CV_CAP_PROP_FPS - frame rate (only for cameras)
CV_CAP_PROP_FOURCC - 4-character code of codec (only for cameras).
Run Code Online (Sandbox Code Playgroud)
或者(如果可能,使用一些实用程序)您可以将相机设置为仅显示灰度图像。
要将彩色图像转换为灰度,您必须使用代码调用cvtColorCV_BGR2GRAY。这应该不会花费太多时间。
| 归档时间: |
|
| 查看次数: |
14151 次 |
| 最近记录: |