Skip to content

Instantly share code, notes, and snippets.

@marcbelmont
Last active March 16, 2022 04:51
Show Gist options
  • Save marcbelmont/fd0a98c1b2e3aeb9373e94eace5e78db to your computer and use it in GitHub Desktop.
Save marcbelmont/fd0a98c1b2e3aeb9373e94eace5e78db to your computer and use it in GitHub Desktop.
Use in-memory image in Plate Recognizer and other speed tricks.
import io
import json
import requests
from PIL import Image
def main():
im = Image.new('RGB', (300, 300))
# or
# im = Image.fromarray(frame)
buffer = io.BytesIO()
im.save(buffer, 'PPM') # PPM does no compression
buffer.seek(0)
response = requests.post('http://localhost:8080/v1/plate-reader/',
files=dict(upload=buffer),
data=dict(regions=[],
config=json.dumps(dict(mode='fast')))) # Speed up processing. Do only 1 detection step.
print(response.json())
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment