您的位置:首页 > 运维架构

树莓派 B+ Yeelink实现图像监控

2014-09-06 12:46 288 查看


树莓派 B+ Yeelink实现图像监控

数值传感器请参考 : http://blog.csdn.net/xiabodan/article/details/39084877

1 安装摄像头

首先需要一个网络摄像头,免驱,插上我们可以在查看是否有/dev/video0 ,

root@raspberrypi:/workplace# ls -l /dev/video0

crw-rw---T+ 1 root video 81, 0 Sep 6 03:37 /dev/video0

安装摄像头抓图软件

sudo apt-get install fswebcam

2 安装opencv

apt-get update
apt-get install libopencv-dev   python-opencv


在 python下测试 import cv 看能否成功

3 向YEELINK POST 单幅图片

http_post.py

def http_picture(url_api_key, pic):
"""
POST a message to yeelink
example:
url_api=("http://api.yeelink.net/v1.0/device/13985/sensor/23188/datapoints","d288d8257ffa56286cbd251610958aab")
pic =
http_post(url_api,pic
"""
apiurl = url_api_key[0]
apiheaders = {'U-ApiKey': url_api_key[1], 'content-type': 'application/json'}
try:
r = requests.post(apiurl, headers=apiheaders, data=pic)
except:
pass
return None

4 captrue image -- 基于opencv(不是python测试用)

int main( int argc, char** argv )
{
printf("I am start \n");
VideoCapture cap(0); // open the default camera
if(!cap.isOpened())  // check if we succeeded
return -1;

printf("11111%f, %f\n",cap.get(CV_CAP_PROP_FRAME_WIDTH),cap.get(CV_CAP_PROP_FRAME_HEIGHT));
cap.set(CV_CAP_PROP_FRAME_WIDTH, 640);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
cap.set(CV_CAP_PROP_FPS, 15);
printf("22222%f, %f\n",cap.get(CV_CAP_PROP_FRAME_WIDTH),cap.get(CV_CAP_PROP_FRAME_HEIGHT));
Mat src_gray;
//      cvNamedWindow( "video", CV_WINDOW_AUTOSIZE );
//      while(1)
{
Mat frame;
cvWaitKey(50);
cap >> frame;
 printf("begin save pic\n");
                imwrite("原图.jpg", frame);
                printf("Save Image Successful\n");
                //imshow("video", frame);
        }
        return 0;
}

5 python下抓取图片POST到YEELINK



参考

树莓派玩家5分钟内将树莓派-USB摄像头与Yeelink连接–最好玩的网页监控器 : http://blog.yeelink.net/?p=468
树莓派+Yeelink实现图像监控 :http://stayrunning.blog.163.com/blog/static/1967580022013222105948256/

红外感应模块+蜂鸣器实现简易报警 : http://shumeipai.nxez.com/2014/08/31/infrared-sensor-module-and-buzzer-alarm-achieve.html
Ubuntu下Opencv与Python的协作 :http://pinkyjie.com/2010/10/19/ubuntu-opencv-python/


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