Ask Your Question

Revision history [back]

set(cv2.CAP_PROP_FPS, 60) is not working and camera feed lagging

using PyCharm on MacOS. installed OpenCV by using command: pip install opencv-contrib-python

cap.set(cv2.CAP_PROP_FPS, 60) does not reset CAP_PROP_FPS and video stream is lagging.

someone mentioned libv4l-dev should be installed, but libv4l-dev cannot be installed on macOS.

after set FPS, cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) will throw below error. OpenCV(4.1.1) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

import cv2

import os

toggle = True

cap = cv2.VideoCapture(0)

cap.set(cv2.CAP_PROP_FPS, 60)

while True:

ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow("image", gray)
if toggle:
    print("testing")
    os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "Python" to true' ''')
    toggle = False

if cv2.waitKey(1) & 0xFF == ord('q'):
    break

cap.release()

cv2.destroyAllWindows()

set(cv2.CAP_PROP_FPS, 60) is not working and camera feed lagging

using PyCharm on MacOS. installed OpenCV by using command: pip install opencv-contrib-python

opencv-contrib-python.

cap.set(cv2.CAP_PROP_FPS, 60) 60) does not reset CAP_PROP_FPS CAP_PROP_FPS and video stream is lagging.

someone mentioned libv4l-dev libv4l-dev should be installed, but libv4l-dev libv4l-dev cannot be installed on macOS.

after set FPS, cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) cv2.COLOR_BGR2GRAY) will throw below error. OpenCV(4.1.1) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

'cvtColor'.

import cv2

cv2 import os

os toggle = True

True cap = cv2.VideoCapture(0)

cv2.VideoCapture(0) cap.set(cv2.CAP_PROP_FPS, 60)

60) while True:

True:

    ret, frame = cap.read()
 gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
 cv2.imshow("image", gray)
 if toggle:
     print("testing")
     os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "Python" to true' ''')
     toggle = False

 if cv2.waitKey(1) & 0xFF == ord('q'):
     break

cap.release()
cv2.destroyAllWindows()

cap.release()

cv2.destroyAllWindows()

set(cv2.CAP_PROP_FPS, 60) is not working and camera feed lagging

using PyCharm on MacOS. installed OpenCV by using command: pip install opencv-contrib-python.

cap.set(cv2.CAP_PROP_FPS, 60) does not reset CAP_PROP_FPS and video stream is lagging.

someone mentioned libv4l-dev should be installed, but libv4l-dev cannot be installed on macOS.

after set FPS, cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) will throw below error. OpenCV(4.1.1) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'.

import cv2

import os

toggle = True

cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FPS, 60)

while True:

    ret, frame = cap.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    cv2.imshow("image", gray)
    if toggle:
        print("testing")
        os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "Python" to true' ''')
        toggle = False

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()