4. 10. 2020

Configure a WebCam in Openwrt

Original: http://openwrt.tuinstituto.es/configurar-una-webcam-en-openwrt

Objective: Install and configure a WebCam in Openwrt on an Amper ASL 26555 router and perform web video streaming with mjpg-streamer.
Firmware: Openwrt Chaos Calmer 15.05
Difficulty: Medium
We need: Router Amper ASL 26555
Webcam (In our case we will test it with 2 webcams):
- Samsung PWC-7000X (ID 0ac8: 0302 Z-Star Microelectronics Corp. ZC0302 Webcam)
- Logitech QuickCam ( ID 046d: 089d Logitech, Inc. QuickCam E2500 series)
Required software: Web browser, SSH Putty client (windows only)
More information: Openwrt webcams, View UVC supported cameras, View GSPCA supported cameras Experienced
Access: Quick Install Access

Depending on the type of webcam we will have to install, we must change the installation process:

Step 1. Identify type of webcam.

On linux

In case of using Linux it is easy. We just have to insert the camera in a Linux computer, open a terminal and execute the command:

lsusb

The output of this command will be similar to this one, although with more lines:

# lsusb
 Bus 001 Device 004: ID 0ac8:0302 Z-Star Microelectronics Corp. ZC0302 Webcam
 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

We must locate the identifier of the camera (marked in red above) that will help us to find out which driver to install.

In our case the identifier is 0ac8:0302that it corresponds to our Samsung camera.

From Openwrt

From Openwrt we have to access by ssh and execute the following to support usb devices:

opkg update
opkg install usbutils kmod-usb2 kmod-usb-core kmod-usb-ohci kmod-usb-uhci 

Then we can make

lsusb

The command will return the identifiers of devices connected by usb:

root@OpenWrt:/# lsusb
 Bus 001 Device 007: ID 046d:089d Logitech, Inc. QuickCam E2500 series
 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 

This time we have marked the identifier 046d:089dof our Logitech webcam in red  .

Step 2. Locate the necessary driver and install it.

The first thing is to install the openwrt USB support :

opkg update
opkg install usbutils kmod-usb2 kmod-usb-core kmod-usb-ohci kmod-usb-uhci

Once the identifier of step 1 of our webcam has been recorded, we must proceed as follows:

In case you find your identifier on this page:  Consult UVC supported cameras

The installation will be:

 opkg update
 opkg install kmod-video-uvc
 

In case you can find your identifier on this page: Check supported cameras GSPCA

We found our Logitech webcam ID here:

...
vc032x		046d:0896	Logitech Orbicam
vc032x		046d:0897	Logitech QuickCam for Dell notebooks
zc3xx		046d:089d	Logitech QuickCam E2500
zc3xx		046d:08a0	Logitech QC IM
zc3xx		046d:08a1	Logitech QC IM 0x08A1 +sound
...

and that of the Samsung too:

...
jeilinj		0979:0280	Sakar 57379
jeilinj		0979:0280	Sportscam DV15
zc3xx		0ac8:0302	Z-star Vimicro zc0302
vc032x		0ac8:0321	Vimicro generic vc0321
vc032x		0ac8:0323	Vimicro Vc0323
...

We will look at what we have put green on the left.

You must replace the XXXX with green in the following commands:

opkg update
opkg install kmod-video-gspca-XXXX

In our case, for the logitech camera we will put:

opkg update
opkg install kmod-video-gspca-zc3xx

and for Samsung:

opkg update
opkg install kmod-video-gspca-zc3xx

It just so happens that the two cameras use the same packages.

Once the packages are installed, we can connect the cameras and they will be recognized by the system.

To test if it has recognized them we can see if the device exists with the following command:

ls /dev/video0

if you return

/dev/video0

is that it has been recognized.

Otherwise we will restart the router with the webcam connected and we will put the command again

ls /dev/video0

Step 3. Install and configure mjpg-streamer.

With this application we can access the router with a browser and we can see the webcam in operation.

We will put the following in the console to install it:

opkg update; opkg install mjpg-streamer

From here we can find problems since it depends on the characteristics of the webcam which we have to put some parameters or others.

In the Samsung camera we tested it as follows:

mjpg_streamer -i "input_uvc.so -d /dev/video0" -o "output_http.so -w /www/webcam -port 8080"

With this instruction we are sending the output of the device / dev / video0 and that of service through the http protocol on port 8080 of our router.

We go to the browser and put the IP address of our router in the browser accessing port 8080.

