I am using opencv with python. I wanted to do an cv2.imwrte:
cv2.imwrite('myimage.png', my_im)
The only problem is that opencv does not recognize the params constants:
cv2.imwrite('myimage.png', my_im, cv2.CV_IMWRITE_PNG_COMPRESSION, 0)
It cannot find CV_IMWRITE_PNG_COMPRESSION at all. Any ideas?
I can’t find key
CV_XXXXXin thecv2module:cv2.XXXXXcv2.cv.CV_XXXXXIn your case,
cv2.cv.CV_IMWRITE_PNG_COMPRESSION.More info.
The docs for OpenCV (cv2 interface) are a bit confusing.
Usually parameters that look like
CV_XXXXare actuallycv2.XXXX.I use the following to search for the relevant
cv2constant name. Say I was looking forCV_MORPH_DILATE. I’ll search for any constant withMORPHin it:From this I see that
MORPH_DILATEis what I’m looking for.However, sometimes the constants have not been moved from the
cvinterface to thecv2interface yet.In that case, you can find them under
cv2.cv.CV_XXXX.So, I looked for
IMWRITE_PNG_COMPRESSIONfor you and couldn’t find it (undercv2....), and so I looked undercv2.cv.CV_IMWRITE_PNG_COMPRESSION, and hey presto! It’s there: