Raspberry Pi + surveillance camera

2023-11-04 09:38

本文主要是介绍Raspberry Pi + surveillance camera,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!


Raspberry Pi – Surveillance WebCam in the Cloud

Why ?
- Why Surveillance Camera: Well it’s fun to be in vacation and to check how the garden looks like, if a friend should be called and sent to wet the flowers, aso …
- Why Web Cam: Together with a Pi it’s flexible and very cheap compared with other solutions
- Why Cloud: I want to see my garden when I’m NOT at home. And I don’t want to open ports in my own firewall. Hence, if I cannot come IN to the content, I obviously have to put the content OUT.



--------------------------------------------------------------------------------------------------------------------------------------

Using the Raspberry Pi for camera surveillance using Motion and cloud storage


If you are looking for a cheap camera surveillance setup, the Raspberry Pi is a great solution.
It is small, easy to install and, most important, has low energy usage.
I own Model B (see the Raspberry Pi Wikipedia page for detail about the models) which uses 3.5 Watts.

There are several open source motion detection applications for Linux such as ZoneMinderand Motion.
Both programs are available through the Rasbian repository.
ZoneMinder looks like a real security control center with all those nice cam screens, but it’s too bloated and too CPU heavy for the Raspberry Pi.
Motion is more lightweight and doesn’t stress the CPU too much when processing 320×200 camera data.
With 2 IP camera’s my average load is less than 0.50 on my RasPi, which also serves as an caching DNS server.

For storage of the AVI video files which contain the captured motion frames, I use a free Box.com account.
Box.com provides the same service as the popular Dropbox.
The reason for choosing Box.com is because Dropbox has no open source client. The Dropbox Linux client is closed source and has, at the moment, no support for ARM devices like the Raspberry Pi.
Furthermore the free Box.com account gives you 5 GB of storage. Way enough to store home camera data for a couple of months.

BoxFS is the weapon of choice to mount your Box.com account as a drive partition on your Raspberry Pi.
Some basic Linux knowledge is preferred.

Setting up BoxFS

Read the Compiling page on the BoxFS site carefully :-)
From release 63 of BoxFS libapp is used for parsing config files. Be sure to compile and install this first.

When libapp is compiled and installed properly, install the rest of the BoxFS prerequisites:

sudo apt-get install subversion libxml2-dev libfuse-dev libcurl4-gnutls-dev libzip-dev

I recommend using the latest commit of BoxFS in the repository.
The latest release, version 0.7, does not support user/group id’s and file/directory permissions. The latest commit (>=release 63) does.

svn checkout http://boxfs.googlecode.com/svn/trunk/ boxfs-read-only

After checking out the BoxFS source code, go to the boxfs-read-only directory to compile and install BoxFS:

sudo make install

The BoxFS binary will be installed in /usr/local/bin.

Mounting your Box.com account using BoxFS

I found out that running BoxFS as root gives the best results. I tried running BoxFS as a non-root user and it gave me some curious and unpredictable results.

Create a configuration file (for example boxfs.cfg) first.
A valid configuration file looks like this:

#This is a comment line
username   = me@domain.com
password   = mystrongpass
mountpoint = /path/to/folder
# from version 0.6:
verbose    = yes
secure     = no
# from version 0.7:
largefiles = yes
# from commit r86
uid        = 1000
gid        = 1000
fperm      = 644
dperm      = 755

The mount point must be provided in either way.  This can be an empty directory called /motion for example.

To start the BoxFS client, simply run this command as root:

boxfs -f boxfs.cfg

To check if everything is doing what it should be doing, go to your BoxFS mount point and try to create or copy some files.
For debugging I recommend to be logged in to your Box.com account with your browser to see if things are actually written in to the cloud storage.

I noticed that the BoxFS partition doesn’t appear when you run the df command as a non-root user. When you run the df command as root (or something like sudo df), the BoxFS partition is shown.
Just keep that in mind.

Installing and configuring Motion

To install Motion just run this command:

sudo apt-get install motion

