0
votes

I want to get the most significant bit of a Grey image, but when I try to run this script, it just gives me a depth error: 'const class cv::_InputArray &,const class cv::_OutputArray &,int)'

Unsupported depth of input image: 'VDepth::contains(depth)' where 'depth' is 6 (CV_64F)'

I have other college colleges that can run this script just fine, but I am unable to. . .

import cv2
import numpy as np

img = cv2.imread("lenac.tif")
x_img_g = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
y = x_img_g > 128
cv2.imshow("BW", y*1.0)
Traceback (most recent call last): File "C:\ISEL\2018-2019\Semestre_Verao\CSM\TP1\teste.py", line 9, in <module>
cv2.imshow("BW", y*1.0)
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)
1
That error is coming from cv2.cvtColor, correct? (In future, please attach complete backtrace) | What's the dtype of img? - Dan Mašek
Traceback (most recent call last): File "C:\ISEL\2018-2019\Semestre_Verao\CSM\TP1\teste.py", line 9, in <module> cv2.imshow("BW", y*1.0) 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) - António Dos Reis

1 Answers

-1
votes

Check if you have the same opencv version as your colleges. I had some problems with opencv 4.0, but when I downgraded to version 3.7 everything worked fine.