简体   繁体   中英

how to capture image from phone camera with python?

I need to capture the images from a phone camera using python and save the image on the PC in a given folder. I found a way to do it with OpenCV and IPWebCam but unfortunately I cannot connect the PC and the phone on the same Wifi network. Is there a workaround or an alternative that does not require for the devices to be connected to the same wifi? I am using Windows and the phone is an Android

I put forward my solution. Of course, I cannot report the whole code of the idea as it would be impossible.

  1. Create Server on your PC (Use the technology you prefer for Backend, for example Flask)
  2. Create route for retrieve images
  3. Inside your app, when take photo send it to this route (the route save picture for you inside desidered folder)

If you want such functionality to be usable with 4G outside the home, think about and consider the idea of a Real Server ( HETZNER SERVER CLOUD for example). This way you make sure you contact a remote backend and it will be irrelevant whether you own 4G,5G or wifi.

If, on the other hand, you don't like the Server idea and want to force it onto your local computer but want to allow the fact that the cell phone doesn't have to be under the same local network that the PC is connected to, unfortunately, you would have to call your network provider and request a static IP (for an extra few pennies a month). With the static IP you are reachable from the outside. That's not the only step you have to do actually, because, you also have to enable portforward because you have to make sure that the call comes to the private IP assigned by your router.

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