Be sure that your camera’s and/or webcams output a 320×200 (or 240) image and Motion is configured with the same resolution.
I’ve tried a resolution like 640×400 pixels, but the CPU load went sky high on the RasPi, so I’ve settled for a lower resolution.
The images generated by my camera’s are quite clear and useful, so I’m happy.
I have no experience over clocking the Pi in combination with Motion, but if you do, please share your findings in the comments.
Same goes for solving the above resolution problem :)

Further configuring Motion is something you have to do on your own.
The on line manual is quite clear about the numerous settings which can be done.
Mailing an image snapshot or a simple message when motion is detected is just one of the many possibilities.
Oh, and don’t forget to set the path to your BoxFS mount point to store your videos ;-)

When you’ve got an mobile device, you can use the Box.com app to download an AVI file and watch it using a movie player which supports the file format.
Great when you’re on holiday for example, and want to know what’s going on at home.
And all of this without tampering  your firewall, keeping your home network closed and secure.

I hope this post helps you to set up your own budget camera surveillance system.
For less than 180 euro (that’s 2 decent IP camera’s and a RasPi) you’re all set to go.


----------------------------------------------------------------------------

基于树莓派实现的开门君

开门君是一个基于树莓派(raspberry pi)实现可以通过手机开门的小项目,也许是为了方便搞基,总之他就是被设定成为开门君了。

第一问:为什么通过浏览器访问一个地址就能把门禁开了?请看以下简略的流程解释:

  • 1、浏览器向服务器端发送请求。

  • 2、树莓派接收到请求后控制GPIO输出高电平。

  • 3、高电平信号会让继电器模块吸合,相当于按下了门禁开关,于是开门。

第二问:树莓派是什么?树莓派起到了什么作用?


上图的电路板就是树莓派

树莓派是一款基于ARM的微型电脑主板,以SD卡为内存硬盘,卡片主板周围有两个USB接口和一个网口,可连接键盘、鼠标和网线,同时拥有视频模拟信号的电视输出接口和HDMI高清视频输出接口,以上部件全部整合在一张仅比信用卡稍大的主板上...

 

树莓派上面可以运行Raspbian,一个基于Debian为树莓派优化的Linux,这里树莓派就是一个Linux服务器.你可以在上面使用你熟悉的编程语言进行开发.

同时更方便的是树莓派带有8个GPIO接口,可以非常方便地用程序控制GPIO口输入或者输出高低电位来控制继电器开或者关.


python代码:

web.py是python下的一个小型web框架.

wiringpi是一个开源的GPIO控制库.

sesame模块是我基于wiringpi用来实现开关门的动作.

 

index.py

#yishanju 2013/02/27 18:07
#import web
import sesameurls = ("/","index",)
app =web.application(urls,globals())class index:def GET(self):sesame.k()return "Open sesame."if __name__ == '__main__':app.run()

 

sesame.py

#!/bin/env python
#coding=GB18030
#yishanju 2013/02/27import wiringpi
from time import sleeppin=6
t=1io=wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
io.pinMode(pin,io.OUTPUT)def Open ():io.digitalWrite(pin,io.HIGH)if io.digitalRead(pin):return 1def Close():io.digitalWrite(pin,io.LOW)return io.digitalRead(pin)def k():Open()sleep(t)Close()if __name__=='__main__':k()

 

 

硬件: 

树莓派 x1 约300元

继电器模块 (工作电压5V,高电平吸合,单刀双掷地) 5元

无线网卡 x1 约 50元

HDMI转DVI X1 约40元

SD卡 x1 约70元

万用表 x1

杜邦线 3根 用来连接树莓派与继电器

测试夹 方便测量测试用.

这个开门小项目的基础上还可以做得出什么?:

  • 增加身份验证

  • 加上声音接收模块,简单的可以实现声控开门,

  • 更难一些的通过接收声音二维码开门.

  • 加上摄像头,可以当监控用,也许可以实现人脸识别~

  • 加上指纹模块,可以自己来实现指纹识别..

  • 更NB也许还可以通过脚步声,步态进行身份识别呢?

  • 加上粉尘传感器,还可以兼职PM2.5检测器.其它什么温湿度压力依此类推.

 

 

 

收获:

在想如何实现开门君的过程当中也想明白了饮水机娘的一个实现方式.

做的过程里发现自己需要更深的知识和技术才能发挥出价值~~ T_T这种浮浅的水平根本做不好事情啊.

