Hi,
- I am processing real time video from logitech c922 webcam in python. I can set width and hight using the below functions successfully:
camera.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
camera.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
However, I can’t able to set the focus type(manual) and FPS using below functions:
camera.set(cv2.CAP_PROP_AUTOFOCUS, 0)
camera.set(cv2.CAP_PROP_FOCUS, 30)
camera.set(cv2.CAP_PROP_FPS, 50)
How to do it?
- I have attached python code which displays realtime video with FPS.
import cv2
import time
font = cv2.FONT_HERSHEY_SIMPLEX
camera = cv2.VideoCapture(0)
camera.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080) #1080, 720, 360
camera.set(cv2.CAP_PROP_FRAME_WIDTH, 1920) #1920, 1280, 640
while True:
start = time.time()
ret, image = camera.read()
[h, w, d] = image.shape
if cv2.waitKey(1)& 0xFF == ord('q'):
break;
end = time.time()
fps = "FPS: %.1f" % (1/(end - start))
cv2.putText(image, fps, (0, 25), font, 1, (0, 0, 255), 2)
cv2.imshow('Image', image)
camera.release()
cv2.destroyAllWindows()
Actual problem is for 1080p resolution FPS is 30. But i am getting 46 fps(oscillating values) sometimes as per the above calculation, while using logitech c922 webcam.
how to calculate FPS exactly? Is there any other formula to find it? or Is there any explanation behind it? Please help to let me know about it…