- opencv环境部署
参考文件Android Studio下opencv部署
注意,在这里实际不需要第3步-导入opencv包,直接把include头文件和.so动态库放进对应的目录就好,其他的按博主示例操作。 - ncnn部署
参考文章Android Studio下ncnn部署
基本是一个套路,下载第三方的包,导入头文件和库,配置CMake
3.模型转换
参考文章ncnn模型转换
你下载的ncnn里面就有,window环境下模型转换操作如下:
cd C:\Users\login\Desktop\ncnn-20230816-windows-vs2022\x64\bin
C:\Users\login\Desktop\ncnn-20230816-windows-vs2022\x64\bin>onnx2ncnn.exe
Usage: onnx2ncnn.exe [onnxpb] [ncnnparam] [ncnnbin]
C:\Users\login\Desktop\ncnn-20230816-windows-vs2022\x64\bin>dir
驱动器 C 中的卷是 Windows
卷的序列号是 96B3-D72F
C:\Users\login\Desktop\ncnn-20230816-windows-vs2022\x64\bin 的目录
2023/08/16 12:54 <DIR> .
2023/08/16 12:54 <DIR> ..
2023/08/16 12:41 1,153,024 caffe2ncnn.exe
2023/08/16 12:41 81,920 darknet2ncnn.exe
2023/08/16 12:41 86,528 mxnet2ncnn.exe
2023/08/16 12:50 9,584,640 ncnn2int8.exe
2023/08/16 12:50 9,422,336 ncnn2mem.exe
2023/08/16 12:50 9,690,624 ncnn2table.exe
2023/08/16 12:41 17,920 ncnnmerge.exe
2023/08/16 12:50 9,662,464 ncnnoptimize.exe
2023/08/16 12:41 984,576 onnx2ncnn.exe
9 个文件 40,684,032 字节
2 个目录 148,911,742,976 可用字节
C:\Users\login\Desktop\ncnn-20230816-windows-vs2022\x64\bin>darknet2ncnn.exe
Usage: darknet2ncnn.exe [darknetcfg] [darknetweights] [ncnnparam] [ncnnbin] [merge_output]
[darknetcfg] .cfg file of input darknet model.
[darknetweights] .weights file of input darknet model.
[cnnparam] .param file of output ncnn model.
[ncnnbin] .bin file of output ncnn model.
[merge_output] merge all output yolo layers into one, enabled by default.
C:\Users\login\Desktop\ncnn-20230816-windows-vs2022\x64\bin>darknet2ncnn.exe D:\Native\app\src\main\assets\model.cfg D:\Native\app\src\main\assets\model.weights D:\Native\app\src\main\assets\model.param D:\Native\app\src\main\assets\model.bin
Loading cfg...
WARNING: The ignore_thresh=0.700000 of yolo0 is too high. An alternative value 0.25 is written instead.
WARNING: The ignore_thresh=0.700000 of yolo1 is too high. An alternative value 0.25 is written instead.
Loading weights...
Converting model...
194 layers, 211 blobs generated.
NOTE: The input of darknet uses: mean_vals=0 and norm_vals=1/255.f.
NOTE: Remember to use ncnnoptimize for better performance.
C:\Users\login\Desktop\ncnn-20230816-windows-vs2022\x64\bin>