NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple webcam on LinuxRT - vlc, mjpg-streamer, ?

Solved!
Go to solution

I am using a SOM (-9651), so arm7, LV LinuxRT 2014.  I would like to connect a usb camera and have the image appear via a web page.  I think mjpg-streamer or VLC will do that for me, but I can't find a repository where I can install either.  Can someone point me to a repo?  /dev/v4l and /dev/video0 appear when I plug the camera in, so I think the kernel has what I need.  Other suggestions are welcome, if there is a simpler way.  All we need is remote eyes on our process; no storage or processing.  Thanks.

Matt

0 Kudos
Message 1 of 7
(6,301 Views)

If you use NI-IMAQdx, it can natively capture from UVC webcams (which your camera appears to be if it shows up associated with the V4L support in the stock kernel).

You'd still have to do a bit of work (but it could be done in LabVIEW) if you wanted the image to be available via a webpage. I'd probably just make a web service that when run, acquires one image and returns it in a JPEG string. Then your web page could just refer to this web service's URL for the image.

Eric

Message 2 of 7
(5,013 Views)

Thanks Eric, I'll think about that approach.  I was trying to avoid bringing the image through LV, mostly because I don't need to bring it in and the tools are available in Linux to do what I want, I just can't figure out how to install them.  This will definitely be my fall back plan, though.

Matt

0 Kudos
Message 3 of 7
(5,013 Views)

You have a couple of options:

  1. Find an opkg feed to add to you target for the same architecture and install the tools through that
  2. Configure a machine to be able to build images and packages through https://github.com/ni/nilrt
  3. Make a recommendation on https://decibel.ni.com/content/polls/23759

I would personally do #2 but I'd recommend if you don't forsee the need to build a ton of packages, go with #1. In either case, do #3 to express your interest.

Message 4 of 7
(5,013 Views)
Solution
Accepted by topic author Matthew_Williams

Hi Brad.  Thanks.  I started down the cross-compile route but decided to go native.  My notes on what worked in case anyone else wants to do this, YMMV.  Using a $20 Logitech webcam from the junk drawer, now streaming nicely. 

Matt

Notes:

*2015.04.10 MRW notes on getting webcam stream running on -9651 SOM

*comments lines start with *

*confirm you get something like this in /var/log/messages:

*Apr 10 13:40:35 NI-sbRIO-9651-03074ebe kernel: [1808897.066695] usb 1-1.4: new high-speed USB device number 8 using xusbps-ehci

*Apr 10 13:40:36 NI-sbRIO-9651-03074ebe kernel: [1808897.415439] uvcvideo: Found UVC 1.00 device <unnamed> (046d:081b)

*Apr 10 13:40:36 NI-sbRIO-9651-03074ebe kernel: [1808897.531311] input: UVC Camera (046d:081b) as /devices/amba.0/e0003000.usb/xusbps-ehci.1/usb1/1-1/1-1.4/1-1.4:1.0/input/input3

*when you plug in your usb camera, specifically the 'UVC' part

ssh to SOM

opkg install packagegroup-core-buildessential

opkg install subversion

opkg install libjpeg-dev

opkg install coreutils

svn co https://svn.code.sf.net/p/mjpg-streamer/code/mjpg-streamer mjpg-streamer

*note mixed use of '-' and '_' in the following between mjpg and streamer

cd mjpg-streamer

make

make install

*this will install the following:

*install --mode=755 mjpg_streamer /usr/local/bin

*install --mode=644 input_uvc.so output_file.so output_udp.so output_http.so input_testpicture.so input_file.so /usr/*local/lib/

*install --mode=755 -d /usr/local/www

*install --mode=644 -D www/* /usr/local/www

*these are the files to be included in the deployment image

*edit /etc/config/mjpg_streamer

*config mjpg-streamer core

*        option device           "/dev/video0"

*        option resolution    "640x480"

*        option fps              "5"

*        option port             "58081"

*        option enabled          "true"

export LD_LIBRARY_PATH=/usr/local/lib

mjpg_streamer -i "input_uvc.so -d /dev/video0" -o "output_http.so -p 58081"

*from a browser on the network

http://192.168.11.81:58081/?action=stream

*cleanup - TBD; start with just 'opkg remove all_of_the_above'

Message 5 of 7
(5,013 Views)

Sounds good! Somehow I forgot to mention that one.

Is there already a /etc/ld.so.conf.d/local_libs.conf file? If so, you can fix the need to export LD_LIBRARY_PATH by simply re-running ldconfig.

0 Kudos
Message 6 of 7
(5,013 Views)

There is an /etc/ld.so.conf.d/local_libs.conf file; thanks for the tip.

Matt

0 Kudos
Message 7 of 7
(5,013 Views)