python opencv imwrite … can't find params

前端 未结 4 1395
梦谈多话
梦谈多话 2021-01-02 16:39

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 r

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-02 17:34

    Expanding on mathematical.coffee to ignore case and look in both namespaces:

    import cv2
    import cv2.cv as cv
    nms  = [(n.lower(), n) for n in dir(cv)] # list of everything in the cv module
    nms2 = [(n.lower(), n) for n in dir(cv2)] # list of everything in the cv2 module
    
    search = 'imwrite'
    
    print "in cv2\n ",[m[1] for m in nms2 if m[0].find(search.lower())>-1]
    print "in cv\n ",[m[1] for m in nms if m[0].find(search.lower())>-1]
    
    >>> 
    in cv2
      ['imwrite']
    in cv
      ['CV_IMWRITE_JPEG_QUALITY', 'CV_IMWRITE_PNG_COMPRESSION', 'CV_IMWRITE_PXM_BINARY']
    >>>
    

    Hopefully this problem will go away in some later release of cv2...

提交回复
热议问题