PAL/NpuYoloV5/03_rk3588_hdmi_in_out_py/hdminVideo.py
2025-04-28 14:48:28 +08:00

24 lines
700 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

cap = cv2.VideoCapture('/dev/video10')
frames, loopTime, initTime = 0, time.time(), time.time()
fps = 0
while True:
frames += 1
ret, frame = cap.read()
if not ret:
break
# 现在应该可以直接使用frame不需要reshape
if frames % 30 == 0:
print("30帧平均帧率:\t", 30 / (time.time() - loopTime), "")
fps = 30 / (time.time() - loopTime)
loopTime = time.time()
cv2.putText(frame, "FPS: {:.2f}".format(fps), (10, 30),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
cv2.imshow("MIPI Camera", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()