detecting unchanged images

R

Roedy Green

I am polishing a snapshot webcam viewer. I am trying to detect if the
image the server sent me is the exact same one it sent before (or if I
am getting a cached version, against my wishes. )

In the DOS days, this would be straight forward. I would compute a
checksum of the bits and compare them, also comparing
URLConnection.getLastModified dates and images sizes in the header
(jpg files grow and shrink slightly due to compression when they
change even when the frame size does not change.

But in Java I am puzzled.

the URLConnection getLastModified just gives 0. Any hints on methods
to use or techniques to try? Ideally I would like to use a single
connection where I detect if I am reloading too frequently because the
image is not changing.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
K

Kevin McMurtrie

Roedy Green said:
I am polishing a snapshot webcam viewer. I am trying to detect if the
image the server sent me is the exact same one it sent before (or if I
am getting a cached version, against my wishes. )

In the DOS days, this would be straight forward. I would compute a
checksum of the bits and compare them, also comparing
URLConnection.getLastModified dates and images sizes in the header
(jpg files grow and shrink slightly due to compression when they
change even when the frame size does not change.

But in Java I am puzzled.

the URLConnection getLastModified just gives 0. Any hints on methods
to use or techniques to try? Ideally I would like to use a single
connection where I detect if I am reloading too frequently because the
image is not changing.

Put capture sequence numbers in a CGI parameter. The advantage here is
that proxy caching is now a good thing. If you want to get really
fancy, you can have the server not reply until the requested sequence is
available.

Client: GET image.jpg
Server: Temp moved, location: image.jpg?seq=85857636
Client: GET image.jpg?seq=85857636
Server: OK, Image 85857636
Client: GET image.jpg?seq=85857637
Server: ....... OK, Image 85857637
Client: GET image.jpg?seq=85857638
Server: ....... OK, Image 85857638
 
R

Roedy Green

Put capture sequence numbers in a CGI parameter. The advantage here is
that proxy caching is now a good thing. If you want to get really
fancy, you can have the server not reply until the requested sequence is
available.

my problem is I have no control over the servers. In fact they may be
downright hostile, trying to stop me from hooking up to their feeds.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
R

Roedy Green

Put capture sequence numbers in a CGI parameter. The advantage here is
that proxy caching is now a good thing. If you want to get really
fancy, you can have the server not reply until the requested sequence is
available.

Client: GET image.jpg
Server: Temp moved, location: image.jpg?seq=85857636
Client: GET image.jpg?seq=85857636
Server: OK, Image 85857636
Client: GET image.jpg?seq=85857637
Server: ....... OK, Image 85857637
Client: GET image.jpg?seq=85857638

The problem is webcam servers try to make the stream for webcams also
serve those without working software. They have to use the same URL
every time to serve both purposes. There really should be a Webcam
protocol to avoid sending unchanged images where both server and
client can put a brake on refresh frequency. This is so eau de kludge.

I was astounded googling to discover just how many webcams there are
and how much totally useless traffic they are generating.



--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
A

Andrey Kuznetsov

Hi Roedy,
The problem is webcam servers try to make the stream for webcams also
serve those without working software. They have to use the same URL
every time to serve both purposes. There really should be a Webcam
protocol to avoid sending unchanged images where both server and
client can put a brake on refresh frequency. This is so eau de kludge.

If I understood you right, you want to get image from webcam only if
something changed,
e.g. something has moved.
The solution is easy - you should buy webcam which implements it internally.
Since it is an easy task, there are pretty many cameras which can do such
things (for example from sony)
 
K

Knute Johnson

Roedy said:
I am polishing a snapshot webcam viewer. I am trying to detect if the
image the server sent me is the exact same one it sent before (or if I
am getting a cached version, against my wishes. )

In the DOS days, this would be straight forward. I would compute a
checksum of the bits and compare them, also comparing
URLConnection.getLastModified dates and images sizes in the header
(jpg files grow and shrink slightly due to compression when they
change even when the frame size does not change.

But in Java I am puzzled.

the URLConnection getLastModified just gives 0. Any hints on methods
to use or techniques to try? Ideally I would like to use a single
connection where I detect if I am reloading too frequently because the
image is not changing.

Roedy:

You could request only the header. Odds are that the file length has
changed.
 
R

Roedy Green

If I understood you right, you want to get image from webcam only if
something changed,
e.g. something has moved.
The solution is easy - you should buy webcam which implements it internally.
Since it is an easy task, there are pretty many cameras which can do such
things (for example from sony)

The problem is there is no stream protocol. The JPG to the outside
world is just an ordinary jpg image that he webserver updates rather
frequently. There is no notification it changed or any indication of
when it will change next. You just get in periodically.

My idea was you notice if you are say fetching every 5 seconds, you
are not getting very frequent changes, so you can dynamically stretch
the polling frequency.

You can dynamically track to get the optimum balance between what the
end user desires and the server is currently providing.

What we really need is a standard protocol. It would be unusual as
porotocols go, since most users don't want all the available data.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
R

Roedy Green

You could request only the header. Odds are that the file length has
changed.

I am trying to make this work in general, where the bastards give you
-1 length, no timestamps etc. I think it will have to use a layered
set of approaches depending how much info they divulge. I don't think
I will bother with a PixelGrabber. Length should be sufficient.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top