AFL++实战(六)-测试light-LPR

light-LPR

Light-LPR是一个瞄准可以在嵌入式设备、手机端和普通的x86平台上运行的车牌识别开源项目,旨在支持开放场景的车牌识别, 支持目前国内所有的车牌识别。项目源码

light-LPR的下载
#安装opencv4.0及以上
#安装cmake3.0以上版本
git clone https://github.com/lqian/light-LPR

有源码测试

测试代码
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>

#include <assert.h>
#include "mlpdr/MLPDR.h"

using namespace std;
using namespace mlpdr;
using namespace cv;
int main(int argc, char ** argv) {
	MLPDR detector("../models/", 0.9f, 0.7f, 0.7f);
	Mat img = imread(argv[1],1);
	assert(!img.empty());
	TickMeter tm;
	tm.start();
//	std::vector<mlpdr::PlateInfo> plateInfos = detector.Detect(img, 40, 3);  // 608.23 ms
	vector<PlateInfo> plateInfos = detector.recognize(img);
	tm.stop();
	printf("detect cost: %f (ms)\n", tm.getTimeMilli());

	for (auto pi: plateInfos) {
		cout << "plateNo: " << pi.plateNo << endl;
	}

}
配置

对于完整的项目,需要将编译器指定为 afl-clang,然后再进行编译。

export CC=afl-clang
export CXX=afl-clang++
mkdir build
cd build
cmake ../
make -j4
fuzz

正式执行 fuzz 测试的命令如下:

mkdir in
# 在in文件下下创建image语料库,使用jpeg.dict字典
# https://github.com/AFLplusplus/AFLplusplus/tree/stable/dictionaries
afl-fuzz  -x dict/jpeg.dict -m none -i in -o out_res ./examples/demo @@
测试结果

在这里插入图片描述

黑盒测试

配置

首先在下载好 light-LPR 后,对 light-LPR 直接进行编译安装,生成二进制文件。


# 测试 ./examples/demo in/1.jpg

# make的时候会出现与opencv4的很多兼容问题,下面有解决方案。
cmake ../
make

启用QEMU模式,要先编译。

# 进入到AFLplusplus所在位置
cd qemu_mode
./build_qemu_support.sh
fuzz
afl-fuzz -Q -m none -i in -o out_res ./examples/demo -f
测试结果

在这里插入图片描述
在加了字典之后会出现第一个测试图片就crash的错误。

注意事项

  1. CMake Error at CMakeLists.txt:23 (find_package): Could not find a configuration file for package “OpenCV” that is compatible with requested version “3.0.0”.
    在这里插入图片描述
    打开CMakeLists.txt文件,然后将opencv 3.0.0改为4.0.0,这样opencv4以上的版本就可以使用了。

  2. CMake Error at src/examples/CMakeLists.txt:1 (find_package): Could not find a configuration file for package “OpenCV” that is compatible with requested version “3.4.0”.
    解决办法同1.

  3. error: use of undeclared identifier ‘CV_BGR2RGBA’; cv::cvtColor(img, MatTemp, CV_BGR2RGBA, 4);
    在这里插入图片描述
    改为 cv::cvtColor(imageBGR, imageRGBA, cv::COLOR_BGR2BGRA)

  4. PROGRAM ABORT : Test case ‘id:000000,time:0,orig:1.jpg’ results in a timeout. Location : perform_dry_run(), src/afl-fuzz-init.c:593。

不是jpg格式,引起了程序的崩溃,使用afl++的字典即可。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值