I'm trying to update some code from openCV to openCV2 in python. The original code is as follows:
self.capture = cv.CaptureFromCAM(0)
cv.SetCaptureProperty( self.capture, cv.CV_CAP_PROP_FRAME_WIDTH, 160 );
cv.SetCaptureProperty( self.capture, cv.CV_CAP_PROP_FRAME_HEIGHT, 120 );
The code that I wrote for openCV2 is this:
self.capture = cv2.VideoCapture(0)
cv2.VideoCapture.set( CV_CAP_PROP_FRAME_WIDTH, 160 );
cv2.VideoCapture.set( CV_CAP_PROP_FRAME_HEIGHT, 120 );
However this does not work I'm getting an error that says:
cv2.VideoCapture.set( CV_CAP_PROP_FRAME_WIDTH, 160 ); AttributeError: 'builtin_function_or_method' object has no attribute 'set'
I removed .cv.CV_
, and it worked.
Change:
cv2.cv.CV_CAP_PROP_FRAME_HEIGHT
to:
cv2.CAP_PROP_FRAME_HEIGHT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With