Sheepdog
Posts: 16
Joined: Sun Aug 21, 2016 7:44 pm

Using Python to (IP/TCP) fetch jpg, save it. On digital input.

Fri Mar 01, 2019 3:19 pm

I'm very new to Pi... but old to computers.

Once you have things set up right... I can do this bit!... an IpCam can serve an IMAGE to a web browser in response to a command. I use this across my lan to look at what different cameras are seeing at the moment.

When you fetch a page this way, you don't get a page of html with an img tag leading to an image on the screen, but the image itself (which also appears in the browser, looking much like the result of the html- with- img. But for my wants (read on) the difference matters.

Something like the following is all that it takes.

http://192.168.0.225/cgi-bin/jpg/image

I managed to write a Windows program to fetch an image from such a source, and save it to my hard disk. It can be done! (I don't want to go the "camera sends image by FTP" route... because I want to use the Pi to control when images are fetched.)

Now I'm hoping to do the same with a Pi, with the Python normally "attached" to Thonny. Using Thonny for the development work.

And have that happen when a simple push button connected to the Pi is pushed.

For the moment, it will be enough to store the image somewhere on the SD card, using the same name over and over again, overwriting whatever was in that file previously each time. (I'm assuming that sending the data to a different storage device, say a usb hard drive, would be a trivial tweak, once the rest of this is in place.

Not a small ask, but... I'm hoping that some kind person will write the code for that, post it here for us all. Not JUST out of the kindness of their heart, but because the challenge amuses them?

I'm hoping the program will be well structured, to make re-using the various parts easy.

In related news: If anyone could post a URL for a site that will serve up small .jpgs to "the public", to simulate the image-from-IpCam, that alone would be a help, in that it would be helpful to people trying to help me in this quest.
Last edited by Sheepdog on Fri Mar 01, 2019 11:19 pm, edited 3 times in total.
New to Pi and Linux generally... old to computers. Using Raspbian 9 (Stretch) on a Pi 3 B (ver 1.2), apt-get update, apt-get upgrade at least as recently as 5 Aug 2018

User avatar
B.Goode
Posts: 9831
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Thonny to fetch IpCam snapshot jpg save on digital input

Fri Mar 01, 2019 4:35 pm

Now I'm hoping to do the same with a Pi, in Thonny.


Thonny is an IDE or programmer's editor, focussed on the Python3 version of the Python language.

It doesn't seem to be an appropriate platform to actually implement an application such as the one you describe.

(It might be a useful tool while developing the python source code for such an application. But once the script exists the specific editor used to create it becomes irrelevant.)

Sheepdog
Posts: 16
Joined: Sun Aug 21, 2016 7:44 pm

Re: Thonny to fetch IpCam snapshot jpg save on digital input

Fri Mar 01, 2019 6:54 pm

Thonny is an IDE...
(B.Good was addressing an earlier edition of my first post, which was unclear. before I fixed it, his comment made sense, and I answered it with "Understood. Is the interpreter/ compiler invoked when Thonny used in the most novice-likey way unsuitable for the task?")

In other news...

For testing, if your app can fetch and store a .jpg from "within" an ordinary webpage, that will be sufficient. Indistinguishable, for my purposes, from fetching an image from an IpCam... duh. Sorry I made it more complicated than it was in original post.

In other words, if your app can fetch and store...

http://sheepdogguides.com/dt3q-findruleA.jpg

.... then... Job Done!

(That jpg is a part of http://sheepdogguides.com/dt3q.htm)
New to Pi and Linux generally... old to computers. Using Raspbian 9 (Stretch) on a Pi 3 B (ver 1.2), apt-get update, apt-get upgrade at least as recently as 5 Aug 2018

Return to “Python”