Hi, i have an OAK-D PRO POE that i'm trying to learn how to use.
I would like for it to listen for an UDP message and based on the message do an action ( transmit the depth image )
My code :
import cv2
import depthai as dai
# Start defining a pipeline
pipeline = dai.Pipeline()
# Define a source - color camera
cam = pipeline.create(dai.node.ColorCamera)
# Script node
script = pipeline.create(dai.node.Script)
script.setScript("""
import time
import socket
ctrl = CameraControl()
ctrl.setCaptureStill(True)
UDP_IP = "10.168.3.55"
UDP_PORT = 5005
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))
test = True
while test:
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
node.io['out'].send(ctrl)
if data == 2:
test = False
#while True:
#time.sleep(1)
#node.io['out'].send(ctrl)
""")
# XLinkOut
xout = pipeline.create(dai.node.XLinkOut)
xout.setStreamName('still')
# Connections
script.outputs['out'].link(cam.inputControl)
cam.still.link(xout.input)
# Connect to device with pipeline
with dai.Device(pipeline) as device:
while True:
img = device.getOutputQueue("still").get()
cv2.imshow('still', img.getCvFrame())
if cv2.waitKey(1) == ord('q'):
break
[19443010F168761300] [10.168.3.55] [5.457] [Script(1)] [critical] ModuleNotFoundError: No module named 'socket'
At:
/usr/lib/python3.9/importlib/_bootstrap.py(984): _find_and_load_unlocked
/usr/lib/python3.9/importlib/_bootstrap.py(1007): _find_and_load
<script>(3): <module>
Traceback (most recent call last):
File "C:/Users/de anta-a/Desktop/Camera OAK/gen2-pointcloud/rgbd-pointcloud/test_ondevice.py", line 52, in <module>
img = device.getOutputQueue("still").get()
RuntimeError: Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: 'still' (X_LINK_ERROR)'
I updated the bootloader.
Is there something else i need to do ?