How to decode data using Zxing C ++

I am having problems using C ++ sources from a Zxing project. I downloaded the whole project from https://code.google.com/p/zxing/downloads/list and just took the cpp files (core and cli).

I just want to have a method like this:

decode(byte[] dataToDecode, int widthFrame, int heightFrame) 

but I really don't know how to do this (I'm really new to C ++ and the Zxing project).

I did a research on the Internet and found http://wiki.ssrrsummerschool.org/doku.php?id=robocup2012:qrcode-cppexample , which was exactly what I needed.

Unfortunately, the Zxing core has changed, and now I have some problems due to ArrayRef

Is there an easy way to decode a byte array (RGB) and return a result string?

Help will be really appreciated

+4
source share
1 answer

The problem was solved by changing the example of the BufferBitmapSource class ( http://wiki.ssrrsummerschool.org/doku.php?id=robocup2012:qrcode-cppexample ) in accordance with the Zxing 2.2 library.

BufferBitmapSource.hpp:

 #include <zxing/LuminanceSource.h> #include <stdio.h> #include <stdlib.h> using namespace zxing; namespace qrviddec { class BufferBitmapSource : public LuminanceSource { private: ArrayRef<char>* buffer; public: BufferBitmapSource(int inWidth, int inHeight, ArrayRef<char> buffer); ~BufferBitmapSource(); ArrayRef<char> getRow(int y, ArrayRef<char> row) const; ArrayRef<char> getMatrix() const; }; } 

BufferBitmapSource.cpp Too long to publish, but can share to those who ask.

test.cpp (main)

 ... // Convert the buffer to something that the library understands. ArrayRef<char> data((char*)buffer, width*height); Ref<LuminanceSource> source (new BufferBitmapSource(width, height, data)); ... 
+4
source

Source: https://habr.com/ru/post/1494525/


All Articles