11187| 6
|
[讨论交流] 【树莓派】人脸追踪(1)树莓派+百度人脸识别 |
1、树莓派 VNC Viewer 远程桌面配置教程 http://shumeipai.nxez.com/2018/08/31/raspberry-pi-vnc-viewer-configuration-tutorial.html 需要在目录下添加ssh空白文件以开启SSH功能 使用 ipscan22.exe软件,扫描局域网内ip地址,获取树莓派IP(最好能进路由器查看)树莓派无法连接vnc,树莓派 vnc viewer 显示 cannot currently show the desktop 的解决方法 树莓派中如何让自己的py程序自己启动 2、新手教程:如何 SSH 进入树莓派 https://linux.cn/article-10888-1.html?pr 3、3.5英寸树莓派触摸屏 https://wiki.dfrobot.com.cn/index.php?title=(SKU:DFR0428)3.5%22_TFT_Touchscreen_for_Raspberry_Pi 4.镜像烧录工具 开始之前的注意事项: Pi的不同版本可能会有所不同!在将任何东西连接到板上之前,请确保您使用的是正确的。一种快速的检查方法是在Raspberry Pi的终端中键入 pinout ,这将弹出您当前的设置图。 进入 LCD-show 目录 cd /home/pi/LCD-show ls sudo ./LCD35-show 切换回 HDMI 显示 cd /home/pi/LCD-show/ sudo ./LCD-hdmi 用户名密码是pi/raspberry 1、网速贼慢,需要进行更换树莓派软件源,包括系统源与系统更新源,操作方法: # 编辑 `/etc/apt/sources.list` 文件,原文件所有内容,用以下内容取代: deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib # 编辑 `/etc/apt/sources.list.d/raspi.list` 文件,原文件所有内容,用以下内容取代: deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui 2、因修改文件权限不够 修改文件权限https://blog.csdn.net/jiangsujiangjiang/article/details/80311018 4、树莓派系统换国内源 https://www.cnblogs.com/xiangzhuo/p/9431502.html 5、树莓派python3导入cv2 https://blog.csdn.net/Hankerchen/article/details/103510024(正在安装中……) 6、子豪兄教你在树莓派上安装OpenCV https://www.jianshu.com/p/56929416b4a1 用的还是python2.7 +Opencv [mw_shl_code=python,true]from picamera import PiCamera from time import sleep import base64,cv2 import json """camera.start_preview()""" """sleep(40)""" """camera.stop_preview()""" from aip import AipFace import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) pan = 27 tilt = 17 GPIO.setup(tilt, GPIO.OUT) # white => TILT GPIO.setup(pan, GPIO.OUT) # gray ==> PAN def setServoAngle(servo, angle): assert angle >=5 and angle <= 175 pwm = GPIO.PWM(servo, 50) pwm.start(8) dutyCycle = angle / 18. + 3. pwm.ChangeDutyCycle(dutyCycle) sleep(0.1) pwm.stop() camera=PiCamera() """ APPID AK SK """ APP_ID = '15554766' API_KEY = 'FVnVC1EiWLdgoZIXe5GByBP3' SECRET_KEY = 'EteHK89dvmcDefKstYsWf9DairVf9Eox' client = AipFace(APP_ID, API_KEY, SECRET_KEY) AngleX=90 AngleY=90 setServoAngle(tilt, AngleX) setServoAngle(pan, AngleY) while True: camera.start_preview() camera.capture('/home/pi/Desktop/image.jpg') filePath ="/home/pi/Desktop/image.jpg" img = cv2.imread(filePath,1) sleep(0.02) with open(filePath,"rb") as f: base64_data = base64.b64encode(f.read()) #image = str(base64_data,'utf-8') #python3 image = base64_data imageType = "BASE64" """ """ options = {} options["face_field"] = "age,beauty" options["max_face_num"] = 1 options["face_type"] = "LIVE" """ """ result = client.detect(image, imageType, options) #result=json.loads(result) if(result['error_msg'] in "SUCCESS"): #print(result['result']['face_list'][0]['location']['left']) #print(result['result']['face_list'][0]['location']['width']) x=result['result']['face_list'][0]['location']['left']+result['result']['face_list'][0]['location']['width']/2 y=result['result']['face_list'][0]['location']['top']+result['result']['face_list'][0]['location']['height']/2 x=int(x) y=int(y) print(x) print(y) center = (x, y) # if(x>420): AngleX-=8 if(x<380): AngleX+=8 if(AngleX>140): AngleX=140 if(AngleX<30): AngleX=30 if(y>260): AngleY-=10 if(x<220): AngleY+=10 if(AngleY>140): AngleY=140 if(AngleY<30): AngleY=30 setServoAngle(tilt, AngleX) setServoAngle(pan, AngleY) cv2.circle(img, center, radius=100, color=(0,0,255)) # cv2.imshow('imshow',img) key = cv2.waitKey(30) & 0xff if(key == 27): break print(result['error_msg']) camera.stop_preview() cv2.destroyAllWindows() [/mw_shl_code] |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed