1

I am trying to set the return format for a video stream from an Imaging Source DFK31AU03 USB 2.0 camera. When I get the video format using the following Python2 code:

import cv2

# Get a handle to the camera
cam = cv2.VideoCapture(0)

# Print various camera properties
print "CV_CAP_PROP_FORMAT: " + str(cam.get(cv2.cv.CV_CAP_PROP_FORMAT))
print "CV_CAP_PROP_MODE: " + str(cam.get(cv2.cv.CV_CAP_PROP_MODE))
print "CV_CAP_PROP_FPS: " + str(cam.get(cv2.cv.CV_CAP_PROP_FPS))
print "CV_CAP_PROP_CONTRAST: " + str(cam.get(cv2.cv.CV_CAP_PROP_CONTRAST))
print "CV_CAP_PROP_GAIN: " + str(cam.get(cv2.cv.CV_CAP_PROP_GAIN))
print "CV_CAP_PROP_FRAME_WIDTH: " + str(cam.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH))
print "CV_CAP_PROP_FRAME_HEIGHT: " + str(int(cam.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)))
print "CV_CAP_PROP_POS_FRAMES: " + str(cam.get(cv2.cv.CV_CAP_PROP_POS_FRAMES))
print "CV_CAP_PROP_EXPOSURE: " + str(cam.get(cv2.cv.CV_CAP_PROP_EXPOSURE))

# Edit a troublesome property and print again
cam.set(cv2.cv.CV_CAP_PROP_MODE, cv2.cv.CV_8UC1);

# Print the "MODE" property again
print "\n-- This is one of the problem variables --"
print "The \"MODE\" property should be set to: " + str(cv2.cv.CV_8UC1)
print "CV_CAP_PROP_MODE: " + str(cam.get(cv2.cv.CV_CAP_PROP_MODE))

# Release the handle to the camera
cam.release()

This code prints some of the properties of the camera. For me, the problem is that many of the properties print as -1.0 or 0.0 when they should have other values. The documentation that I have found for this class is quite poor and there is little explanation as to what each value means and possible reasons for the properties of the camera not being returned. The camera I am using is not cheap.

Here is a sample output of the code as it runs for me:

enter image description here

Is it the case that my camera does not have access to these properties? It is not cheap camera so this would be surprising. Any help would be appreciated.

deanshanahan
  • 318
  • 5
  • 14
  • 1
    Have you looked at this [answer](http://stackoverflow.com/a/11433221/5699807)? – Priyank Mar 07 '17 at 14:00
  • @Priyank Thank you. That part answers my question. I am hoping someone on here will have a nice workaround for getting some of these properties. I have a already worked out the FPS using a busy-wait loop and a timer. – deanshanahan Mar 07 '17 at 14:26

0 Answers0