2 Star 13 Fork 4

Assassin/树莓派 YOLO 检测

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
threading_camera.py 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
Assassin 提交于 2020-12-17 20:11 . add file
from main_yolov3 import *
import requests
import time
import threading
# url = "http://192.168.0.100:8081"
# 打开网络摄像头
# cap = cv2.VideoCapture(url)
# cap = cv.VideoCapture("http://127.0.0.1:8080/?action=stream")
# cap = cv.VideoCapture("http://127.0.0.1:8080/?action=stream")
cap = cv.VideoCapture('xbd.mp4')
# 创建可以调节大小的窗口
# cv.namedWindow("video",0)
# cap = cv.VideoCapture(0)
# cap.set(cv.CAP_PROP_BUFFERSIZE, 3)
cap.set(cv.CAP_PROP_FPS, 60)
# cap.set(3, 320)
# cap.set(4, 320)
def get(url):
header = {'Content-Type':'application/json'}
response = requests.get(url,header)
return response.json()
RTip = True
def read_frame():
global frame, RTip, cap
while RTip:
_, frame = cap.read()
th1 = threading.Thread(target=read_frame, name='Thread_1')
th1.start()
time.sleep(3)
while(1):
global frame
net = cv.dnn.readNetFromDarknet(modelConfiguration, modelWeights)
net.setPreferableBackend(cv.dnn.DNN_BACKEND_OPENCV)
net.setPreferableTarget(cv.dnn.DNN_TARGET_CPU)
blob = cv.dnn.blobFromImage(frame, 1/255.0, (inpWidth, inpHeight), [0, 0, 0], swapRB=False, crop=False)
net.setInput(blob)
outs = net.forward(getOutputsNames(net))
postprocess(frame, outs)
t, _ = net.getPerfProfile()
label = 'Inference time: %.2f ms' % (t * 1000.0 / cv.getTickFrequency())
cv.putText(frame, label, (0, 15), cv.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255))
cv.imshow("video",frame)
if (cv.waitKey(1) & 0xFF == ord('q') ):
break
cap.release()
cv.destroyAllWindows()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hardychenlong/raspberry-pie4b-yolo-detection.git
git@gitee.com:hardychenlong/raspberry-pie4b-yolo-detection.git
hardychenlong
raspberry-pie4b-yolo-detection
树莓派 YOLO 检测
master

搜索帮助