1

So I set

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

I also tried integer 5 instead of cv2.CAP_PROP_FPS. Neverteless, frame rate doesn't change. I get 30 when I

print(cap.get(cv2.CAP_PROP_FPS))

Why?

Alex
  • 944
  • 4
  • 15
  • 28
  • Which specific version of OpenCV? Some standard distribution or self-compiled? What specific operating system and version? Which video capture backend is it using? What specific camera? – Dan Mašek May 25 '16 at 16:08
  • 5 is a reference to fps variable – Alex May 25 '16 at 16:46
  • Ok i changed fps to 10 in the VideoWrite instance, so it sort of does the job. Im still perplexed why camera fps doesnt change though – Alex May 25 '16 at 16:47
  • fps is used by videowrite. Your program try to grab image when you ask it. Grabbing is possible if time exposure+time transfert to system is less than interval between two grab called. There is no fps here. – LBerger May 25 '16 at 18:58
  • so essentially a camera can't have fps? – Alex May 25 '16 at 20:40
  • My english is not very good. I write fps is for videowrite as it is written here http://stackoverflow.com/questions/19662193/opencv-videocapturegetcv-cap-prop-fps-returns-0-fps. I think now some interface in opencv support cap-prop-fps like DC1394. For my basic logitech webcam I cannot set CAP_PROP_FPS (may be driver is not supported). I use CV_CAP_PROP_EXPOSURE CV_CAP_PROP_GAIN to set camera parameter. If your camera got automatic adjustement all settings are disable – LBerger May 26 '16 at 14:39
  • I have the same issue. Have you found something? – LucG Sep 07 '18 at 07:21

2 Answers2

1

The problem maybe is with the codec of the camera stream and not with the FPS itself, for example, if your camera only supports YUYV it is probably that you could only work with some specific FPS, try with the app guvcview to check this in a GUI.

Try to change the codec to MJPG and then change the FPS using CAP_PROP_FPS. I'm using a Logitech C922 pro and this works for me to configure 1080p and 30fps, if you have other camera probably yu need to use a lower resolution to achieve 30fps:

import cv2 as cv
def decode_fourcc(v):
    v = int(v)
    return "".join([chr((v >> 8 * i) & 0xFF) for i in range(4)])

def setfourccmjpg(cap):
    oldfourcc = decode_fourcc(cap.get(cv.CAP_PROP_FOURCC))
    codec = cv.VideoWriter_fourcc(*'MJPG')
    res=cap.set(cv.CAP_PROP_FOURCC,codec)
    if res:
        print("codec in ",decode_fourcc(cap.get(cv.CAP_PROP_FOURCC)))
    else:
        print("error, codec in ",decode_fourcc(cap.get(cv.CAP_PROP_FOURCC)))
cap = cv.VideoCapture(CAMERANUM)
cu.setfourccmjpg(cap)
w=1920
h=1080
fps=30
res1=cap.set(cv.CAP_PROP_FRAME_WIDTH,w)
res2=cap.set(cv.CAP_PROP_FRAME_HEIGHT,h)
res3=cap.set(cv.CAP_PROP_FPS,fps)

then resume your normal video capture polling loop.

-1

Not all openCV parameters are supported by all cameras from an opencv standpoint. Each camera has a different set of parameters that need to be set. You need to find out what parameters are supported by your camera...

kush
  • 11
  • 5