Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Creating an Image in python from a numpy array doesn't work #1963

Open
icaven opened this issue Dec 15, 2023 · 0 comments · May be fixed by #1964
Open

Creating an Image in python from a numpy array doesn't work #1963

icaven opened this issue Dec 15, 2023 · 0 comments · May be fixed by #1964

Comments

@icaven
Copy link

icaven commented Dec 15, 2023

The function create_from_ndarray() in src/python/k4a/src/k4a/_bindings/image.py has a number of errors:

  • the naming of the modules used (_nd instead of _np, and ctypes instead of _ctypes)

  • when the defaults for the size of the image are used (all set to 0), the correct values are not fetched from the array.

  • None is not permitted as the callback in k4a_image_create_from_buffer(), it leads to the following error:

    ctypes.ArgumentError: argument 7: <class 'TypeError'>: expected CFunctionType instance instead of NoneType

  • the reference count on the numpy array passed in should have its reference count incremented so that the array will not be
    deallocated when the caller deletes it

Related to the callback, in src/python/k4a/src/k4a/_bindings/k4a.py:

  • the declaration of the k4a_image_create_from_buffer has the incorrect callback function type (_memory_allocate_cb instead of the correct _memory_destroy_cb).
@icaven icaven linked a pull request Dec 15, 2023 that will close this issue
7 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant