-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Description
Describe the doc issue
The documentation on basic image operations still mentions that we can set a pixel value with numpy's itemset since that is faster than accessing it through the index
| >>> img.itemset((10,10,2),100) |
This results in the following error:
Traceback (most recent call last):
File ".../opencv_ws/scripts/basic_image_operations.py", line 18, in <module>
img.itemset((10,10,2),100)
^^^^^^^^^^^
AttributeError: `itemset` was removed from the ndarray class in NumPy 2.0. Use `arr[index] = value` instead.
Fix suggestion
We can remove those instructions. Also in numpy's migration guide from 1 to version 2.0 they also advise the same as the error message said: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#ndarray-and-scalar-methods
The only thing is is that I can't find if they have solved the issue of the direct setting method being slower.
Another solution that we can do instead is we can also consider fixing the numpy version in install_requirements to install the latest of numpy 1 and not 2, as now it will just install the latest.
opencv/modules/python/package/setup.py
Line 47 in 78630dd
| install_requires="numpy", |