luxonis / depthai-core

DepthAI C++ Library
MIT License
235 stars 127 forks source link

OAK-FFC-6P RVC3 Simultaneous VideoEncoder & Preview Pipeline #901

Closed RaymondCM closed 1 year ago

RaymondCM commented 1 year ago

Can't get simultaneous preview and video encoder pipelines working, simple example below for the 6P. Is this a known issue?

MRE

import depthai as dai

def _main():
    pipeline = dai.Pipeline()

    camRgb = pipeline.create(dai.node.ColorCamera)
    camRgb.setBoardSocket(dai.CameraBoardSocket.CAM_F)
    camRgb.setPreviewSize(300, 300)
    camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
    camRgb.setInterleaved(False)
    camRgb.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)

    videoEnc = pipeline.create(dai.node.VideoEncoder)
    videoEnc.setDefaultProfilePreset(30, dai.VideoEncoderProperties.Profile.H264_MAIN)
    camRgb.video.link(videoEnc.input)

    xoutRgb = pipeline.create(dai.node.XLinkOut)
    xoutRgb.setStreamName("rgb")
    camRgb.preview.link(xoutRgb.input)
    xoutEnc = pipeline.create(dai.node.XLinkOut)
    xoutEnc.setStreamName("h264")
    videoEnc.bitstream.link(xoutEnc.input)

    with dai.Device(pipeline) as device:
        device.setLogLevel(dai.LogLevel.DEBUG)
        device.setLogOutputLevel(dai.LogLevel.DEBUG)
        qRgb = device.getOutputQueue(name="rgb", maxSize=4, blocking=False)
        qH264 = device.getOutputQueue(name="h264", maxSize=30, blocking=True)

        while True:
            inRgb = qRgb.get()
            inH264 = qH264.get()
            print("Working!")

if __name__ == "__main__":
    _main()
Erol444 commented 1 year ago

Hi @RaymondCM , Does just streaming one or the other work? I might suspect the CAM_F port, have you confirmed it already works?

RaymondCM commented 1 year ago

@Erol444 Yes each work independently, but neither work together CAM_F just happens to be the working RGB port for the FFC-6P.

RaymondCM commented 1 year ago

@Erol444 It turns out that setting certain preview sizes on previous runs (270x480) crashes the VPU and a hard device reset is required to get it working again.

RaymondCM commented 1 year ago

The encoder works regardless of the crash, hence the confusing issue.