基于yolov5和AidLux平台的目标检测 对街道人数统计
文章目录
为什么使用aidlux(aidlux官网)
- 基于ARM架构的跨生态(Android/鸿蒙+Linux)一站式AIoT应用开发和部署平台
创新性的Android/鸿蒙+Linux融合架构与AI工具链,构建下一代AIoT解决方案,服务开发者探索新未来。
使用方便,功能强大 vscode联调等。
提示:以下是本篇文章正文内容,下面案例可供参考
一、在连接上Aidlux的情况下开发
使用vscode在ssh连接上 将文件导入home下
二、使用教程
1.打开手机下载 Aidlux
2.
2.打开后找到
3.在浏览器输入 端口 进入界面输入默认密码aidlux
4.出现问题配置参数
(1) 小米手机和平板设置教程:
(2)OPPO 手机与平板设置教程:
(3)vivo 手机与平板设置教程:
(4)华为鸿蒙/HarmonyOS 2.0 设置教程:
(5)华为鸿蒙/HarmonyOS 3.0 设置教程:
5.运行代码需要python和opencv
6.安装Remote SSH
(1) 点击Vscode左侧的“Extensions”,输入“Remote”,针对跳出的Remote SSH,点击安装。
(2) 点击"Remote Explorer" ,进行远程连接的页面,点击左下角的 “Open a Remote Window”,再选择 “Open SSH Configuration file” 针对跳出的弹窗,再选择第一个config .
7.界面选择链接按钮 选linux 密码aidlux 当左下角跳出SSH Aidlux时,表示已经连接成功。
8.本次需要的文件 请在aidlux公众号 输入lesson5获取
9.下载后上传到aidlux平台home下即可链接 ssh休要修改的地请观看代码
三、使用步骤
1.写utils
代码如下(示例):
import time
import cv2
import numpy as np
coco_class = ['person']
def xywh2xyxy(x):
'''
Box (center x, center y, width, height) to (x1, y1, x2, y2)
'''
y = np.copy(x)
y[:, 0] = x[:, 0] - x[:, 2] / 2 # top left x
y[:, 1] = x[:, 1] - x[:, 3] / 2 # top left y
y[:, 2] = x[:, 0] + x[:, 2] / 2 # bottom right x
y[:, 3] = x[:, 1] + x[:, 3] / 2 # bottom right y
return y
def xyxy2xywh(box):
'''
Box (left_top x, left_top y, right_bottom x, right_bottom y) to (left_top x, left_top y, width, height)
'''
box[:, 2:] = box[:, 2:] - box[:, :2]
return box
def NMS(dets, thresh):
'''
单类NMS算法
dets.shape = (N, 5), (left_top x, left_top y, right_bottom x, right_bottom y, Scores)
'''
x1 = dets[:,0]
y1 = dets[:,1]
x2 = dets[:,2]
y2 = dets[:,3]
areas = (y2-y1+1) * (x2-x1+1)
scores = dets[:,4]
keep = []
index = scores.argsort()[::-1]
while index.size >0:
i = index[0] # every time the first is the biggst, and add it directly
keep.append(i)
x11 = np.maximum(x1[i], x1[index[1:]]) # calculate the points of overlap
y11 = np.maximum(y1[i], y1[index[1:]])
x22 = np.minimum(x2[i], x2[index[1:]])
y22 = np.minimum(y2[i], y2[index[1:]])
w = np.maximum(0, x22-x11+1) # the weights of overlap
h = np.maximum(0, y22-y11+1) # the height of overlap
overlaps = w*h
ious = overlaps / (areas[i]+areas[index[1:]] - overlaps)
idx = np.where(ious<=thresh)[0]
index = index[idx+1] # because index start from 1
return dets[keep]
def letterbox(img, new_shape=(640, 640), color=(114, 114, 114), auto=True, scaleFill=False, scaleup=True, stride=32):
# Resize and pad image while meeting stride-multiple constraints
shape = img.shape[:2] # current shape [height, width]
if isinstance(new_shape, int):
new_shape = (new_shape, new_shape)</