erik Hi Erik, I want to process images from color camera before sending it to neural network. I just need to multiply some values with each channel of RGB image. I am unable to get the image in an array or list format and getCvFrame() and getFrame also do not work in script node. I first need to convert (1080,1920*3) image to byte array or list after that it would be easy i think. I have following code but it gives the error. I have attached screen shot of error for your reference.
import cv2
import numpy as np
import depthai as dai
import os
from time import monotonic
time_bb_cord=[0.3617,0.6175,0.6414,0.7887]
local_bb_cord=[0.2750,0.28,0.4365,0.44375]
visit_bb_cord=[0.5846,0.27625,0.7435,0.445]
def Manip_Frame(pipeline,region_bb_cord):
manip_time = pipeline.create(dai.node.ImageManip)
manip_time.initialConfig.setCropRect(region_bb_cord[0],region_bb_cord[1],region_bb_cord[2],region_bb_cord[3])
manip_time.setKeepAspectRatio(False)
manip_time.initialConfig.setResize(100,32)
return manip_time
pipeline = dai.Pipeline()
cam = pipeline.create(dai.node.ColorCamera)
cam.setBoardSocket(dai.CameraBoardSocket.RGB)
cam.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
cam.setInterleaved(False)
cam.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)
gray_scale_script=pipeline.create(dai.node.Script)
cam.video.link(gray_scale_script.inputs['video_link'])
gray_scale_script.setScript("""
b=Buffer(2074680)
while True:
frame=node.io['video_link'].get()
array=list(frame.getData())
b.setData(array[0:2074680])
node.warn(str(b[0]))
node.warn(str(array[0]))
# node.warn(str(imgGray[0,0]))
# b=imgFrame(2,074,680)
# b.setData(imgGray)
# b.setHeight(1080)
# b.setWidth(1920)
node.io['script_out'].send(b)
""")
camout = pipeline.create(dai.node.XLinkOut)
camout.setStreamName("right_cam")
gray_scale_script.outputs['script_out'].link(camout.input)
with dai.Device(pipeline) as device:
right_cam = device.getOutputQueue(name="right_cam", maxSize=4, blocking=False)
while True:
right_frame=right_cam.get()
if right_frame is not None:
print(right_frame.getCvFrame().shape)
else:
break
if cv2.waitKey(1) == ord('q'):
break
`