Skip to content

Bug: readonly array error for OpenCV 4.9+ in owl_drawing.py #41

@cristi-zz

Description

@cristi-zz

Tl;Dr:

OpenCV obey the readonly tag in Numpy. As a result, this line:

image = np.asarray(image)
will fail if ran with OpenCV 4.9+

Workaround:

Add image = np.copy(image) after the infringing line

Longer story:

I am running the nanoowl using Jetson Containers. In Nov 2024 the nanoowl dustynv/nanoowl:r36.4.0 container has OpenCV 4.10.0 and numpy 1.26.4

In OpenCV 4.9 release, functions that change the output image are observing the readonly flag from numpy arrays: opencv/opencv-python#859 As a result, if the array is readonly, this error will surface: opencv/opencv#24522 .

Numpy version is important because there is a copy parameter to asarray but only in ver 2+ https://numpy.org/doc/stable/reference/generated/numpy.asarray.html

Question:

To make a more "permanent" fix:

  • Create a PR with image = np.asarray(image).copy() or other suggested method to return a r/w array
  • Create issue in Jetson Containers to work there a solution (openCV build version pinning, etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions