Closed dleazer closed 5 years ago
I'm not able to reproduce this error. I ran this script using python 2 & 3 with opencv 4.0.0.21 in macos. Have you modified the paths to be compatible with windows?
If the error is only linked to the array depth type try converting them to uint8 before each imshow call:
img_uint8 = (255 * img).astype("uint8")
cv2.imshow("Image", img_uint8)
cv2.waitKey(0) # will wait until any key is pressed
Converting to uint8 was indeed the solution. Thank you for your help.
I'm getting this error when trying to run the solution for gradient_quiz.py:
Traceback (most recent call last): File "CV-lecture-quizzes-python/2A-L5/answers/gradient_quiz.py", line 22, in
cv2.imshow('Image', img) # assumes [0, 1] range for double images
cv2.error: OpenCV(4.0.0) c:\projects\opencv-python\opencv\modules\imgproc\src\color.hpp:261: error: (-2:Unspecified error) in function '__cdecl cv::CvtHelper<struct cv::Set<1,-1,-1>,struct cv::Set<3,4,-1>,struct cv::Set<0,2,5>,2>::CvtHelper(const class cv::_InputArray &,const class cv::_OutputArray &,int)'
> Unsupported depth of input image:
> 'VDepth::contains(depth)'
> where
> 'depth' is 6 (CV_64F)