别的没什么,可是,电子学,Linux,python这些技能都用到了,放组合技能的感觉太爽了,哈哈.

 

其它:

针对树莓派GPIO这一块还有一些不明白的地方.争取弄明白后补上文章.

 

最后向web.py创始人Aaron Swartz致敬.

参考资料:

使用树莓派制作的远程开门器http://www.cnblogs.com/guanhe/archive/2012/12/25/2832982.html

wiringpi作者Gordon的博客https://projects.drogon.net/raspberry-pi/wiringpi/

WiringPi的github主页 https://github.com/WiringPi

树莓派外部接口详细说明

SPI、I2C接口的定义以及区别

用NodeJs来控制硬件(基于Raspberry Pi)(一)http://cnodejs.org/topic/509a960c637ffa41553bbd4c

 

让你们通过超链接跳转到外星球去吧!!:

DIY NB到极致的比尔•博鲁茨基: 送望远镜上天,去寻找外星行星!http://www.guokr.com/article/425871/

自制Arduino检测器,随时关注空气质量 http://www.guokr.com/article/434130/

用Siri语音打开车库门 树莓派发烧友新玩法http://iphone.tgbus.com/news/class/201212/20121225110024.shtml

电子点火器 http://www.guokr.com/article/436640/

揭开“饮水机娘”的神秘面纱 http://www.guokr.com/article/81621/  

扫地机器人也发微博,才是真正的微博时代http://www.guokr.com/article/49759/  



参考内容:


1. http://www.instructables.com/id/Pan-Tilt-face-tracking-with-the-raspberry-pi/?ALLSTEPS

Step 4: Connecting the servos


2. 

The Dark Pi Rises


To use it, let's install some required programs:

sudo apt-get install gstreamer-tools gstreamer0.10-plugins-bad gstreamer0.10-plugins-good v4l-utils

There are several ways to stream the webcam output to the network, but I settled on GStreamer because 1) I couldn't get VLC to work, 2) ffserver, motion and mjpeg consumed more CPU when I tried them. The following command gives me 10fps at 320x240, at only 25-30% CPU usage:

UPDATE: The Raspberry Pi Foundation has updated the firmware to enable H.264 encode on the GPU - I'll be working on getting this working as this could enable phenomenal improvement in the webcam streaming while using *less* CPU!

To open the Raspberry Pi's stream on your desktop, just fire up VLC and click 'File->Open Network Stream' and type in 'tcp://192.168.1.135:5000' in the location bar (replace the IP address with your Raspberry Pi's IP address!).

Now you should have 'live' streaming from your Raspberry Pi!




3. 

Object Tracking on the Raspberry Pi with C++, OpenCV, and cvBlob

Frame-rates on the Intel processor-based Ubuntu laptops easily performed at or beyond the maximum 30 fps rate of the webcams, at 640 x 480 pixels. On a positive note, the Raspberry Pi was able to compile and execute the tests of OpenCV and cvBlob (see bug noted at end of article). Unfortunately, at least in my tests, the Raspberry Pi could not achieve more than 1.5 – 2 fps at most, even in the most basic tests, and at a reduced capture size of 320 x 240 pixels. This can be seen in the first and second screen-grabs of Test #1, above. Although, I’m sure there are ways to improve the code and optimize the image capture, the results were much to slow to provide accurate, real-time data to the robot’s targeting system.

这篇关于Raspberry Pi + surveillance camera的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/344877

相关文章

4-4.Andorid Camera 之简化编码模板(获取摄像头 ID、选择最优预览尺寸)

