6、在树莓派usb口中插入Movidius NCS(神经计算棒)我们这里用两根来测试一下ncsdk和ncs设备是否正常
cd /lance/ncappzoo/apps/hello_ncs_py
在这个目录下创建一个Python文件multi_ncs.py,内容如下:
##################################################
#! /usr/bin/env python3
# Copyright(c) 2017 Intel Corporation.
# License: MIT See LICENSE file in root directory.
# Python script to open and close a single NCS device
import mvnc.mvncapi as fx
# main entry point for the program
def main():
# set the logging level for the NC API
fx.SetGlobalOption(fx.GlobalOption.LOG_LEVEL, 0)
# get a list of names for all the devices plugged into the system
ncs_names = fx.EnumerateDevices()
if (len(ncs_names) < 1):
print("Error - no NCS devices detected, verify an NCS device is connected.")
quit()
else:
print("We have %d NCS devices!"%len(ncs_names))
dev = [0 for x in range(len(ncs_names))]
for i in range (len(ncs_names)):
dev = fx.Device(ncs_names)
try:
dev.OpenDevice()
except:
print("Error - Could not open the NO.%d NCS device."%i)
quit()
print("Hello NCS! The NO.%d device opened normally."%i)
try:
dev.CloseDevice()
except:
print("Error - could not close the NO.%d NCS device."%i)
quit()
print("Goodbye NCS! The NO.%d device closed normally."%i)
print("The NO.%d NCS device working."%i)
# Initial here:
if __name__=="__main__":
main()
##################################################
运行此python程序,屏幕打印结果上能看到0和1两个ncs device正常打开关闭,就表示ncsdk和ncs设备正常安装了。正常显示信息如下:
We have 2 NCS devices!
Hello NCS! The NO.0 device opened normally.
Goodbye NCS! The NO.0 device closed normally.
The NO.0 NCS device working.
Hello NCS! The NO.1 device opened normally.
Goodbye NCS! The NO.1 device closed normally.
The NO.1 NCS device working.
8、我们再来试一个ncappzoo里面的TinyYolo神经网络的例子
cd /lance/ncappzoo/caffe/TinyYolo
make profile
make compile
make run_py
好了,如果每一步中,屏幕上打印出来的信息中没有错误,并且最后能看到识别信息(一张图片上框住的识别出来的目标物体),那么代表已经能用这个树莓派上安装的ncs进行预测工作了。接下来我们就可以进行更复杂的Object Detection工作了。