0

everyone!

I'm trying to pass cv2.UMat object to cv2.calcHist function:

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

and I'm getting the error

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

but it seems like cpp version of OpenCV allows using UMat as source image.

Is it me doing something wrong or python OpenCV doesn't allow using UMat as source image for calcHist?

1 Answer 1

0

IU guess the reason for that error can be found in the documentation of 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 expects an image or a matrix containing the data in a specific order, which is fullfilled by a mat-instance supported by OpenCV. The UMat-format does not fullfil this requirement and so the error will be occur.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks for answering, but what does pyzbar.decode have in common with cv2.calcHist?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.