Skip to content

Instantly share code, notes, and snippets.

@satomacoto
Last active April 25, 2019 02:12
Embed
What would you like to do?
import base64
import cv2
from PIL import Image
cap = cv2.VideoCapture(0)
_, img = cap.read()
image_string = cv2.imencode(".png", img)[1].tostring()
output = io.BytesIO()
Image.fromarray(img).save(output, format='PNG')
buf = output.getvalue()
b64 = base64.b64encode(buf)
import requests
from PIL import Image
from io import BytesIO
import numpy as np
res = requests.get(image_url)
image = Image.open(BytesIO(res.content))
image_array = np.array(image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment