You can use simple javascript
to refresh it on page.
Let say that your camera update the same image names imagefromcamera.jpg
. Then you show it on your page with simple html, or with asp image control, and you update it with javascript as:
<img id="LiveImg" width="320" height="320" alt="" src="imagefromcamera.jpg?" />
<script>
var myImg = document.getElementById("LiveImg");
if (myImg){
window.setInterval(function(){
myImg.src = myImg.src.replace(/\?.*$/, '?' + Math.random());
}, 3000);
}
</script>
Adding this random number at the end of the image we make sure that is not keep in cache of the browser. The timer here is needed to update it every some seconds, let say here 3 seconds.
Now if your camera make different names you can use the same idea and loaded them. If you have some other way to get the images from your camera you can use a handler to send the image. Here is a similar example. I made an handler names captureimage.ashx
, use the same code in javascript side:
<img id="LiveImg" width="320" height="320" alt="" src="captureimage.ashx?" />
<script>
var myImg = document.getElementById("LiveImg");
if (myImg){
window.setInterval(function(){
myImg.src = myImg.src.replace(/\?.*$/, '?' + Math.random());
}, 3000);
}
</script>
and on server side the handler can be something like:
public class ReadTheCameraImage : IHttpHandler
{
public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "image/jpeg";
context.Response.Buffer = false;
// read the ImageData from what ever source you have
context.Response.OutputStream.Write(ImageData, 0, ImageData.Length);
}
public bool IsReusable
{
get {
return false;
}
}
}
Here I like to say, that this is not a solution for live video, but for just display the capture of a web camera to a page, like make live web cameras on the internet that show some places. For live video, and live communication you need a far more complicate code, and the use of Adobe flash player together with server streaming, direct connection with each client connected and other stuff.
Some other answers for the video, in case that your camera software support the direct video streaming :
how to work with videos in ASP.NET?
How to play audio and video files in web browser?
how can i play vimeo player on image click?