Im going to assume you have read the Part-1 and Part-2 of this post. Part-1 provides the hardware and Part-2 with the software for streaming and controlling the camera. This part will focus on the php file which is generated by the PHP webpage and its usage by the microcontroller to move or pan the camera. Lets get started.
Firstly we need a host program to read the data generated by the PHP and poll our “request” folder created in part-2 for updated data. Then we need to transmit this information serially to the microcontroller which pans based on that information. Im using C# to create this host program so here it goes. Start Visual Studio create a windows application. Throw in a button, a combo box and timer control. The stop button would stop the timer which will be initiated by the combo box changed event.
If you are reading this without reading the part 1 of this post I suggest you give that a read before starting with this since its gives the basic hardware needed to get everything going. However if your requirements are a simple streaming server with a client read on.
There are two modules within this post aswell I wont bother splitting them up into two rather just go on describing them in one. The first one is the streaming server with a client which serves the need for our surveillance. The second part includes the PHP webpage which includes the streaming client followed by code to generate a request file telling the motor which direction to rotate in.
The Story: Its been a while since my last post due to some work projects which have been occupying a lot of time and effort. However I still managed to find time for a hobby project, a DIY surveillance system using a webcam so I thought I’d go and share it with the rest. It’s not really a hobby project the real motivation behind the project are some of the cleaners which mess up some of the wirings of some work related project I am involved in. So you’d leave everything okay and when you come back in the morning something would either be unplugged or just not working. I’d to spend a lot of time probing on the scope of what’s wrong and most important where! with so many wires it’s a pain. So I decided to go ahead with building a surveillance system for myself using a webcam and some other hardware which I will mention in a while (I don’t want to go in detail of why not buy one off the shelf so don’t ask). The project however did help me learn about some valuable electronics concepts and it wasn’t all for fun. Anyway without further delay id just get on with it.
Right so the objective is to use PHP with AJAX to achieve what is normally known as “refresh less browsing”. When I started off with my work I had to deal with quiet a lot of forms which posted variables to a PHP page and then I could use them either by query string or whatever method to display them. The only problem with this was that the page had to be refreshed. I had a vague idea about AJAX but never really got into using it until I really got fed up of page refreshes, so if you share the same enthusiasm (slightly) this might prove helpful.