第一个RISC-V条码识别应用

Dynamsoft最近为开发者提供了测试版的RISC-V条形码SDK。感兴趣的可以玩一下。

RISC-V条码识别SDK下载

由于没有正式发布,开发者需要下载:

下载之后解压,并替换安装包中的库文件:

$ file libDynamsoftBarcodeReader.so 
libDynamsoftBarcodeReader.so: ELF 64-bit LSB shared object, UCB RISC-V, version 1 (SYSV), dynamically linked, with debug_info, not stripped
$ tar xvf dbr-linux-7.6.tar.gz
$ cp libDynamsoftBarcodeReader.so Dynamsoft/BarcodeReader/lib/libDynamsoftBarcodeReader.so

安装RISC-V交叉编译器

源码编译比较耗时,在Ubuntu上可以直接安装:

$ sudo apt install g++-riscv64-linux-gnu gcc-riscv64-linux-gnu

安装QEMU RISC-V模拟器

通过命令行下载,编译,安装QEMU RISC-V模拟器:

$ wget https://download.qemu.org/qemu-5.1.0.tar.xz
$ tar xvf qemu-5.1.0.tar.xz
$ cd qemu-5.1.0
$ ./configure --target-list=riscv64-softmmu 
$ make
$ sudo make install

下载Fedora RISC-V镜像文件:

启动Fedora:

qemu-system-riscv64 \
   -nographic \
   -machine virt \
   -smp 4 \
   -m 2G \
   -kernel Fedora-Minimal-Rawhide-*-fw_payload-uboot-qemu-virt-smode.elf \
   -bios none \
   -object rng-random,filename=/dev/urandom,id=rng0 \
   -device virtio-rng-device,rng=rng0 \
   -device virtio-blk-device,drive=hd0 \
   -drive file=Fedora-Minimal-Rawhide-20200108.n.0-sda.raw,format=raw,id=hd0 \
   -device virtio-net-device,netdev=usernet \
   -netdev user,id=usernet,hostfwd=tcp::10000-:22
  • 用户名: riscv
  • 密码: fedora_rocks!

编译运行RISC-V条码识别程序

在解压的目录里找到示例代码$(pwd)/Dynamsoft/BarcodeReader/samples/ReadBarcode

从Dynamsoft网站上申请一个试用序列号,并更新代码:

reader.InitLicense("LICENSE-KEY");

编译程序:

$ riscv64-linux-gnu-g++ -o ReadBarcode ReadBarcode.cpp -lDynamsoftBarcodeReader -L<library directory> -Wl,-rpath=.

接下来通过scp,把程序,动态链接库和测试图片拷贝到模拟器环境里:

$ scp <user-name>@<ip address>:/<executable file path> ./
$ scp <user-name>@<ip address>:/<library file path> ./
$ scp <user-name>@<ip address>:/<image file path> ./

注意:如果编译的时候没有使用-rpath,你需要把库拷贝到/lib64/lp64d/目录中。不然会报错:

error while loading shared libraries: libDynamsoftBarcodeReader.so: cannot open shared object file: No such file or directory

现在可以正常运行程序了:

$ ./ReadBarcode AllSupportedBarcodeTypes.tif

在这里插入图片描述

源码

https://github.com/Dynamsoft/riscv-barcode-sdk-experimental

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值