http://192.168.1.1:8080

In case you use another ip you must put:

http: // <ip_del_router>: 8080

On the Logitech camera it works with the following:

mjpg_streamer -i "input_uvc.so -d /dev/video0  -r 640x472 -f 10" -o "output_http.so -w /www/webcam -port 8080"

By default it uses the resolution of 640 × 480 which the camera does not support. -R 640 × 472 has been added We can also put the number of frames per second that one wants it to emit. In this case we have put 10 frames per second with that addition of -f 10.

After a while of operation, the Logitech camera dims and darkens the image. Is it driver failure? Configuration failure? Camera failure? Could the router be saturated? In our case we have to investigate a little more why this failure occurs.

Step 4. Let it run automatically as soon as the router starts up.

We have tested that it works and now we will configure it to start as soon as we turn on the router.

We are going to use the nano as a text editor since vi can be a bit cumbersome for those who are not used to it.

We install nano:

opkg install nano

We access the mjpg_stramer service configuration and edit the configuration file:

nano / etc / config / mjpg-streamer

In the file we configure the necessary parameters for our camera.

In the case of the Samsung camera we will use the following configuration:

config mjpg-streamer 'core'
         option enabled '1' // always set to 1 to boot
        option input 'uvc'
        option output 'http'
        option device '/ dev / video0'
        option resolution '640x480' // resolution
        option yuv '0' // set to 1 if camera supports YUV color space
        option quality '100' // 100% image quality
        option fps '30' // frames per second
        option led 'auto' // 0,1, auto turns the webcam led on or off
        option www '/ www / webcam'
        option port '8080' // listening port
        option username 'openwrt' // login user
        option password 'openwrt' // access password

We have left you a username and password so that no one can access it.

In the case of the Logitech camera, we will lower the resolution with this configuration:

config mjpg-streamer 'core'
        option enabled '1'
        option input 'uvc'
        option output 'http'
        option device '/ dev / video0'
        option resolution '640x472'
        option yuv '0'
        option quality '100'
        option fps '30'
        option led 'auto'
        option www '/ www / webcam'
        option port '8080'
        option username 'openwrt'
        option password 'openwrt'

To save the document we will use the keys CTRL + O and then CTRL + X .

Once the configuration is saved, we will test if it works by starting the service with the following command:

/etc/init.d/mjpg-streamer start

We access the camera by putting in the browser

http: // <ip_del_router>: 8080

in our case

http://192.168.1.1:8080

If we see that it works, we can finish and leave the service activated at startup with the following command:

/etc/init.d/mjpg-streamer enable

Summary for more experienced people:

In openwrt console we install USB support:

 opkg update; opkg install usbutils kmod-usb2 kmod-usb-core kmod-usb-ohci kmod-usb-uhci

We find out the ID of the lsusb webcam

In case the identifier here:   Consult UVC supported cameras

La instalación será: opkg update; opkg install kmod-video-uvc 

In case the identifier here:   Check supported cameras GSPCA

The installation will be substituting XXXX:

opkg update; opkg install mod-video-gspca-XXXX

We test if it recognizes it with command, otherwise we restart and see if it has recognized it:

ls / dev / video0 We install mjpg-streamer:

opkg update; opkg install mjpg-streamer

We test the streaming with command:

mjpg_streamer -i "input_uvc.so -d /dev/video0" -o "output_http.so -w /www/webcam -port 8080" 

We edit the configuration file so that it starts as a service:

nano /etc/config/mjpg-streamer

We set the option enabled to 1 and configure parameters according to the camera model:

  config mjpg-streamer 'core'
        option enabled '1' //siempre poner a 1 para que arranque
        option input 'uvc'
         option output 'http'
         option device '/dev/video0'
         option resolution '640x480' //resolución
         option yuv '0' //poner a 1 si camara sporta espacio de color YUV
         option quality '100' // calidad de la imagen al 100%
         option fps '30' // frames por segundo
         option led 'auto' // 0,1,auto enciende o apaga el led de la webcam
         option www '/www/webcam'
         option port '8080' // puerto de escucha
         option username 'openwrt' //usuario de acceso
         option password 'openwrt' //password de acceso 

We start the service with:

/etc/init.d/mjpg-streamer start

and it will start the service when turning on the router like this:

/etc/init.d/mjpg-streamer enable 

Žádné komentáře:

Okomentovat

K vkládání komentáře se můžete přihlásit bez registrace pomocí OpenID na Seznam.cz