DoubangoTelecom / ultimateALPR-SDK

World's fastest ANPR / ALPR implementation for CPUs, GPUs, VPUs and NPUs using deep learning (Tensorflow, Tensorflow lite, TensorRT, OpenVX, OpenVINO). Multi-Charset (Latin, Korean, Chinese) & Multi-OS (Jetson, Android, Raspberry Pi, Linux, Windows) & Multi-Arch (ARM, x86).
https://www.doubango.org/webapps/alpr/
Other
593 stars 157 forks source link

Frame/data ownership in process #242

Closed egimbernat closed 2 years ago

egimbernat commented 2 years ago

I'm building a Rust binding for the SDK, so far, the last piece is to understand which memory model to use to send the data pointer to process when is operating in parallel. By https://www.doubango.org/SDKs/anpr/docs/Memory_management_design.html#memory-pooling seems it's covered, but I just want to make sure I'm not assuming that the SDK takes ownership of the pointer and is safe to pass the pointer and not track the object to release the allocated memory.

DoubangoTelecom commented 2 years ago

We do not take ownership of the memory. The memory is copied.

egimbernat commented 2 years ago

Okay, so is safe to reuse allocated memory, for example, cv::Mat? I mean, is copied immediately when calling process?

DoubangoTelecom commented 2 years ago

Okay, so is safe to reuse allocated memory, for example, cv::Mat? I mean, is copied immediately when calling process?

The copy is immediate and you can reuse the memory or delete it. When parallel mode is enabled you don't need to wait for the result.