Last active
March 16, 2022 04:51
-
-
Save marcbelmont/fd0a98c1b2e3aeb9373e94eace5e78db to your computer and use it in GitHub Desktop.
Use in-memory image in Plate Recognizer and other speed tricks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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