错误远期净值()在pycharm中的OpenCV EAST文本检测器中

2024-05-19 15:38:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试pycharm中的EAST文本检测器,但在第行有一个错误。 (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'

代码:

^{pr2}$

设置新的宽度和高度,然后确定变化的比率 宽度和高度

(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"]

从图像构造一个blob,然后执行 得到两个输出层集的模型

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)

Tags: imageneterrorcv2opencvblobforwardshape
3条回答

换行

(newW, newH) = (375, 500)

^{pr2}$

我在opencv4.1.1中也遇到了同样的错误。我正在试着运行这个。我的图像是320x320。在

# define the two output layer names for the EAST detector model that
# we are interested   the first is the output probabilities and the
# second can be used to derive the bounding box coordinates of text
layerNames = [
    "feature_fusion/Conv_7/Sigmoid",
    "feature_fusion/concat_3"]
# load the pre-trained EAST text detector
print("[INFO] loading EAST text detector...")
net = cv.dnn.readNet(east_network)

# construct a blob from the image and then perform a forward pass of
# the model to obtain the two output layer sets
blob = cv.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)
end = time.time()

# show timing information on text prediction
print("[INFO] text detection took {:.6f} seconds".format(end - start))

但当我运行它时,我得到以下错误:

^{pr2}$

你不是resizing to a multiple of 32。在

Important: The EAST text requires that your input image dimensions be multiples of 32, so if you choose to adjust your width and height values, make sure they are multiples of 32!

相关问题 更多 >