【DragonBoard 410c 试用体验】人脸识别上传到Yeelink

为了在手机上实现对家庭的监控,首先需要将本地数据传到云端服务器,然后再在手机设备上获取信息。今天我们来完成前一部分的内容。

在线看效果如下:http://www.yeelink.net/devices/344726

首先安装curl:
sudo apt-get install curl
vim yeelink.sh
sudo fswebcam -d /dev/video1 -r 1024x720 --bottom-banner --title "DragonBoard@ Yeelink" --no-timestamp ~/Desktop/yeelink.jpg

ApiKey还有地址都可以在Yeelink上找到。

为脚本增加执行权限:
chmod +x yeelink.sh


至此,一个基本雏形就有了,现在加上上一帖的识别,进行一个人脸识别判断即可。

下面给出代码:
import os
from PIL import Image, ImageDraw
import cv
import shutil

def detect_object(image):
grayscale = cv.CreateImage((image.width, image.height), 8, 1)
cv.CvtColor(image, grayscale, cv.CV_BGR2GRAY)

cascade = cv.Load("~/Desktop/a.xml")
rect = cv.HaarDetectObjects(grayscale, cascade, cv.CreateMemStorage(), 1.1, 2,
cv.CV_HAAR_DO_CANNY_PRUNING, (20,20))

result = []
for r in rect:
result.append((r[0][0], r[0][1], r[0][0]+r[0][2], r[0][1]+r[0][3]))

return result

def process(infile):
image = cv.LoadImage(infile);
if image:
faces = detect_object(image)

im = Image.open(infile)
path = os.path.abspath(infile)
save_path = os.path.splitext(path)[0]+"_face"
if os.path.isdir(save_path):
shutil.rmtree(save_path)
try:
os.mkdir(save_path)
except:
pass
if faces:
draw = ImageDraw.Draw(im)
count = 0
for f in faces:
count += 1
draw.rectangle(f, outline=(255, 0, 0))
a = im.crop(f)
file_name = os.path.join(save_path,str(count)+".jpg")
# print file_name
a.save(file_name)

drow_save_path = os.path.join(save_path,"out.jpg")
im.save(drow_save_path, "JPEG", quality=80)
else:
print "Error: cannot detect faces on %s" % infile

if __name__ == "__main__":
process("yeelink.jpg")

#!/bin/sh

sudo fswebcam -d /dev/video1 ~/Desktop/yeelink.jpg --bottom-banner --title "DragonBoard@wenjie" --no-timestamp -r 1280x720

python identify_face.py

if [ -f "~/Desktop/yeelink_face/out.jpg" ];then
curl --request POST --data-binary @"/home/fa/yeelink_face/out.jpg" --header "U-ApiKey:818c7d66df46c26d610e6a4a37ebda12" http://api.yeelink.net/v1.0/device/344726/sensor/383332/photos
fi

看一下效果:



好了,下一节看看怎么在android上取回本地~
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值