Google_zxing_cpp代码阅读

Zxing  是Google公司开发的一款1D/2D条码识别开源工具包,该工具跨平台,支持Android,IOS,Windows,Linux。本文主要走读Linux 平台下面运行的CPP 代码。

查看目录结构:

我们这里查看cpp 里面的

 

 

入口:

ZXing\cpp\magick\src\main.c

int main(int argc, char** argv)

 

进入后执行,

    test_image_global     

test_image_local

// 为什么这会执行这两个行数呢?这两个行数的作用是什么?区别是什么?

调用区别:

解答:

test_image_global 检查全局图像,test_image_local 检查局部图像,两个函数的作用都是对图像二值化处理,区别在于一个是局部处理,一个是全局处理。

 

int test_image_local(Image& image, string out_prefix) {

  return test_image(image, out_prefix, true);

}

 

int test_image_global(Image& image, string out_prefix) {

  return test_image(image, out_prefix, false);

}

 

test_image(Image& image, string out_prefix, bool localized)

Ref<BitMatrix> matrix(NULL);   // 位图矩阵

 Ref<Binarizer> binarizer(NULL); // 二值化

 if (localized) {

      binarizer = new LocalBlockBinarizer(source); // 定义局部块二值化

    } else {

      binarizer = new GlobalHistogramBinarizer(source);//定义全局直方图二值化

    }

 

Binarizer 二值化类,

matrix = binarizer->getBlackMatrix(); // 获取二值化后处理后的图像

 

Ref<BinaryBitmap> binary(new BinaryBitmap(binarizer)); // 定义BinaryBitmap 类变量 binary, 这是一个bitmap 类型的图像数据

 

Ref<Result> result(decode(out_prefix, binary, cell_grid, cell_transformed));// 定义Result类变量,在形参中调用 decode 解码函数, 对图像进行解码操作。

 

Ref<Result> decode(string out_prefix, Ref<BinaryBitmap> image, string& cell_grid, string& cell_transformed) {

      QREdgeDetector detector = QREdgeDetector(image->getBlackMatrix());// 定义QRcode 解码类

      Ref<DetectorResult> detectorResult(detector.detect()); // 探测结果类

}

cell_result = result->getText()->getText(); // 使用result 变量获取识别处理文本结果

    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值