First of all, my test scenario is “ Identify QR codes printed on paper ”, Look for the QR code in the scanning results and identify it , Instead of just having the camera scan the QR code .

zbar and zxing It's all about yourself github On clone Of c++ Source code / Interface dll, All are default parameters

Let's talk about the conclusion : We took thousands of pictures , The accuracy of the two libraries is similar ( Because of the diversity of images and scenes , The exact accuracy figures don't make any sense ), however zbar It's a lot faster , Probably zxing Of 4-5 times . In fact, the accuracy of the two databases is not very satisfactory , It's not recognizable if it's a little fuzzy , Even some non blurred images can't be recognized . by comparison , The recognition effect of wechat is against the sky , You can tell how to toss , It makes me curious .

Later, I tried to improve the recognition effect , Let's take a look at the recognition principle of QR code , It's too complicated , Do not know how to start . So we try to improve the image preprocessing , As a result, the recognition effect is greatly improved by using a binary addition operation , It makes me wonder why developers didn't do such a simple preprocessing ? And then went on to optimize , It is found that the threshold of binarization is very important for the recognition of two-dimensional code ,badcase Usually because the threshold is not appropriate , So at the expense of performance , Try different thresholds many times in the recognizer , Finally, the recognition result is satisfactory , The accuracy is from 90% Up to 99.8% about , Most of the printing is not clear badcase It's all settled , The code is as follows :

#include <iostream>
#include <include\zbar.h>
#include "opencv/cv.h"
#include "opencv/highgui.h" using namespace std;
using namespace cv;
using namespace zbar; //zbar Interface
string ZbarDecoder(Mat img)
{
string result;
ImageScanner scanner;
const void *raw = (&img)->data;
// configure the reader
scanner.set_config(ZBAR_QRCODE, ZBAR_CFG_ENABLE, );
// wrap image data
Image image(img.cols, img.rows, "Y800", raw, img.cols * img.rows);
// scan the image for barcodes
int n = scanner.scan(image);
// extract results
result = image.symbol_begin()->get_data();
image.set_data(NULL, );
return result;
} // Recognize binary image , If it fails, open operation is used for secondary identification
string GetQRInBinImg(Mat binImg)
{
string result = ZbarDecoder(binImg);
if(result.empty())
{
Mat openImg;
Mat element = getStructuringElement(MORPH_RECT, Size(, ));
morphologyEx(binImg, openImg, MORPH_OPEN, element);
result = ZbarDecoder(openImg);
}
return result;
} //main function
string GetQR(Mat img)
{
Mat binImg;
// stay otsu On the basis of binary results , Increasing the threshold , Fuzzy image recognition
int thre = threshold(img, binImg, , , cv::THRESH_OTSU);
string result;
while(result.empty() && thre<)
{
threshold(img, binImg, thre, , cv::THRESH_BINARY);
result = GetQRInBinImg(binImg);
thre += ;// The threshold step size is set to 20, The greater the step length , The lower the recognition rate , The faster the speed.
}
return result;
}

