Festlegen von Kameraparametern in OpenCV / Python

Ich verwende OpenCV (2.4) und Python (2.7.3) mit einer USB-Kamera von Thorlabs (DC1545M).

Ich mache eine Bildanalyse in einem Videostream und möchte in der Lage sein, einige der Kameraparameter in meinem Videostream zu ändern. Das Verwirrende ist, dass ich einige der Kameraeigenschaften ändern kann, aber nicht alle, und ich bin mir nicht sicher, was ich falsch mache.

Hier ist der Code, der die cv2-Bindungen in Python verwendet, und ich kann bestätigen, dass er ausgeführt wird:

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()

Als Referenz dient das erste Argument in dercap.set () Befehl bezieht sich auf die Aufzählung der Kameraeigenschaften, die unten aufgeführt sind:

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.
2. CV_CAP_PROP_POS_AVI_RATIO Relative position of the video file
3. CV_CAP_PROP_FRAME_WIDTH Width of the frames in the video stream.
4. CV_CAP_PROP_FRAME_HEIGHT Height of the frames in the video stream.
5. CV_CAP_PROP_FPS Frame rate.
6. CV_CAP_PROP_FOURCC 4-character code of codec.
7. CV_CAP_PROP_FRAME_COUNT Number of frames in the video file.
8. CV_CAP_PROP_FORMAT Format of the Mat objects returned by retrieve() .
9. CV_CAP_PROP_MODE Backend-specific value indicating the current capture mode.
10. CV_CAP_PROP_BRIGHTNESS Brightness of the image (only for cameras).
11. CV_CAP_PROP_CONTRAST Contrast of the image (only for cameras).
12. CV_CAP_PROP_SATURATION Saturation of the image (only for cameras).
13. CV_CAP_PROP_HUE Hue of the image (only for cameras).
14. CV_CAP_PROP_GAIN Gain of the image (only for cameras).
15. CV_CAP_PROP_EXPOSURE Exposure (only for cameras).
16. CV_CAP_PROP_CONVERT_RGB Boolean flags indicating whether images should be converted to RGB.
17. CV_CAP_PROP_WHITE_BALANCE Currently unsupported
18. CV_CAP_PROP_RECTIFICATION Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently)

Meine Fragen sind:

Ist es möglich, die Belichtungszeit der Kamera (oder die anderen Kameraparameter) über Python / OpenCV einzustellen?

Wenn nicht, wie würde ich vorgehen, um diese Parameter einzustellen?

Hinweis: Es gibt C ++ - Code, den der Kamerahersteller zur Verfügung stellt, der zeigt, wie man das macht, aber ich bin (bei weitem nicht) ein Experte in C ++ und würde jede pythonbasierte Lösung begrüßen.

Danke im Voraus!

Antworten auf die Frage(5)

Ihre Antwort auf die Frage