GithubHelp home page GithubHelp logo

zxing-cpp's Introduction

ZXing C++ Port

Build Status

ZXing is/was a Java library.

At some point a complete C++ port/rewrite was created and maintained in the official ZXing repo. However, at the time of writing the C++ port is no longer maintained and has been removed from the official ZXing repo.

This project was forked from the last ZXing commit to contain the C++ project, with the following exceptions

  • scons (Python) build system has been deleted.
  • Deleted black box tests, because they refer to a large test data in ZXing repo.
  • Added appropriate copyright/licensing details (based on those in the ZXing repo).
  • Updated README.md

Removal of build systems was done to minimise maintenance burden.

If tests and XCode projects (other than those produced automatically be CMake) are desired, then another repo should be created and this repo referenced as a submodule.

Building using CMake

CMake is a tool, that generates native makefiles and workspaces. It integrates well with a number of IDEs including Qt Creator and Visual Studio.

Usage with CLion or Qt Creator:

  1. Simply open CMakeLists.txt as a new project
  2. Additional command line arguments can be specified (see below)

Usage with Makefiles, Visual Studio, etc. (see cmake --help for a complete list of generators):

  1. mkdir build
  2. cd to build
  3. Unix: run cmake -G "Unix Makefiles" ..
  4. Windows: run cmake -G "Visual Studio 10" ..

You can switch between build modes by specifying:

  • -DCMAKE_BUILD_TYPE=Debug or
  • -DCMAKE_BUILD_TYPE=Release

OpenCV integration

When build on a system where opencv is installed the open cv bridge classes and executable will be built too.

Development tips

To profile the code (very useful to optimize the code):

  1. Install Valgrind
  2. Run valgrind --tool=callgrind build/zxing - path/to/test/data/*.jpg > report.html
  3. Analyze output using KCachegrind

zxing-cpp's People

Contributors

afrancescon avatar aidansteele avatar benjamin-dobell avatar bentley avatar chakrit avatar dushibaiyu avatar guoxiao avatar kenny1847 avatar kousu avatar mcrapet avatar mojodna avatar rcdailey avatar sebastiangoebel avatar sebgdev avatar skylook avatar thekvs avatar tm-drtina avatar tpetazzoni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zxing-cpp's Issues

Bitmatrix::clear

Method Bitmatrix::clear() is declared but the implementation doesn't exist.

Can't cross compile under linux with arm-linux-g++.3.2.1

I have added these lines in the CMakeList.txt:
SET(CMAKE_SYSTEM_NAME Linux)

SET(CMAKE_C_COMPILER "arm-linux-gcc")

SET(CMAKE_CXX_COMPILER "arm-linux-g++")
SET(CMAKE_FIND_ROOT_PATH "/usr/local/arm-linux/")
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

but after "mkdir build && cd build && ccmake. && cmake .. && make" ,error occurs as follow:
.../zxing-cpp-master/core/src/bigint/BigInteger.cc: In function X convertBigUnsignedToPrimitiveAccess(const BigUnsigned&)': .../zxing-cpp-master/core/src/bigint/BigInteger.cc:89: parse error before>' token
make[2]: *** [CMakeFiles/libzxing.dir/core/src/bigint/BigInteger.cc.o] Error 1
make[1]: *** [CMakeFiles/libzxing.dir/all] Error 2
make: *** [all] Error 2

what should I do to make it OK?

Execute multiple instances of zxing binary in parallel?

I read in a previous issue that the library is not thread safe. In my case I'm not making use of the library directly (yet), but instead just executing the zxing binary and eating the output.

If multiple threads may execute zxing processes in parallel, is it still safe? Or does this need to be protected against (presumably because the process make use of some shared resource)?

Thanks.

Problem with datamatrix area detection

Hi, I have a problem with the datamatrix below.

barcode_ko
There is a bug in the detect method of the WhiteRectangleDetector object. Since my DataMatrix contains a white rectangular area, it detects this area as the datamatrix area instead of keeping increasinf the area to the whole datamatrix. The barcode detection then fails. The area detected as the datamatrix is in red on the image below :
barcode_ko_detected
Is there a way to improve the datamatrix area detection ?

can't decode code93 with the c++ version

is there anyone who used this for code93 decoding? i have tested zxing-cpp for codebar、EAN、code39、code128 and it can do for these codes, but it can't work for code93?
what's the problem?

Not compiling under VS 2013 IDE

Project generated by CMake: cmake -G "Visual Studio 12 2013" ..\ do not compile in VS2013 giving errors:

  • error C2039: 'max' : is not a member of 'std'
  • error C3861: 'max': identifier not found

Compilation in VS2012 IDE as well as by nmake (for VC2012 and VC2013) runs fine. I am not sure if it is problem with my config or cmake (tested with 3.1.x) or maybe something changed in IDE.

Can be fixed by adding #include <algorithm> in sources.

Not thread safe?

As there are so many static functions and members, I think zxing is not thread safe.
Any body know how to make it thread safe?

warning: shifting a negative signed value is undefined

clang-6 prints these warnings that seem important:

/usr/ports/textproc/zxing-cpp/work/zxing-cpp-e0e40dd/cli/src/jpgd.cpp:568:170: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
static const int s_extend_offset[16] = { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
                                                                                                                                                                     ~~~~^
/usr/ports/textproc/zxing-cpp/work/zxing-cpp-e0e40dd/cli/src/jpgd.cpp:568:185: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
static const int s_extend_offset[16] = { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
                                                                                                                                                                                    ~~~~^
/usr/ports/textproc/zxing-cpp/work/zxing-cpp-e0e40dd/cli/src/jpgd.cpp:568:201: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
static const int s_extend_offset[16] = { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
                                                                                                                                                                                                    ~~~~^
/usr/ports/textproc/zxing-cpp/work/zxing-cpp-e0e40dd/cli/src/jpgd.cpp:568:217: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
static const int s_extend_offset[16] = { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
                                                                                                                                                                                                                    ~~~~^
/usr/ports/textproc/zxing-cpp/work/zxing-cpp-e0e40dd/cli/src/jpgd.cpp:568:233: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
static const int s_extend_offset[16] = { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
                                                                                                                                                                                                                                    ~~~~^

FreeBSD

Detecting QR code before all 3 centers.

Hi, I'm not entirely sure if what I'm asking is possible. Is there any way for ZXing to alert me when at least 2 centers of a QRcode are detected? From what I managed to understand from the code, if at least 3 centers of the QRcode are detected ZXing will attempt to decode the QRcode and return the information. What I want is for ZXing to alert me when 2 centers are detected, without attempting to decode it obviously.

Memory leaks

It has a lot of memory leaks from every file it read. I have to read hundreds of barcodes, but after first hundred it crashes with bad_alloc. ~ at 120th barcode it have leaks about 2Gb, so it crashs.

Maybe if I will understand how does this lib works inside I'll try to fix it. But if anybody from porters will solve this problem it will be great

Display zxing::BinaryBitmap

Hi,
is there a way to display the Binary Bitmap?
Some of the images I get are blurry, so I am working on sharpening the image. I also tried binarizing the image before I send it in, so I can see the output.
Is there a way to visualize the Binary Bitmap?

Thank you!

Build fails: Source directory is polluted

I am getting this error:

-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:13 (message):
  Source directory is polluted:

    * remove CMakeCache.txt
    * remove CMakeFiles directory

on FreeBSD.

trouble with exception handling on Android NDK 12r with clang compiler

I used gcc compile,but google deprecated it in android ndk. I switched to clang and got this crash

Abort message: '/Volumes/Android/buildbot/src/android/ndk-r12-release/ndk/sources/cxx-stl/llvm-libc++abi/libcxxabi/src/abort_message.cpp:74: void abort_message(const char *, ...): assertion "terminating with uncaught exception of type zxing::ReaderException: Could not find three finder patterns" failed'
08-29 17:47:58.711 3035-3035/? A/DEBUG: r0 00000000 r1 0000651c r2 00000006 r3 d7c7f978
08-29 17:47:58.711 3035-3035/? A/DEBUG: r4 d7c7f980 r5 d7c7f930 r6 00000000 r7 0000010c
08-29 17:47:58.711 3035-3035/? A/DEBUG: r8 dc697ad1 r9 d7c7f734 sl d7c7f7bc fp d7c7f7b8
08-29 17:47:58.711 3035-3035/? A/DEBUG: ip 00000006 sp d7c7f198 lr f6f6f365 pc f6f71754 cpsr 400d0010
08-29 17:47:58.721 3035-3035/? A/DEBUG: backtrace:
08-29 17:47:58.721 3035-3035/? A/DEBUG: #00 pc 00042754 /system/lib/libc.so (tgkill+12)
08-29 17:47:58.721 3035-3035/? A/DEBUG: #1 pc 00040361 /system/lib/libc.so (pthread_kill+32)
08-29 17:47:58.721 3035-3035/? A/DEBUG: #2 pc 0001ca9b /system/lib/libc.so (raise+10)
08-29 17:47:58.721 3035-3035/? A/DEBUG: #3 pc 00019d19 /system/lib/libc.so (__libc_android_abort+34)
08-29 17:47:58.721 3035-3035/? A/DEBUG: #4 pc 0001755c /system/lib/libc.so (abort+4)
08-29 17:47:58.721 3035-3035/? A/DEBUG: #5 pc 0001b6af /system/lib/libc.so (__libc_fatal+16)
08-29 17:47:58.721 3035-3035/? A/DEBUG: #6 pc 00019da1 /system/lib/libc.so (__assert2+20)
08-29 17:47:58.721 3035-3035/? A/DEBUG: #7 pc 000d40ad /data/app/com.amudo.bear-1/lib/arm/libzxing.so
08-29 17:47:58.721 3035-3035/? A/DEBUG: #8 pc 000d4171 /data/app/com.amudo.bear-1/lib/arm/libzxing.so
08-29 17:47:58.721 3035-3035/? A/DEBUG: #9 pc 000d2a19 /data/app/com.amudo.bear-1/lib/arm/libzxing.so
08-29 17:47:58.721 3035-3035/? A/DEBUG: #10 pc 000d23a1 /data/app/com.amudo.bear-1/lib/arm/libzxing.so (__cxa_throw+96)
08-29 17:47:58.721 3035-3035/? A/DEBUG: #11 pc 000967a3 /data/app/com.amudo.bear-1/lib/arm/libzxing.so (_ZN5zxing6qrcode19FinderPatternFinder18selectBestPatternsEv+794)
08-29 17:47:58.721 3035-3035/? A/DEBUG: #12 pc 000972db /data/app/com.amudo.bear-1/lib/arm/libzxing.so (_ZN5zxing6qrcode19FinderPatternFinder4findERKNS_11DecodeHintsE+930)
08-29 17:47:58.721 3035-3035/? A/DEBUG: #13 pc 00093c73 /data/app/com.amudo.bear-1/lib/arm/libzxing.so (_ZN5zxing6qrcode8Detector6detectERKNS_11DecodeHintsE+206)
08-29 17:47:58.721 3035-3035/? A/DEBUG: #14 pc 0009cb19 /data/app/com.amudo.bear-1/lib/arm/libzxing.so (_ZN5zxing6qrcode12QRCodeReader6decodeENS_3RefINS_12BinaryBitmapEEENS_11DecodeHintsE+76)
08-29 17:47:58.721 3035-3035/? A/DEBUG: #15 pc 0017f1e8 /data/app/com.amudo.bear-1/lib/arm/libBEARGL.so
08-29 17:47:58.721 3035-3035/? A/DEBUG: #16 pc 0003fc63 /system/lib/libc.so (_ZL15__pthread_startPv+30)
08-29 17:47:58.721 3035-3035/? A/DEBUG: #17 pc 0001a39b /system/lib/libc.so (__start_thread+6)

i'm using this part of code

try{ ... }catch (zxing::Exception& e) {}
to handle exceptions

Manually-specified variables were not used by the project:

I am trying to build zxipg to use in out application (Feathercoin). Something has happened in Ubuntu 16.04, where our usual build from source has failed (although we already moved over to Qt5) it seems to an issue with -

   -D_GLIBCXX_USE_CXX11_ABI=0

or =1 , which needs to be set the same for both builds, I get the error message :

Manually-specified variables were not used by the project:

 _GLIBCXX_USE_CXX11_ABI

The method which worked before, copying compiled zxing headers to /src/zxing/ sub directory/

we now get error :

src/qt/snapwidget.cpp:71: undefined reference to `zxing::String::getTextabi:cxx11 const'

crosscompile

hello,
please help to crosscompile your app,
at first i'm make and activate (use export) cpu toolchain,
next i'm make build as i686 linux by default,
and correct CMakeCCompiler.cmake and CMakeCXXCompile.cmake ( make changes about new compile and ar,ld, and other like this arm-linux-gcc)
then i'm compile and install at /usr/local/lib iconv library compiled by arm,
at now if i'm make software get this text:
root@ubuntu:/home/zxing-cpp-master/build# make
[ 1%] Building CXX object CMakeFiles/libzxing.dir/core/src/zxing/aztec/decoder/Decoder.cpp.o
/home/zxing-cpp-master/core/src/zxing/aztec/decoder/Decoder.cpp:24:19: error: iconv.h: No such file or directory
/home/zxing-cpp-master/core/src/zxing/aztec/decoder/Decoder.cpp: In function 'void::add(std::string&, char)':
/home/zxing-cpp-master/core/src/zxing/aztec/decoder/Decoder.cpp:53: error: 'iconv_t' was not declared in this scope
/home/zxing-cpp-master/core/src/zxing/aztec/decoder/Decoder.cpp:53: error: expected `;' before 'ic'
/home/zxing-cpp-master/core/src/zxing/aztec/decoder/Decoder.cpp:54: error: 'ic' was not declared in this scope
/home/zxing-cpp-master/core/src/zxing/aztec/decoder/Decoder.cpp:54: error: 'iconv' was not declared in this scope
/home/zxing-cpp-master/core/src/zxing/aztec/decoder/Decoder.cpp:55: error: 'iconv_close' was not declared in this scope
make[2]: *** [CMakeFiles/libzxing.dir/core/src/zxing/aztec/decoder/Decoder.cpp.o] Error 1
make[1]: *** [CMakeFiles/libzxing.dir/all] Error 2
make: *** [all] Error 2

how to agree compiled library and doing next?
Thank's

zxing dead loop while detecting qrcode

There is a server for image transferring. when an image comes to system, it is detected by zxing for qrcode. The server works well most of the time. Sometime, there happens a dead loop. The call stack is as follows.
Thread 1 (process 47568):
#0 0x000000000053c222 in __gnu_cxx::__normal_iteratorzxing::Ref<zxing::qrcode::FinderPattern, std::vectorzxing::Ref<zxing::qrcode::FinderPattern, std::allocatorzxing::Ref<zxing::qrcode::FinderPattern > > >::__normal_iterator(zxing::Refzxing::qrcode::FinderPattern const&) ()
#1 0x000000000053c27b in std::vectorzxing::Ref<zxing::qrcode::FinderPattern, std::allocatorzxing::Ref<zxing::qrcode::FinderPattern > >::begin() ()
#2 0x000000000053f5d0 in std::vectorzxing::Ref<zxing::qrcode::FinderPattern, std::allocatorzxing::Ref<zxing::qrcode::FinderPattern > >::_M_insert_aux(__gnu_cxx::__normal_iteratorzxing::Ref<zxing::qrcode::FinderPattern, std::vectorzxing::Ref<zxing::qrcode::FinderPattern, std::allocatorzxing::Ref<zxing::qrcode::FinderPattern > > >, zxing::Refzxing::qrcode::FinderPattern const&) ()
#3 0x000000000053f7fa in std::vectorzxing::Ref<zxing::qrcode::FinderPattern, std::allocatorzxing::Ref<zxing::qrcode::FinderPattern > >::push_back(zxing::Refzxing::qrcode::FinderPattern const&) ()
#4 0x000000000053b08e in zxing::multi::MultiFinderPatternFinder::selectBestPatterns() ()
#5 0x000000000053bcd2 in zxing::multi::MultiFinderPatternFinder::findMulti(zxing::DecodeHints const&) ()
#6 0x00000000005396b3 in zxing::multi::MultiDetector::detectMulti(zxing::DecodeHints) ()
#7 0x0000000000536da0 in zxing::multi::QRCodeMultiReader::decodeMultiple(zxing::Refzxing::BinaryBitmap, zxing::DecodeHints) ()
#8 0x0000000000501770 in BarcodeDecoder::decode(std::basic_string, std::allocator > const&, unsigned char, unsigned long, std::basic_string, std::allocator >&) ()
#9 0x000000000047dc1a in WWS::FtsHandler::onSendAck(unsigned long) ()
#10 0x000000000047fd80 in WWS::FtsHandler::onPackData(char const, unsigned long) ()
#11 0x0000000000480090 in WWS::FtsHandler::onPackHead(char const, unsigned long) ()
#12 0x00000000004800eb in WWS::FtsHandler::onData(char const, unsigned long) ()
#13 0x0000000000480334 in WWS::FtsHandler::onRecv(char const, unsigned long) ()
#14 0x00000000004bce92 in WWS::Asynchat::onCanRead() ()
#15 0x00000000004c6c79 in WWS::Poller::poll(int) ()
#16 0x00000000004c9e93 in WWS::PollerThread::thread() ()
#17 0x00000000004b20b4 in WWS::threadFunction(void*) ()
#18 0x00007f0a758a873d in start_thread () from /lib64/libpthread.so.0
#19 0x0000003faa2d44bd in clone () from /lib64/libc.so.6

[Q] Custom barcode zebra format

Hello
I wonder if it's possible to create a custom barcode that will be unique to me?
can i create another format of my own using predefined symbols and spaces and line widths ?

let say i want to set that
e.g:
| || | ||| | = 1
|| || | | ||| = 2

and to be able to use zxing to read this custom barcode?

Thanks a lot

search-multi: "This luminance source does not support cropping."

I've been using zxing-cpp for a while now and it seems to work just fine when trying to read a single code that is pre-cropped (in my case, a data-matrix). However, if I have an image that potentially contains multiple codes, I cannot figure out how to get zxing to decode these. If I execute:

./zxing --search-multi --try-harder --more -v myimage.png

I get the output:

Hybrid binarizer failed: zxing::IllegalArgumentException: This luminance source does not support cropping.
Global binarizer failed: zxing::IllegalArgumentException: This luminance source does not support cropping.

What exactly does this mean and is there any way of working around it?

Interestingly, if I process the exact same image (which contains one data-matrix and one bar-code) without the search-multi argument, it works (./zxing myimage.png)! (I assume that in this case it extracts the first code that it finds and ignores the rest?).

Any help would be appreciated.

GenericGFPoly::isZero() BAD_ACCESS crash

Yet another baby from my 5 million barcodes test..

Crashed Thread:        134  QThread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000010

VM Regions Near 0x10:
--> 
    __TEXT                 000000010771e000-0000000107c16000 [ 5088K] r-x/rwx SM=COW  /Users/USER/Desktop/pixel_v2.205.app/Contents/MacOS/test

Thread 134 Crashed:: QThread
0   com.test            0x0000000107a240ca zxing::Array<int>::operator[](int) + 42
1   com.test            0x0000000107a2382f zxing::ArrayRef<int>::operator[](int) + 31
2   com.test            0x0000000107a297ee zxing::GenericGFPoly::isZero() + 30
3   com.test            0x0000000107a29a66 zxing::GenericGFPoly::addOrSubtract(zxing::Ref<zxing::GenericGFPoly>) + 198
4   com.test            0x0000000107a2c69d zxing::ReedSolomonDecoder::runEuclideanAlgorithm(zxing::Ref<zxing::GenericGFPoly>, zxing::Ref<zxing::GenericGFPoly>, int) + 1565
5   com.test            0x0000000107a2ba50 zxing::ReedSolomonDecoder::decode(zxing::ArrayRef<int>, int) + 992
6   com.test            0x0000000107a38bb2 zxing::datamatrix::Decoder::correctErrors(zxing::ArrayRef<char>, int) + 242
7   com.test            0x0000000107a390da zxing::datamatrix::Decoder::decode(zxing::Ref<zxing::BitMatrix>) + 954
8   com.test            0x0000000107a3032f zxing::datamatrix::DataMatrixReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 239
9   com.test            0x0000000107a5258a zxing::MultiFormatReader::decodeInternal(zxing::Ref<zxing::BinaryBitmap>) + 250
10  com.test            0x0000000107a52716 zxing::MultiFormatReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 118
11  com.test            0x0000000107995dd0 test::decode_image_barcode(cv::Mat const?, std::__1::vector<int, std::__1::allocator<int> >) + 1680
1

So this goes wrong in GenericGFPoly::isZero()

bool GenericGFPoly::isZero() {
  return coefficients_[0] == 0;
}

Which is called from

Ref<GenericGFPoly> GenericGFPoly::addOrSubtract(Ref<zxing::GenericGFPoly> other) {
  if (!(field_.object_ == other->field_.object_)) {
    throw IllegalArgumentException("GenericGFPolys do not have same GenericGF field");
  }
  if (isZero()) {
    return other;
  }
  if (other->isZero()) {
    return Ref<GenericGFPoly>(this);
  }

  ArrayRef<int> smallerCoefficients = coefficients_;
  ArrayRef<int> largerCoefficients = other->getCoefficients();
  if (smallerCoefficients.size() > largerCoefficients.size()) {
    ArrayRef<int> temp = smallerCoefficients;
    smallerCoefficients = largerCoefficients;
    largerCoefficients = temp;
  }

  ArrayRef<int> sumDiff(new Array<int>(largerCoefficients.size()));
  int lengthDiff = largerCoefficients.size() - smallerCoefficients.size();
  // Copy high-order terms only found in higher-degree polynomial's coefficients
  for (int i = 0; i < lengthDiff; i++) {
    sumDiff[i] = largerCoefficients[i];
  }

  for (int i = lengthDiff; i < (int)largerCoefficients.size(); i++) {
    sumDiff[i] = GenericGF::addOrSubtract(smallerCoefficients[i-lengthDiff],
                                          largerCoefficients[i]);
  }

  return Ref<GenericGFPoly>(new GenericGFPoly(field_, sumDiff));
}

From the error I guess coefficients_[0] doesnt exist, which gets initialized here, with his constructor

GenericGFPoly::GenericGFPoly(GenericGF &field,
                             ArrayRef<int> coefficients)
  :  field_(field) {
  if (coefficients->size() == 0) {
    throw IllegalArgumentException("need coefficients");
  }
  int coefficientsLength = coefficients->size();
  if (coefficientsLength > 1 && coefficients[0] == 0) {
    // Leading term must be non-zero for anything except the constant polynomial "0"
    int firstNonZero = 1;
    while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0) {
      firstNonZero++;
    }
    if (firstNonZero == coefficientsLength) {
      coefficients_ = field.getZero()->getCoefficients();
    } else {
      coefficients_ = ArrayRef<int>(new Array<int>(coefficientsLength-firstNonZero));
      for (int i = 0; i < (int)coefficients_->size(); i++) {
        coefficients_[i] = coefficients[i + firstNonZero];
      }
    }
  } else {
    coefficients_ = coefficients;
  }
}

So i guess coefficients has to be declared, or it throws an error, which it does not. So then coefficients_ is not intialized. Then what.. Anyone understands this code better than I?

Memory leak using HybridBinarizer

I've noticed quite a large memory leak using the Hybrid Binarizer (at least under certain circumstances). I've started debugging but so far haven't figured it out. Any ideas about this? Below is a repro (will eat up several GB quickly) as well as some valgrind output. Any help would be appreciated.

Valgrind:

==14603== 13,160,000 bytes in 7 blocks are possibly lost in loss record 1,401 of 1,408
==14603==    at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14603==    by 0x4E7FC28: zxing::BitMatrix::BitMatrix(int, int) (in /usr/local/lib/libzxing.so)
==14603==    by 0x4E88FFB: zxing::HybridBinarizer::getBlackMatrix() (in /usr/local/lib/libzxing.so)
==14603==    by 0x4E7E771: zxing::BinaryBitmap::getBlackMatrix() (in /usr/local/lib/libzxing.so)
==14603==    by 0x4EE05F6: zxing::qrcode::QRCodeReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) (in /usr/local/lib/libzxing.so)
==14603==    by 0x4EA9211: zxing::MultiFormatReader::decodeInternal(zxing::Ref<zxing::BinaryBitmap>) (in /usr/local/lib/libzxing.so)
==14603==    by 0x4EAA40C: zxing::MultiFormatReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) (in /usr/local/lib/libzxing.so)
==14603==    by 0x113D31: read_image(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, zxing::Ref<zxing::LuminanceSource>, bool, bool, bool) (in /media/user/data/doc/dev/test/zxing-opencv/build/zxtest)
==14603==    by 0x114679: decodeDataMatrix[abi:cxx11](cv::Mat const&) (in /media/user/data/doc/dev/test/zxing-opencv/build/zxtest)
==14603==    by 0x1148B4: main (in /media/user/data/doc/dev/test/zxing-opencv/build/zxtest)
==14603== 
==14603== 148,527,568 (4,128 direct, 148,523,440 indirect) bytes in 86 blocks are definitely lost in loss record 1,406 of 1,408
==14603==    at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14603==    by 0x4E88FEA: zxing::HybridBinarizer::getBlackMatrix() (in /usr/local/lib/libzxing.so)
==14603==    by 0x4E7E771: zxing::BinaryBitmap::getBlackMatrix() (in /usr/local/lib/libzxing.so)
==14603==    by 0x4EE05F6: zxing::qrcode::QRCodeReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) (in /usr/local/lib/libzxing.so)
==14603==    by 0x4EA9211: zxing::MultiFormatReader::decodeInternal(zxing::Ref<zxing::BinaryBitmap>) (in /usr/local/lib/libzxing.so)
==14603==    by 0x4EAA40C: zxing::MultiFormatReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) (in /usr/local/lib/libzxing.so)
==14603==    by 0x113D31: read_image(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, zxing::Ref<zxing::LuminanceSource>, bool, bool, bool) (in /media/user/data/doc/dev/test/zxing-opencv/build/zxtest)
==14603==    by 0x114679: decodeDataMatrix[abi:cxx11](cv::Mat const&) (in /media/user/data/doc/dev/test/zxing-opencv/build/zxtest)
==14603==    by 0x1148B4: main (in /media/user/data/doc/dev/test/zxing-opencv/build/zxtest)
==14603== 
==14603== 152,287,568 (4,128 direct, 152,283,440 indirect) bytes in 86 blocks are definitely lost in loss record 1,408 of 1,408
==14603==    at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14603==    by 0x4E88FEA: zxing::HybridBinarizer::getBlackMatrix() (in /usr/local/lib/libzxing.so)
==14603==    by 0x4E7E771: zxing::BinaryBitmap::getBlackMatrix() (in /usr/local/lib/libzxing.so)
==14603==    by 0x4EE05F6: zxing::qrcode::QRCodeReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) (in /usr/local/lib/libzxing.so)
==14603==    by 0x4EA9211: zxing::MultiFormatReader::decodeInternal(zxing::Ref<zxing::BinaryBitmap>) (in /usr/local/lib/libzxing.so)
==14603==    by 0x4EAA40C: zxing::MultiFormatReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) (in /usr/local/lib/libzxing.so)
==14603==    by 0x113D31: read_image(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, zxing::Ref<zxing::LuminanceSource>, bool, bool, bool) (in /media/user/data/doc/dev/test/zxing-opencv/build/zxtest)
==14603==    by 0x11454D: decodeDataMatrix[abi:cxx11](cv::Mat const&) (in /media/user/data/doc/dev/test/zxing-opencv/build/zxtest)
==14603==    by 0x1148B4: main (in /media/user/data/doc/dev/test/zxing-opencv/build/zxtest)

Repro:

#include <thread>
#include <exception>
#include <iostream>
#include <opencv2/opencv.hpp>
#include <zxing/common/Counted.h>
#include <zxing/Binarizer.h>
#include <zxing/MultiFormatReader.h>
#include <zxing/Result.h>
#include <zxing/ReaderException.h>
#include <zxing/common/GlobalHistogramBinarizer.h>
#include <zxing/Exception.h>
#include <zxing/common/IllegalArgumentException.h>
#include <zxing/BinaryBitmap.h>
#include <zxing/DecodeHints.h>
#include <zxing/qrcode/QRCodeReader.h>
#include <zxing/MultiFormatReader.h>
#include <zxing/MatSource.h>
#include <zxing/common/HybridBinarizer.h>
#include <zxing/qrcode/QRCodeReader.h>
#include <zxing/multi/qrcode/QRCodeMultiReader.h>
#include <zxing/multi/ByQuadrantReader.h>
#include <zxing/multi/MultipleBarcodeReader.h>
#include <zxing/multi/GenericMultipleBarcodeReader.h>


using namespace cv;
using namespace std;
using namespace zxing;
using namespace zxing::multi;
using namespace zxing::qrcode;



void decodeDataMatrix(const Mat& imgOrig) {
  Mat img;
  cvtColor(imgOrig, img, CV_RGB2GRAY);
  Ref<LuminanceSource> source = MatSource::create(img);

  try {
    Ref<Binarizer> binarizer;
    binarizer = new HybridBinarizer(source);
    DecodeHints hints(DecodeHints::DEFAULT_HINT);
    hints.setTryHarder(false);
    Ref<BinaryBitmap> binary(new BinaryBitmap(binarizer));

    // Decode single code
    Ref<Reader> reader(new MultiFormatReader);
    reader->decode(binary, hints);
    //results = vector<Ref<Result> >(1, reader->decode(binary, hints));
  } catch (const ReaderException& e) {
    cout << "zxing::ReaderException: " << string(e.what()) << endl;
  } catch (const zxing::IllegalArgumentException& e) {
    cout << "zxing::IllegalArgumentException: " << string(e.what()) << endl;
  } catch (const zxing::Exception& e) {
    cout << "zxing::Exception: " << string(e.what()) << endl;
  } catch (const std::exception& e) {
    cout << "std::exception: " << string(e.what()) << endl;
  } catch(...) {
    cout << "exception" << endl;
  }
}


int main() {

    while(true) {
        Mat mat(5000, 3000, CV_8UC3, Scalar(0,0,0));
        decodeDataMatrix(mat);
        cout << "..." << endl;
    }

    return 0;
}

Darwin build fails

Trying to build on OS X Mojave after brew install opencv fails:

$ mkdir build
$ cd build
$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
$ make
[  1%] Building CXX object CMakeFiles/libzxing.dir/opencv/src/zxing/MatSource.cpp.o
In file included from /Users/kousu/src/zxing-cpp/opencv/src/zxing/MatSource.cpp:17:
In file included from /Users/kousu/src/zxing-cpp/opencv/src/zxing/MatSource.h:21:
In file included from /usr/local/include/opencv4/opencv2/core/core.hpp:48:
In file included from /usr/local/include/opencv4/opencv2/core.hpp:52:
/usr/local/include/opencv4/opencv2/core/cvdef.h:656:4: error: "OpenCV 4.x+ requires enabled C++11 support"
#  error "OpenCV 4.x+ requires enabled C++11 support"
...
/usr/local/include/opencv4/opencv2/core/mat.hpp:1011:52: error: no template named 'initializer_list' in namespace 'std'
    template<typename _Tp> explicit Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list);
...

I think these are because Darwin's clang compiler isn't defaulting to C++11 fully.

Bad detection of DataMatrix

I know this project is in maintenance mode. However I found that the detection rate of QR codes is fairly robust but detecting DataMatrix codes is almost impossible.
Anyone know the reason for this? Has the Java part a better detector?

build error on win10 x64

when i have compiled the zxing cpp and generated a libzxing-debug.lib on win10 x64, and i used the lib and .h files in the zxing folder in my own project. But when i built the project, the error came as the following, (the more errors but i just listed some here, just same about the libzxing-debug.lib), what should i do to avoid this and success to run my project? a lot thanks for help!:

1>libzxing-debug.lib(OneDReader.obj) : error LNK2001: unresolved external symbol _purecall
1>libzxing-debug.lib(UPCEANReader.obj) : error LNK2001: unresolved external symbol _purecall
1>libzxing-debug.lib(DataMask.obj) : error LNK2001: unresolved external symbol _purecall
1>libzxing-debug.lib(MultiFormatReader.obj) : error LNK2001: unresolved external symbol _purecall
1>libzxing-debug.lib(QRCodeReader.obj) : error LNK2001: unresolved external symbol _purecall
1>libzxing-debug.lib(LuminanceSource.obj) : error LNK2001: unresolved external symbol _purecall
1>libzxing-debug.lib(Binarizer.obj) : error LNK2001: unresolved external symbol _purecall

image
there are lots of .cpp files named with the same name as the picture shows. Does it cause the build errors?

${OpenCV_LIBRARIES} needs to be added to zxing

It fails to link:

: && /usr/bin/c++  -O2 -pipe -fno-omit-frame-pointer -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -fno-omit-frame-pointer  -DLIBICONV_PLUG -std=c++11 -O2 -pipe -fno-omit-frame-pointer -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -fno-omit-frame-pointer  -DLIBICONV_PLUG  -fstack-protector CMakeFiles/zxing.dir/cli/src/ImageReaderSource.cpp.o CMakeFiles/zxing.dir/cli/src/jpgd.cpp.o CMakeFiles/zxing.dir/cli/src/lodepng.cpp.o CMakeFiles/zxing.dir/cli/src/main.cpp.o  -o zxing  -Wl,-rpath,/usr/ports/textproc/zxing-cpp/work/.build: libzxing.so -lc && :
libzxing.so: undefined reference to `cv::Mat::deallocate()'
libzxing.so: undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
libzxing.so: undefined reference to `cv::fastFree(void*)'

The FreeBSD port has this patch to fix this:

--- CMakeLists.txt.orig 2018-07-09 07:47:42 UTC
+++ CMakeLists.txt
@@ -83,7 +83,7 @@ file(GLOB_RECURSE ZXING_FILES
 )

 add_executable(zxing ${ZXING_FILES})
-target_link_libraries(zxing libzxing)
+target_link_libraries(zxing libzxing ${OpenCV_LIBRARIES})

 install(TARGETS zxing libzxing EXPORT zxing-targets
        LIBRARY DESTINATION lib

Working too slow on ARM64 cpu

When there is no qrcode, the scanning seems to be too slow on some arm64 cpu like Qualcomm Snapdrago 810, but works fine with armv7.
Anybody knows how to deal with this?

cannot decode EAN8, code93, UPC-E !!!???

i used the zxing c++ version to decode the following images, but it can work for the images about EAN8, UPC-E, but i cropped the barcode ROI for the image to decode and it doesn't work, what's the problem? i am a freshman in this and i hope i can get some help from you! Thank s a lot for your help! The images and their ROIs are listed in the following, and my code also:

EAN8 image:
EAN8
and its ROI:
ROI_EAN8

UPC-E image:
upca
and its ROI:
ROI_upca

#include "zxing_decode.h"

const char* my_code_type[] = {
	"NONE",
	"AZTEC",
	"CODABAR",
	"CODE_39",
	"CODE_93",
	"CODE_128",
	"DATA_MATRIX",
	"EAN_8",
	"EAN_13",
	"ITF"
	"MAXICODE",
	"PDF_417",
	"QR_CODE",
	"RSS_14",
	"RSS_EXPANDED",
	"UPC_A",
	"UPC_E",
	"UPC_EAN_EXTENSION"
};

bool decode_by_zxing(cv::Mat& matGray, std::string& code, std::string& code_type)
{
	zxing::Ref<zxing::LuminanceSource> source(new MatSource(matGray));
	int width = source->getWidth();
	int height = source->getHeight();
	fprintf(stderr, "image width: %d, height: %d\n", width, height);

	//zxing::Ref<zxing::Reader> reader;
	//reader.reset(new zxing::oned::EAN13Reader);
	//reader.reset(new zxing::oned::Code128Reader);
	zxing::oned::MultiFormatOneDReader reader(zxing::DecodeHints::DEFAULT_HINT);

	zxing::Ref<zxing::Binarizer> binarizer(new zxing::HybridBinarizer(source));
	//zxing::Ref<zxing::Binarizer> binarizer(new zxing::);
	zxing::Ref<zxing::BinaryBitmap> bitmap(new zxing::BinaryBitmap(binarizer));
	try
	{
		zxing::Ref<zxing::Result> result(reader.decode(bitmap, zxing::DecodeHints(zxing::DecodeHints::DEFAULT_HINT)));
		//zxing::Ref<zxing::Result> result(zxing::MultiFormatReader().decode(bitmap, zxing::DecodeHints(zxing::DecodeHints::EAN_13_HINT)));
		code = result->getText()->getText();
		code_type = my_code_type[result->getBarcodeFormat().value];
		/*fprintf(stdout, "recognization result: %s\n", code.c_str());
		std::cout << "barcode type is: " << my_code_type[result->getBarcodeFormat().value] << "\n\n";
		*/
		return true;
	}
	catch (zxing::Exception& e)
	{
		//std::cout << "Error: " << e.what() << "\n";
		return false;
	}
	
}

