Jump to content

Archived

This topic is now archived and is closed to further replies.

babylonsr

Video survailance

Recommended Posts

Hi all

I am new to PHP! I am creating a project with my friends about video survailance. Our goal is to monitor few webcams as in LAN, i mean in the same building and also to put few webcams in another place and monitor them remotely via internet. Anyone has any idea before starting. We would like to do it using PHP, so is it possible?

Thanks all

Share this post


Link to post
Share on other sites
I think you can do it if you are able to stream the video feed. Make a script to run from the command line and have the code inside an infinite loop*, that should make it work.

* an infinite loop is something like this: [code]while(1==1)
{

}[/code]

Share this post


Link to post
Share on other sites
I suggest you don't use infinite loops for anything, just because they're infinite loops. You should be able to easily stream the video feed without any PHP at all. As to exactly how you would do that, you should refer to your webcams' manuals or manufacturers.

Share this post


Link to post
Share on other sites
I found few interesting softwares like Active WebCam... but i am not sure if it is good to use it. We would like to access by LAN and also via Internet, so i can view the cams and also any other guest. Advice!

Share this post


Link to post
Share on other sites
check to see if your webcams have an ethernet port on them - if so, you can plug them directly into your network and they'll act as a regular network device. The one we have at work has a little httpd server that you can access to see the stream - I'm not sure as to the capabilities of yours, but it might be worth looking into.

Share this post


Link to post
Share on other sites
Tell me any brand of such cams. I haven't bought anything yet, i am trying on few small USB webcams, but we sure will buy with enternet port as you said... Since u have tested it what is the brand... Thanks

Share this post


Link to post
Share on other sites
I don't know the brand, but when I get to work, I'll look and get the brand and model. I didn't set it up, but I use it regularly, so I know it works. :)

Share this post


Link to post
Share on other sites
[quote author=neylitalo link=topic=110606.msg447398#msg447398 date=1160072826]
I suggest you don't use infinite loops for anything
[/quote]

If you need an application to run until something happens, then you would need an infinite loop. Try to look at some C/C++ tutorials, many of them tells you to use an infinite loop, well, not entirely infinite as it might be some like this (not sure if it's correct - I'm not very good at C): [code]#include <stdio.h>

int main()
{
int option;

while(1==1)
{
option = menu();
if(option == 1)
{
printf("Hello");
}
else if(option == 0)
{
printf("Bye!");
break;
}
else {
printf("Invalid option!");
}
}

return 0;
}

int menu()
{
int user_option;

printf("MENU:");
printf("1) Say hello");
printf("----------");
printf("0) Exit");

scanf("%d", &user_option);

return user_option;
}[/code]

I know it might be stupid to post a C example on a PHP forum, but it's the only thing I could come up with. And the reason why I said how he could do it in PHP is that he requested it to be like this.

Share this post


Link to post
Share on other sites
daniel, scripting languages do not work the same way as compiled programming languages. with programming languages, loops work perfectly as you can manipulate screen contents in the middle of a loop.

what you need to remember is that PHP essentially creates a HTML document, and until the script has finished its job of doing that, nothing is output to the browser. so setting PHP into an infinite loop will give you an infinite page of blankness - until a script timeout error occurs, of course.

if you were to type something like this: (pseudocode, just for cross-language idea):

[code]
for ($i = 0; $i < 100000; $i++)
{
  echo 'hello world ';
}
[/code]

run something like it in C/C++/whatever, and you'll see each word come on the screen one by one.
do this in a scripting language (PHP/ASP/JSP, etc) and you wont see anything until ALL 100000 'hello world's' have been output - the '"echo" in a scripting language is essentially forming part of the HTML to be sent out in one go, and not outputting it to the screen directly with each loop iteration.

Share this post


Link to post
Share on other sites
Sorry, a bit OT, but....

[quote]do this in a scripting language (PHP/ASP/JSP, etc) and you wont see anything until ALL 100000 'hello world's' have been output[/quote]

Not entirely true. This is more to do with the fact that your working within a web environment. If you run your example using php's cli the output is exactly the same as it would be done in C/C++/whatever.

Ive written quite a few daemons in scripting languages, bash, python and php, its just http that makes this sort of thing more difficult.

Share this post


Link to post
Share on other sites
[quote author=redbullmarky link=topic=110606.msg447441#msg447441 date=1160075623]
daniel, scripting languages do not work the same way as compiled programming languages
[/quote]

Depends on how you run it. If you run it using a webserver, then it don't, but if you run it from command-line it will work sort of the same way.

Share this post


Link to post
Share on other sites
[quote author=Daniel0 link=topic=110606.msg447772#msg447772 date=1160112687]
[quote author=redbullmarky link=topic=110606.msg447441#msg447441 date=1160075623]
daniel, scripting languages do not work the same way as compiled programming languages
[/quote]

Depends on how you run it. If you run it using a webserver, then it don't, but if you run it from command-line it will work sort of the same way.
[/quote]

Huh. Is that how it works?

Share this post


Link to post
Share on other sites
i didnt know that either :) cheers thorpe/daniel.

however i get the feeling from the original post that "monitoring webcambs" and "via the internet" would effectively mean that this sort of infinite loop would not be applicable as the final app would be running via the browser.

Share this post


Link to post
Share on other sites
In fact I think it runs like that on a webserver too, but it will interpret the code for the webserver and while it does that, it sends it to the webserver continuously. When it is all done the webserver sends the result to the client in one piece. That gives the illusion that nothing is output before script execution.

The main difference between compiled and interpreted languages is that compiles languages is interpreted into something the computer can understand [i]one[/i] time where interpreted languages is interpreted [i]each[/i] time. So in my oppinion PHP is just as much a "real" programming language as the compiled ones.

Share this post


Link to post
Share on other sites
I would't start a project like this in PHP if you're not familiar with the language. Also, I think it'll be more stable in C/C++.

Share this post


Link to post
Share on other sites
this may sound stupd
but why do you want to program that ?
the webcams that have an ethernet interface come mostly with surveilance software that let you do exactly what you want.

Unless it is for a school project of something similar.

here is a case of why and how webcams were used.
http://www.windfinder.com/wind/webcam_en.htm

http://www.macworld.com/2006/06/reviews/axis207w/index.php

wireless (beware for security problems)
http://www.amazon.com/D-Link-DCS-1000W-802-11b-Wireless-Webcam/dp/B000067JZF

and not wireless
http://computing.kelkoo.co.uk/b/a/cp_116901_filter_pc_interface_ethernet_10basemt100basemtx.html

Share this post


Link to post
Share on other sites
Your cams, depending on their capability should have that sort of feature built-in. You may need a third party streaming server to do the streaming to the web, which would be a very tall order to create, even for someone with a lot of programming experience. You can use PHP to build your website around the streams, thats fine, but not to control the streams themselves.

Also, for those of you who have never used it, PHP has a very [url=http://us3.php.net/manual/en/features.commandline.php]comprehensive CLI[/url] (Command Line Interface) and I've written a number of very efficient (and stable) daemons including listeners and chat bots using PHP on the command line.  Using [url=http://gtk.php.net/]PHP-GTK[/url] you can even write your own client software using PHP which is also little-known to PHP developers.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.