luxonis / depthai-core

DepthAI C++ Library
MIT License
231 stars 126 forks source link

Replace custom python implementations for cvFrame with bindings #1092

Closed moratom closed 1 month ago

moratom commented 1 month ago

Added bindings instead of custom python implementations for the getCvFrame and getFrame functions.

Should be easier to maintain with a single source of truth.

Another thing we get for free is setCvFrame from python - that one is quite neat :)

TODO before merge:

themarpe commented 1 month ago

Neat! Does getFrame remain zerocopy?

moratom commented 1 month ago

Neat! Does getFrame remain zerocopy? I don't think so, we can revisit though, the conversions seems of "manageable complexity" - 350 LOC.

Existing zero-copy is unsafe, so it would be nice if we somehow managed to tie the lifetimes now. Right now this crashes:

imgFrame = queue.get()
myNpFrame = imgFrame.getFrame()
imgFrame = None
myPixel = myNpFrame[3][5] #  A likely crash as memory was already released :(