File size: 836 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
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:40921"
# Global variables, change it to adapt your needs
CAMERA_WIDTH = 960
CAMERA_HEIGHT = 540

# Create a VideoCapture object using the TCP stream URL
cap = cv2.VideoCapture(TCP_STREAM_URL)

# Check if the VideoCapture object opened successfully
assert cap.isOpened(), "Error: Could not open video capture."

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()