【问题标题】:Failed to display image无法显示图片
【发布时间】:2019-08-14 07:04:57
【问题描述】:

我想获取灰度图像的最重要位,但是当我尝试运行此脚本时,它只会给我一个深度错误: '常量类 cv::_InputArray &,常量类 cv::_OutputArray &,int)'

不支持的输入图像深度: 'VDepth::contains(depth)' 在哪里 '深度' 为 6 (CV_64F)'

我有其他大学可以很好地运行这个脚本,但我不能。 . .

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)

【问题讨论】:

  • 那个错误来自cv2.cvtColor,对吗? (以后请附上完整的回溯) | imgdtype 是什么?
  • Traceback(最近一次调用最后):文件“C:\ISEL\2018-2019\Semestre_Verao\CSM\TP1\teste.py”,第 9 行,在 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函数'__cdecl cv::CvtHelper,struct cv::Set,struct cv::Set, 2>::CvtHelper(const class cv::_InputArray &,const class cv::_OutputArray &,int)' > 不支持的输入图像深度:> 'VDepth::contains(depth)' > 其中 > 'depth' 为 6 (CV_64F)

标签: python-3.x opencv


【解决方案1】:

检查您是否有与您的大学相同的 opencv 版本。 我在使用 opencv 4.0 时遇到了一些问题,但是当我降级到 3.7 版时一切正常。

【讨论】:

  • 是的。我的是 4.0,我的大学有 3.4,可能会降级看看它是否有效!
猜你喜欢
  • 1970-01-01
  • 2018-07-18
  • 2020-09-17
  • 2020-10-02
  • 2012-03-10
  • 1970-01-01
  • 2016-07-21
  • 2017-07-19
  • 1970-01-01
相关资源
最近更新 更多