pycharm中的OpenCV EAST文本检测器中的net.forward()错误 [英] Error with net.forward() in OpenCV EAST text detector in pycharm
本文介绍了pycharm中的OpenCV EAST文本检测器中的net.forward()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在pycharm中使用EAST文本检测器,但该行出现错误.
(scores, geometry) = net.forward(layerNames)
I am trying EAST text detector in pycharm but there is an error at line.
(scores, geometry) = net.forward(layerNames)
cv2.error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\dnn\src\layers\concat_layer.cpp:95: error: (-201:Incorrect size of input array) Inconsistent shape for ConcatLayer in function 'cv::dnn::ConcatLayerImpl::getMemoryShapes'
代码:
print("[INFO] loading EAST text detector...")
name = 'Pictures/non crop/maths soln analysis 4_89.jpg'
image = cv2.imread(name, 1)
(H, W) = image.shape[:2]
设置新的宽度和高度,然后确定变化的比例 宽度和高度都一样
set the new width and height and then determine the ratio in change for both the width and height
(newW, newH) = (375, 500)
rW = W / float(newW)
rH = H / float(newH)
# resize the image and grab the new image dimensions
image = cv2.resize(image, (newW, newH))
orig = image.copy()
(H, W) = image.shape[:2]
net = cv2.dnn.readNet("frozen_east_text_detection.pb")
layerNames = [
"feature_fusion/Conv_7/Sigmoid",
"feature_fusion/concat_3"]
根据图像构造一个斑点,然后执行正向传递 获取两个输出层集的模型
construct a blob from the image and then perform a forward pass of the model to obtain the two output layer sets
blob = cv2.dnn.blobFromImage(image, 1.0, (W, H),
(123.68, 116.78, 103.94), swapRB=True, crop=False)
start = time.time()
net.setInput(blob)
此行错误
(scores, geometry) = net.forward(layerNames)
推荐答案
查看全文