Solved

Webcam Photo not refreshing

Posted on 2011-03-09
8
596 Views
Last Modified: 2012-05-11
We are trying to put a webcam on our website. My page www.downtownrapidcity.com/camera.html is set to refresh every 5 seconds which it does. But the photo doesn't change from the webcam. I have to manually click on Refresh on my browser window to get the image to change.

If you go to http://208.117.100.102/cgi-bin/viewer/video.jpg where it is pulling the photo, it updates with each refresh of the page.

How do I get the image to change with each auto refresh?
0
Comment
Question by:katlees
  • 5
  • 2
8 Comments
 
LVL 2

Assisted Solution

by:Roza
Roza earned 200 total points
ID: 35086352
I guess browser is cacheing your image instead of reloading it when page reloads.

Try adding

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

between HEAD tag.
0
 
LVL 16

Accepted Solution

by:
sjklein42 earned 300 total points
ID: 35086725
My approach is to add a random tag to the image URL each time it is fetched to bypass caching.  Sometimes it is the webcam software itself that does the caching.

<SCRIPT LANGUAGE="JavaScript">

url='http://208.117.100.102/cgi-bin/viewer/video.jpg?v=';

var image1 = new Image();
function RefreshMyCamera()
{
    if ( ( image1.src != '' ) && (image1.complete) )
    {
        document.images['mycamera'].src = image1.src
    }
    imgno = Math.round(Math.random()*215815);
    image1.src = url + imgno;
    setTimeout('RefreshMyCamera()', 5000);  // inter-frame delay in msec
}
</script>

<img border='0' src='http://208.117.100.102/cgi-bin/viewer/video.jpg' name='mycamera'>

<SCRIPT LANGUAGE="JavaScript">
setTimeout('RefreshMyCamera()', 10);
</SCRIPT>

Open in new window

0
 
LVL 16

Expert Comment

by:sjklein42
ID: 35086822
You video server (camera) appears to be down.

Instead of an image it is returning this:

http://208.117.100.102/cgi-bin/viewer/video.jpg

HTTP/1.1 500 Internal Server Error
0
 
LVL 16

Expert Comment

by:sjklein42
ID: 35087287
The javascript approach has the added advantage that only the image is updated, so you can embed it in a static web page and not have to refresh the whole page.

Did we take down your camera server?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:katlees
ID: 35087298
I don't know. Another company does the camera server I have put in a trouble ticket to them. Thanks... as soon as it is back up I can try these fixes.
0
 
LVL 16

Expert Comment

by:sjklein42
ID: 35087977
Improved version.  I have it pointing at my webcam for now.  You can change the URL (in two places) and try it with your camera when your server comes back online.

<SCRIPT LANGUAGE="JavaScript">

var url='http://sjklein.dyndns.org:11001/cam_1.jpg?';
var frq=1500;           // interval in msec

function PrefetchImage()
{
    var imgno = Math.round(Math.random()*215815);
    image1 = new Image();
    image1.src = url + imgno;
}

var imgno;
var image1;

PrefetchImage();

function RefreshMyCamera()
{
    if (image1.complete)
    {
        document.images['mycamera'].src = image1.src
        PrefetchImage();
    }

    setTimeout('RefreshMyCamera()',frq);
}
</script>

<img border='0' src='http://sjklein.dyndns.org:11001/cam_1.jpg' name='mycamera' width=95%>

<SCRIPT LANGUAGE="JavaScript">
setTimeout('RefreshMyCamera()', 10);
</SCRIPT>

Open in new window

0
 
LVL 16

Expert Comment

by:sjklein42
ID: 35090889
I'm afraid my code is taking down the camera server.
0
 

Author Closing Comment

by:katlees
ID: 35101354
Both responses worked but I liked the one where I could embed it right into the website! Thanks guys
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WMI, model #, retrieving information 10 117
Re-position the objects 7 97
Recommendation vb6 to vb.net or others 14 109
Not seen Link button 5 15
This is an explanation of a simple data model to help parse a JSON feed
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now