简体   繁体   中英

How to pass image to python script using flask?

I have a website (managed with python-flask) with images on canvas and i would like to pass the content of those canvas to another python script as images.

The other python script is using openCV in order to perform face detection.

I know i could upload the image on my server and then read the file on my opencv application but i would like not to save any data on my server.

Do you have any ideas ?

You anyway should upload file to the server, because you need to transfer user's data to your server application.

But instead of saving it as a regular file, you could use someting like SpooledTemporaryFile

In other words, you'll have workflow like this:

  1. Send image with POST to the server;
  2. Read file from POST request with flask;
  3. Write it to SpooledTemporaryFile and receive a file-like object;
  4. Use that file-like object for OpenCV

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM