convert openCV image into PIL Image in Python (for use with Zbar library)

后端 未结 4 584
长发绾君心
长发绾君心 2021-02-05 01:18

I\'m trying to use the Zbar library\'s QR code detection methods on images I extract with OpenCV\'s camera methods. Normally the QR code detection methods work with images (jpg,

4条回答
  •  礼貌的吻别
    2021-02-05 01:55

    With the python CV2, you can also do this:

    import Image, cv2
    
    cap = cv2.VideoCapture(0) # says we capture an image from a webcam
    _,cv2_im = cap.read()
    cv2_im = cv2.cvtColor(cv2_im,cv2.COLOR_BGR2RGB)
    pil_im = Image.fromarray(cv2_im)
    pil_im.show()
    

提交回复
热议问题