Thorlabs(DC1545M)のUSBカメラでOpenCV(2.4)とPython(2.7.3)を使用しています。OpenCV/Pythonでのカメラパラメータの設定
私は、ビデオストリーム上のいくつかの画像解析をやっていると私は私のビデオストリームからカメラパラメータの一部を変更できるようにしたいと思います。混乱させることは、私がカメラのプロパティの一部を変更することができますが、それらのすべてを変更することができず、私が間違っていることがわかりません。ここ
PythonでCV2バインディングを使用して、コードであり、私はそれが動作することを確認することができる:コマンドが参照)参考
import cv2
#capture from camera at location 0
cap = cv2.VideoCapture(0)
#set the width and height, and UNSUCCESSFULLY set the exposure time
cap.set(3,1280)
cap.set(4,1024)
cap.set(15, 0.1)
while True:
ret, img = cap.read()
cv2.imshow("input", img)
#cv2.imshow("thresholded", imgray*thresh2)
key = cv2.waitKey(10)
if key == 27:
break
cv2.destroyAllWindows()
cv2.VideoCapture(0).release()
、cap.setの最初の引数(以下に示すカメラのプロパティの列挙、:
0. CV_CAP_PROP_POS_MSEC Current position of the video file in milliseconds.
1. CV_CAP_PROP_POS_FRAMES 0-based index of the frame to be decoded/captured next.
3. CV_CAP_PROP_POS_AVI_RATIO Relative position of the video file
4. CV_CAP_PROP_FRAME_WIDTH Width of the frames in the video stream.
5. CV_CAP_PROP_FRAME_HEIGHT Height of the frames in the video stream.
6. CV_CAP_PROP_FPS Frame rate.
7. CV_CAP_PROP_FOURCC 4-character code of codec.
8. CV_CAP_PROP_FRAME_COUNT Number of frames in the video file.
9. CV_CAP_PROP_FORMAT Format of the Mat objects returned by retrieve() .
10. CV_CAP_PROP_MODE Backend-specific value indicating the current capture mode.
11. CV_CAP_PROP_BRIGHTNESS Brightness of the image (only for cameras).
12. CV_CAP_PROP_CONTRAST Contrast of the image (only for cameras).
13. CV_CAP_PROP_SATURATION Saturation of the image (only for cameras).
14. CV_CAP_PROP_HUE Hue of the image (only for cameras).
15. CV_CAP_PROP_GAIN Gain of the image (only for cameras).
16. CV_CAP_PROP_EXPOSURE Exposure (only for cameras).
17. CV_CAP_PROP_CONVERT_RGB Boolean flags indicating whether images should be converted to RGB.
18. CV_CAP_PROP_WHITE_BALANCE Currently unsupported
19. CV_CAP_PROP_RECTIFICATION Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently)
私の質問は以下のとおりです。
python/opencvでカメラ露出時間(または他のカメラパラメータ)を設定することはできますか?
ない場合は、どのように私はこれらのパラメータの設定については行くだろうか?
注:カメラメーカーが提供するC++コードは、これを行う方法を示していますが、私はC++の熟練者ではなく、Pythonベースのソリューションに感謝します。
ありがとうございます!
したがって、15番目のオプションは何ですか、つまりCV_CAP_PROP_EXPOSUREですか?それは暴露時間ですか? –
です。私が作ったのは、それを修正しようとすると、測定可能な結果が出るということです。 (これは 'cap.set(15、x)'で、 'x'の値は測定可能な変化をもたらさない)。 ところで、あなたのブログにありがとう。 Pythonを使ってopencvを高速化することは、私にとって非常に便利でした。 – Mike
最後の行:cv2.VideoCapture(0).release()は単にcap.release()になることができます: – otterb