Skip to content

imdecode failing on image fetch from url #1132

@lexmarionb

Description

@lexmarionb

I have the following code:

def getImg(url):
    request = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
    return cv2.imdecode(np.frombuffer(request.read(), dtype=np.uint8), cv2.IMREAD_GRAYSCALE)

However, I'm encountering the following error whenever cv2.imdecode() is used.

OpenCV(4.12.0) D:\a\opencv-python\opencv-python\opencv\modules\flann\src\miniflann.cpp:338: error: (-5:Bad argument) Only continuous arrays are supported in function 'cv::flann::buildIndex_'

This doesn't happen when an image file is passed instead. The process is almost identical wherein a file buffer is passed to cv2.imdecode(). Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions