本文介绍了opencv VideoCapture.set灰度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我会避免使用cvtColor(frame, image, CV_RGB2GRAY);
转换摄像机拍摄的每一帧无论如何,是否可以将VideoCapture
设置为直接获得灰度?
I would avoid to convert each frame taken by video camera with cvtColor(frame, image, CV_RGB2GRAY);
Is there anyway to set VideoCapture
to get directly in greyscale?
示例:
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); //< ???
推荐答案
这是不可能的.这是所有代码的列表:
This is impossible. Here's list of all codes:
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).
或者(如果可能,使用某些实用程序)可以将相机设置为仅显示灰度图像.
Or (if it's possible, using some utilities) you can setup your camera to show only grayscale image.
要将彩色图像转换为灰度图像,必须调用 cvtColor ,代码为CV_BGR2GRAY
.这应该不会花很多时间.
To convert colored image to grayscale you have to call cvtColor with code CV_BGR2GRAY
. This shouldn't take much time.
这篇关于opencv VideoCapture.set灰度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!