CGI Interface trial (Last update 20140322)

NetIO was handy but as the client application is not free, I tried to make an alternative. The result is a python based CGI script. Currently the servo control related functions are working. To do list includes voice related (python<>espeak) and camera related (I'll try the python library). Any information about usage of the python-espeak is welcomed.
libraries to install: (in addition to the list in my last post)
-lighttpd: instead of apache. it seems this is easier to set webserver user as root.
-serial (python library): to communicate with Rapiro board, instead of minicom
-python-espeak (python library): not working yet, if anyone has information about a tutorial or reference please tell me.
20140322 update:
Object and Face detection added. These are based on opencv 2.4.8, and as the version is not the default version installed with apt-get on Raspbian, please get source code from opencv site and compile/install the library, of course with python support. The detection now is triggered by "Take Picture" button, result is shown as text on the screen area.

Library list update:
-opencv 2.4.8 with python support

Object detection usage:
A text file "ObjectList.txt" is included in the pack. Please add a picture of the object into the same directory, and add a line to the text file as "object name,image file name,action". The action parameter is not used at the moment. When an object is detected the name and center location on a VGA image will be displayed. I've add a picture of my favourite cookie as a sample. The object can be detected is restricted to planar things with some texture, for example OK for postar, painting, photo, book cover etc and NG for apple, laptop, cola can, any deformable and moving things etc.

Face detection usage:
A pure haarlike based face detection. Can detect multiple faces within the camera view and display their location as text. By some basic test I found its not very stable to hairstyle. It only detects frontal face now.
CGI source pack:

posted by lacarte on 2014-03-15 22:30

This is a much better approach. Thanks for your effort.
I did a basic control project in netio but then switched to python script as it made much more sense.
Your control is much more elaborate. I haven't been able to get the camera working yet either.
I got the MJPG Streamer demo page to work but when I click on "here" it just shows one frame, no stream. Haven't tried creating a web page with camera frame yet.

posted by brad98408 on 2014-03-16 02:55

Thanks lacarte, i will try asap

posted by djakku on 2014-03-16 04:46

brad98408, the problem for me with camera was always power supply, so I havent really tried much with long term streaming or any recognition things. I'll try these from now on. Is your 'one frame' problem happens within NetIO? If so, then I think I had the same when implementing mine. The reason is NetIO's web object is a basic Android browser and does not support motion jpeg. You can try to access the address from a firefox or chrome maybe, it should be fine.

djakku, this version is a little bit slow in response compared to the NetIO version, but it should work from most browsers, so I think this direction is better for most people, including my self. Currently the movement buttons (yellow blocks) and the servo power (josef) are implemented.

The retro TV screen is now a simple background image, if anybody knows a good resource such as a 'TV screen like frame + transparent center' so the camera stream can be fit into it, please tell me. As I'm not a photoshopper collecting reasonable resource is always a pain.

posted by lacarte on 2014-03-16 06:35

I try to run your cgi script, when I run the script in the terminal I get an html code. I said you should put it in the index.html file to be accessed remotely (eg I came across a page with buttons but are directed to "" but impossible to operate (404 - Not Found).

Thank you to explain the procedure, please!
I think all libraries are installed correctly because when the script can check if there is an error!

Good work and continuous as well! + +

posted by Shelldone on 2014-03-21 09:47

Shelldone, the script is a cgi, so is meant to work as a server side script for remote access. Please put the files in the cgi-bin directory (if you are using apache this should be /usr/lib/cgi-bin). Then, to give execution permission to the script, type 'sudo chmod +x /usr/lib/cgi-bin/RapiroController.cgi'. Maybe its better to give cgi-bin directory a free access by "sudo -R chmod 777 cgi-bin". And I think it should be fine. The script can be accessed by http://your Pi's IP/cgi-bin/RapiroController.cgi

If some access error appears or the images do not show up, please try to modify the setting of apache. So, go to /etc/apache2/sites-enabled and edit '000-default' in the directory. Add the following lines between <Directory "/usr/lib/cgi-bin"> and </Directory> tag.

AddHandler cgi-script .py
AddHandler image/gif .gif
AddHandler image/jpg .jpg
AddHandler image/png .png
AddHandler text/html .html .htm

Editing this file will need sudo permission, so either by select "Tools->Open current *** as root" in the file browser or by sudo in a terminal. Good luck!

posted by lacarte on 2014-03-21 22:15

Read Terms of Service upon submitting. 投稿する前に利用規約をお読みください。