cv2 has no attribute cv_32f
时间: 2023-08-10 15:05:57 浏览: 185
This error usually occurs when you try to use the attribute `cv_32f` with OpenCV's `cv2` module. The reason for this error is that there is no such attribute in the `cv2` module.
To fix this error, you can try changing the attribute from `cv_32f` to `CV_32F`, which is the correct attribute name in OpenCV's Python bindings. Alternatively, you can import the `cv` module instead of the `cv2` module and use the `cv.CV_32F` attribute.
Here's an example:
```python
import cv2 as cv
# create a new image
img = cv.imread('image.jpg')
# convert the image to float32
img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
img = img.astype('float32')
# apply some filter
img = cv.GaussianBlur(img, (5, 5), cv.CV_32F)
# show the image
cv.imshow('image', img)
cv.waitKey(0)
cv.destroyAllWindows()
```
Note that `cv.CV_32F` is used instead of `cv2.cv_32f`.
阅读全文