ZXing compilieren



  • Hallo,
    ich versuche gerade die aktuelle ZXING lib mit meinem C Builder 2007 zu bauen.

    Habe dieses kleine Beispiel gefunden:
    http://wiki.ssrrsummerschool.org/doku.php?id=robocup2012:qrcode-cppexample

    #include <iostream>
    #include <stdlib.h>
    #include <stdint.h>
    #include <fstream>
    #include <string>
    #include <zxing/qrcode/QRCodeReader.h>
    #include <zxing/Exception.h>
    #include <zxing/common/GlobalHistogramBinarizer.h>
    #include <zxing/DecodeHints.h>
    #include "BufferBitmapSource.h"
    
    using namespace std; 
    using namespace zxing; 
    using namespace zxing::qrcode;
    using namespace qrviddec; 
    
    int main(int argc, char ** argv)
    {
    	try
    	{
    
    		// A buffer containing an image. In your code, this would be an image from your camera. In this 
    		// example, it's just an array containing the code for "Hello!". 
    		uint8_t buffer[] = 
    		{ 
    			255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    			255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255,  0 ,  0 ,  0 ,  0 ,  0 , 255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255, 
    			255,  0 , 255, 255, 255, 255, 255,  0 , 255, 255,  0 , 255,  0 , 255, 255,  0 , 255, 255, 255, 255, 255,  0 , 255, 
    			255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 255,  0 ,  0 , 255, 255, 255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 
    			255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 255,  0 ,  0 ,  0 , 255, 255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 
    			255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 255, 255,  0 , 255,  0 , 255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 
    			255,  0 , 255, 255, 255, 255, 255,  0 , 255, 255, 255, 255,  0 ,  0 , 255,  0 , 255, 255, 255, 255, 255,  0 , 255, 
    			255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255,  0 , 255,  0 , 255,  0 , 255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255, 
    			255, 255, 255, 255, 255, 255, 255, 255, 255,  0 ,  0 ,  0 ,  0 ,  0 , 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    			255,  0 ,  0 , 255,  0 ,  0 , 255,  0 , 255, 255,  0 ,  0 , 255,  0 , 255,  0 , 255, 255, 255, 255, 255,  0 , 255, 
    			255,  0 ,  0 ,  0 ,  0 ,  0 , 255, 255,  0 , 255, 255,  0 , 255,  0 , 255,  0 , 255,  0 ,  0 ,  0 , 255, 255, 255, 
    			255, 255, 255, 255, 255, 255, 255,  0 , 255,  0 ,  0 ,  0 , 255, 255,  0 ,  0 , 255,  0 , 255,  0 ,  0 ,  0 , 255, 
    			255, 255, 255,  0 ,  0 , 255, 255, 255,  0 ,  0 ,  0 , 255,  0 , 255, 255, 255, 255, 255, 255,  0 , 255, 255, 255, 
    			255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255, 255,  0 , 255, 255, 255, 255,  0 , 255, 255,  0 , 255,  0 , 255, 255, 
    			255, 255, 255, 255, 255, 255, 255, 255, 255,  0 ,  0 , 255,  0 ,  0 , 255, 255, 255, 255,  0 , 255,  0 ,  0 , 255, 
    			255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255, 255, 255,  0 , 255,  0 ,  0 ,  0 ,  0 ,  0 , 255,  0 , 255, 255, 255, 
    			255,  0 , 255, 255, 255, 255, 255,  0 , 255, 255,  0 ,  0 ,  0 ,  0 ,  0 , 255,  0 ,  0 ,  0 ,  0 , 255, 255, 255, 
    			255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255,  0 , 255, 255,  0 ,  0 , 255,  0 ,  0 , 255,  0 , 255,  0 ,  0 , 255, 
    			255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255,  0 , 255,  0 ,  0 ,  0 , 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    			255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 255,  0 ,  0 , 255, 255, 255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255, 
    			255,  0 , 255, 255, 255, 255, 255,  0 , 255,  0 , 255,  0 , 255, 255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255, 
    			255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255,  0 , 255,  0 ,  0 , 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    			255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
    		}; 
    		int width = 23; 
    		int height = 23; 
    
    		// Convert the buffer to something that the library understands. 
    		Ref<LuminanceSource> source (new BufferBitmapSource(width, height, buffer)); 
    
    		// Turn it into a binary image. 
    		Ref<Binarizer> binarizer (new GlobalHistogramBinarizer(source)); 
    		Ref<BinaryBitmap> image(new BinaryBitmap(binarizer));
    
    		// Tell the decoder to try as hard as possible. 
    		DecodeHints hints(DecodeHints::DEFAULT_HINT); 
    		hints.setTryHarder(true); 
    
    		// Perform the decoding. 
        QRCodeReader reader;
        Ref<Result> result(reader.decode(image, hints));
    
    		// Output the result. 
        cout << result->getText()->getText() << endl;
    
      } 
    	catch (zxing::Exception& e) 
    	{
        cerr << "Error: " << e.what() << endl;
      }
    	return 0; 
    }
    

    Dies habe ich nun so abgespeckt dass es verarbeitet wird:

    using namespace std;
    using namespace zxing;
    
    ....
    		// A buffer containing an image. In your code, this would be an image from your camera. In this
    		// example, it's just an array containing the code for "Hello!". 
    		unsigned char buffer[] =
    		{ 
    			255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    			255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255,  0 ,  0 ,  0 ,  0 ,  0 , 255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255,
    			255,  0 , 255, 255, 255, 255, 255,  0 , 255, 255,  0 , 255,  0 , 255, 255,  0 , 255, 255, 255, 255, 255,  0 , 255, 
    			255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 255,  0 ,  0 , 255, 255, 255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 
    			255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 255,  0 ,  0 ,  0 , 255, 255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 
    			255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 255, 255,  0 , 255,  0 , 255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 
    			255,  0 , 255, 255, 255, 255, 255,  0 , 255, 255, 255, 255,  0 ,  0 , 255,  0 , 255, 255, 255, 255, 255,  0 , 255,
    			255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255,  0 , 255,  0 , 255,  0 , 255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255, 
    			255, 255, 255, 255, 255, 255, 255, 255, 255,  0 ,  0 ,  0 ,  0 ,  0 , 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    			255,  0 ,  0 , 255,  0 ,  0 , 255,  0 , 255, 255,  0 ,  0 , 255,  0 , 255,  0 , 255, 255, 255, 255, 255,  0 , 255, 
    			255,  0 ,  0 ,  0 ,  0 ,  0 , 255, 255,  0 , 255, 255,  0 , 255,  0 , 255,  0 , 255,  0 ,  0 ,  0 , 255, 255, 255, 
    			255, 255, 255, 255, 255, 255, 255,  0 , 255,  0 ,  0 ,  0 , 255, 255,  0 ,  0 , 255,  0 , 255,  0 ,  0 ,  0 , 255, 
    			255, 255, 255,  0 ,  0 , 255, 255, 255,  0 ,  0 ,  0 , 255,  0 , 255, 255, 255, 255, 255, 255,  0 , 255, 255, 255, 
    			255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255, 255,  0 , 255, 255, 255, 255,  0 , 255, 255,  0 , 255,  0 , 255, 255, 
    			255, 255, 255, 255, 255, 255, 255, 255, 255,  0 ,  0 , 255,  0 ,  0 , 255, 255, 255, 255,  0 , 255,  0 ,  0 , 255, 
    			255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255, 255, 255,  0 , 255,  0 ,  0 ,  0 ,  0 ,  0 , 255,  0 , 255, 255, 255, 
    			255,  0 , 255, 255, 255, 255, 255,  0 , 255, 255,  0 ,  0 ,  0 ,  0 ,  0 , 255,  0 ,  0 ,  0 ,  0 , 255, 255, 255,
    			255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255,  0 , 255, 255,  0 ,  0 , 255,  0 ,  0 , 255,  0 , 255,  0 ,  0 , 255,
    			255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255,  0 , 255,  0 ,  0 ,  0 , 255, 255, 255, 255, 255, 255, 255, 255, 255,
    			255,  0 , 255,  0 ,  0 ,  0 , 255,  0 , 255, 255,  0 ,  0 , 255, 255, 255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255,
    			255,  0 , 255, 255, 255, 255, 255,  0 , 255,  0 , 255,  0 , 255, 255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255,
    			255,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 , 255,  0 , 255,  0 ,  0 , 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
    			255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
    		};
    		int width = 23;
    		int height = 23;
    
    		// Convert the buffer to something that the library understands.
    		Ref<LuminanceSource> source (new BufferBitmapSource(width, height, buffer));
    

    Leider scheitert es aktuell:
    [BCC32 Warnung] QRCodeReader.h(43): W8022 'QRCodeReader::decode(Ref<BinaryBitmap>,DecodeHints)' verbirgt virtuelle Funktion 'Reader::decode(Ref<BinaryBitmap>)'
    [BCC32 Fehler] Unit6.cpp(73): E2303 Typname erwartet
    [BCC32 Fehler] Unit6.cpp(73): E2293 ) erwartet
    [BCC32 Fehler] Unit6.cpp(73): E2285 Keine Übereinstimmung für 'Ref<LuminanceSource>::Ref(int *)' gefunden
    [BCC32 Warnung] Unit6.cpp(76): W8004 'source' wurde ein Wert zugewiesen, der nie verwendet wird
    [BCC32 Warnung] Unit6.cpp(76): W8004 'height' wurde ein Wert zugewiesen, der nie verwendet wird
    [BCC32 Warnung] Unit6.cpp(76): W8004 'width' wurde ein Wert zugewiesen, der nie verwendet wird
    [BCC32 Warnung] Unit6.cpp(76): W8004 'buffer' wurde ein Wert zugewiesen, der nie verwendet wird

    Weiß einer Rat?



  • Wenn Du uns die Zeilen zeigst in denen die Fehler sind, vielleicht 😉



  • Sorry für die späte Antwort, der Teil läuft nun aber auch. Lösung:

    Ref<LuminanceSource> source (new BufferBitmapSource(width, height, buffer));
    Ref<Binarizer> binarizer (new GlobalHistogramBinarizer(source));
    Ref<BinaryBitmap> image(new BinaryBitmap(binarizer));
    DecodeHints hints(DecodeHints::DEFAULT_HINT );
    hints.setTryHarder(true);
    QRCodeReader reader;
    Ref<Result> result(reader.decode(image, hints));
    

    Nun steh ich leider vor dem nächsten Problem:
    [BCC32 Fehler] Counted.h(135): E2315 'release' ist kein Element von 'oned::UPCEANReader', weil der Typ nicht definiert ist

    Das ganze in:

    // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
    #ifndef __COUNTED_H__
    #define __COUNTED_H__
    
    /*
     *  Copyright 2010 ZXing authors All rights reserved.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *      http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    #include <iostream>
    
    namespace zxing {
    
    /* base class for reference-counted objects */
    class Counted {
    private:
      unsigned int count_;
    public:
      Counted() :
          count_(0) {
      }
      virtual ~Counted() {
      }
      Counted *retain() {
        count_++;
        return this;
      }
      void release() {
        count_--;
        if (count_ == 0) {
          count_ = 0xDEADF001;
          delete this;
        }
      }
    
      /* return the current count for denugging purposes or similar */
      int count() const {
        return count_;
      }
    };
    
    /* counting reference to reference-counted objects */
    template<typename T> class Ref {
    private:
    public:
      T *object_;
      explicit Ref(T *o = 0) :
          object_(0) {
        reset(o);
      }
      Ref(const Ref &other) :
          object_(0) {
        reset(other.object_);
      }
    
      template<class Y>
      Ref(const Ref<Y> &other) :
          object_(0) {
        reset(other.object_);
      }
    
      ~Ref() {
        if (object_) {
          object_->release();
        }
      }
    
      void reset(T *o) {
        if (o) {
          o->retain();
        }
        if (object_ != 0) {
          object_->release();
        }
        object_ = o;
      }
      Ref& operator=(const Ref &other) {
        reset(other.object_);
        return *this;
      }
      template<class Y>
      Ref& operator=(const Ref<Y> &other) {
        reset(other.object_);
        return *this;
      }
      Ref& operator=(T* o) {
        reset(o);
        return *this;
      }
      template<class Y>
      Ref& operator=(Y* o) {
        reset(o);
        return *this;
      }
    
      T& operator*() {
        return *object_;
      }
      T* operator->() const {
        return object_;
      }
      operator T*() const {
        return object_;
      }
    
      bool operator==(const T* that) {
        return object_ == that;
      }
      bool operator==(const Ref &other) const {
        return object_ == other.object_ || *object_ == *(other.object_);
      }
      template<class Y>
      bool operator==(const Ref<Y> &other) const {
        return object_ == other.object_ || *object_ == *(other.object_);
      }
    
      bool operator!=(const T* that) {
        return !(*this == that);
      }
    
      bool empty() const {
        return object_ == 0;
      }
    };
    
    }
    
    #endif // __COUNTED_H__
    

    Die Hilfe zu diesem Fehler sagt mir mal sowas von Garnichts....
    Weiß nun jemand Rat?



  • Hallo,

    Der Fehler stammt nicht aus der gezeigten Headerdatei. Der ensteht wahrscheinlich wenn du versuchst ein Objekt vom Typ Ref<UPCEANReader> zu instanziieren. Der Typ ist da scheinbar nicht bekannt. Evtl. fehlt ein Include UPCEANReader.h



  • Genau ein include hat gefehlt. Vielen Dank.


Anmelden zum Antworten