Skip to content

Instantly share code, notes, and snippets.

@companje
Created February 26, 2025 10:32
Show Gist options
  • Save companje/880b7712bd9191952606d17a3a0ac648 to your computer and use it in GitHub Desktop.
Save companje/880b7712bd9191952606d17a3a0ac648 to your computer and use it in GitHub Desktop.
Kurokesu C3_4K resolutions
import cv2
def get_framerate(prev_time=[0], fps=[30]):
current_time = cv2.getTickCount()
elapsed = (current_time - prev_time[0]) / cv2.getTickFrequency()
prev_time[0] = current_time
fps[0] = (1.0 / elapsed * 0.1) + (fps[0] * 0.9)
return fps[0]
cam = cv2.VideoCapture(0)
resolutions = [(3840,2160), (2592,1944), (2048,1563), (1920,1080), (1600,1200),
(1280,720), (1280,960), (800,600), (640,480), (320,240)]
for w, h in resolutions:
print(f"testing {w}x{h}...")
cam.set(cv2.CAP_PROP_FRAME_WIDTH, w)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, h)
for _ in range(60):
ret, frame = cam.read()
fps = get_framerate()
cv2.putText(frame, f'fps: {fps:.0f}', (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
cv2.putText(frame, f'res: {w}x{h}', (10, 80), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
cv2.imwrite(f"{w}x{h}.jpg", frame)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment