Files
karung-counting-feedmill-se…/archive/get_calib_frame.py
T

36 lines
940 B
Python

import cv2
import sys
def main():
source = "2026-07-27 09-11-50.mp4"
if len(sys.argv) > 1:
source = sys.argv[1]
print(f"Connecting to: {source}")
cap = cv2.VideoCapture(source)
if not cap.isOpened():
print("Error: Could not open source!")
return
# Read a few frames to let the camera stabilize exposure/stream
print("Reading frames...")
frame = None
for i in range(10):
ret, temp_frame = cap.read()
if ret:
frame = temp_frame
if frame is None:
print("Error: Could not read any frame from the source!")
cap.release()
return
output_filename = "calib_frame.jpg"
cv2.imwrite(output_filename, frame)
print(f"Successfully saved clean frame as {output_filename}!")
print(f"Resolution: {frame.shape[1]}x{frame.shape[0]}")
cap.release()
if __name__ == "__main__":
main()