dwFrameCapture_appendFrame() returns DW_NOT_AVAILABLE

I’m trying to use DriveWorks FrameCapture module to encoded processed images (DW_IMAGE_NVMEDIA or DW_IMAGE_CUDA) in H.264 bitstream. Previously, I used SensorSerializer module to encoded camera frames into H.264 bitstream, and it works fine. However, to encoded processed images, it seems I have to used FrameCapture API since dwSensorSerializer_serializeImage() has been marked as ‘Deprecated’.

The code I used to initialize FrameCapture is like:

dwFrameCaptureHandle_t frameCapturer = DW_NULL_HANDLE;
        dwSerializerParams serializerParams;
        serializerParams.onData = (dwSensorSerializerOnDataFunc_t)&encoderCallback;
        serializerParams.parameters = "format=h264,bitrate=8000000,framerate=30,type=user,slave=0";
        dwFrameCaptureParams frameCaptureParams;
        frameCaptureParams.captureCustom = false;
        frameCaptureParams.height = 1208;
        frameCaptureParams.width = 1920;
        frameCaptureParams.params = serializerParams;
        frameCaptureParams.serializeGL = false;
        frameCaptureParams.mode = DW_FRAMECAPTURE_MODE_SERIALIZE;
        CHECK_DW_ERROR(dwFrameCapture_initialize(&frameCapturer, &frameCaptureParams, sal, sdk));

and the code executed on camera reading is like:

dwSensorCamera_readFrame(&cameraFrame, 0, timeout, cameraSensor);
        dwSensorCamera_getImage(&processedImage, DW_CAMERA_OUTPUT_NATIVE_PROCESSED, cameraFrame);
        CHECK_DW_ERROR(dwFrameCapture_appendFrame(processedImage, frameCapturer))

The error I got is:

terminate called after throwing an instance of 'std::runtime_error'
  what():  [2020-02-06 10:28:59] DW Error DW_NOT_AVAILABLE executing DW function:
 dwFrameCapture_appendFrame(processedImage, frameCapturer)

I tried to use both DW_IMAGE_NVMEDIA and DW_IMAGE_CUDA, but both raised the same error. I also tried to convert dwImageHandle_t into dwImageCUDA or dwImageNvMedia first, then call dwFrameCapture_appendFrameCUDA() or dwFrameCapture_appendFrameNvMedia. The error is still the same. I wonder is the FrameCapture module not implemented or maybe there’s something I’m missing?

Please advise, thank you!

Hi James22,

I have no idea about the issue yet. But please refer to below samples first and see if you can find some clues. Thanks!

$ grep -rl dwFrameCapture_appendFrame /usr/local/driveworks/samples/

Hi Vick,

Thank you for the suggestions. After checking these samples, I think I have identified where the problem is.
If the FrameCapture is initialized like this:

dwFrameCaptureParams frameCaptureParams{};
        frameCaptureParams.params.parameters = "type=disk,format=h264,bitrate=8000000,framerate=30,file=Encoded.h264";
        dwFrameCapture_initialize(&m_frameCapture, &frameCaptureParams, sal, sdk);

It worked fine and could dump bitstream into file “Encoded.h264”.

However, if I want to use the callback function to process encoded date instead of dumping it into a file, and initialize FrameCapture in this way:

dwFrameCaptureParams frameCaptureParams{};
        frameCaptureParams.params.parameters = "type=user,format=h264,bitrate=8000000,framerate=30";
        frameCaptureParams.params.onData = (dwSensorSerializerOnDataFunc_t)&encoderCallback;
        dwFrameCapture_initialize(&m_frameCapture, &frameCaptureParams, sal, sdk);

Then it would raise DW_NOT_AVAILABLE error when calling dwFrameCapture_appendFrame();

BTW, my callback function looks like this:

void encoderCallback(const uint8_t* data, size_t size, void* userData) {
    data = data;
    size = size;
    userData = userData;
    printf("hello from encoderCallBack\n");
    // do something with data here

The callback function works if I’m using SensorSerializer module. I guess it’s a bug if this callback only works for SensorSerializer but not for FrameCapture, since dwFrameCaptureParams.params has type dwSerializerParams. Could you help look into when the callback functionality of FrameCapture would become available?

Thank you.

Thanks for the information! We will check internally and then get back to you here.

Hi @James22,

We are still fixing the issue of initializing frame capture module with serializer callback.

dwFrameCapture_start() is only for asynchronous serialization (call dwFrameCapture_appendFrame*Aync() functions) so you don’t really need to call dwFrameCapture_start() for non async. You can take a look at samples in my below post.

The fix will be included in the next DriveWorks release. FYI. Thanks!

1 Like