I am trying to test OAK-D-Lite pipelines by sending recorded .mp4 file back through the device. I am basically following the example from the Video & MobilenetSSD example code. I started out simplifying the code to input the .mp4 file to a xLinkIn node and send the frames back out to a xLinkOut node and viewed the output with cv2.imshow() and all was fine.
However, when I added an ImageManip node in between the xLinkIn and xLinkOut nodes, I got the fatal error. I have used the ImageManip node with the same parameters in another pipeline and it worked fine. Did I do something wrong or did I come across a bug of some sort?
The following is the code I am running
import depthai as dai
import numpy as np
from time import monotonic
# Define Frame
FRAME_SIZE = (640, 400)
DET_INPUT_SIZE = (300,300)
# Define input file and capture source
fileName = "Test_Videos/test640x400.mp4"
# Start defining a pipeline
pipeline = dai.Pipeline()
# Define an input stream node
xinFrame_in = pipeline.createXLinkIn()
xinFrame_in.setStreamName("inFrame")
# Create ImageManip node
manip = pipeline.createImageManip() # create the imageManip node
manip.initialConfig.setResize(DET_INPUT_SIZE[0], DET_INPUT_SIZE[1]) # scale image to detection NN need
manip.initialConfig.setKeepAspectRatio(False)
# Create a output stream node
x_manip_out = pipeline.createXLinkOut()
x_manip_out.setStreamName("outFrame")
# Link input stream to manip to output stream
xinFrame_in.out.link(manip.inputImage)
manip.out.link(x_manip_out.input)
# Start pipeline
with dai.Device(pipeline) as device:
# Input queue will be used to send video frames from the file to the device.
q_inFrame = device.getInputQueue(name="inFrame")
# Output queue to be used to view what is sent to the nn.
q_outFrame = device.getOutputQueue(name="outFrame", maxSize=1, blocking=False)
frame = None
def to_planar(arr: np.ndarray, shape: tuple) -> np.ndarray:
return cv2.resize(arr, shape).transpose(2, 0, 1).flatten()
cap = cv2.VideoCapture(fileName)
while cap.isOpened():
# Get frame from file and send to xLink input
ret, frame = cap.read()
img = dai.ImgFrame()
img.setData(to_planar(frame, (FRAME_SIZE[0], FRAME_SIZE[1])))
img.setTimestamp(monotonic())
img.setWidth(FRAME_SIZE[0])
img.setHeight(FRAME_SIZE[1])
q_inFrame.send(img)
out_manip = q_outFrame.get()
manip_frame = out_manip.getCvFrame()
# Capture the key pressed
key_pressed = cv2.waitKey(1) & 0xff
# Stop the program if Esc key was pressed
if key_pressed == 27:
break
# Display the video input frame and the manip output
cv2.imshow("Direct video from file", frame)
cv2.imshow("manip output", manip_frame)
cap.release()
cv2.destroyAllWindows()
`
The following is the error I got:
`francis@raspberrypi:~/Desktop/learningOAK-D-Lite $ /bin/python /home/francis/Desktop/learningOAK-D-Lite/pipeline_file_in_imageManip.py
[18443010F1AECE1200] [1038.519] [system] [critical] Fatal error. Please report to developers. Log: 'ImageManipHelper' '61'
Stack trace (most recent call last):
#16 Object "/bin/python", at 0x587533, in
#15 Object "/lib/aarch64-linux-gnu/libc.so.6", at 0x7f9c6d9217, in __libc_start_main
#14 Object "/bin/python", at 0x587637, in Py_BytesMain
#13 Object "/bin/python", at 0x5b7afb, in Py_RunMain
#12 Object "/bin/python", at 0x5c7c37, in PyRun_SimpleFileExFlags
#11 Object "/bin/python", at 0x5c8457, in
#10 Object "/bin/python", at 0x5c251f, in
#9 Object "/bin/python", at 0x5c850b, in
#8 Object "/bin/python", at 0x5976fb, in PyEval_EvalCode
#7 Object "/bin/python", at 0x49628f, in _PyEval_EvalCodeWithName
#6 Object "/bin/python", at 0x4964f7, in
#5 Object "/bin/python", at 0x49c257, in _PyEval_EvalFrameDefault
#4 Object "/bin/python", at 0x4c6cc7, in
#3 Object "/bin/python", at 0x4a52ff, in _PyObject_MakeTpCall
#2 Object "/bin/python", at 0x4cac53, in
#1 Object "/home/francis/.local/lib/python3.9/site-packages/depthai.cpython-39-aarch64-linux-gnu.so", at 0x7f89fd8037, in
#0 Object "/home/francis/.local/lib/python3.9/site-packages/depthai.cpython-39-aarch64-linux-gnu.so", at 0x7f8a09cd00, in
Segmentation fault (Address not mapped to object [0x219])
Segmentation fault
`