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

32 lines
807 B
Python

import cv2
import time
def main():
source = "rtsp://192.168.192.96:8554/cam"
print("Connecting to stream...")
cap = cv2.VideoCapture(source)
if not cap.isOpened():
print("Error: Could not open RTSP source.")
return
print("Warming up reader...")
time.sleep(3.0)
# Read a few frames to clear the buffer
for _ in range(15):
ret, frame = cap.read()
if ret and frame is not None:
h, w, c = frame.shape
print(f"Captured frame with resolution: {w}x{h}")
cv2.imwrite("/home/jetson/karung/live_frame_native.png", frame)
print("Frame saved successfully on Jetson.")
else:
print("Error: Failed to read frame from stream.")
cap.release()
if __name__ == '__main__':
main()