zbar识别条码

CV算子之识别条形码,将其做在相机一直拿图程序里面,看看效率以及延迟

测试zbar识别一帧图像215ms左右,优化zbar识别程序,减少它识别的类别,一帧图像 165ms左右

该程序基于QT写的

ubuntu安装zbar
sudo apt-get install libzbar-dev 

.pro
LIBS += /usr/lib/x86_64-linux-gnu/libzbar.so.0.2.0

.cpp
#include <zbar.h>
using namespace zbar;

#ifdef cvTool
	QDateTime current_date_time = QDateTime::currentDateTime();
    QString start_time = current_date_time.toString("yyyy.MM.dd hh:mm:ss.zzz");
    qDebug() << "start_time:" << start_time << endl;
    long long MSec_time = QDateTime::currentDateTime().toMSecsSinceEpoch();

    cv::Mat grayImg;
    //output_img是相机的原始图像
    pyrDown(output_img,output_img);
    cvtColor(output_img,grayImg,cv::COLOR_BGR2GRAY);

    int cv_width = grayImg.cols;
    int cv_height = grayImg.rows;
    uchar *raw = (uchar *)(grayImg.data);
    Image image( cv_width, cv_height, "Y800", raw, cv_width*cv_height);
    ImageScanner scanner;
    scanner.set_config(ZBAR_NONE,ZBAR_CFG_ENABLE,0);
    scanner.set_config(ZBAR_EAN13,ZBAR_CFG_ENABLE,1);
    scanner.scan((image));
    int counter =0;

    int i=0;
    for(Image::SymbolIterator symbol = image.symbol_begin();symbol!=image.symbol_end();++symbol)
	{
        string text =to_string(counter++)+"-" +symbol->get_type_name()+": "+symbol->get_data();
        putText(output_img,text,cv::Point(10,50*counter),cv::FONT_HERSHEY_PLAIN,5,cv::Scalar(0,0,255),1);
        i++;
    }

    qDebug() << "Processing speed:" <<  QDateTime::currentDateTime().toMSecsSinceEpoch() - MSec_time << "ms" << endl;
#endif
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值