【发布时间】:2020-12-04 00:26:02
【问题描述】:
cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-71670poj\opencv\modules\dnn\src\dnn.cpp:371: error: (-215:Assertion failed) image.depth() == blob_.depth() in function 'cv::dnn::dnn4_v20200609::blobFromImages'
当我运行以下代码时出现此错误:
crop = frame[y:y + h, x:x + w]
img_blob = cv.dnn.blobFromImage(crop)
【问题讨论】:
-
numpy 索引是
frame[y:y+h, x:x+w],除非你做了一些很奇怪的事情 -
其实听上去顺序倒了
-
您可能还需要在图像导入的某处使用
dtype='uint8'ddepth=np.uint8或.astype(np.uint8)。从这里看不出来,粘贴的代码不够看。 -
是的,numpy 反转 [col, row]。在这里阅读 cmets -- stackoverflow.com/a/15589825/3342050
-
谢谢。我裁剪了 muy 图像,因为我只需要那个特定区域。使用
dtype='uint8' ddepth=np.uint8 or .astype(np.uint8)是什么意思?
标签: python opencv machine-learning computer-vision