【发布时间】:2018-09-05 14:43:34
【问题描述】:
我遵循了这个教程:https://www.pyimagesearch.com/2017/09/11/object-detection-with-deep-learning-and-opencv/ 我更改了这部分,将图像馈送转换为灰度,然后再将其插入神经网络
frame = vs.read()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frame = imutils.resize(frame, width=400)
(h, w) = frame.shape[:2]
blob = cv2.dnn.blobFromImage(cv2.resize(frame, (300, 300)),
0.007843, (300, 300), 127.5)
net.setInput(blob)
detections = net.forward()
但是会出现这个错误:
OpenCV(3.4.1) Error: Assertion failed (ngroups > 0 && inpCn % ngroups == 0 && outCn % ngroups == 0) in cv::dnn::ConvolutionLayerImpl::getMemoryShapes, file D:\Build\OpenCV\opencv-3.4.1\modules\dnn\src\layers\convolution_layer.cpp, line 234
Traceback (most recent call last):
File "C:/Users/Toshiba/PycharmProjects/real-time-object-detection/study7ver2.py", line 75, in <module>
detections = net.forward()
cv2.error: OpenCV(3.4.1) D:\Build\OpenCV\opencv-3.4.1\modules\dnn\src\layers\convolution_layer.cpp:234: error: (-215) ngroups > 0 && inpCn % ngroups == 0 && outCn % ngroups == 0 in function cv::dnn::ConvolutionLayerImpl::getMemoryShapes
第 75 行是:detections = net.forward()
为什么要将其转换为灰度?因为我需要在将图像输入神经网络之前进行直方图均衡化,这样夜间输入的图像会更清晰。
【问题讨论】:
标签: python opencv machine-learning neural-network deep-learning