File size: 975 Bytes
b98ffbb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
import cv2
import pyarrow as pa
from dora import Node
node = Node()
# TCP stream URL (replace with your stream URL)
# TCP_STREAM_URL = "tcp://192.168.2.1:40922"
STREAM_URL = "tcp://192.168.2.1:40921"
# TCP_STREAM_URL = "/home/peiji/截图/截图 2024-02-22 10-48-33.png"
# Global variables, change it to adapt your needs
CAMERA_WIDTH = 1920
CAMERA_HEIGHT = 1080
# Create a VideoCapture object using the TCP stream URL
cap = cv2.VideoCapture(STREAM_URL)
# Check if the VideoCapture object opened successfully
assert cap.isOpened(), "Error: Could not open video capture."
# print(cap.isOpened())
while True:
# Read a frame from the stream
ret, frame = cap.read()
if not ret:
break # Break the loop when no more frames are available
frame = cv2.resize(frame, (CAMERA_WIDTH, CAMERA_HEIGHT))
node.send_output("image", pa.array(frame.ravel()))
# Release the VideoCapture object and any OpenCV windows
cap.release()
cv2.destroyAllWindows()
|