Brandon Hello Brandon,
I am having the same issue as @atb4c and would like to resize a 1080p NV12 Image into a 300 by 300 RGB Image.
I want to capture STILL images at 1080p, and then resize them too 300 by 300 to feed them to a NN.
My code is as follows:
import cv2
import depthai as dai
xxx = cv2.imread("blue.png")
# Create the pipeline
pipeline = dai.Pipeline()
# 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.setPreviewSize(1080, 1080)
camRGB.setVideoSize(1080, 1080)
# camRGB.setInterleaved(False)
camRGB.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)
# Create Image manipulation node, to resize image from 1080p to 300by300
manip = pipeline.create(dai.node.ImageManip)
manip.initialConfig.setResize(300,300)
manip.initialConfig.setFrameType(dai.ImgFrame.Type.RGB888p)
# Create output node for still images
outStillRGB = pipeline.create(dai.node.XLinkOut)
outStillRGB.setStreamName("rgbStill")
# Create input control node to acquire capture command
xinCaptureCommand = pipeline.create(dai.node.XLinkIn)
xinCaptureCommand.setStreamName("capture")
# Link output of encoder to input of xlinkout to send to deivce
camRGB.still.link(manip.inputImage)
manip.out.link(outStillRGB.input)
# Link output of xinCaptureCommand to camera input control
xinCaptureCommand.out.link(camRGB.inputControl)
# Connect to device and start the pipeline
with dai.Device(pipeline) as device:
# Create output queue that will get RGB frame (Output from device, and input to host)
stillQueue = device.getOutputQueue(name="rgbStill")
# Create input queue to device, that receives capture command
captureInputQueue = device.getInputQueue("capture")
cv2.imshow("xxx",xxx)
while True:
stillFrame = stillQueue.tryGet()
if stillFrame is not None:
frame = stillFrame.getCvFrame()
#frame = cv2.imdecode(stillFrame.getData(), cv2.IMREAD_UNCHANGED)
cv2.imshow("frame", frame)
# 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")
The problems is that the output I get is a grayscale image.
Any thoughts on how to resolve the issue?