tagetage 发表于 2020-9-13 12:15

【树莓派4B测评】树莓派4连接USB摄像头实现网络视频监控

<div class='showpostmsg'><p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span style="font-family:宋体">树莓派</span>4<span style="font-family:宋体">本身具有</span>USB<span style="font-family:宋体">接口,还具有千兆网口,</span>CPU<span style="font-family:宋体">的速度也很快,正好可以使用树莓派连接一个</span>USB<span style="font-family:宋体">的摄像头作为网络视频监控,可以查看家里的小孩或老人,或用作查看鱼缸,车位等。</span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span lang="EN-US" style="font-size:16.0pt"><span style="font-family:宋体">1</span></span><span style="font-size:16.0pt"><span style="font-family:宋体">,使用lsusb命令查看系统是否支持</span></span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span style="font-family:宋体">树莓派使用官方的系统,</span>USB<span style="font-family:宋体">摄像头我找的是几十年前的杂牌摄像头,使用</span>lsusb<span style="font-family:宋体">命令查看,系统还是支持这款摄像头的。</span></span></span></p>

<p style="text-align:justify"></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span lang="EN-US" style="font-size:16.0pt"><span style="font-family:宋体">2</span></span><span style="font-size:16.0pt"><span style="font-family:宋体">,具体查看</span></span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span style="font-family:宋体">使用命令查看是</span>video0</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif">ls /dev</span></span></p>

<p style="text-align:justify"></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span lang="EN-US" style="font-size:16.0pt"><span style="font-family:宋体">3</span></span><span style="font-size:16.0pt"><span style="font-family:宋体">,查看USB摄像头参数</span></span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span style="font-family:宋体">使用命令</span>(v4l2<span style="font-family:宋体">是字母的</span>l) v4l2-ctl -d&nbsp; /dev/video0 --all</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span style="font-family:宋体">可以看到我这款摄像头是</span>640*480<span style="font-family:宋体">分辨率</span></span></span></p>

<p style="text-align:justify"></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span lang="EN-US" style="font-size:16.0pt"><span style="font-family:宋体">4</span></span><span style="font-size:16.0pt"><span style="font-family:宋体">,安装motion</span></span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span style="font-family:宋体">使用命令行安装</span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif">sudo apt-get install motion</span></span></p>

<p style="text-align:justify"></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span lang="EN-US" style="font-size:16.0pt"><span style="font-family:宋体">5</span></span><span style="font-size:16.0pt"><span style="font-family:宋体">,修改配置文件</span></span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif">sudo nano /etc/motion/motion.conf</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span style="font-family:宋体">改为</span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif">width 640</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif">width 480</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif">webcontrol_localhost off</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif">stream_localhost off</span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span lang="EN-US" style="font-size:16.0pt"><span style="font-family:宋体">6</span></span><span style="font-size:16.0pt"><span style="font-family:宋体">,运行motion</span></span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span style="font-family:宋体">输入命令</span>sudo motion<span style="font-family:宋体">开始运行,</span>Ctrl+C<span style="font-family:宋体">退出。</span></span></span></p>

<p style="text-align:justify"></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span lang="EN-US" style="font-size:16.0pt"><span style="font-family:宋体">7</span></span><span style="font-size:16.0pt"><span style="font-family:宋体">,局域网web查看</span></span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span style="font-family:宋体">在</span>PC<span style="font-family:宋体">上输入树莓派的地址,单个摄像头查看端口为</span>8081<span style="font-family:宋体">,多个摄像头或配置端口为</span>8080</span></span></p>

<p style="text-align:justify"></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span lang="EN-US" style="font-size:16.0pt"><span style="font-family:宋体">8</span></span><span style="font-size:16.0pt"><span style="font-family:宋体">,外网(广域网)web查看</span></span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span style="font-family:宋体">需要公网</span>IP<span style="font-family:宋体">,需要设置</span>DDNS<span style="font-family:宋体">,还需要在路由器里做设置,有两个方法做设置,一个是将树莓派的</span>IP<span style="font-family:宋体">地址设成</span>dmz<span style="font-family:宋体">主机,另一个是将树莓派的</span>IP<span style="font-family:宋体">地址做端口映射。这里就不详细说明了。</span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>
</div><script>                                        var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;"   style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
                                       
                                        if(parseInt(discuz_uid)==0){
                                                                                                (function($){
                                                        var postHeight = getTextHeight(400);
                                                        $(".showpostmsg").html($(".showpostmsg").html());
                                                        $(".showpostmsg").after(loginstr);
                                                        $(".showpostmsg").css({height:postHeight,overflow:"hidden"});
                                                })(jQuery);
                                        }                </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script>
页: [1]
查看完整版本: 【树莓派4B测评】树莓派4连接USB摄像头实现网络视频监控