当前位置:   article > 正文

【openvino+树莓派】实现实时摄像头人脸检测_openpose部署树莓派

openpose部署树莓派

目录

参考步骤 

人脸检测py代码 

图片形式

摄像头实时

树莓派+openvino 人脸检测实时效果

openvino 树莓派 人脸实时检测测试效果_哔哩哔哩_bilibili 


参考步骤 

  • Openvino:安装、部署。(可参考以下文档,验证不建议参考)

树莓派+神经计算棒2部署Openvino的human_pose_estimation_demo实例_hwxhxyz1998403的博客-CSDN博客_openpose 树莓派

树莓派4B使用OpenVINO部署人体关键点检测模型Demo (视频中使用的文件在介绍里下载)_哔哩哔哩_bilibili

安装包链接:https://pan.baidu.com/s/1g-pCfJY0wkwTCclqOCKOng 
提取码:48z7

参考到此部分

  

人脸检测py代码 

图片形式

  1. #coding=utf-8
  2. import cv2 as cv
  3. # Load the model.
  4. net = cv.dnn.readNet('face-detection-adas-0001.xml',
  5. 'face-detection-adas-0001.bin')
  6. # Specify target device.
  7. net.setPreferableTarget(cv.dnn.DNN_TARGET_MYRIAD)
  8. # Read an image.
  9. frame = cv.imread('/home/pi/Downloads/inference_engine_vpu_arm/deployment_tools/inference_engine/samples/cpp/build/1.jpeg')
  10. if frame is None:
  11. raise Exception('Image not found!')
  12. # Prepare input blob and perform an inference.
  13. blob = cv.dnn.blobFromImage(frame, size=(672, 384), ddepth=cv.CV_8U)
  14. net.setInput(blob)
  15. out = net.forward()
  16. # Draw detected faces on the frame.
  17. for detection in out.reshape(-1, 7):
  18. confidence = float(detection[2])
  19. xmin = int(detection[3] * frame.shape[1])
  20. ymin = int(detection[4] * frame.shape[0])
  21. xmax = int(detection[5] * frame.shape[1])
  22. ymax = int(detection[6] * frame.shape[0])
  23. if confidence > 0.5:
  24. cv.rectangle(frame, (xmin, ymin), (xmax, ymax), color=(0, 255, 0))
  25. # Save the frame to an image file.
  26. cv.imwrite('out111.png', frame)

摄像头实时

  1. #coding=utf-8
  2. import cv2 as cv
  3. import numpy as np
  4. print("start!")
  5. # Load the model.
  6. net = cv.dnn.readNet('face-detection-adas-0001.xml',
  7. 'face-detection-adas-0001.bin')
  8. # Specify target device.
  9. net.setPreferableTarget(cv.dnn.DNN_TARGET_MYRIAD)
  10. # Read an image.
  11. #frame = cv.imread('/home/pi/Downloads/inference_engine_vpu_arm/deployment_tools/inference_engine/samples/cpp/build/1.jpeg')
  12. #
  13. cap = cv.VideoCapture(0)
  14. while(1):
  15. ret, frame = cap.read()
  16. frame = cv.resize(frame,(480,320),interpolation=cv.INTER_CUBIC)
  17. # Prepare input blob and perform an inference.
  18. blob = cv.dnn.blobFromImage(frame, size=(672, 384), ddepth=cv.CV_8U)
  19. net.setInput(blob)
  20. out = net.forward()
  21. # Draw detected faces on the frame.
  22. for detection in out.reshape(-1, 7):
  23. confidence = float(detection[2])
  24. xmin = int(detection[3] * frame.shape[1])
  25. ymin = int(detection[4] * frame.shape[0])
  26. xmax = int(detection[5] * frame.shape[1])
  27. ymax = int(detection[6] * frame.shape[0])
  28. if confidence > 0.5:
  29. cv.rectangle(frame, (xmin, ymin), (xmax, ymax), color=(0, 255, 0))
  30. cv.imshow('capture',frame)
  31. if cv.waitKey(1) &0xFF==ord('q'):
  32. # Save the frame to an image file.
  33. cv.imwrite('out111.png', frame)
  34. print('save done')
  35. cap.release()
  36. cv.destroyAllWindows()

树莓派+openvino 人脸检测实时效果

openvino 树莓派 人脸实时检测测试效果_哔哩哔哩_bilibili

问题小记录(其中涉及到一些我的机器人的具体问题,仅作为自己复习用)

  1.  手机要开启定位才能进入局域网连接,误操作长按KEY1进入直连模式再次尝试。
  2. 问题:cmake编译问题,重新换了一个终端可以了。
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/59558
推荐阅读
相关标签
  

闽ICP备14008679号