Howdy,
I'm running feature tracker on OAK-D-IoT-40 and sending the results over SPI to on-board integrated ESP32. I've combined these example codes:
https://github.com/luxonis/esp32-spi-message-demo/tree/main/parse_meta
https://docs.luxonis.com/projects/api/en/latest/samples/FeatureTracker/feature_tracker/
Messages come through but I can't figure out what I'm doing wrong when extracting the values. Here's the ESP code that never enters the for loop:
...
dai::SpiApi mySpiApi;
mySpiApi.set_send_spi_impl(&esp32_send_spi);
mySpiApi.set_recv_spi_impl(&esp32_recv_spi);
while(1)
{
dai::Message msg;
if (mySpiApi.req_message (&msg, METASTREAM))
{
dai::RawTrackedFeatures features;
mySpiApi.parse_metadata (&msg.raw_meta, features);
printf ("message size: %d \t features: %d \t type is correct: %d \n",
msg.raw_meta.size,
features.trackedFeatures.size(),
msg.raw_meta.type==dai::DatatypeEnum::TrackedFeatures);
for(const auto& feat : features.trackedFeatures)
{
...
Output is as follows. Message size changes when moving camera but no features are extracted from data:
Should I care about the 'Allocate RX buffer for DMA note? It appears also with parse_meta example that is working well.
And Myriad side of the code:
pipeline` = dai.Pipeline()
camera = pipeline.create(dai.node.ColorCamera)
featureTracker = pipeline.create(dai.node.FeatureTracker)
xoutPassthroughFrame = pipeline.create(dai.node.XLinkOut)
xoutTrackedFeatures = pipeline.create(dai.node.XLinkOut)
xinTrackedFeaturesConfig = pipeline.create(dai.node.XLinkIn)
xoutPassthroughFrame.setStreamName("passthroughFrame")
xoutTrackedFeatures.setStreamName("trackedFeatures")
xinTrackedFeaturesConfig.setStreamName("trackedFeaturesConfig")
camera.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
camera.setBoardSocket(dai.CameraBoardSocket.RGB)
camera.video.link(featureTracker.inputImage)
featureTracker.passthroughInputImage.link(xoutPassthroughFrame.input)
featureTracker.outputFeatures.link(xoutTrackedFeatures.input)
xinTrackedFeaturesConfig.out.link(featureTracker.inputConfig)
spiOut = pipeline.create(dai.node.SPIOut)
spiOut.setStreamName ("Myriad_to_ESP32")
spiOut.setBusId(0)
spiOut.input.setBlocking(False)
spiOut.input.setQueueSize (2)
featureTracker.outputFeatures.link (spiOut.input)
numShaves = 2
numMemorySlices = 2
featureTracker.setHardwareResources(numShaves, numMemorySlices)
featureTrackerConfig = featureTracker.initialConfig.get()
with dai.Device(pipeline) as device:
passthroughImageQueue = device.getOutputQueue("passthroughFrame", 8, False)
outputFeaturesQueue = device.getOutputQueue("trackedFeatures", 8, False)
inputFeatureTrackerConfigQueue = device.getInputQueue("trackedFeaturesConfig")
WindowName = "test"
FeatureDrawer = FeatureTrackerDrawer("Feature tracking duration (frames)", WindowName)
while True:
inPassthroughFrame = passthroughImageQueue.get()
passthroughFrame = inPassthroughFrame.getFrame()
Frame = cv2.cvtColor(passthroughFrame, cv2.COLOR_BGR2RGB)
trackedFeatures = outputFeaturesQueue.get().trackedFeatures
FeatureDrawer.trackFeaturePath(trackedFeatures)
FeatureDrawer.drawFeatures(Frame)
cv2.imshow(WindowName, Frame)
key = cv2.waitKey(1)