1:首先安装编译好sophon-sail
比特大陆BM1684X开发环境搭建--SOC mode-CSDN博客
2:在将之前配置的soc-sdk拷贝一份到sdk根目录,将交叉编译好的sail中的build_soc拷贝至soc-sdk文件夹内;
cp -rf build_soc/sophon-sail/inlcude soc-sdk
cp -rf build_soc/sophon-sail/lib soc-sdk
3:安装交叉编译器
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
4:新建文件夹MNIST,目录结构如下
CMakeFile.txt
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_ASM_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
include_directories("/home/wzw/Bitmain/Release_230301-public/soc-sdk/include")
include_directories("/home/wzw/Bitmain/Release_230301-public/soc-sdk/include/sail")
# 添加交叉编译需要使用的头文件目录
link_directories("//home/wzw/Bitmain/Release_230301-public/soc-sdk/lib")
# 添加交叉编译需要使用的动态库目录
set(SOURCE_FILES main.cpp)
set(TARGET_NAME MNIST)
add_executable(${TARGET_NAME} ${SOURCE_FILES})
target_link_libraries(${TARGET_NAME} sail)
# sail为需要链接的库
main.cpp
#define USE_FFMPEG 1
#define USE_OPENCV 1
#define USE_BMCV 1
#include <stdio.h>
#include <sail/cvwrapper.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
int device_id = 0;
std::string video_path = "test.avi";
sail::Decoder decoder(video_path,true,device_id);
if(!decoder.is_opened()){
printf("Video[%s] read failed!\n",video_path.c_str());
exit(1) ;
}
sail::Handle handle(device_id);
sail::Bmcv bmcv(handle);
while(true){
sail::BMImage ost_image = decoder.read(handle);
bmcv.imwrite("test.jpg", ost_image);
break;
}
return 0;
}
5:编译cmake CMakeFile.txt
make
6:拷贝至板端
scp MNIST linaro@10.12.13.112:/home/wzw
./MNIST