-
-
Notifications
You must be signed in to change notification settings - Fork 56.1k
Document OpenCV 4.9 Python changes behavior with readonly numpy arrays #24522
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Related patch: #24026 In case if the numpy array was created by external package write access to RO array may case segmentation fault. Please see details in related OpenCV-Python issue. |
Thx for the pointers, I missed them. I am totally ok with the new behavior, it is a fix. I had to go through https://docs.opencv.org/4.8.0/da/d49/tutorial_py_bindings_basics.html to get that |
.astype(np.uint8) using this with the image solved the problem for me |
I had faced the same issue . It took my 4 hours . I used pip to create a new environment then it was sorted , earlier i had used two different conda environments i faced the same issue at same stage of code (while trianing a CNN). Please create same environment with pip and it will sorted. |
System Information
OpenCV 4.x HEAD, Linux, Python 3.11
Detailed description
When some functions (e.g.
cv::rectangle
,cv::circle
) are called on a readonly argument in OpenCV 4.8.0, they do modify it. It is unclear with the doc if the input should also be modified or not as the function returns an image, cf https://docs.opencv.org/4.8.0/d6/d6e/group__imgproc__draw.html#ga07d2f74cadcf8e305e810ce8eed13bc9.Still, In OpenCV HEAD in 4.x, we get the following error:
I guess the correct behavior is to always make a copy of the image before calling
cv::rectangle
and return it?Steps to reproduce
Issue submission checklist
The text was updated successfully, but these errors were encountered: