查询OpenCV中的最大网络摄像头分辨率 [英] Query maximum webcam resolution in OpenCV
问题描述
我正在处理几种类型的相机,我需要知道每个相机能够提供的最大分辨率.
I'm dealing with several types of cameras and I need to know the maximum resolution each one is capable.
是否可以在OpenCV中查询此类属性?
Is there a way to query such property in OpenCV?
如果没有,还有其他方法吗?目前,该应用程序将在Windows下运行,并且所有项目都使用C ++开发.
If not, is there any other way? The application will work under Windows (by the moment) and all the project is being developed using C++.
推荐答案
一个对我有用的技巧:
只需将其设置为非常高的分辨率(高于任何常规捕获设备的功能),然后获得当前的分辨率. 您会看到设备将自动切换到其最大值.
Just set to a very high resolution (above the capabilities of any usual capture device), then get the current resolution. You will see that the device will automatically switch to his maximum value.
带有OpenCV 3.0的Python中的代码示例:
Code example in Python with OpenCV 3.0:
HIGH_VALUE = 10000
WIDTH = HIGH_VALUE
HEIGHT = HIGH_VALUE
self.__capture = cv2.VideoCapture(0)
fourcc = cv2.VideoWriter_fourcc(*'XVID')
self.__capture.set(cv2.CAP_PROP_FRAME_WIDTH, WIDTH)
self.__capture.set(cv2.CAP_PROP_FRAME_HEIGHT, HEIGHT)
width = int(self.__capture.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(self.__capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
希望有帮助.
这篇关于查询OpenCV中的最大网络摄像头分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!