树莓派和计算棒实现图形识别 RaspBerry Pi4 with OpenVino and Movidius
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了树莓派和计算棒实现图形识别 RaspBerry Pi4 with OpenVino and Movidius,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1829字,纯文字阅读大概需要3分钟。
内容图文
1 import cv2 as cv 2 import sys 3 import logging as log 4 5 # openvino_fd_myriad.py 6 filename =‘./‘ 7 8 log.basicConfig(format="[ %(levelname)s ] %(message)s", level=log.INFO, stream=sys.stdout) 910if len(sys.argv) > 1 : 11 filename = filename + sys.argv[1] 12else: 13 filename = filename + ‘Girls.jpg‘1415 log.info("Image is " + filename) 16# Load the model.17 net = cv.dnn.readNet(‘face-detection-adas-0001.xml‘,‘face-detection-adas-0001.bin‘) 1819# Specify target device.2021net.setPreferableTarget(cv.dnn.DNN_TARGET_MYRIAD) 2223 log.info("Inference model is face-detection-adas-0001") 24# Read an image.25 frame = cv.imread(filename) 2627if frame is None: 28raise Exception(‘Image not found!‘) 2930 log.info("Perform an inference " + filename) 31# Prepare input blob and perform an inference.32 blob = cv.dnn.blobFromImage(frame, size=(672, 384), ddepth=cv.CV_8U) 33net.setInput(blob) 34 out = net.forward() 3536 i = 0 37# Draw detected faces on the frame.38for detection in out.reshape(-1, 7): 39 confidence = float(detection[2]) 40 xmin = int(detection[3] * frame.shape[1]) 41 ymin = int(detection[4] * frame.shape[0]) 42 xmax = int(detection[5] * frame.shape[1]) 43 ymax = int(detection[6] * frame.shape[0]) 44if confidence > 0.5: 45 cv.rectangle(frame, (xmin, ymin), (xmax, ymax), color=(0, 255, 0), thickness=1) 46 cv.rectangle(frame, (xmin-1, ymin-1),(xmin+70, ymin-10), color=(0, 255, 0), thickness= -1) 47 i = i + 1 48 cv.putText(frame, ‘Human : ‘ + str(i) + ‘‘ + str(confidence) , (xmin, ymin -2), cv.FONT_HERSHEY_SIMPLEX, 0.3, (0,0,0), thickness=1) 4950# Save the frame to an image file.51 cv.imwrite(filename + ‘_out.png‘, frame) 52 log.info("Save the frame to an image file as png : " + filename)
原文:https://www.cnblogs.com/cloudrivers/p/11566934.html
内容总结
以上是互联网集市为您收集整理的树莓派和计算棒实现图形识别 RaspBerry Pi4 with OpenVino and Movidius全部内容,希望文章能够帮你解决树莓派和计算棒实现图形识别 RaspBerry Pi4 with OpenVino and Movidius所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。