【问题标题】:OpenCV Python: can not pass UMat to calcHistOpenCV Python:无法将 UMat 传递给 calcHist
【发布时间】:2019-04-16 01:14:00
【问题描述】:

大家!

我正在尝试将 cv2.UMat 对象传递给 cv2.calcHist 函数:

a = np.arange(10, dtype=np.uint8)
b = cv2.UMat(a)
cv2.calcHist([b], [0], None, [10], [0, 10])

我得到了错误

TypeError: images is not a numpy array, neither a scalar

但似乎 cpp 版本的 OpenCV 允许使用 UMat 作为源图像。

是我做错了什么还是 python OpenCV 不允许使用 UMat 作为 calcHist 的源图像?

【问题讨论】:

    标签: python opencv


    【解决方案1】:

    IU猜这个错误的原因可以在decode from pyzbar的文档中找到:

    def decode(image, symbols=None, scan_locations=False):
    """Decodes datamatrix barcodes in `image`.
    Args:
        image: `numpy.ndarray`, `PIL.Image` or tuple (pixels, width, height)
        symbols (ZBarSymbol): the symbol types to decode; if `None`, uses
            `zbar`'s default behaviour, which is to decode all symbol types.
        scan_locations (bool): If `True`, results will include scan
            locations.
    

    Decode 需要一个包含特定顺序数据的图像或矩阵,这些数据由 OpenCV 支持的 mat-instance 填充。 UMat 格式不满足此要求,因此会发生错误。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-09
    • 2019-12-17
    • 1970-01-01
    • 2011-10-11
    • 2015-05-05
    • 1970-01-01
    • 1970-01-01
    • 2016-03-17
    相关资源
    最近更新 更多