PS3EyeDirectShow icon indicating copy to clipboard operation
PS3EyeDirectShow copied to clipboard

OpenCV (Python) cant seem to set at 320x240 with higher frame rates.

Open lucid-codr opened this issue 6 months ago • 1 comments

I tried with OBS and when i select 320x240 i get good high fps feed but

in open cv

import cv2

cap = cv2.VideoCapture(1)
# Start video capture from the webcam
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*'MJPG'))

width = 320  # Set the desired width
height = 240  # Set the desired height
cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)

# Set the frame rate
fps = 183# Set the desired frame rate
cap.set(cv2.CAP_PROP_FPS, fps)

# Check if the settings were applied
actual_width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
actual_height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
actual_fps = cap.get(cv2.CAP_PROP_FPS)
print(f"Resolution set to: {int(actual_width)}x{int(actual_height)} at {int(actual_fps)} fps")

while True:
    # Capture a frame from the webcam
    ret, frame = cap.read()

    curr_time = time.time()
    frame_count += 1

    if curr_time - prev_time >= 1.0:
        fps = frame_count / (curr_time - prev_time)
        prev_time = curr_time
        frame_count = 0
        print(f"Frame Rate: {fps:.2f} FPS")
        
        k = cv2.waitKey(1)
    if k == ord('x'):
        break

# Release the webcam and close all OpenCV windows
cap.release()
cv2.destroyAllWindows()

The actual resolution is always set to ""640x480" at 30 fps I'm using windows 11

could someone please help me through this.

lucid-codr avatar Aug 21 '24 07:08 lucid-codr