Running detectnet-camera on OpenCV Capture


I want to modify detectnet-camera.cpp so that the detections can be performed on captures read from OpenCV.

According to the detectNet.h, the function Detect() takes first argument as a float4 RGBA image that is located in CUDA device memory. Therefore, I guess what I need is to convert cv::Mat to float4* somehow.

Here is what I tried, but did not work.

VideoCapture cap("/path-to-a-video");
cv::Mat frame;
cv::cuda::GpuMat gpu_mat;

while(!signal_received) {;
cv::cvtColor(frame, frame, cv::COLOR_BGR2RGBA);
float* imgRGBA = gpu_mat.ptr<float>();
detectNet::Detection* detections = NULL;
const int numDetections = net->Detect(imgRGBA, camera->GetWidth(), camera->GetHeight(), &detections, overlayFlags);


Any ideas?

Hi mrefedoganay, what’s the error you receive? Does it display any video?

Do you know if the pixel values from OpenCV are between 0.0-1.0, or 0.0-255.0? What is expected by detectNet is 0.0-255.0