Updating code from openCV to openCV2

Try this one. It will work.

self.capture.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, 160)

It seems that CV_CAP_PROP_POS_MSEC and other such similar properties are deprecated in your installed version of Opencv, to solve the problem for example this property ,Change it to cv2.CAP_PROP_POS_MSEC and similarly others too. Works good for me on Opencv 3.1


I removed .cv.CV_, and it worked.

Change:

cv2.cv.CV_CAP_PROP_FRAME_HEIGHT

to:

cv2.CAP_PROP_FRAME_HEIGHT

i came across this same issue, was able to get it work with:

cap = cv2.VideoCapture(0)

cap.set(cv2.CAP_PROP_FRAME_WIDTH, 160);
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 120);

Tags:

Python

Opencv