Skip to content

Software setting : WEB Shared cam

kariloy edited this page Jun 15, 2013 · 23 revisions

Step 1: Install/Setup/Run mjpg-streamer
Start by installing mjpg-streamer:

cd /home/pi
wget -Omjpg-streamer.tar.gz http://mjpg-streamer.svn.sourceforge.net/viewvc/mjpg-streamer/mjpg-streamer/?view=tar
tar xfz mjpg-streamer.tar.gz
cd mjpg-streamer
make

Test your mjpg-streamer installation with:

./mjpg_streamer -i "./input_uvc.so -r 640x480 -f 15" -o "./output_http.so"

Install streamer service on startup
Inside Shapextractor folder you find mjpg_service file, it help you to configure it run at startup this sw:

cd /home/pi/Shapextractor
sudo cp mjpg_service /etc/init.d/mjpg_service
sudo chmod 755 /etc/init.d/mjpg_service
sudo update-rc.d mjpg_service defaults

If you do not want reboot the Rpi you can run the server with this command:

./etc/init.d/mjpg_service start

Step 2: Install/Setup/Run haproxy

sudo apt-get install haproxy
sudo mv /etc/haproxy/haproxy.cfg haproxy.old
sudo nano /etc/haproxy/haproxy.cfg

and modify it using the following code:

global
    maxconn 4096
    user haproxy
    group haproxy
    daemon
    log 127.0.0.1 local0 debug

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    retries 3
    option redispatch
    option http-server-close
    option forwardfor
    maxconn 2000
    timeout connect 5s
    timeout client  15min
    timeout server  15min

frontend public
    bind *:80
    use_backend webcam if { path_beg /webcam/ }
    default_backend Shapextractor

backend Shapextractor
    reqrep ^([^\ :]*)\ /Shapextractor/(.*)     \1\ /\2
    server Shapextractor1 127.0.0.1:7000
    acl AuthOkay http_auth(L1)
    http-request auth realm Shapextractor if !AuthOkay

backend webcam
    reqrep ^([^\ :]*)\ /webcam/(.*)     \1\ /\2
    server webcam1  127.0.0.1:8080

userlist L1
    group shapeusers
    user test insecure-password test groups shapeusers

Now you need to enable haproxy:

sudo nano /etc/default/haproxy 

end by setting the parameter ENABLED to 1.

Now start the haproxy service:

sudo service haproxy start

OK, you are ready to open your browser on Shapextractor : http://"<Rpi ip here>" and for autentication use the username and password present on the haproxy.cfg file (the defaults are: test test)

Step 3: Setup the web server
Use the console to change into the Shapextractor directory and run the following commands:

nano index.htm

need modify on start of last line from start.htm to startip.htm. After this continue with this other commands:

sudo cp Shape_service /etc/init.d/Shape_service
sudo chmod 755 /etc/init.d/Shape_service
sudo update-rc.d Shape_service defaults

Now every time the Rpi is started it also runs a simple python cgi webserver on port 7000

If you do not want reboot the Rpi you can run the server with this command:

./etc/init.d/Shape_service start

or likewise you can stop it with this one:

./etc/init.d/Shape_service stop

now that you can make the webserver run you are ready to use the Shapextractor

Step 4 : Using Shapextractor

Open your browser (Chrome or Firefox) and enter the Shapextractor URL:
http://"RPi-ip_address"
(if want to change PORT number modify it on the /etc/init.d/Shape_service file)

![menu](https://lh5.googleusercontent.com/-KD97u2VOto8/UbXB8zko6II/AAAAAAAADJw/TlhWu_ZkfgA/s600/menu.jpg)
In the homepage you can choose to **Start new 3D-Scan** or see the Previous Scan.

All scans are visible on the web browser (provided it supports webGL). Also the PLY file can be downloaded and opened with Meshlab for Poisson Reconstruction.

![live](https://lh6.googleusercontent.com/-ghCTI5adp2A/UbXB87m5G9I/AAAAAAAADJo/RJE_uc_hAqE/s600/live.jpg)

New scan interface

![start](https://lh3.googleusercontent.com/-pKVhF3AUCr8/UbXB8v0nd5I/AAAAAAAADJs/Hcm7B4XCiME/s600/startip.jpg)
In this configuration have live webcam stream
Option:
LASER POWER        Laser power intensity
CROP               Set pixel height you want to delete from the top to make a cleaner image
QUALITY            Set scan resolution 0 (512steps/photos) 1 (1024 steps/photos) 2(2048 steps/photos)
ROT                Set position of camera 0 horizontal 90 vertical
CAMERA HFOV        Set this to the camera lens angle that you worked out above
CAMERA DISTANCE    The distance from the camera 'foot' to the center of the turntable
LASER OFFSET       The angle between the camera-turntable line and the laser
HORIZONTAL AVG.    The number of consecutive horizontal points to average together to smooth out the surface
VERTICAL AVG.      The number of consecutive vertical points to average together to smooth out the surface.

Other hidden values on html page

A = 9           GPIO RPi for 1 in uln2003 (stepper)
An = 25         GPIO RPi for 2 in uln2003 (stepper)
B = 11          GPIO RPi for 3 in uln2003 (stepper)
Bn = 8          GPIO RPi for 4 in uln2003 (stepper)
LASER = 18      GPIO RPi for 5 in uln2003 (laser line)
LIGHT = 7       GPIO RPi for 6-7 in ulm2003 (light)
DELAY = 0.002   Delay from stepper sequence
FRAME_SKIP = 1  Use every n'th frame for speed
POINT_SKIP = 1  Use every n'th scanline for speed
RESW = 640      Set camera resolution
RESH = 480      Set camera resolution

Note:
If want to change the default values above you need modify them on the file start.htm

After choosing your settings press the Start button and wait for Shapextactor to finish the scan :)

Clone this wiki locally