erik
Erik, thanks a lot for your informative reply.
Will keep them in consideration when working on the project
For (1), do you mean to capture the frame and send it to the host first, and then accordingly send it back to the device to either NN? If so, I have tried sending a frame back to the device, and then again back to the host to display the inference result, however, the output couldn't be displayed. Instead of having an image of (300x300x3), I had an output size of (270000, ). Any thoughts on how to solve this issue?
The pipeline looks like this: I implemented it to solve the issue that ImageManip cannot resize STILL images; so I created this pipeline to capture a still image, resize on the host, and send it back to device for NN inference
xinCaptureCommand --> camRGB -> outStillRGB
then, do the resizing on host, and we have
inResizedImage -> outResult
x = cv2.imread("blue.png")
pipeline = dai.Pipeline()
# Create input control node to acquire capture command
xinCaptureCommand = pipeline.create(dai.node.XLinkIn)
xinCaptureCommand.setStreamName("capture")
# Create Camera node and give its properties
camRGB = pipeline.create(dai.node.ColorCamera)
camRGB.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
camRGB.setStillSize(1080, 1080)
camRGB.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)
# Create output node for still images
outStillRGB = pipeline.create(dai.node.XLinkOut)
outStillRGB.setStreamName("rgbStill")
# Create input node to receive resized imsge from host
inResizedImage = pipeline.create(dai.node.XLinkIn)
inResizedImage.setStreamName("resizedImage")
# Create outResult output node for still images
outResult = pipeline.create(dai.node.XLinkOut)
outResult.setStreamName("outResult")
# Linking
xinCaptureCommand.out.link(camRGB.inputControl)
camRGB.still.link(outStillRGB.input)
inResizedImage.out.link(outResult.input)
# Connect to device and start the pipeline
with dai.Device(pipeline) as device:
# Create queues
stillQueue = device.getOutputQueue(name="rgbStill")
captureInputQueue = device.getInputQueue("capture")
sendResizedQueue = device.getInputQueue("resizedImage")
outResultQ = device.getOutputQueue("outResult")
cv2.imshow("x",x)
while True:
stillFrame = stillQueue.tryGet()
if stillFrame is not None:
print("still frame:", stillFrame.getHeight(), stillFrame.getWidth(), stillFrame.getType())
frame = stillFrame.getCvFrame()
cv2.imshow("frame", frame)
resized = imutils.resize(frame, width = 300)
print("resized frame:" , resized.shape)
sendResized = dai.ImgFrame()
sendResized.setData(resized)
#sendResized.setData(to_planar(resized, (300, 300)))
sendResized.setHeight(300)
sendResized.setWidth(300)
#sendResized.setType("RGB888i")
sendResizedQueue.send(sendResized)
testFrame = outResultQ.tryGet()
if testFrame is not None:
print("frame W,H & type after receiving back again:", testFrame.getHeight(), testFrame.getWidth(), testFrame.getType())
result = testFrame.getCvFrame()
cv2.imshow("result", result)
print("final result shape:", result.shape)
# Send capture command from host to device
key = cv2.waitKey(1)
if key == ord("q"):
break
elif key == ord('c'):
ctrl = dai.CameraControl()
ctrl.setCaptureStill(True)
captureInputQueue.send(ctrl)
print("captured")
For (2), what to you mean by "other outputs"?
Best,
Hussain