Can't Decode Webp

asked 2019-07-03 18:09:37 -0600

jl303 gravatar image

I can open webp from file, but I can't get the following test code to decode the webp encoded format in memory on Python. I'd appreciate any pointer.

img = cv2.imread(file)

retval, buf = cv2.imencode(".webp", img, [cv2.IMWRITE_WEBP_QUALITY, 100])

img = cv2.imdecode(buf, 1)

imdecode_(''): can't read data: OpenCV(4.1.0) /io/opencv/modules/imgcodecs/src/grfmt_webp.cpp:164: error: (-215:Assertion failed) data.rows == 1 in function 'readData'

edit retag flag offensive close merge delete

Comments

please check cv2.getBuildInformation() -- maybe your cv2 does not have any support for webp codecs builtin (look at the Media I/O: section !)

berak gravatar imageberak ( 2019-07-03 23:57:20 -0600 )edit

I can open webp format from File though, so it's capable of decoding webp.

jl303 gravatar imagejl303 ( 2019-07-04 05:27:11 -0600 )edit

Hi all,I want to know how you can solve this problem.I also encountered this problem when calling opencv410 in Java

this is log: imdecode_(''): can't read data: OpenCV(4.1.0) /home/yuxiaoyang/repo_test/xmss_3rdparty/opencv-4.1.0-imsize/modules/imgcodecs/src/grfmt_webp.cpp:164: error: (-215:Assertion failed) data.rows == 1 in function 'readData' imdecode width=0 imdecode height=0

yuxiaoyang gravatar imageyuxiaoyang ( 2019-07-15 05:12:21 -0600 )edit