CV2 Shape Context计算距离-断言失败

时间:2019-04-19 11:41:40

标签: python opencv shapes

我正在尝试在Python中使用OpenCv内置的“ Shape Context”算法。它适用于我的某些图像,但与其他图像一起返回此错误:

OpenCV(4.0.1) /Users/travis/build/skvark/opencv-python/opencv/modules/core/src/matmul.cpp:1218: error: (-215:Assertion failed) type == CV_64FC2 in function 'gemmImpl'

问题是由函数“ computeDistance”引起的:

def getMostSimilarImages(targetCont, _contours, _names, _targetImageName):
    shapeContext = cv2.createShapeContextDistanceExtractor()
    result = []
    for (i, cont) in enumerate(_contours):
        try:
            d = shapeContext.computeDistance(targetCont[0], cont[0])
            result.append((_names[i], d))
        except Exception as e:
            print(str(e))

    return result

我在这里(Shape Context Error by calculating distance of two different shapes)遇到了同样的问题,但就我而言,png图像的大小相同(50x50)

0 个答案:

没有答案