Payload-SDK icon indicating copy to clipboard operation
Payload-SDK copied to clipboard

video stream not working in M3TD

Open kkishore9891 opened this issue 7 months ago • 10 comments

Hello! I Tried to run the sample code in M3TD after setting up USB bulk configuration. I found that the image stream is not being displayed when running the sample script as shown in the video below.

https://github.com/dji-sdk/Payload-SDK/assets/34810513/ffe16347-5543-468e-ac70-89255a778c8c

I would like to know if I need to modify anything in the sample code to recieve the image stream.

For example in my separate code base inspired from the sample test_liveview.cpp code I used a setup like this for the Matrice M30T drone as shown below:

T_DjiReturnCode LiveviewSample::StartWideCameraStream(CameraImageCallback callback, void *userData)
{
    // Obtain the decoder for Wide camera. Perhaps it will work with any decoder. Need to test.
    auto decoder = streamDecoder.find(DJI_LIVEVIEW_CAMERA_POSITION_NO_1);
    // USER_LOG_ERROR("Starting wide");
    
    // If the decoder exists, start it and associate it with a callback
    if ((decoder != streamDecoder.end()) && decoder->second)
    {
        decoder->second->init();
        decoder->second->registerCallback(callback, userData);

        return DjiLiveview_StartH264Stream(DJI_LIVEVIEW_CAMERA_POSITION_NO_1, DJI_LIVEVIEW_CAMERA_SOURCE_M30T_WIDE,
                                           LiveviewConvertH264ToRgbCallback);
    }
    // Error handling
    else
    {
        return DJI_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND;
    }
}

// Function that associates a callback with the thermal camera stream and a user defined data
// in our case the user defined data is a struct object with a publisher and clock.
T_DjiReturnCode LiveviewSample::StartThermalCameraStream(CameraImageCallback callback, void *userData)
{
    // Obtain the decoder for thermal camera. Perhaps it will work with any decoder. Need to test.
    auto decoder = streamDecoder.find(DJI_LIVEVIEW_CAMERA_POSITION_NO_1);

    // If the decoder exists, start it and associate it with a callback
    if ((decoder != streamDecoder.end()) && decoder->second)
    {
        decoder->second->init();
        decoder->second->registerCallback(callback, userData);
        USER_LOG_ERROR("Starting Thermal Camera Streaming");
        return DjiLiveview_StartH264Stream(DJI_LIVEVIEW_CAMERA_POSITION_NO_1, DJI_LIVEVIEW_CAMERA_SOURCE_M30T_IR,
                                           LiveviewConvertH264ToRgbCallback);
    }
    // Error handling
    else
    {
        return DJI_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND;
    }
}

This worked for the M30T drone but using something similar like DJI_LIVEVIEW_CAMERA_POSITION_NO_1 and DJI_LIVEVIEW_CAMERA_SOURCE_M3TD_IR or DJI_LIVEVIEW_CAMERA_SOURCE_M3TD_VIS doesn't send any images to the callback function. I am not sure if USB bulk might have some issue. I would first like to get the video feed working in the sample script so that I can later use that to modify our code base to accomodate the M3TD drone.

kkishore9891 avatar Jul 03 '24 15:07 kkishore9891