当前位置:网站首页>An error CV2 is reported when the picture is converted to grayscale cvtColor(img, cv2.COLOR_BGR2GRAY)
An error CV2 is reported when the picture is converted to grayscale cvtColor(img, cv2.COLOR_BGR2GRAY)
2022-06-13 08:51:00 【Human high quality Algorithm Engineer】
Turn the picture to grayscale cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) An error is as follows :
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.error: OpenCV(4.5.4) d:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function '__cdecl cv::impl::`anonymous-namespace'::CvtHelper<struct cv::impl::`anonymous namespace'::Set<3,4,-1>,struct cv::impl::A0x5252fd2b::Set<1,-1,-1>,struct cv::impl::A0x5252fd2b::Set<0,2,5>,2>::CvtHelper(const class cv::_InputArray &,const class cv::_OutputArray &,int)'
> Invalid number of channels in input image:
> 'VScn::contains(scn)'
> where
> 'scn' is 1
The image should be three channels when positioning to gray conversion , Otherwise, the report will be wrong , Before converting to grayscale , Add the following code to convert the diagram into three channels
img = cv2.merge([img,img,img])
reason :
use CV_BGR2GRAY,
Conversion formula Gray = 0.1140B + 0.5870G + 0.2989*R
Therefore, a single channel will definitely report an error
边栏推荐
- 1、 JS introduction
- 0. some doubts about learning SolidWorks for the first time
- I set up a blog
- 3、 JS notes
- Form exercise 2
- [notes] like the solution to the problem of slow query (index + explicitly specifying query fields)
- 8、 JS data type conversion
- Sky background map, navigation page lovefanfan top
- JS - for cycle case: Horse grain
- H5 mobile terminal adaptation
猜你喜欢
Diversified tables through TL table row consolidation
centos 安装mysql及设置远程访问
File upload JS
Screenshot of cesium implementation scenario
VS安装VAssistX插件导致WPF-XAML文件输入中文出现乱码问题解决方案
On the use of regular expressions (bracket problem)
[notes] like the solution to the problem of slow query (index + explicitly specifying query fields)
關於RSA加密解密原理
Sky background map, navigation page lovefanfan top
0. Quelques doutes au sujet de SolidWorks
随机推荐
JS format file unit display
anaconda下安装pytorch
I set up a blog
Taobao commodity sales interface / Taobao commodity sales monitoring interface / cumulative commodity sales interface
Knowledge points related to system architecture 3
13.inline,const,mutable,this,static
DIY UAV (anonymous controller p2+f330 rack)
VS安装VAssistX插件导致WPF-XAML文件输入中文出现乱码问题解决方案
What is the difference between getfullyear() and getyear()
JS - for cycle case: Horse grain
The 360 mobile assistant on Huawei maimang 7 cannot be uninstalled
「解读」华为云桌面说“流畅”的时候,究竟在说什么?
4、 Js-es5-i / O
Mapbox usage, including drawing, loading, modifying, deleting points and faces, displaying pop ups, etc
On the use of visual studio
Svg text stroke effect
JS - max. of array cases
Judgment of single exclamation point and double exclamation point in JS
淘宝商品销量接口/淘宝商品销量监控接口/商品累计销量接口
VI editor