Jump to content

Video survailance


babylonsr

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
Link to comment
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.
Link to comment
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.
Link to comment
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.
Link to comment
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.
Link to comment
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.
Link to comment
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.
Link to comment
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?
Link to comment
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.
Link to comment
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.
Link to comment
Share on other sites

  • 3 weeks later...
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
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.