OpenCV Python save jpg specifying quality; gives SystemError OpenCV Python save jpg specifying quality; gives SystemError python python

OpenCV Python save jpg specifying quality; gives SystemError


It is probably due to some wrong wrapping of the imwrite() parameters from Python to C, cv2.IMWRITE_JPEG_QUALITY (which is of type "long"), and causes some weird problems. You should 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)