一、Camera 简化思路 在 Camera 的开发中,其实我们通常只关注打开相机、图像预览和关闭相机,其他的步骤我们不应该花费太多的精力 为此,应该提供一个工具类,它有处理相机的一些基本工具方法,包括获取摄像头 ID、选择最优预览尺寸以及打印相机参数信息 二、Camera 工具类 CameraIdResult.java public class CameraIdResult {

使用Azure Devops Pipeline将Docker应用部署到你的Raspberry Pi上

文章目录 1. 添加树莓派到 Agent Pool1.1 添加pool1.2 添加agent 2. 将树莓派添加到 Deployment Pool2.1 添加pool2.2 添加target 3. 添加编译流水线3.1 添加编译命令3.2 配置触发器 4. 添加发布流水线4.1 添加命令行4.2 配置artifact和触发器 5. 完成 1. 添加树莓派到 Agent Pool

Banana Pi BPI-F3 进迭时空RISC-V架构下,AI融合算力及其软件栈实践

RISC-V架构下,AI融合算力及其软件栈实践 面对未来大模型(LLM)、AIGC等智能化浪潮的挑战,进迭时空在RISC-V方向全面布局,通过精心设计的RISC-V DSA架构以及软硬一体的优化策略,将全力为未来打造高效且易用的AI算力解决方案。目前,进迭时空已经取得了显著的进展,成功推出了第一个版本的智算核(带AI融合算力的智算CPU)以及配套的AI软件栈。 软件栈简介 AI算法部署旨

基于PI控制算法的异步感应电机转速控制系统simulink建模与仿真

目录 1.课题概述 2.系统仿真结果 3.核心程序与模型 4.系统原理简介 5.完整工程文件 1.课题概述        基于PI控制算法的异步感应电机转速控制系统simulink建模与仿真。PI控制器是一种经典的线性控制器,它通过将控制量的比例部分和积分部分相结合来实现对系统输出的调节。比例部分用于快速响应偏差,而积分部分则用于消除稳态误差。 2.系统仿真结果 (完整程

Banana Pi BPI-SM9 AI 计算模组采用算能科技BM1688芯片方案设计

产品概述 香蕉派 Banana Pi BPI-SM9 16-ENC-A3 深度学习计算模组搭载算能科技高集成度处理器 BM1688,功耗低、算力强、接口丰富、兼容性好。支持INT4/INT8/FP16/BF16/FP32混合精度计算,可支持 16 路高清视频实时分析,灵活应对图像、语音、自然语言等场景,可集成于智算服务器、边缘智算盒、工控机、无人机、AIOT等多种类型产品。 Banana

Android Camera系列(三):GLSurfaceView+Camera

人类的悲欢并不相通—鲁迅 Android Camera系列(一):SurfaceView+Camera Android Camera系列(二):TextureView+Camera Android Camera系列(三):GLSurfaceView+Camera 本系列主要讲述Android开发中Camera的相关操作、预览方式、视频录制等,项目结构代码耦合性低,旨在帮助大家能从

利用raspberry pi搭建typecho笔记(三) typecho nginx sqlite FAQ

前言 这是一个汇总文,用来总结我在整个配置过程中遇到的各种问题.因为我在解决这些问题的过程中发现,typecho被部署在这种需要完全自己配置的平台上的情况是比较少的,相关的资料也比较少,所以我的解决过程比较困难,因此在此之后,想把这些问题和解决方案都整理出来,如果有同样需要的人,可以直接参考,少走弯路.   1.typecho安装过程中提示"对不起,无法连接数据库,请先检查数据库配置再继续进行安

CameraManager——Camera的过时替代方法

CameraManager 用于检测,表征和连接的系统服务管理器 CameraDevices。 有关与相机设备通信的更多详细信息,请阅读相机开发人员指南或camera2 包文档。 此类的实例,必须使用能够获得Context.getSystemService(Class)与所述参数CameraManager.class或Context.getSystemService(String)使用参数Co

如何在 Raspberry Pi 5 上设置 Raspberry Pi AI Kit

本指南将帮助您在 Raspberry Pi 5 上安装 Raspberry Pi AI Kit。这将使您能够使用 Hailo AI 神经网络加速器运行 rpicam-apps 摄像头演示。 如果您在开始安装人工智能套件之前需要帮助,本指南提供了安装过程的分步图片。 安装人工智能套件:https://www.raspberrypi.com/documentation/accessorie

Android Camera系列(一):SurfaceView+Camera

心行慈善,何需努力看经—《西游记》 本系列主要讲述Android开发中Camera的相关操作、预览方式、视频录制等,项目结构代码耦合性低,旨在帮助大家能从中有所收获(方便copy :) ),对于个人来说也是一个总结的好机会 一. Camera操作 Android系统存在这么多年,google更新了不少API。光是对摄像头的操作目前就有3中API: android.hardware