源碼在github上,
鏈接:https://github.com/dusty-nv/jetson-inference
但是在國內往往下載時會出現問題,我已經講最新的源碼項目移植到了碼雲,
鏈接:https://gitee.com/vcan123/jetson-inference
安裝方式相同。
1、安裝cmake
$sudo apt update $sudo apt upgrade $sudo apt-get install cmake
2、源碼的獲取
①github獲取
先試着從GitHub上獲取源碼
$git clone https://github.com/dusty-nv/jetson-inference
②碼雲獲取
如果GitHub上獲取源碼失敗,可以從我的碼雲上獲取,執行如下代碼即可,一樣
$git clone https://gitee.com/vcan123/jetson-inference
獲取源碼后
$cd jetson-inference $git submodule update --init
在執行git submodule update --init后可能有文題可以參考GitHub登不上去問題解決辦法。實在不行了留言吧,。,
3、換源
路徑切換到jetson-inference/tools下
$cd jetson-inference/tools
模型下載的國內源(在以上路徑下)
$sed -in-place -e 's@https://nvidia.box.com/shared/static@https://bbs.gpuworld.cn/mirror@g' download-models.sh
安裝pytorch,此時只是添加了源可以在第四步build文件夾中安裝(如果不會請留言,很簡單)
$sed -in-place -e 's@https://nvidia.box.com/shared/static@https://bbs.gpuworld.cn/mirror@g' install-pytorch.sh
sed -in-place -e 's@https://github.com/pytorch/vision@https://gitee.com/vcan123/pytorch@g' install-pytorch.sh
$sed -in-place -e 's@https://github.com/dusty-nv/vision@https://gitee.com/vcan123/dusty-nv@g' install-pytorch.sh
4、編譯安裝
$sudo apt-get update $sudo apt-get install git cmake libpython3-dev python3-numpy $cd jetson-inference $mkdir build $cd build $cmake ../ $make
執行以上過程時出現如圖所示,根據自己的需要點確定就可以。
5、物體識別
物體識別在路徑jetson-inference/build/aarch64/bin下
①靜態物體識別
圖片也可選,在bin路徑下有images文件,橘子等的圖片都在里邊。
打開終端輸入
c++:
$ ./imagenet-console --network = googlenet orange_0.jpg output_0.jpg #-- network標志是可選的
python:
$ ./imagenet-console.py --network = googlenet orange_0.jpg output_0.jpg #-- network標志是可選的
如果上邊的不行的話時圖片的路徑不對,用images/orange_0.jpg 替換上邊的orange_0.jpg 就可以了。
顯示識別的圖片:
$display output_0.jpg
靜態圖像識別測試腳本:
$ vi static_picture.sh
內容如下:
#!/bin/sh ./imagenet-console $1 output_$1 display output_$1
添加執行權限和運行上邊的腳本:
$ chmod a+x ./static_picture.sh $ ./static_picture.sh orange_0.jpg
②動態物體識別
支持USB攝像頭基本都可用,CSI攝像頭(樹莓派的)
$ ./imagenet-camera googlenet $ ./imagenet-camera alexnet
如果使用USB攝像頭,需要修改imagenet-camera.cpp中的宏定義DEFAULT_CAMERA,然后重新編譯。
③定位對象坐標
檢測出對象病提取邊框
$ ./detectnet-console dog_1.jpg output_1.jpg coco-dog
有問題歡迎交流。