CHASSIE
CHASSIE

Reputation: 21

How can i fix cv2.error: OpenCV(4.5.4-dev)

I wanna make image to sketch using opencv-python. I already installed the package but why there is still error?

grey_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

Upvotes: 2

Views: 15367

Answers (1)

Jakub
Jakub

Reputation: 184

Just reinstall OpenCV: In terminal like this, if you using Jupiter put it like !pip...

pip uninstall opencv-python
pip install opencv-python

This just worked for me.

Also, make sure, you have the right path for the file, and used image= cv2.imread("path") to convert the image into the numpy array, so cv2 can work with it.

Also, your command only converts images into the shades of gray. If you want pure black-and-white:

threshold_img = cv2.threshold(gray_img, 40, 255, cv2.THRESH_BINARY)

Upvotes: 1

Related Questions