Hi everyone,
In my project, I try to integrate the driveworks with ROS. So I use cv_bridge to convert Image message to OpenCV’s Mat format. Then in the driveworks app, I convert Mat to dwImageCPU and then convert it to dwImageCUDA. But when I call dwLandmarkDetector_detectLandmarks or dwPathDetector_processDeviceAsync to do some dections, the program will terminate.
I have check the converted dwImageCPU by convert it back to Mat and compare it with the origin one, that works fine. So I am sure the problem is happening in convertion from dwImageCPU to dwImageCUDA.
Would somebody to check the bugs of my program…
Here is the convertion code snippet:
void getNextFrame(dwImageCUDA **nextFrameCUDA, const cv::Mat &opencv_image) {
dwImageCPU *nextFrameCPU;
dwImage_getCPU(&nextFrameCPU, m_imageCPU);
mempcpy(nextFrameCPU->data[0], opencv_image.data,
opencv_image.total() * opencv_image.elemSize());
CHECK_DW_ERROR(dwImageStreamer_producerSend(m_imageCPU, m_streamerCPU2CUDA));
dwImageHandle_t imageCUDA;
CHECK_DW_ERROR(
dwImageStreamer_consumerReceive(&imageCUDA, 1000, m_streamerCPU2CUDA));
CHECK_DW_ERROR(dwImage_getCUDA(nextFrameCUDA, imageCUDA));
std::cout << "nextFrameCUDA info:"
<< std::to_string((*nextFrameCUDA)->prop.width) + ":"
<< std::to_string((*nextFrameCUDA)->prop.height);
CHECK_DW_ERROR(
dwImageStreamer_consumerReturn(&imageCUDA, m_streamerCPU2CUDA));
CHECK_DW_ERROR(
dwImageStreamer_producerReturn(nullptr, 1000, m_streamerCPU2CUDA));
};
Here is the process code snippet:
void OnProcess(){
dwImageCUDA *rcbImage;
cv::Mat mat = cv::imread("lane_sample.png");
getNextFrame(&rcbImage, mat);;
CHECK_DW_ERROR(dwLandmarkDetector_detectLandmarks(
&m_landmarkDetectionResult, rcbImage, m_landmarkDetector));
CHECK_DW_ERROR(dwPathDetector_processDeviceAsync(rcbImage, m_pathDetector));
CHECK_DW_ERROR(dwPathDetector_interpretHost(m_pathDetector));
CHECK_DW_ERROR(dwPathDetector_getPathDetections(&m_paths, m_pathDetector));
}