ImageReader using jpgd under GPL 3.0 license

Hello,

the class ImageReader is using jpgd which is released under the GPL 3.0 License. This means you cannot release this library under the Apache 2.0 due to the conditions in the GPL License. Can you please change the used jpg decoder?

segfault on OS X Mojave

I'm getting a segfault if I use GenericMultipleBarcodeReader. I'm on OS X Mojave and I installed zxing-cpp from brew.

It triggers on this image:

code.png

$ zxing --search-multi code.png 
Segmentation fault: 11

It does not trigger on this image:

table.png

$ zxing --search-multi table.png 
decoding failed

( I discovered this while trying to use the python wrapper: lubo/zxinglight#5 )

It seems like for some reason the thing ..compiled..wrong?? It's crashing in GenericMultipleBarcodeReader::translateResultPoints(). The disassembly is showing that it's trying to execute %rdi=*((void*)0x18) which doesn't make any sense.

$ lldb -- zxing --search-multi code.png 
(lldb) target create "zxing"
Current executable set to 'zxing' (x86_64).
(lldb) settings set -- target.run-args  "--search-multi" "code.png"
(lldb) run
Process 15820 launched: '/usr/local/bin/zxing' (x86_64)
Process 15820 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
    frame #0: 0x00000001000483af zxing`zxing::multi::GenericMultipleBarcodeReader::translateResultPoints(zxing::Ref<zxing::Result>, int, int) + 249
zxing`zxing::multi::GenericMultipleBarcodeReader::translateResultPoints:
->  0x1000483af <+249>: movq   0x18, %rdi
    0x1000483b7 <+257>: cmpq   0x20, %rdi
    0x1000483bf <+265>: je     0x1000483dc               ; <+294>
    0x1000483c1 <+267>: movq   $0x0, (%rdi)
Target 0: (zxing) stopped.
(lldb)
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
  * frame #0: 0x00000001000483af zxing`zxing::multi::GenericMultipleBarcodeReader::translateResultPoints(zxing::Ref<zxing::Result>, int, int) + 249
    frame #1: 0x00000001000478ef zxing`zxing::multi::GenericMultipleBarcodeReader::doDecodeMultiple(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints, std::__1::vector<zxing::Ref<zxing::Result>, std::__1::allocator<zxing::Ref<zxing::Result> > >&, int, int, int) + 315
    frame #2: 0x00000001000476c0 zxing`zxing::multi::GenericMultipleBarcodeReader::decodeMultiple(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 116
    frame #3: 0x000000010001fc16 zxing`decode_multi(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 123
    frame #4: 0x000000010001fea2 zxing`read_image(zxing::Ref<zxing::LuminanceSource>, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 450
    frame #5: 0x0000000100022251 zxing`main + 2747
    frame #6: 0x00007fff5c2b0ed9 libdyld.dylib`start + 1
    frame #7: 0x00007fff5c2b0ed9 libdyld.dylib`start + 1

GenericGF::multiply(int,int) BAD_ACCESS crash

Hi guys, i am doing some test on a huge barcode batch. It crashes often on multiply for some reason, see the trace below. Can't get my head around why, any ideas?

Crashed Thread: 125 QThread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00007ffe73094600

VM Regions Near 0x7ffe73094600:
 MALLOC_SMALL 00007ffcbf825000-00007ffcc0000000 [ 8044K] rw-/rwx SM=ZER 
--> 
 STACK GUARD 00007fff4ff8d000-00007fff5378d000 [ 56.0M] ---/rwx SM=NUL stack guard for thread 0

(...)

Thread 125 Crashed:: QThread
0 com.test 0x000000010bf6c4de zxing::GenericGF::multiply(int, int) + 62
1 com.test 0x000000010bf6d04f zxing::GenericGFPoly::evaluateAt(int) + 175
2 com.test 0x000000010bf6e80d zxing::ReedSolomonDecoder::decode(zxing::ArrayRef<int>, int) + 269
3 com.test 0x000000010bf7604e zxing::datamatrix::Decoder::correctErrors(zxing::ArrayRef<char>, int) + 414
4 com.test 0x000000010bf76448 zxing::datamatrix::Decoder::decode(zxing::Ref<zxing::BitMatrix>) + 648
5 com.test 0x000000010bf710e9 zxing::datamatrix::DataMatrixReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 137
6 com.test 0x000000010bf83374 zxing::MultiFormatReader::decodeInternal(zxing::Ref<zxing::BinaryBitmap>) + 148
7 com.test 0x000000010bf83553 zxing::MultiFormatReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 131
8 com.test 0x000000010beeac50 scanprocessor::decode_image_barcode(cv::Mat const?, std::__1::vector<int, std::__1::allocator<int> >) + 1680
9 com.test 0x000000010becc37b scanprocessor::getBarcodes(cv::Mat, double, std::__1::vector<int, std::__1::allocator<int> >, int) + 9739
10 com.test 0x000000010beb7ba7 scanprocessor::process(int, _CameraFile*, int, int, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 49575
11 com.test 0x000000010bcb0fce scanprocessor::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 1982
12 QtCore 0x000000010ed22743 QObject::event(QEvent*) + 755
13 QtWidgets 0x000000010df9e98b QApplicationPrivate::notify_helper(QObject*, QEvent*) + 251
14 QtWidgets 0x000000010dfa1c0c QApplication::notify(QObject*, QEvent*) + 7964
15 QtCore 0x000000010ecf7fab QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 987
16 QtCore 0x000000010ed57e38 postEventSourceDispatch(_GSource*, int (*)(void*), void*) + 24
17 libglib-2.0.0.dylib 0x00000001118d8728 g_main_context_dispatch + 282
18 libglib-2.0.0.dylib 0x00000001118d8a0b g_main_context_iterate + 404
19 libglib-2.0.0.dylib 0x00000001118d8a63 g_main_context_iteration + 55
20 QtCore 0x000000010ed57331 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 97
21 QtCore 0x000000010ecf488d QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 381
22 QtCore 0x000000010eb34b15 QThread::exec() + 117
23 QtCore 0x000000010eb38679 QThreadPrivate::start(void*) + 313
24 libsystem_pthread.dylib 0x00007fff90484268 _pthread_body + 131
25 libsystem_pthread.dylib 0x00007fff904841e5 _pthread_start + 176
26 libsystem_pthread.dylib 0x00007fff9048241d thread_start + 13

Roll new release

A few years ago I packaged zxing for OpenBSD. Back then, the C++ app was part of the official upstream source.

I would like to update the package (which hasn’t been updated since 2.0) to this version. But in order to do that I would be most comfortable if:

  • there’s a tagged release version; I don’t generally package git master on projects because in many projects it’s not stable enough.
  • there’s a tarball provided with the release. Github lets you do that by attaching a file to a tag with the “releases” feature. (Github‐provided .tar.gzs aren’t guaranteed to have a stable checksum, don’t include submodules, don’t provide a pregenerated configure script, and can’t be signed with a GPG key—I realize those aren’t necessarily concerns with this project, but they’re why it’s good practice in general to provide your own tarballs.)

Thanks for preserving this project!

How to run this code ?

I am a newer to ubuntu, I don't know how to run this code. Can anyone tell me how to run it ? Thank you very much!

GenericGF::inverse(int) BAD_ACCESS crash

And another one-in-a-million crash.

Crashed Thread:        179  QThread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00007fa351185688

VM Regions Near 0x7fa351185688:
    MALLOC_NANO            0000658000000000-0000658000600000 [ 6144K] rw-/rwx SM=PRV  
--> 
    MALLOC_TINY            00007fa3b9c00000-00007fa3ba000000 [ 4096K] rw-/rwx SM=PRV  

Thread 179 Crashed:: QThread
0   com.test            0x00000001089aeaa2 zxing::GenericGF::inverse(int) + 210
1   com.test            0x00000001089b2447 zxing::ReedSolomonDecoder::runEuclideanAlgorithm(zxing::Ref<zxing::GenericGFPoly>, zxing::Ref<zxing::GenericGFPoly>, int) + 967
2   com.test            0x00000001089b1a50 zxing::ReedSolomonDecoder::decode(zxing::ArrayRef<int>, int) + 992
3   com.test            0x00000001089bebb2 zxing::datamatrix::Decoder::correctErrors(zxing::ArrayRef<char>, int) + 242
4   com.test            0x00000001089bf0da zxing::datamatrix::Decoder::decode(zxing::Ref<zxing::BitMatrix>) + 954
5   com.test            0x00000001089b632f zxing::datamatrix::DataMatrixReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 239
6   com.test            0x00000001089d858a zxing::MultiFormatReader::decodeInternal(zxing::Ref<zxing::BinaryBitmap>) + 250
7   com.test            0x00000001089d8716 zxing::MultiFormatReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 118

comes from GenericGF.cpp

int GenericGF::inverse(int a) {
  checkInit();
  if (a == 0) {
    throw IllegalArgumentException("Cannot calculate the inverse of 0");
  }
  return expTable[size - logTable[a] - 1];
}

Unable to read QR cord.

The JAVA version of ZXing can read, but the C++ version of ZXing cannot read.
The error message was "versionNumber must be between 1 and 40".
The QR cord made following cords in some site, but the result was the same.

  • version=1
  • level=M
  • data=RFHJ5FJSDZCNSESGE2WU

Does anyone know the solution ?
badqr

QT Creator build failure

I installed CMake and QT Creator 4.1.0 and after a fresh pull from the repo I'm getting a link error where it can't find libzxing. I haven't developed code under QT in a few years and it doesn't let me manually add the library for some reason. Anyway. Easier to ask questions first than to fix it in some nonstandard way.

libzxing.lib(LinesSampler.cpp.obj):-1: error: LNK2019: unresolved external symbol "protected: static int const zxing::pdf417::detector::LinesSampler::BARS_IN_SYMBOL" (?BARS_IN_SYMBOL@LinesSampler@detector@pdf417@zxing@@1hb) referenced in function "protected: static void __cdecl zxing::pdf417::detector::LinesSampler::linesMatrixToCodewords(class std::vector<class std::vector<int,class std::allocator >,class std::allocator<class std::vector<int,class std::allocator > > > &,int,class std::vector<float,class std::allocator > const &,class zxing::Ref,class std::vector<class std::vector<int,class std::allocator >,class std::allocator<class std::vector<int,class std::allocator > > > &)" (?linesMatrixToCodewords@LinesSampler@detector@pdf417@zxing@@KAXAEAV?$vector@V?$vector@HV?$allocator@H@std@@@std@@v?$allocator@V?$vector@HV?$allocator@H@std@@@std@@@2@@std@@HAEBV?$vector@MV?$allocator@M@std@@@6@V?$Ref@VBitMatrix@zxing@@@4@0@Z)

Add Install script to CMakelists.

For apple and linux, add something like this to Cmakelists?

INSTALL(FILES _build/libzxing.a DESTINATION /usr/local/lib/ )
INSTALL(FILES _build/zxing DESTINATION /usr/local/bin/ )
INSTALL(DIRECTORY core/src/ DESTINATION /usr/local/include FILES_MATCHING PATTERN "*.h" )

Teamwork

Hello together,

I've some minor bugfixes for the zxing-cpp version to share. Can I add my changes directly to the zxing-cpp repository or should I post it as an issue?

Best regards from germany,
Sebastian

Error in make install

I used Cmake for generating the build files, but when I make install appeared this message about the using of zxing::bolean.

C:\Users\rogge\Desktop\nuevo\zxing-cpp-master\build>mingw32-make install
[ 1%] Building CXX object CMakeFiles/libzxing.dir/core/src/zxing/InvertedLuminanceSource.cpp.obj
C:\Users\rogge\Desktop\nuevo\zxing-cpp-master\core\src\zxing\InvertedLuminanceSource.cpp:21:14: error: 'boolean' is already declared in this scope
using zxing::boolean;
^
CMakeFiles\libzxing.dir\build.make:1237: recipe for target 'CMakeFiles/libzxing.dir/core/src/zxing/InvertedLuminanceSource.cpp.obj' failed
mingw32-make[2]: *** [CMakeFiles/libzxing.dir/core/src/zxing/InvertedLuminanceSource.cpp.obj] Error 1
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/libzxing.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/libzxing.dir/all] Error 2
Makefile:128: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

C:\Users\rogge\Desktop\nuevo\zxing-cpp-master\build>

I wanna know what I have to change. Please help.

Fails to build shared libs

Getting these errors:

[1/1] : && /usr/bin/c++  -O2 -pipe -fno-omit-frame-pointer -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -fno-omit-frame-pointer  -DLIBICONV_PLUG -O2 -pipe -fno-omit-frame-pointer -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -fno-omit-frame-pointer  -DLIBICONV_PLUG  -fstack-protector CMakeFiles/zxing.dir/cli/src/ImageReaderSource.cpp.o CMakeFiles/zxing.dir/cli/src/jpgd.cpp.o CMakeFiles/zxing.dir/cli/src/lodepng.cpp.o CMakeFiles/zxing.dir/cli/src/main.cpp.o  -o zxing  -Wl,-rpath,/usr/ports/textproc/zxing-cpp/work/.build: libzxing.so -lc && :
FAILED: zxing 
: && /usr/bin/c++  -O2 -pipe -fno-omit-frame-pointer -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -fno-omit-frame-pointer  -DLIBICONV_PLUG -O2 -pipe -fno-omit-frame-pointer -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -fno-omit-frame-pointer  -DLIBICONV_PLUG  -fstack-protector CMakeFiles/zxing.dir/cli/src/ImageReaderSource.cpp.o CMakeFiles/zxing.dir/cli/src/jpgd.cpp.o CMakeFiles/zxing.dir/cli/src/lodepng.cpp.o CMakeFiles/zxing.dir/cli/src/main.cpp.o  -o zxing  -Wl,-rpath,/usr/ports/textproc/zxing-cpp/work/.build: libzxing.so -lc && :
libzxing.so: undefined reference to `cv::Mat::deallocate()'
libzxing.so: undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
libzxing.so: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
libzxing.so: undefined reference to `cv::Mat::copySize(cv::Mat const&)'
libzxing.so: undefined reference to `cv::fastFree(void*)'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.