luxonis / depthai-core

DepthAI C++ Library
MIT License
235 stars 127 forks source link

Replace custom python implementations for cvFrame with bindings #1092

Closed moratom closed 3 months ago

moratom commented 3 months 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 3 months ago

Neat! Does getFrame remain zerocopy?

moratom commented 3 months 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 :(