Software Version
DRIVE OS 6.0.10.0
DRIVE OS 6.0.8.1
DRIVE OS 6.0.6
DRIVE OS 6.0.5
DRIVE OS 6.0.4 (rev. 1)
DRIVE OS 6.0.4 SDK
other
Target Operating System
Linux
QNX
other
Hardware Platform
DRIVE AGX Orin Developer Kit (940-63710-0010-300)
DRIVE AGX Orin Developer Kit (940-63710-0010-200)
DRIVE AGX Orin Developer Kit (940-63710-0010-100)
DRIVE AGX Orin Developer Kit (940-63710-0010-D00)
DRIVE AGX Orin Developer Kit (940-63710-0010-C00)
DRIVE AGX Orin Developer Kit (not sure its number)
other
Host Machine Version
native Ubuntu Linux 20.04 Host installed with SDK Manager
native Ubuntu Linux 20.04 Host installed with DRIVE OS Docker Containers
native Ubuntu Linux 18.04 Host installed with DRIVE OS Docker Containers
other
Issue Description
Hello guys,
I am trying to serialize Frames, that I captured with a Camera, in order to create a mp4 file. When I start the program, a mp4 file is created, but it remains empty. The code is attached down below. I hope you can help me with this problem
Thanks in advance!
Code
include “CCameraSample.h”
using namespace std;
void CCameraSample::initContext() {
// Initialize the DW Context
CHECK_DW_ERROR(dwGetVersion(&m_sdkVersion));
CHECK_DW_ERROR(dwInitialize(&m_context, m_sdkVersion, NULL));// Print start message
cout << getCurrentTime().str() << “Initialize DriveWorks SDK v”
<< m_sdkVersion.major << “.” << m_sdkVersion.minor << “.”
<< m_sdkVersion.patch << endl << endl;
}void CCameraSample::initCamera() {
// Initialize the Sensor Abstraction layer
CHECK_DW_ERROR(dwSAL_initialize(&m_sal, m_context));// Specifiy the gmsl protocol for the fourth camera
m_senParams.parameters =
“camera-name=C2SIM623S2RU1195NB20,interface=csi-cd,CPHY-mode=1,”
“link=3,output-format=processed,skip-eeprom=1”;
m_senParams.protocol = “camera.gmsl”;// Create the sensor (here: camera)
CHECK_DW_ERROR(dwSAL_createSensor(&m_camera, m_senParams, m_sal));// Start the Sensor Abstraction Layer
CHECK_DW_ERROR(dwSAL_start(m_sal));// Start the sensor (here: camera)
CHECK_DW_ERROR(dwSensor_start(m_camera));
}void CCameraSample::initImageStreamer() {
// Get the CUDA Image Properties
dwImageProperties cudaProp { };
CHECK_DW_ERROR(
dwSensorCamera_getImageProperties(&cudaProp,
DW_CAMERA_OUTPUT_CUDA_RGBA_UINT8, m_camera));// Initialize the ImageStreamer Module
CHECK_DW_ERROR(
dwImageStreamer_initialize(&m_streamerCUDA2CPU, &cudaProp,
DW_IMAGE_CPU, m_context));
}void CCameraSample::initSerializer() {
// Specifiy the Video Parameters
dwSerializerParams serializerParams;
serializerParams.parameters =
“format=mp4,bitrate=800000,framerate=30,type=disk,”
“file-buffer-size=16777216,file=test.mp4”;// Initialize the Serializer
CHECK_DW_ERROR(
dwSensorSerializer_initialize(&m_serializer, &serializerParams,
m_camera));// Start the serializer
CHECK_DW_ERROR(dwSensorSerializer_start(m_serializer));
}void CCameraSample::init() {
initContext();
initCamera();
initSerializer();
initImageStreamer();
}CCameraSample::CCameraSample() {
m_context = DW_NULL_HANDLE;
m_camera = DW_NULL_HANDLE;
m_sal = DW_NULL_HANDLE;
m_serializer = DW_NULL_HANDLE;
m_streamerCUDA2CPU = DW_NULL_HANDLE;
m_choice = WAIT;
init();
displayMenu();
}void CCameraSample::exportImage(dwImageHandle_t frameCUDA, int idx) {
dwImageHandle_t imageHandle;
dwImageCPU *imgCPU;
cout << getCurrentTime().str() << “ImageStreamer(CUDA → CPU)” << endl;// stream the CUDA frame to the CPU domain
CHECK_DW_ERROR(dwImageStreamer_producerSend(frameCUDA, m_streamerCUDA2CPU));// receive the streamed CPU image as a handle
CHECK_DW_ERROR(
dwImageStreamer_consumerReceive(&imageHandle, 0,
m_streamerCUDA2CPU));// Converts the Image into the CPU format
CHECK_DW_ERROR(dwImage_getCPU(&imgCPU, imageHandle));// write the image data to a png-file
char fname[128];
sprintf(fname, “GMSL_IDX_framegrab_%s.png”, std::to_string(idx).c_str());
lodepng_encode32_file(fname, imgCPU->data[0], imgCPU->prop.width,
imgCPU->prop.height);
cout << getCurrentTime().str() << "Image saved to: " << fname << “\n”;// Return the consumed image
CHECK_DW_ERROR(
dwImageStreamer_consumerReturn(&imageHandle, m_streamerCUDA2CPU));// Notify the producer that the work is done
CHECK_DW_ERROR(
dwImageStreamer_producerReturn(nullptr, 0,
m_streamerCUDA2CPU));
}void CCameraSample::getFrame() {
// has to be called twice
dwCameraFrameHandle_t frameHandle = DW_NULL_HANDLE;
CHECK_DW_ERROR(dwSensorCamera_readFrame(&frameHandle, 0, m_camera));// Create a image out of the taken Frame
dwImageHandle_t imageHandle = DW_NULL_HANDLE;
CHECK_DW_ERROR(
dwSensorCamera_getImage(&imageHandle,
DW_CAMERA_OUTPUT_CUDA_RGBA_UINT8, frameHandle));// Passes the Image to the Image-Streamer
exportImage(imageHandle, 3);// Releasing the handles
CHECK_DW_ERROR(dwSensorCamera_returnFrame(&frameHandle));// needs to be called, otherwise there is always the same frame in the buffer
CHECK_DW_ERROR(dwSensor_reset(m_camera));
}