查看了app文件夹下,从01-07一共七个案例文件夹,分别是 01-基础图片分类,到图片分割,USB摄像头以及MIPI Camera 案例以及Yolov3和Yolov5检测模型

利用SSH连接,在VScode上远程开发(这里其实不用管很多,主要自己板子ip和主机PC连接一个网络,SSH 连接ip地址也写这个,连接就很简单)

由于我的目录只有home/sunrise,无法直接查看/app文件下图片,所以我把app文件夹copy了一份到、home/sunrise目录下,我觉得这个方法不错

sunrise@ubuntu:/$ ls
app  bin  boot  dev  etc  home  lib  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tftpboot  tmp  userdata  usr  var
sunrise@ubuntu:/$ sudo cp -r app/ /home/sunrise/

1.图像分割算法

由于我们是对板子性能进行分析,所以这里不对代码进行过多解释,只展示了代码

from hobot_dnn import pyeasy_dnn
import numpy as np
import cv2
from PIL import Image
from matplotlib import pyplot as pltdef bgr2nv12_opencv(image):height, width = image.shape[0], image.shape[1]area = height * widthyuv420p = cv2.cvtColor(image, cv2.COLOR_BGR2YUV_I420).reshape((area * 3 // 2,))y = yuv420p[:area]uv_planar = yuv420p[area:].reshape((2, area // 4))uv_packed = uv_planar.transpose((1, 0)).reshape((area // 2,))nv12 = np.zeros_like(yuv420p)nv12[:height * width] = ynv12[height * width:] = uv_packedreturn nv12def get_hw(pro):if pro.layout == "NCHW":return pro.shape[2], pro.shape[3]else:return pro.shape[1], pro.shape[2]def plot_image(origin_image, onnx_output):def get_pallete():pallete = [128,64,128,244,35,232,70,70,70,102,102,156,190,153,153,153,153,153,250,170,30,220,220,0,107,142,35,152,251,152,0,130,180,220,20,60,255,0,0,0,0,142,0,0,70,0,60,100,0,80,100,0,0,230,119,11,32,]return palleteonnx_output = onnx_output.astype(np.uint8)onnx_output = np.squeeze(onnx_output)image_shape = origin_image.shape[:2][::-1]onnx_output = np.expand_dims(onnx_output, axis=2)onnx_output = cv2.resize(onnx_output,image_shape,interpolation=cv2.INTER_NEAREST)out_img = Image.fromarray(onnx_output)out_img.putpalette(get_pallete())plt.imshow(origin_image)plt.imshow(out_img, alpha=0.6)fig_name = 'segment_result.png'print(f"Saving predicted image with name {fig_name} ")plt.savefig(fig_name)def postprocess(model_output, origin_image):pred_result = np.argmax(model_output[0], axis=-1)print("=" * 10, "Postprocess successfully.", "=" * 10)print("=" * 10, "Waiting for drawing image ", "." * 10)plot_image(origin_image, pred_result)print("=" * 10, "Dump result image segment_result.png successfully.", "=" * 10)if __name__ == '__main__':# test classification resultmodels = pyeasy_dnn.load('../models/mobilenet_unet_1024x2048_nv12.bin')print("=" * 10, "Model load successfully.", "=" * 10)h, w = get_hw(models[0].inputs[0].properties)img_file = cv2.imread('./segmentation.png')des_dim = (w, h)resized_data = cv2.resize(img_file, des_dim, interpolation=cv2.INTER_AREA)nv12_data = bgr2nv12_opencv(resized_data)outputs = models[0].forward(nv12_data)print("=" * 10, "Model forward finished.", "=" * 10)postprocess(outputs[0].buffer, img_file)

图像分割结果:

对比原图,分割效果还可以

2.Yolov3 模型算法

这里也是对现成Sample进行的测试。查看文件,Yolov3和Yolov5都分了80个类,如下

person
bicycle
car
motorbike
aeroplane
bus
train
truck
boat
traffic light
fire hydrant
stop sign
parking meter
bench
bird
cat
dog
horse
sheep
cow
elephant
bear
zebra
giraffe
backpack
umbrella
handbag
tie
suitcase
frisbee
skis
snowboard
sports ball
kite
baseball bat
baseball glove
skateboard
surfboard
tennis racket
bottle
wine glass
cup
fork
knife
spoon
bowl
banana
apple
sandwich
orange
broccoli
carrot
hot dog
pizza
donut
cake
chair
sofa
pottedplant
bed
diningtable
toilet
tvmonitor
laptop
mouse
remote
keyboard
cell phone
microwave
oven
toaster
sink
refrigerator
book
clock
vase
scissors
teddy bear
hair drier
toothbrush

Yolov3源码和识别效果分别如下:

#!/usr/bin/env python3import numpy as np
import cv2
from postprocess import postprocessfrom hobot_dnn import pyeasy_dnn as dnndef bgr2nv12_opencv(image):height, width = image.shape[0], image.shape[1]area = height * widthyuv420p = cv2.cvtColor(image, cv2.COLOR_RGB2YUV_I420).reshape((area * 3 // 2,))y = yuv420p[:area]uv_planar = yuv420p[area:].reshape((2, area // 4))uv_packed = uv_planar.transpose((1, 0)).reshape((area // 2,))nv12 = np.zeros_like(yuv420p)nv12[:height * width] = ynv12[height * width:] = uv_packedreturn nv12def get_hw(pro):if pro.layout == "NCHW":return pro.shape[2], pro.shape[3]else:return pro.shape[1], pro.shape[2]def print_properties(pro):print("tensor type:", pro.tensor_type)print("data type:", pro.dtype)print("layout:", pro.layout)print("shape:", pro.shape)if __name__ == '__main__':models = dnn.load('../models/yolov3_darknet53_416x416_nv12.bin')# 打印输入 tensor 的属性print_properties(models[0].inputs[0].properties)# 打印输出 tensor 的属性print(len(models[0].outputs))for output in models[0].outputs:print_properties(output.properties)img_file = cv2.imread('./kite.jpg')h, w = get_hw(models[0].inputs[0].properties)des_dim = (w, h)resized_data = cv2.resize(img_file, des_dim, interpolation=cv2.INTER_AREA)nv12_data = bgr2nv12_opencv(resized_data)outputs = models[0].forward(nv12_data)prediction_bbox = postprocess(outputs, model_hw_shape=(416, 416), origin_image=img_file)print(prediction_bbox)

这里可以将./kite.jpg图片替换为其他你想测试的图片。

3.Yolov5 模型算法

Yolov3源码和识别效果分别如下:

#!/usr/bin/env python3import numpy as np
import cv2
from postprocess import postprocessfrom hobot_dnn import pyeasy_dnn as dnndef bgr2nv12_opencv(image):height, width = image.shape[0], image.shape[1]area = height * widthyuv420p = cv2.cvtColor(image, cv2.COLOR_RGB2YUV_I420).reshape((area * 3 // 2,))y = yuv420p[:area]uv_planar = yuv420p[area:].reshape((2, area // 4))uv_packed = uv_planar.transpose((1, 0)).reshape((area // 2,))nv12 = np.zeros_like(yuv420p)nv12[:height * width] = ynv12[height * width:] = uv_packedreturn nv12def get_hw(pro):if pro.layout == "NCHW":return pro.shape[2], pro.shape[3]else:return pro.shape[1], pro.shape[2]def print_properties(pro):print("tensor type:", pro.tensor_type)print("data type:", pro.dtype)print("layout:", pro.layout)print("shape:", pro.shape)if __name__ == '__main__':models = dnn.load('../models/yolov5s_672x672_nv12.bin')# 打印输入 tensor 的属性print_properties(models[0].inputs[0].properties)# 打印输出 tensor 的属性print(len(models[0].outputs))for output in models[0].outputs:print_properties(output.properties)img_file = cv2.imread('./kite.jpg')h, w = get_hw(models[0].inputs[0].properties)des_dim = (w, h)resized_data = cv2.resize(img_file, des_dim, interpolation=cv2.INTER_AREA)nv12_data = bgr2nv12_opencv(resized_data)outputs = models[0].forward(nv12_data)prediction_bbox = postprocess(outputs, model_hw_shape=(672, 672), origin_image=img_file)print(prediction_bbox)

03-旭日X3派测评——Samples案例测试相关推荐

  1. 01-旭日X3派测评——开箱测试系统烧写性能初测

    目录 1. 开箱测试 2. 预备工作 3.烧写系统 3.1 烧写软件 3.2 镜像文件下载 4.3 制作系统启动盘 4.4 测试系统 4.4.1串口登录测试 4.4.2 SSH登录测试 5. Hell ...

  2. PPYOLO垃圾检测+地平线旭日X3派部署(下)

    请点击此处查看本环境基本用法. Please click here for more detailed instructions. 1. 简介 在上一个教程中,我们介绍了如何利用百度PaddlePad ...

  3. 智能搬运机器人系列之使用旭日X3派实现机器人防脱轨功能

    准备工作 (1)旭日X3派 本摄像头小车上位机采用旭日X3派开发板.开发环境为Ubuntu系统下的opencv-python环境.通过HDMI外接显示器实现对两个车载USB摄像头的监测与开发,进而感知 ...

  4. [首发] 多方位玩转“地平线新发布AIoT开发板——旭日X3派(Sunrise x3 Pi)” 插电!开机!轻松秒杀!

    有幸在发布会前拿到了开发板,可以提前对开发板测试,感受下新品AIoT的魅力.(我这个是体验装,不花钱,需要啥设备他们还得给我买→_→) 下面我将以自己的科研项目经历来对这款芯片进行评估,简单来说,就是 ...

  5. 体验极速——在旭日X3派上使用双频1300M USB无线网卡

    上一篇博客<在旭日X3派开发板上使用USB Wifi来提高网络速度>提供一种低成本¥20的USB Wifi解决方案.这个模块的传输速度在10M/s以内,尽管满足正常的开发需求,但在项目应用 ...

  6. 002_旭日X3派初探:TogetherROS安装

    文章目录 1. What is TogetherROS? 2. How to install TogetherROS? 2.1 准备工作 2.2 局域网连接 2.2.1 网线互联 2.2.2 通过SS ...

  7. AI 边缘计算平台 - RK3588 / 旭日 X3 派 / 爱芯派 AX620A / K510 简介

    今年的双 11,看起来好像没有往年那么火,各大厂家优惠的力度感觉也不是很大.盘点一下 AI 边缘计算平台,发现有几款性价比还比较高平台的加入,值得大家考察一番. 我将几款性价比还不错的平台做了整理,列 ...

  8. 地平线旭日X3派小白上手

    1.购买 各个经销商对地平线旭日X3派2G板的统一报价是499,但各种套餐中价格有差异,建议选用带散热和串口的套餐,原因是CPU发热量还是有点大的,板载调试接口是2.0间距,大部分人手头没有这种杜邦线 ...

  9. 旭日x3派个人配置总结(ubuntu server + xrdp)

    旭日x3派基本设置 旭日x3派使用文档 [首发]多方位玩转旭日x3派 XRDP+Xface4远程桌面设置 安装xrdp并解决闪退.黑屏问题 ROS2-Foxy配置 解决"Failed to ...

最新文章

  1. ajax判断密码是否一致,jquery.validate ajax方式验证密码是否正确
  2. java清除控制台_Java:清除控制台
  3. tensorflow sobel算子实现
  4. xgboost调参指南
  5. java 接口编程_JAVA面向接口编程
  6. LeetCode 457. 环形数组循环(暴力+快慢指针)
  7. Linux 内核里的数据结构——基数树
  8. sql server Developer Edition版本的下载安装
  9. 流量分析技术丨分享科来网络通讯协议图2022版本(附下载链接)
  10. Unity Editor资源重命名
  11. android:layout_margintop=3dip,ConstraintLayout 中android:layout_marginStart
  12. 11月合资SUV销量:日系车统治榜单 大众产品攻势“拳意渐乱”
  13. centos 6.5 mysql 5.5 安装,centos6.5 安装mysql-5.5
  14. 官宣!CATCTF不日开赛!!
  15. 用mysql查找姓王的行为轨迹_mysql查询
  16. 支付宝wap支付配置应用公钥/应用私钥
  17. Alpha事后诸葛会议
  18. 文章:叶绿体 rRNA 甲基转移酶 CMAL 在核糖体形成和植物发育中的关键作用
  19. Axure RP 基础元件
  20. PostgreSQL+postgis入门及简单应用(dijkstra实现最短路径)

热门文章

  1. 戴森全新V12 Detect Slim轻量无绳吸尘器中国首发
  2. 2022年劳务员-通用基础(劳务员)考试模拟100题及在线模拟考试
  3. 《Windows程序设计》读书笔九 子窗口控件
  4. python cocos2d菜鸟教程,cocos2dx技术选型
  5. 同程旅游缓存系统设计:如何打造Redis时代的完美体系(含PPT)
  6. 用来读的词典:牛津当代百科大辞典(英汉·英英·彩色·图解)
  7. 出国(国际会议)-韩国
  8. 汕头大学信息与计算机学院研究生院,汕头大学研究生院
  9. Python全栈(十)Django框架之10.ORM模型对象和QuerySet方法
  10. 另类数字剖析车王轨迹 舒马赫的16年F1赛车人生