I have created the dll with function to do inference of the object detection model using openvino cpp. I got the detection output from the tensor. Need to write the output of the detection struct to the heap memory to copy and use the dll value to the main application.
I some one give insights into this would be very much helpful.
The detections_out struct I need to copy to the heap memory. I have tried allocating the memory by using new keyword but it doesn’t help much.
extern "C" bool gpa_process_frame(YoloADR* adr, uint32_t frame_rows, uint32_t frame_cols, uint32_t frame_stride, void* frame_data, ProcessFrameOutput * detections_out)
{
//*detections_out = new ProcessFrameOutput;
Mat frame(frame_rows, frame_cols, CV_8UC4, frame_data, frame_stride);
Mat formatted_frame;
cvtColor(frame, formatted_frame, COLOR_RGBA2BGR, 3);
auto detection = adr->process_frame(formatted_frame); // SHOULD limit copies to MAX_GPA_OUTPUT_SIZE (currently = 16, defined in caller) to reduce waste cpu+memory bandwidth
ADROutput* detection_ptr = detection.data();
uint32_t size = detection.size();
ProcessFrameOutput output = {
output.size = size,
output.detections = detection_ptr
};
// ProcessFrameOutput* detections_out = new ProcessFrameOutput;
std::memcpy(detections_out, &output, sizeof(ProcessFrameOutput));
/* detections_out->size = size;
detections_out->detections = static_cast<ADROutput*>(operator new[](size * sizeof(ADROutput)));
// Initialize each element using placement new
for (uint32_t i = 0; i < size; ++i) {
new (&detections_out->detections[i]) ADROutput(detection[i].bbox, detection[i].score, detection[i].class_id);
}*/
// detections_out->size = static_cast<uint32_t>(detection.size());
//detections_out->detections = reinterpret_cast<ADROutput*>(detection.data());
// detections_out->detections = new ADROutput[detections_out->size];
return true;
}
2