QR code open source library zbar、zxing More articles about using the experience

  1. iOS QR code scanning adopt ZBar ZXing Third party library

    There are many open source libraries for scanning QR code, such as ZBar.ZXing etc. ZBar How to use : download ZBar SDK Address https://github.com/bmorton/ZBarSDK ZBarSDK It's an open source SD ...

  2. QR code open source library ZBar- To make complaints about articles

    I saw an article on the Internet not long ago <QR-Decoder-OV5640 QR code recognition > , Is a development board tutorial . Remember that the corresponding development board was purchased before , It was just to see OV5640 Of JPG The output effect of , As a result of the company's wonderful ...

  3. QR code open source library ZBar-MDK STM32F429 transplant

    The first two articles have been implemented ZBar stay Windows Platform compilation and use , This article will introduce how to put ZBar Migration to STM32F429,IDE Use MDK. 1. MDK Engineering setup (1) Don't check Use MicroLIB , Use I ...

  4. QR code open source library ZBar- Realize Chinese decoding

    Chinese garbled Part 1 <ZBar-windows Compile and use > The barcode has been successfully parsed , But the target is QR code , After testing, two-dimensional code Chinese will appear garbled . The content of the QR code below is "http123 test 456", ...

  5. QR code open source library ZBar-windows Compile and use

    Source code Download the latest Zbar Source code (http://zbar.sourceforge.net/), Website WIKI It's blank , So you can only find the instructions in the source code package , unfortunately Windows I don't know how to compile it , It just shows Wind ...

  6. Android QR code open source project zxing Use case simplification and QR code generation 、 Bar code

    The last one said :Android QR code open source project zxing compile , After compiling, there is a built-in test program :CaptureActivity It's complicated , I just want to get rid of something I don't use , It looks more convenient to use , The popularity of two-dimensional code and bar code is from ...

  7. C++ Two dimensional code related library compilation

    One . Think of nothing It's boring sitting on the subway , I suddenly thought of QR code , Conveniently Baidu under the relevant information , at present C++ There are not many libraries related to QR code , It's just zbar( Open source China hasn't downloaded it for a long time ).zxing, But both libraries are said to parse QR code , No ...

  8. Personality QR code open source topic &lt; Replace element points &gt;

    Basic method :ChangeFillShape // Modify the fill shape ChangeFillShape(...) // Abstract : // Modify the fill shape // // Parameters : // g: // Sketchpad // // Fo ...

  9. Personality QR code open source topic &lt; Replace anchor points &gt;

    Basic method : ChangeFillShape // Modify the fill shape ChangeFillShape(...) // Abstract : // Modify the fill shape // // Parameters : // g: // Sketchpad // // F ...

Random recommendation

  1. 30 God C# Foundation consolidation ----- serialize , aggregate

    Exercises on sets . -----> Count the number of times each character of a string appears . Console.WriteLine(" Please enter ?"); string input = Console.ReadLi ...

  2. Ruby on rails Learning notes —— Installation environment

    Problems arise : C:\Users\len>gem install rails ERROR: While executing gem ... (Gem::RemoteFetcher::FetchErr ...

  3. FJNU 1159 Fat Brother’s new way( Fat brother's new posture )

    FJNU 1159 Fat Brother’s new way( Fat brother's new posture ) Time Limit: 1000MS   Memory Limit: 257792K [Description] [ subject ...

  4. Server deployment _nginx Report errors : [warn] conflicting server name &quot;www.test.com&quot; on 0.0.0.0:80, ignored

    Today's revision nginx The configuration file nginx.conf after , start-up nginx You're going to report a mistake . After careful inspection, it is a duplicate configuration server Elements lead to , When nginx Duplicate... Detected  server_name item.test.com ...

  5. WebDriverWait in and, or, not usage

    1. And usage wait.until(ExpectedConditions.and( ExpectedConditions.visibilityOfAllElementsLocatedBy(By. ...

  6. apache Of 500 The error is in which file

    apache Of 500 The error is in which file

  7. LINQ to SQL and Entity Framework contrast

    LINQ to SQL and Entity Framework It's all kind of including LINQ Functional object relation mapping technology . The essential difference between them is EF Better decouple the database architecture from the types of our queries . Use EF, The object we are looking for is not ...

  8. Detailed explanation EBS Interface development of inventory transaction processing, purchase receiving -- Add

    Except that it can be used  Detailed explanation EBS Interface development of the inventory transaction processing purchase receiving method can also use the following methods , The difference is that with batch and sequence control, the implementation is different The script will load records into ...

  9. css Common units

    css Common units This article will give a brief introduction to css Common units of . A unit of absolute length The unit of absolute length represents a physical measurement . Pixels px(pixels) stay web On , Pixels px It's a typical unit of measure , Many other units of length map directly to pixels . Final , ...

  10. P4147 Jade toad Palace -- Monotonic stack

    P4147 Jade toad Palace Background one day , kitten rainbow and freda Came to Tianmen Mountain Jade toad palace in Zhangjiajie, Western Hunan , Blue rabbit, the leader of Yuchan palace, entertained them , And give them a piece of land . Title Description The land is divided into N*M Lattice , Every lattice ...