您的位置:首页 > 理论基础 > 计算机网络

【SOCLAB】网络摄像头的使用

2013-12-20 15:57 295 查看
网络摄像头的使用是基于mjpg-streamer-mini2440-bin-r6的,用的比较简单,下载地址:https://code.google.com/p/mjpg-streamer-mini2440/

因为我们只用拍照的功能,所以这里我只说下拍照的方法,把压缩包解压后,里面有这么几个文件:



图1
把这些文件放到arm开发板上:
[root@FriendlyARM usbcamera]# pwd
/apps/usbcamera
[root@FriendlyARM usbcamera]# ls
LICENSE               mjpg_streamer         start_uvc.sh
input_s3c2410.so      output_file.so        start_uvc_yuv.sh
input_testpicture.so  output_http.so
input_uvc.so          start_s3c2410.sh
www文件我一般喜欢放在主目录下面,你们放哪都行,不过配置的时候要注意下,我们主要看start_uvc.sh
[root@FriendlyARM usbcamera]# cat start_uvc.sh 
#!/bin/sh

#/******************************************************************************
#                                                                              #
#      MJPG-streamer allows to stream JPG frames from an input-plugin          #
#      to several output plugins                                               #
#                                                                              #
#      Copyright (C) 2007 Tom St枚veken                                         #
#                                                                              #
# This program is free software; you can redistribute it and/or modify         #
# it under the terms of the GNU General Public License as published by         #
# the Free Software Foundation; version 2 of the License.                      #
#                                                                              #
# This program is distributed in the hope that it will be useful,              #
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
# GNU General Public License for more details.                                 #
#                                                                              #
# You should have received a copy of the GNU General Public License            #
# along with this program; if not, write to the Free Software                  #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA    #
#                                                                              #
#******************************************************************************/

## This example shows how to invoke mjpg-streamer from the command line
NOWPATH=/apps/usbcamera
export LD_LIBRARY_PATH=$NOWPATH
#./mjpg_streamer -o "output_http.so -w ./www" -i "input_s3c2410.so"

#./mjpg_streamer -o "output_http.so -w ./www" -i "input_uvc.so "
$NOWPATH/mjpg_streamer -o "output_http.so -w /www -p 88" -i "input_uvc.so -r 640x480" &

## pwd echos the current path you are working at,
## the backticks open a subshell to execute the command pwd first
## the exported variable name configures ldopen() to search a certain
## folder for *.so modules
#export LD_LIBRARY_PATH=`pwd`

## this is the minimum command line to start mjpg-streamer with webpages
## for the input-plugin default parameters are used
#./mjpg_streamer -o "output_http.so -w `pwd`/www"

## to query help for the core:
# ./mjpg_streamer --help

## to query help for the input-plugin "input_uvc.so":
# ./mjpg_streamer --input "input_uvc.so --help"

## to query help for the output-plugin "output_file.so":
# ./mjpg_streamer --output "output_file.so --help"

## to query help for the output-plugin "output_http.so":
# ./mjpg_streamer --output "output_http.so --help"

## to specify a certain device, framerage and resolution for the input plugin:
# ./mjpg_streamer -i "input_uvc.so -d /dev/video2 -r 320x240 -f 10"

## to start both, the http-output-plugin and write to files every 15 second:
# mkdir pics
# ./mjpg_streamer -o "output_http.so -w `pwd`/www" -o "output_file.so -f pics -d 15000"

## to protect the webserver with a username and password (!! can easily get sniffed and decoded, it is just base64 encoded !!)
# ./mjpg-streamer -o "output_http.so -w ./www -c UsErNaMe:SeCrEt"

## If you want to track down errors, use this simple testpicture plugin as input source.
## to use the testpicture input plugin instead of a webcam or folder:
# ./mjpg_streamer -i "./input_testpicture.so -r 320x240 -d 500" -o "./output_http.so -w www"
别看他这么多,我们其实用的只有一句:
$NOWPATH/mjpg_streamer -o "output_http.so -w /www -p 88" -i "input_uvc.so -r 640x480" &


其他的都是注释,刚刚说道www放的位置问题,/www大家应该知道这是放在主目录下吧?如果你想放到别的地方,你在这里改下就可以了,88代表的是PORT,端口。
就这么多,使用的时候非常方便:
[root@FriendlyARM /apps]# /bin/sh /apps/usbcamera/start_uvc.sh
 MJPG Streamer Version.: 2.0
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 5
 i: Format............: MJPEG
ERROR opening V4L interface: No such file or directory
 Init v4L2 failed !! exit fatal 
 i: init_VideoIn failed


由于我今天没有找到摄像头,所以,就没有插上去。可能有的摄像头我们不支持,如果想要支持的话,需要在kernel里面选择。
这样把服务器启动起来了,我们就可以下载图片,或者录像了
wget http://127.0.0.1:8080/?action=snapshot -O new.jpg


OK,就这么多!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: