玩转Atlas200DK(十四)玩转摄像头

十四、在Atlas 200DK上玩转摄像头

200DK有两个摄像头的接口,早在两年前,张小白就在早期CANN版本中试过摄像头:

Atlas 200DK系统折腾纪实:(1)论图片及18.04.1的诞生​bbs.huaweicloud.com/blogs/194291

当然也要注意里面的坑,比如说接口中排线的方向等等。

我们下面看看,在CANN 5.0.4 alpha005的版本对摄像头的支持如何:

1、在200DK上执行ascend camera例程

根据:https://gitee.com/ascend/samples/tree/v0.6.0/cplusplus/level1_single_api/5_200dk_peripheral/ascendcamera

cd samples/cplusplus/level1_single_api/5_200dk_peripheral/ascendcamera

mkdir -p build/intermediates/host

cd build/intermediates/host

cmake ../../../src -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_SKIP_RPATH=TRUE

make

cd $HOME/samples/cplusplus/level1_single_api/5_200dk_peripheral/ascendcamera/out

mkdir output

摄像头1:

./main -i -c 1 -o ./output/filename.jpg --overwrite

摄像头0:

./main -i -c 0 -o ./output/filename0.jpg --overwrite

从宿主机将结果文件拷贝回来:

mkdir camera

cd camera

scp HwHiAiUser@192.168.1.2:~/samples/cplusplus/level1_single_api/5_200dk_peripheral/ascendcamera/out/output/*.jpg .

打开看看:

说明这两个摄像头拍照都没(太大的)问题。(尽管这个带夜视的廉价摄像头是一如既往的发红。。)

2、在200DK上执行face_detection_camera例程

根据 https://gitee.com/ascend/samples/tree/v0.6.0/cplusplus/level2_simple_inference/2_object_detection/face_detection_camera

执行以下脚本下载caffe模型,并转换为om模型:

cd ${HOME}/samples/cplusplus/level2_simple_inference/2_object_detection/face_detection_camera/model
wget https://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/AE/ATC%20Model/facedection/face_detection_fp32.caffemodel
wget https://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/AE/ATC%20Model/facedection/face_detection.prototxt
wget https://c7xcode.obs.cn-north-4.myhuaweicloud.com/models/face_detection_camera/insert_op.cfg


atc --output_type=FP32 --input_shape="data:1,3,300,300" --weight=./face_detection_fp32.caffemodel --input_format=NCHW --output=./face_detection --soc_version=Ascend310 --insert_op_conf=./insert_op.cfg --framework=0 --save_original_model=false --model=./face_detection.prototxt

编译:

cd ~/samples/cplusplus/level2_simple_inference/2_object_detection/face_detection_camera/scripts

bash ./sample_build.sh

运行:

bash sample_run.sh

具体报错如下:

HwHiAiUser@davinci-mini:~/samples/cplusplus/level2_simple_inference/2_object_detection/face_detection_camera/scripts$ bash sample_run.sh
[INFO] The sample starts to run
Current environment valid ip list:
	127.0.0.1
	192.168.199.204
Please choose one to show the presenter in browser:192.168.199.204
[INFO]  Acl init ok
[INFO]  Open device 0 ok
[INFO]  Use default context currently
content_type config string:1
[INFO]  dvpp init resource ok
[INFO]  Load model ../model/face_detection.om success
[INFO]  Create model description success
[INFO]  Create model(../model/face_detection.om) output success
[INFO]  Init model ../model/face_detection.om success
[INFO]  No specified carmera id, use camera0
[ERROR]  Set camera fps failed
[ERROR]  Set camera0 property failed
[ERROR]  Open camera failed
[2022-04-23 18:24:44][LIBMEDIA_ERROR] CloseCamera failed!!! Camera[0] is not opened
[ERROR]  Close camera 0 failed
[INFO]  Unload model ../model/face_detection.om success
[INFO]  destroy context ok
[INFO]  Reset device 0 ok
[INFO]  Finalize acl ok
[INFO] The program runs successfully, Please visit http://192.168.199.204:7007 for display server!
Enter any command to stop the application:
 kill existing project process: kill -9 3147.
/home/HwHiAiUser/Ascend/thirdpart/aarch64/common/sample_common.sh: line 40: kill: (3147) - No such process
ERROR: kill project process failed.

经过专家指点,是目前摄像头相关底层代码的fps设置有误:

当然,专家的指点只是一个方向,代码具体的实现张小白仔细看了一下,face_detection_camera 调用的是acllite。

首先,main.cpp调用了 ~/samples/cplusplus/common/acllite/src/AclLiteVideoProc.cpp:

然后,位于 /home/HwHiAiUser/samples/cplusplus/common/acllite/src 的 AclLiteVideoProc.cpp 调用了CameraCapture:

由于不知道它调了哪个,所以两边都加了个日志。

最后在 ./samples/cplusplus/common/acllite/src/CameraCapture.cpp 的 SetProperty设置属性:

张小白对于代码逻辑都没改,只是加了几行日志。

然后

cd ~/samples/cplusplus/common/acllite

make

make install

再回到工程目录:

cd ~/samples/cplusplus/level2_simple_inference/2_object_detection/face_detection_camera/scripts

bash sample_build.sh

bash sample_run.sh

此时,代码正在运行,浏览器打开 192.168.199.204:7007

出现了Presenter Server的页面,点击person可以打开:

可以看到,视频中的人脸可以被成功识别。

(未完待续)

  • 0
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论
Atlas 200 DK是华为推出的一款人工智能开发者套件,用于快速入门和开发AI应用程序。对于新手来说,以下是一些入门建议。 首先,了解Atlas 200 DK的组成部分。它包括开发板、NPU芯片、摄像头、以及软件开发包(SDK)。这些组件合作运行,可以实现AI计算和图像处理。 其次,学习华为提供的文档和教程。华为为Atlas 200 DK提供了详细的开发指南和教程,包括软件安装、环境配置和示例代码等。通过仔细阅读这些文档,可以了解如何使用Atlas 200 DK进行开发和调试。 第三,掌握相关的AI技术和算法。了解深度学习、计算机视觉和自然语言处理等AI领域的基本概念和方法。掌握相关算法和模型,例如神经网络、卷积神经网络和循环神经网络等。 第四,实践并进行小型项目开发。通过使用Atlas 200 DK的开发环境和示例代码,可以进行一些小型项目的尝试和实践,例如人脸识别、图像分类或者语音处理等。通过实际操作,可以加深对Atlas 200 DK的理解和应用。 最后,参与社区和参考其他资源。参与华为开发者社区和论坛,与其他开发者交流经验和问题,获得更多的帮助和支持。此外,还可以参考相关的书籍、教程和在线课程,进一步扩充知识和提高技能。 总之,Atlas 200 DK是一个强大的人工智能开发者套件,通过逐步学习和实践,新手可以快速入门并开发出各种AI应用程序。加油!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

张小白TWO

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值