Ask Your Question
0

OpenCV Python save jpg specifying quality; gives SystemError

asked 2012-07-04 14:37:12 -0600

sebhaase gravatar image
>>> import cv2
>>> a = cv2.imread(r"DMap.jpg")
>>> a.shape
(1080, 1920, 3)
>>> cv2.imwrite('img_CV2_90.jpg', a, [cv2.IMWRITE_JPEG_QUALITY, 90])
Traceback (most recent call last):
  File "<input>", line 1, in <module>
SystemError: error return without exception set

I just installed the newest OpenCV 2.4 on windows 7 (32bit)/ Python 2.7.3, but I still get the same error I got using the beta version.

Also get this error with 2.4.1. Any ideas ? Using tuple instead of list, or adding a trailing 0 to the sequence does not help - same error.

Thanks - Sebastian Haase

PS: I asked this on http://stackoverflow.com/questions/10410521 - not resolving the issue.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2012-07-04 16:26:46 -0600

Pavel Campr gravatar image

probably due to some wrong wrapping of imwrite() parameters from Python to C, cv2.IMWRITE_JPEG_QUALITY (which is of type "long") causes some weird problems... try to convert this constant to "int" type:

cv2.imwrite('img_CV2_90.jpg', a, [int(cv2.IMWRITE_JPEG_QUALITY), 90])

for me it solved the problem (python 2.7.2, opencv 2.4.1)

(answered on stackoverflow.com too)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2012-07-04 14:37:12 -0600

Seen: 7,644 times

Last updated: Jul 04 '12