473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

smooth images from webcam

JD
Hello,

I have webcams, and I want to display the images (jpg) from the cameras
on a webpage, refreshed continuously.

For a smooth transition I found a script that utilises double buffering.
This works nice, but it is rather complex. I need to change it because
it is made to display one camera, but I want more cameras on one page.
With every change I make the refresh stops.

Does someone have an example (or a pointer) how to make such a
script/page (simple)?

Thank you
Jan 5 '07 #1
2 3965
JD said the following on 1/5/2007 5:05 AM:
Hello,

I have webcams, and I want to display the images (jpg) from the cameras
on a webpage, refreshed continuously.

For a smooth transition I found a script that utilises double buffering.
This works nice, but it is rather complex. I need to change it because
it is made to display one camera, but I want more cameras on one page.
With every change I make the refresh stops.
Then you are changing something that shouldn't be changed.
Does someone have an example (or a pointer) how to make such a
script/page (simple)?
Post your page so far, it may be something simple that can be modified
rather than guessing at your setup.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 6 '07 #2
JD
On 2007-01-06, Randy Webb <Hi************@aol.comwrote:
JD said the following on 1/5/2007 5:05 AM:
>Hello,

I have webcams, and I want to display the images (jpg) from the cameras
on a webpage, refreshed continuously.

For a smooth transition I found a script that utilises double buffering.
This works nice, but it is rather complex. I need to change it because
it is made to display one camera, but I want more cameras on one page.
With every change I make the refresh stops.

Then you are changing something that shouldn't be changed.
>Does someone have an example (or a pointer) how to make such a
script/page (simple)?

Post your page so far, it may be something simple that can be modified
rather than guessing at your setup.
Here is my working code so far. It is a stripped-down version of the
page provided by the manufacturer. Some parts are rewritten, but a full
rewrite can only be done if I understand the reload/buffering mechnism.
The code can only display 1 camera, I would like to display several
(e.g. 4) cameras. Does someone how the code must be changed to make this
possible?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!-- Camera viewer -->
<!-- Javascript to reload automatically -->
<!-- based on code by Mobotix -->
<!-- rewritten by Fulko van Westrenen -->
<!-- 4 April 2005 -->

<html>
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1st August 2004), see www.w3.org">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<title>Live Camera</title>
<style type="text/css">
<!--
table.code{background:#ccffcc; border: 0;}
div.width{width:640}
div.date{font - style:italic;text - align:right;font - size:80 %;}
div.footer{font - size:80 %}
-->
</style>

<meta http="" equiv="Content-Script-Type" content="text/javascript">

<script type="text/javascript" language="JavaScript1.2">
var pic_url = "http://address/picture.jpg";
var noframepath = "http://address/error.jpg";
var n = Math.floor (Math.random () * 1000000);
var session_id = Math.floor (Math.random () * 1000000);
var startn = n;
var GetItOn = 1;
var recordmult = 1;
var framestep = recordmult * 12;
var buffer = new Image ();
var aktiv = null;
var db_enabled = 0;
var passiv = null;
var current_refresh_method_nr=0;

function debugmsg(k) {};

function DoComplete ()
{
if (db_enabled != 0)
{
if (db_enabled < 0)
{
document.CamPic.style.display = "";
buffer.style.display = "none";
}
else
{
buffer.style.display = "";
document.CamPic.style.display = "none";
}
db_enabled *= -1;
}
else
{
document.CamPic.src = buffer.src;
}
GetItOn = 1;

}

function LoadError ()
{
debugmsg ("LoadError:#" + (n - 1) + " db:" + db_enabled);
if (db_enabled != 0)
{
db_enabled *= -1;
}
else
{
document.CamPic.src = noframepath;
}
GetItOn = 1;

}

function setframerate()
{
recordmult=1;
framestep = Math.round (recordmult * 12);
debugmsg ("setframerate: aktiv=" + aktiv + " rm=" + current_refresh_method_nr + " mult:" + recordmult + " fs=" + framestep);
if (aktiv)
{
window.clearInterval (aktiv);
aktiv = null;
}
document.CamPic.onerror = null;
buffer.onerror = null;
if (recordmult < 0)
{

return;
}

aktiv = window.setInterval ("Animation()", 1000 * recordmult);
GetItOn = 1;
Animation ();
}

function Animation()
{
var my_rm_nr = current_refresh_method_nr;
var my_fr_step = framestep;
var my_session = session_id;

if (GetItOn == 1 || (my_rm_nr == 1 && my_fr_step 0))
{
GetItOn = 0;
if (db_enabled < 0)
{
buffer.onerror = buffer.onload = null;
document.CamPic.onerror = LoadError;
document.CamPic.onload = DoComplete;
if (my_rm_nr == 0)
document.CamPic.src = pic_url + "?rand=" + String (n++);
else
document.CamPic.src =
pic_url + "?sync=" + my_fr_step + "&session=" + my_session +
"&rand=" + String (n++);
}
else
{
document.CamPic.onerror = document.CamPic.onload = null
buffer.onerror = LoadError;
buffer.onload = DoComplete;
if (my_rm_nr == 0)
buffer.src = pic_url + "?rand=" + String (n++);
else
buffer.src =
pic_url + "?sync=" + my_fr_step + "&session=" + my_session +
"&rand=" + String (n++);
}
}
}

function animation_init()
{
if (document.all && (navigator.platform.substr (0, 3) != "Mac"))
{
document.CamPic.insertAdjacentHTML ("AfterEnd",
"<img border=0 style=\"display:none;\" name=dbbuffer><\/b>");
buffer = document.dbbuffer;
db_enabled = 1;
}
setframerate ();
}

</script>

</head>

<body onload="animation_init()">

<h3>webcam </h3>

<p><img src="http://address/picture.jpg" name=
"CamPic" id="animImage"></p>

</body>
</html>
Jan 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Michel | last post by:
Here is a litle script that preload images and show a thumbnail. Once you get on the picture you see the real size It worsk fine with normal picture but when the url has some parameters like in...
3
by: Alex | last post by:
Hi all, Thanks to Els from another post I got my CSS hover-overs working in IE, Firefox, and about everything else I've tried. Problem is the CSS hover overs are VERY choppy in IE while very...
11
by: mercurius_1 | last post by:
I need some help with this page: http://www.sarahpollock.com/new/x.php I stole much of this layout from "A List Apart," but I'm no CSS guru and I desperately need some help with the finishing...
10
by: aceto | last post by:
Hi. I'm sorry for my bad english, but it's not my motherlanguage. I need to read data from a webcam and display the images on DOS . So, how can i show this images? i have to translate the data...
1
by: Fleets422 | last post by:
Hi, new kid on the block... Hope I am posting this in the proper forum as it involves HTML, JAVA as well as PHP. A little background... I have been writing PC apps using Borland's C++ Builder for...
13
by: Berco Beute | last post by:
I've been trying to access my webcam using Python, but I failed miserably. The camera works fine under Ubuntu (using camora and skype), but I am unable to get WebCamSpy or libfg to access my...
17
by: mrcw | last post by:
private void timer1_Tick(object sender, EventArgs e) { Bitmap m_Undo = new Bitmap(pbLeftWebcam.Image); if (Invert(m_Undo)) ...
1
by: ezat azah | last post by:
I am doing a project in C++ to retrieve stream of images from webcam using Codegear compiler. Honestly I am new in C++ languages. After a few research I found out that C++ can do the filtering to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.