Added a project written on Qt framework for Symbian and added tutorials for both ZXingBarcodeReader and QQrDecoder

git-svn-id: https://zxing.googlecode.com/svn/trunk@1339 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
ftylitak 2010-05-06 11:18:01 +00:00
parent c462988c61
commit e29b06083d
143 changed files with 12792 additions and 0 deletions

View file

@ -30,6 +30,7 @@ Mateusz Jędrasik
Matthew Schulkind (Google)
Matt York (LifeMarks)
Mohamad Fairol
Nikolaos Ftylitakis
Paul Hackenberger
Randy Shen (Acer)
Rasmus Schrøder Sørensen

View file

@ -0,0 +1,77 @@
#include "CameraImageWrapper.h"
#include <QColor>
#include <QApplication>
#include <QDesktopWidget>
CameraImageWrapper::CameraImageWrapper() : LuminanceSource()
{
}
CameraImageWrapper::CameraImageWrapper(CameraImageWrapper& otherInstance) : LuminanceSource()
{
image = otherInstance.getOriginalImage().copy();
}
CameraImageWrapper::~CameraImageWrapper()
{
}
int CameraImageWrapper::getWidth()
{
return image.width();
}
int CameraImageWrapper::getHeight()
{
return image.height();
}
unsigned char CameraImageWrapper::getPixel(int x, int y)
{
QRgb pixel = image.pixel(x,y);
return qGray(pixel);//((qRed(pixel) + qGreen(pixel) + qBlue(pixel)) / 3);
}
void CameraImageWrapper::setImage(QString fileName, char* format)
{
image.load(fileName);
if(image.width() > QApplication::desktop()->width())
image = image.scaled(QApplication::desktop()->width(), image.height(), Qt::IgnoreAspectRatio);
if(image.height() > QApplication::desktop()->height())
image = image.scaled(image.width(), QApplication::desktop()->height(), Qt::IgnoreAspectRatio);
}
void CameraImageWrapper::setImage(QImage newImage)
{
image = newImage.copy();
if(image.width() > 640)
image = image.scaled(640, image.height(), Qt::KeepAspectRatio);
}
QImage CameraImageWrapper::grayScaleImage(QImage::Format f)
{
QImage tmp(image.width(), image.height(), f);
for(int i=0; i<image.width(); i++)
{
for(int j=0; j<image.height(); j++)
{
int pix = (int)getPixel(i,j);
tmp.setPixel(i,j, qRgb(pix ,pix,pix));
}
}
return tmp;
//return image.convertToFormat(f);
}
QImage CameraImageWrapper::getOriginalImage()
{
return image;
}

View file

@ -0,0 +1,31 @@
#ifndef CAMERAIMAGE_H
#define CAMERAIMAGE_H
#include <QImage>
#include <QString>
#include <zxing/LuminanceSource.h>
using namespace zxing;
class CameraImageWrapper : public LuminanceSource
{
public:
CameraImageWrapper();
CameraImageWrapper(CameraImageWrapper& otherInstance);
~CameraImageWrapper();
int getWidth();
int getHeight();
unsigned char getPixel(int x, int y);
void setImage(QString fileName, char* format);
void setImage(QImage newImage);
QImage grayScaleImage(QImage::Format f);
QImage getOriginalImage();
private:
QImage image;
};
#endif //CAMERAIMAGE_H

View file

@ -0,0 +1,31 @@
Copyright © 2009 Nokia Corporation. All rights reserved.
Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
Java and all Java-based marks are trademarks or registered trademarks of
Sun Microsystems, Inc. Other product and company names mentioned herein may be
trademarks or trade names of their respective owners.
Subject to the conditions below, you may, without charge:
· Use, copy, modify and/or merge copies of this software and
associated documentation files (the “Software”)
· Publish, distribute, sub-license and/or sell new software
derived from or incorporating the Software.
This file, unmodified, shall be included with all copies or substantial portions
of the Software that are distributed in source code form.
The Software cannot constitute the primary value of any new software derived
from or incorporating the Software.
Any person dealing with the Software shall not misrepresent the source of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,322 @@
#include "QCameraControllerWidget.h"
#include <QPainter>
QCameraControllerWidget::QCameraControllerWidget(QWidget* parent) : QWidget(parent),
iCameraWrapper(NULL), iBackBuffer(NULL), iBackBufferDevice(NULL), iBackBufferContext(NULL)
{
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(sendBackbufferToDecode()));
timer->start(500);
}
QCameraControllerWidget::~QCameraControllerWidget()
{
if (iCameraWrapper)
{
iCameraWrapper->ReleaseAndPowerOff();
}
delete iCameraWrapper;
if(timer)
{
delete timer;
timer = NULL;
}
ReleaseBackBuffer();
}
void QCameraControllerWidget::CaptureImage()
{
if (iCameraWrapper && iCameraWrapper->State() == CCameraEngine::EEngineViewFinding)
{
emit logMessage("Capturing picture");
iCameraWrapper->StopViewFinder();
TRAPD(err,iCameraWrapper->CaptureL());
if (err)
{
emit logMessage("Camera capture error");
}
}
}
void QCameraControllerWidget::paintEvent(QPaintEvent* event)
{
if(iBackBuffer)
{
QPainter paint(this);
paint.drawPixmap(0,0,QPixmap::fromSymbianCFbsBitmap(iBackBuffer));
}
}
void QCameraControllerWidget::resizeEvent(QResizeEvent* event)
{
static int savedWidth = 0;
static int savedHeight = 0;
if(!savedWidth || !savedHeight)
{
InitializeCamera();
savedWidth = geometry().width();
savedHeight = geometry().height();
}
}
void QCameraControllerWidget::InitializeCamera()
{
// Create camera wrapper class here because
// whole camera wrapper and all handles have to reset
// while orientatio of the application changes.
if (iCameraWrapper)
{
// Power off camera if it is on
iCameraWrapper->StopViewFinder();
iCameraWrapper->ReleaseAndPowerOff();
delete iCameraWrapper; iCameraWrapper = NULL;
}
TInt camErr(KErrNotSupported);
if(CCameraEngine::CamerasAvailable() > 0)
{
TRAP(camErr, iCameraWrapper = CCameraEngine::NewL(0,0,this));
}
// iViewFinderSize is picture size for viewfinder.
// iCaptureSize is picture size for capturing picture.
// We want fill whole screen
if (geometry().width() > geometry().height())
{
iViewFinderSize = TSize(geometry().width(),geometry().width());
iCaptureSize = TSize(geometry().width(),geometry().width()); // Captured picture size
}
else
{
iViewFinderSize = TSize(geometry().height(), geometry().height());
iCaptureSize = TSize(geometry().height(),geometry().height()); // Captured picture size
}
// Create back buffer where recieved camera pictures are copied
ReleaseBackBuffer();
CreateBackBufferL();
// Power on camera, start viewfinder when MceoCameraReady() received
if(camErr == KErrNone)
{
iCameraWrapper->ReserveAndPowerOn();
emit logMessage("Camera power on");
}
else
{
emit logMessage("no camera found");
}
}
void QCameraControllerWidget::CreateBackBufferL()
{
// create back buffer bitmap
iBackBuffer = q_check_ptr(new CFbsBitmap);
try{
TSize size;
size.iHeight = this->geometry().height();
size.iWidth = this->geometry().width();
QT_TRAP_THROWING( iBackBuffer->Create(size,EColor64K));
}
catch(std::exception& e)
{
}
// create back buffer graphics context
iBackBufferDevice = CFbsBitmapDevice::NewL(iBackBuffer);
User::LeaveIfError(iBackBufferDevice->CreateContext(iBackBufferContext));
iBackBufferContext->SetPenStyle(CGraphicsContext::ESolidPen);
iBackBufferContext->SetBrushColor(KRgbBlack);
iBackBufferContext->Clear();
}
void QCameraControllerWidget::ReleaseBackBuffer()
{
if (iBackBufferContext)
{
delete iBackBufferContext;
iBackBufferContext = NULL;
}
if (iBackBufferDevice)
{
delete iBackBufferDevice;
iBackBufferDevice = NULL;
}
if (iBackBuffer)
{
delete iBackBuffer;
iBackBuffer = NULL;
}
}
void QCameraControllerWidget::MceoCameraReady()
{
if (iCameraWrapper->State() == CCameraEngine::EEngineIdle)
{
// Prepare camera
TSize imageSize;
imageSize.iHeight = 480;
imageSize.iWidth = 640;
CCamera::TFormat format = CCamera::EFormatFbsBitmapColor64K;
TRAPD(err,iCameraWrapper->PrepareL(imageSize, format));
if (err)
{
emit logMessage("Camera prepare error");
return;
}
// Start viewfinder. Viewfinder pictures starts coming into MceoViewFinderFrameReady();
TSize finderSize;
finderSize.iHeight = this->geometry().height();
finderSize.iWidth = this->geometry().width();
TRAPD(err2,iCameraWrapper->StartViewFinderL(finderSize));
if (err2)
{
emit logMessage("Camera start viewfinder error");
return;
}
emit logMessage("Camera viewfinder started");
}
}
void QCameraControllerWidget::MceoFocusComplete()
{
// CameraEngine state is EEngineIdle
emit logMessage("Focused");
// Capture picture after it has focused
iCameraWrapper->StopViewFinder();
TRAPD(err,iCameraWrapper->CaptureL());
if (err)
{
emit logMessage("Camera capture error");
}
}
void QCameraControllerWidget::MceoCapturedDataReady( TDesC8* aData )
{
}
void QCameraControllerWidget::MceoCapturedBitmapReady( CFbsBitmap* aBitmap )
{
if (iBackBufferContext)
{
emit logMessage("Succesfull capture");
QPixmap pix(QPixmap::fromSymbianCFbsBitmap(aBitmap));
emit imageCaptured(pix.toImage());
TSize finderSize;
finderSize.iHeight = this->geometry().height();
finderSize.iWidth = this->geometry().width();
TRAPD(err2,iCameraWrapper->StartViewFinderL(finderSize));
if (err2)
{
emit logMessage("Camera start viewfinder error");
return;
}
}
if (iCameraWrapper)
iCameraWrapper->ReleaseImageBuffer();
}
void QCameraControllerWidget::MceoViewFinderFrameReady( CFbsBitmap& aFrame )
{
if (iBackBufferContext)
{
TSize bmpSizeInPixels = aFrame.SizeInPixels();
TInt xDelta = 0;
TInt yDelta = 0;
TPoint pos( xDelta, yDelta );
// Copy received viewfinder picture to back buffer
iBackBufferContext->BitBlt( pos, &aFrame, TRect( TPoint( 0, 0 ), bmpSizeInPixels ));
// Update backbuffer into screen
update();
}
if (iCameraWrapper)
iCameraWrapper->ReleaseViewFinderBuffer();
}
void QCameraControllerWidget::MceoHandleError( TCameraEngineError aErrorType, TInt aError )
{
// NOTE: CameraEngine state seems to go into CCameraEngine::EEngineIdle state
if (aErrorType == EErrReserve)
{
return; //-18 comes on application startup, but everything works ok
}
switch (aErrorType)
{
case EErrReserve:
{
emit logMessage("Camera reserved error");
break;
}
case EErrPowerOn:
{
emit logMessage("Camera power on error");
break;
}
case EErrViewFinderReady:
{
emit logMessage("Camera viewfinder error");
break;
}
case EErrImageReady:
{
emit logMessage("Camera image ready error");
break;
}
case EErrAutoFocusInit:
case EErrAutoFocusMode:
case EErrAutoFocusArea:
case EErrAutoFocusRange:
case EErrAutoFocusType:
case EErrOptimisedFocusComplete:
{
//emit logMessage("Try focusing again");
break;
}
default:
{
emit logMessage("Unknown error");
break;
}
};
// Try handle error
//CancelCapturedPicture(EFalse);
// iAppUi->UseOptionsExitCbaL();
}
void QCameraControllerWidget::MceoHandleOtherEvent( const TECAMEvent& /*aEvent*/ )
{
}
//Timer slot
void QCameraControllerWidget::sendBackbufferToDecode()
{
if(!iBackBuffer)
return;
QPixmap pix(QPixmap::fromSymbianCFbsBitmap(iBackBuffer));
emit imageCaptured(pix.toImage());
if(timer)
timer->start(500);
}

View file

@ -0,0 +1,67 @@
#ifndef QCAMERACONTROLLER_H
#define QCAMERACONTROLLER_H
#include <QWidget>
#include <FBS.H>
#include <BITDEV.H>
#include <BITSTD.H>
#include <e32cmn.h>
#include <GDI.H>
#include <cameraengine.h>
#include <cameraengineobserver.h>
#include <QTimer>
class QCameraControllerWidget : public QWidget, public MCameraEngineObserver
{
Q_OBJECT
public:
QCameraControllerWidget(QWidget* parent);
~QCameraControllerWidget();
protected:
void paintEvent(QPaintEvent* event);
void resizeEvent(QResizeEvent* event);
private: // From MCameraEngineObserver
void CreateBackBufferL();
void ReleaseBackBuffer();
void MceoCameraReady();
void MceoFocusComplete();
void MceoCapturedDataReady( TDesC8* aData );
void MceoCapturedBitmapReady( CFbsBitmap* aBitmap );
void MceoViewFinderFrameReady( CFbsBitmap& aFrame );
void MceoHandleError( TCameraEngineError aErrorType, TInt aError );
void MceoHandleOtherEvent( const TECAMEvent& /*aEvent*/ );
void InitializeCamera();
////////////////////////
public slots:
void CaptureImage();
private slots:
void sendBackbufferToDecode();
signals:
void logMessage(QString str);
void imageCaptured(QImage cImage);
private:
// CameraWrapper class
CCameraEngine* iCameraWrapper;
CFbsBitmap* iBackBuffer;
CFbsBitmapDevice* iBackBufferDevice;
CFbsBitGc* iBackBufferContext;
TSize iViewFinderSize;
TSize iCaptureSize;
//Timer
QTimer* timer;
};
#endif //QCAMERACONTROLLER_H

View file

@ -0,0 +1,99 @@
/****************************************************************************
**
** Trolltech hereby grants a license to use the Qt/Eclipse Integration
** plug-in (the software contained herein), in binary form, solely for the
** purpose of creating code to be used with Trolltech's Qt software.
**
** Qt Designer is licensed under the terms of the GNU General Public
** License versions 2.0 and 3.0 ("GPL License"). Trolltech offers users the
** right to use certain no GPL licensed software under the terms of its GPL
** Exception version 1.2 (http://trolltech.com/products/qt/gplexception).
**
** THIS SOFTWARE IS PROVIDED BY TROLLTECH AND ITS CONTRIBUTORS (IF ANY) "AS
** IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
** OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** Since we now have the GPL exception I think that the "special exception
** is no longer needed. The license text proposed above (other than the
** special exception portion of it) is the BSD license and we have added
** the BSD license as a permissible license under the exception.
**
****************************************************************************/
#include "QQrDecoder.h"
#include <zxing/qrcode/QRCodeReader.h>
#include <zxing/common/GlobalHistogramBinarizer.h>
#include <zxing/Binarizer.h>
#include <zxing/BinaryBitmap.h>
#include <QFileDialog>
#include <QGraphicsView>
#include <QPainter>
#include <QPoint>
#include <QPixmap>
using namespace zxing;
using namespace zxing::qrcode;
QQrDecoder::QQrDecoder(QWidget *parent): QMainWindow(parent)
{
ui.setupUi(this);
connect(ui.startDecode, SIGNAL(clicked()), this, SLOT(findAndDecode()));
connect(ui.cameraWidget, SIGNAL(imageCaptured(QImage)), this, SLOT(decodeImage(QImage)));
connect(ui.cameraWidget, SIGNAL(logMessage(QString)), ui.resultLabel, SLOT(setText(QString)));
}
QQrDecoder::~QQrDecoder()
{
}
void QQrDecoder::InitializeSymbianCamera()
{
}
void QQrDecoder::findAndDecode()
{
ui.cameraWidget->CaptureImage();
}
void QQrDecoder::decodeImage(QImage originalImage)
{
QRCodeReader decoder;
image.setImage(originalImage);
Ref<Result> res;
try{
Ref<LuminanceSource> imageRef(new CameraImageWrapper(image));
GlobalHistogramBinarizer* binz = new GlobalHistogramBinarizer(imageRef);
Ref<Binarizer> bz (binz);
BinaryBitmap* bb = new BinaryBitmap(bz);
Ref<BinaryBitmap> ref(bb);
res = decoder.decode(ref);
QString string = QString(res->getText()->getText().c_str());
ui.resultLabel->setText(string);
}
catch(zxing::Exception& e)
{
ui.resultLabel->setText("Error");
}
}
void QQrDecoder::reloadFormatedPicture(int x)
{
}

View file

@ -0,0 +1,62 @@
/****************************************************************************
**
** Trolltech hereby grants a license to use the Qt/Eclipse Integration
** plug-in (the software contained herein), in binary form, solely for the
** purpose of creating code to be used with Trolltech's Qt software.
**
** Qt Designer is licensed under the terms of the GNU General Public
** License versions 2.0 and 3.0 ("GPL License"). Trolltech offers users the
** right to use certain no GPL licensed software under the terms of its GPL
** Exception version 1.2 (http://trolltech.com/products/qt/gplexception).
**
** THIS SOFTWARE IS PROVIDED BY TROLLTECH AND ITS CONTRIBUTORS (IF ANY) "AS
** IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
** OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** Since we now have the GPL exception I think that the "special exception
** is no longer needed. The license text proposed above (other than the
** special exception portion of it) is the BSD license and we have added
** the BSD license as a permissible license under the exception.
**
****************************************************************************/
#ifndef QQRDECODER_H
#define QQRDECODER_H
#include <QtGui/QMainWindow>
#include <QPixmap>
#include "ui_QQrDecoder.h"
#include "CameraImageWrapper.h"
class QQrDecoder : public QMainWindow
{
Q_OBJECT
public:
QQrDecoder(QWidget *parent = 0);
~QQrDecoder();
private:
void InitializeSymbianCamera();
protected slots:
void findAndDecode();
void decodeImage(QImage originalImage);
void reloadFormatedPicture(int x);
private:
Ui::QQrDecoder ui;
CameraImageWrapper image;
QPixmap px;
};
#endif // QQRDECODER_H

View file

@ -0,0 +1,159 @@
TEMPLATE = app
TARGET = QQrDecoder
QT += core \
gui
HEADERS += CameraImageWrapper.h \
zxing/BarcodeFormat.h \
zxing/Binarizer.h \
zxing/BinaryBitmap.h \
zxing/Exception.h \
zxing/LuminanceSource.h \
zxing/MultiFormatReader.h \
zxing/Reader.h \
zxing/ReaderException.h \
zxing/Result.h \
zxing/ResultPoint.h \
zxing/common/Array.h \
zxing/common/BitArray.h \
zxing/common/BitMatrix.h \
zxing/common/BitSource.h \
zxing/common/Counted.h \
zxing/common/DecoderResult.h \
zxing/common/DetectorResult.h \
zxing/common/EdgeDetector.h \
zxing/common/GlobalHistogramBinarizer.h \
zxing/common/GridSampler.h \
zxing/common/IllegalArgumentException.h \
zxing/common/LocalBlockBinarizer.h \
zxing/common/PerspectiveTransform.h \
zxing/common/Point.h \
zxing/common/Str.h \
zxing/common/reedsolomon/GF256.h \
zxing/common/reedsolomon/GF256Poly.h \
zxing/common/reedsolomon/ReedSolomonDecoder.h \
zxing/common/reedsolomon/ReedSolomonException.h \
zxing/oned/Code128Reader.h \
zxing/oned/Code39Reader.h \
zxing/oned/EAN13Reader.h \
zxing/oned/EAN8Reader.h \
zxing/oned/ITFReader.h \
zxing/oned/MultiFormatOneDReader.h \
zxing/oned/MultiFormatUPCEANReader.h \
zxing/oned/OneDReader.h \
zxing/oned/OneDResultPoint.h \
zxing/oned/UPCAReader.h \
zxing/oned/UPCEANReader.h \
zxing/oned/UPCEReader.h \
zxing/qrcode/ErrorCorrectionLevel.h \
zxing/qrcode/FormatInformation.h \
zxing/qrcode/QRCodeReader.h \
zxing/qrcode/Version.h \
zxing/qrcode/decoder/BitMatrixParser.h \
zxing/qrcode/decoder/DataBlock.h \
zxing/qrcode/decoder/DataMask.h \
zxing/qrcode/decoder/DecodedBitStreamParser.h \
zxing/qrcode/decoder/Decoder.h \
zxing/qrcode/decoder/Mode.h \
zxing/qrcode/detector/AlignmentPattern.h \
zxing/qrcode/detector/AlignmentPatternFinder.h \
zxing/qrcode/detector/Detector.h \
zxing/qrcode/detector/FinderPattern.h \
zxing/qrcode/detector/FinderPatternFinder.h \
zxing/qrcode/detector/FinderPatternInfo.h \
zxing/qrcode/detector/QREdgeDetector.h \
QQrDecoder.loc \
QQrDecoder.h
SOURCES += CameraImageWrapper.cpp \
zxing/BarcodeFormat.cpp \
zxing/Binarizer.cpp \
zxing/BinaryBitmap.cpp \
zxing/Exception.cpp \
zxing/LuminanceSource.cpp \
zxing/MultiFormatReader.cpp \
zxing/Reader.cpp \
zxing/ReaderException.cpp \
zxing/Result.cpp \
zxing/ResultPoint.cpp \
zxing/common/Array.cpp \
zxing/common/BitArray.cpp \
zxing/common/BitMatrix.cpp \
zxing/common/BitSource.cpp \
zxing/common/Counted.cpp \
zxing/common/DecoderResult.cpp \
zxing/common/DetectorResult.cpp \
zxing/common/EdgeDetector.cpp \
zxing/common/GlobalHistogramBinarizer.cpp \
zxing/common/GridSampler.cpp \
zxing/common/IllegalArgumentException.cpp \
zxing/common/LocalBlockBinarizer.cpp \
zxing/common/PerspectiveTransform.cpp \
zxing/common/Str.cpp \
zxing/common/reedsolomon/GF256.cpp \
zxing/common/reedsolomon/GF256Poly.cpp \
zxing/common/reedsolomon/ReedSolomonDecoder.cpp \
zxing/common/reedsolomon/ReedSolomonException.cpp \
zxing/oned/Code128Reader.cpp \
zxing/oned/Code39Reader.cpp \
zxing/oned/EAN13Reader.cpp \
zxing/oned/EAN8Reader.cpp \
zxing/oned/ITFReader.cpp \
zxing/oned/MultiFormatOneDReader.cpp \
zxing/oned/MultiFormatUPCEANReader.cpp \
zxing/oned/OneDReader.cpp \
zxing/oned/OneDResultPoint.cpp \
zxing/oned/UPCAReader.cpp \
zxing/oned/UPCEANReader.cpp \
zxing/oned/UPCEReader.cpp \
zxing/qrcode/ErrorCorrectionLevel.cpp \
zxing/qrcode/FormatInformation.cpp \
zxing/qrcode/QRCodeReader.cpp \
zxing/qrcode/Version.cpp \
zxing/qrcode/decoder/BitMatrixParser.cpp \
zxing/qrcode/decoder/DataBlock.cpp \
zxing/qrcode/decoder/DataMask.cpp \
zxing/qrcode/decoder/DecodedBitStreamParser.cpp \
zxing/qrcode/decoder/Decoder.cpp \
zxing/qrcode/decoder/Mode.cpp \
zxing/qrcode/detector/AlignmentPattern.cpp \
zxing/qrcode/detector/AlignmentPatternFinder.cpp \
zxing/qrcode/detector/Detector.cpp \
zxing/qrcode/detector/FinderPattern.cpp \
zxing/qrcode/detector/FinderPatternFinder.cpp \
zxing/qrcode/detector/FinderPatternInfo.cpp \
zxing/qrcode/detector/QREdgeDetector.cpp \
QQrDecoder.rss \
QQrDecoder_reg.rss \
main.cpp \
QQrDecoder.cpp
FORMS += QQrDecoder.ui
RESOURCES +=
symbian {
TARGET.UID3 = 0xEF2CE79D
HEADERS += QCameraControllerWidget.h
SOURCES += QCameraControllerWidget.cpp
LIBS += -leuser \
-lapparc \
-lcone \
-leikcore \
-lavkon \
-lcommonengine \
-lefsrv \
-lestor \
-laknnotify \
-lfbscli \
-lbitgdi \
-leikcoctl \
-lbafl \ # BafUtils
-lecam \ # Camera
-lcamerawrapper
TARGET.CAPABILITY = UserEnvironment
customrules.pkg_prerules = \
";CameraWrapper" \
"@\"$(EPOCROOT)Epoc32\InstallToDevice\CameraWrapper\sis\camerawrapper.sisx\", (0x2001ec5f)" \
" "
DEPLOYMENT += customrules
}
ICON = QQrDecoder.svg

View file

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
<svg version="1.2" baseProfile="tiny" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px" y="0px" width="135px" height="135px" viewBox="0 0 135 135" xml:space="preserve">
<image width="135" height="135" xlink:href="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEASABIAAD/7AARRHVja3kAAQAEAAAAHgAA/+4AIUFkb2JlAGTAAAAAAQMA
EAMCAwYAAALJAAAGlAAAErr/2wCEABALCwsMCxAMDBAXDw0PFxsUEBAUGx8XFxcXFx8eFxoaGhoX
Hh4jJSclIx4vLzMzLy9AQEBAQEBAQEBAQEBAQEABEQ8PERMRFRISFRQRFBEUGhQWFhQaJhoaHBoa
JjAjHh4eHiMwKy4nJycuKzU1MDA1NUBAP0BAQEBAQEBAQEBAQP/CABEIAIcAhwMBIgACEQEDEQH/
xACvAAACAwEBAQAAAAAAAAAAAAAABQMEBgIBBwEBAAAAAAAAAAAAAAAAAAAAABAAAgICAQIFAwMF
AAAAAAAAAwQCBQEGAAcXERITFDUzFTdgIxZAMSI0NhEAAgECAwQECggDAw0AAAAAAQIDABEhEgQx
QSITUWEyBXGRQlKSs9MUNHSBobHB0eFyIxBissIzBkDxgqLSg5PDJIQVNRYSAQAAAAAAAAAAAAAA
AAAAAGD/2gAMAwEAAhEDEQAAANFjdBaMqaC4ZPZY3ZFpWvsGmtZnADXZIGplxg2MyaAGQtACwfJ9
A9YCL6h8v+oHyG9p6BfW1HAltQ2STDa0MF9QVNQALWR3OSDi90Kb8dgqRTRHXfkhz3UCLlxwKeHa
01pIFZG7RnttVbJl7CgTc9zlC1bmF0L2oVe/ahVt1rhoDoI0z7MEvXdUl8i9KlyT0tt1j4VxP0ZC
iZ1T2vbomtJQjy2lQks0HpDVvAtar4TTd0gZU4+yhQbqjxjDwaspBylcpSbtTYOmK2+JvL8BJMru
E/VCAcLOZyxUlsjsshSo28mMbVAOdX84+uHzdoj+lGXc8ODAt1FUtrWOoMNsEAa0lB8AAAAAAAAA
AAAAAH//2gAIAQIAAQUA/SP/2gAIAQMAAQUA/SP/2gAIAQEAAQUA3G9boazudfc7nX3O519zudfc
3G9boazWrNi3pN12d/X+VbRHKznc6+5XXrbWo9zr7nc6+53Ovudzr7ldettaj1O+B1Boaek9zqHl
TvVRb2HU757caJu+rENnQ1FTudQ829obmk1Gqu2yt1aLbmqsnmu0bpXxzqJSJt9zqHnU74Gk/G3U
74Gk/G3NE/6vqd89zdxkLt+q0NVHlk5VNoQRGKJgqCiHBft3TpT2Z9g+e51O+BpPxt1O+B1RT3ui
z6YiHzXtFFVWvU757j2l+72TqDALLSaxMzmgQfA1RzlOkdRCjfmqaw0utddF00WNzqd8DSfjbfat
6zpqxW7VWF6wZ5A9KbSLpyOmblDBY+3hH0uLYZGw/ZPxKxal8kGmzowUchmSr0pZUsY5cXt3hVdT
YL6Re2K80ZNEg1KQ/HGceVxmYM11vgESjEaQs4cwvNiZjpoFm2nXgGoTmcExn++cZ8cSfPjCV/6u
u7gtifFjQDyyT8/FxxEBhuAcmRyAa3lwCwxgXM15ciTZgsJlwZ4YrZMQUCVTjeMCgSQmzMDC0KqU
H/Fd0LMWRQjNchZm4sViOTYTLMhWD4QmOAsRVPycBlXRRSyKQKyWDrmjkBSZwM8pMlHCDTXnhCnm
bOqbgD15iB5V8VvPU9Xkq3/KY/YYLn1sKr5YwNXECpJelBqs9AYWci5aJ4NMgP38g9qSFp5sVBvN
qmz/AFpkJh5qDEuSAyLkcOF4CUiyPJOEq04QygSEX0yiLGR1D4fVLk9hlsQWZiIpj1RwQUnE1XGG
NZ2f6xP99piYOeXB1zkylMZpBlgsj4xXA8BpgMP3UkZGJFOGbJiebFyTRMklEp7ExD4xjGKzHhre
2miEkbAPMWIefcQclYA8bLH7CrghLizkcoeplWIfNxuxSKMTucJDbESPr4WZXLEsrD6NHnOdO3ji
q6818Br+RXRll4UBHMMZYnHCLMsZxFZxkRGLLHqN5UgNdxfK0PZg5PMTtBKpjhJNlxSCJDTt5z4c
BPH2/BI8SJH3NmTGWM+MuGR87FlKXF/VyTK0JcYEsvDLU84WBI+ftuZcxV4xxguAQrDYlqHUWcQV
VTTt2Ov/AMc2rlbrew5c3HEqeytKyiqAN3Nfi9fVBccCfUFYVlbSW6+n+N7Z2a2tKmjrm3x4A1yx
ZWZrmoPsmqt5Qq6uyX0rqd8DU71b1Ff3Ovudzr7l7et3zd7RKXyljRKK7dr+sIa/xzp3SON0VEpQ
qdMfntvaInu3c6+5Q6whJjqd893OvuV1621qP9D/AP/aAAgBAgIGPwAj/9oACAEDAgY/ACP/2gAI
AQEBBj8Ai1mjSN5HnWIiUMy5WSR/IZceGvh9J6Entq+H0noSe2r4fSehJ7avh9J6Entqi1mjSN5H
nWIiUMy5WSR/IZceGtN3hqVRJpuZmWMEIMkjxiwYsdi9NaL3KOGT3nm5+crNbl8u2XI6efWj1koA
k1EEUrhbhQ0iBza5OGP8Ph9J6EntqfvyRIxqlg1EoRQ3LzQmQLgWLW4BfGvh9J6Entq+H0noSe2r
4fSehJ7avh9J6EntqfvyRIxqlg1EoRQ3LzQmQLgWLW4BfGtP82nq5qg1koJj08eolcLYsVjllc2u
RjhXw+r9CP21Rd36aHUJNNmytIqBBkVpDcrIx2L0Vp/lE9ZNUWj0bxpIk6ykyllXKqSJ5CtjxVH/
AIe7yjml1mivzZNOqtEecxnXKZHjbsyC/Dtr4fV+hH7ap9ZECI9RHp5UDWDBZJYnF7E440dVHqdN
pkDmMLqXaNmsFbMoCNhxUndegDaKWGQalpdcBDEVRWjyqyGQ5ryDC2y9aru6SaKaaDSasu0LZ14+
a4tcA7G6K70/7f8A51T6OWDVGTTyPE5VIypaNihteUYYV8Pq/Qj9tWn+bT1c1SfKa3+qetP82nq5
qk+U1v8AVP8Aw0P++9TJWn+UT1k38NZFEpeRzAqIoLMzNDEAABtJrVf/AFcHul+X7p7476TP2+bk
zNHmtw322w6a/wDCaURy6FFSIjOxusWUoEKsGNso4r+OgoJZBsVybDC2HRsoNpAiyE2JD5zbwXNT
LzWtNDLE6mxGVwyEAbsOiu84i4YOICnSQvNv4swrvP5uf1jfw0/zaermqT5TW/1T1p/m09XNUWiz
8v3mHUw57ZsvMkmTNa4va9fud8Kn6oAPtnqDvKPvJdUIM/7axBc2dGj7Qla3a6K0/wAonrJv4L3/
AO+5Ms0E3u/Kv/cBBlz8wdrJ5td2pmDGDnNIgOPHysv9JqKRWVbLewBuoI2XvV2ZTgTexOwXO1vo
poroMq5r5fqxajiCuVsBfEEZtmY2wNGZVHAV7OwjG4I66m17d9xwe+yPqFjaMXUSsWtjMNmzZX7P
fKSfphDfZPWn+bT1c1SfKa3+qeo4dDGJXinWWQFlQLGscgLXkZR5QpYo9XqI1W9okmZY1BN2sga2
JNMJ4n1BJzJJnDEA9Rb66Mumz6e9uWgkub34m7WF+qlk1Lyah7ZS0rh2UAmwDMdlyaCxzzM4NyFd
r2seujHJIzT2IxJJzHs8VEavYbFb8Z/mxx6qEkblYSSQGN1y45eEm9ACXArsBYbSSdhr/p5FV2Nm
KhlJXHfh01Z5AWZXAO03NxtY1+zmTpIYAG3gNXUsCe0M+/x1cZwdxV/wak0+ommmiDAokkuZVbsh
gGa2ANP3VNFl1zafVRiHMp4pTKUGYNlxzDfRg00ySPKwVgrA2UcRvbwWoRYLioub3xtvvauMZmG8
f5jXC2RDuGB+6skagqVBzNfbfw1JnCoznNmsxuCNmBqTXKCpZmlCDBRy9mHXaiZzly7MuFy3hv0U
NOQscS3UMw47Le2+26ryyMzgWsp6OoCg4EikttYG2w1HFp3VlvaxFzxH6DVmQ3HRYg+DfVgeE4jw
1eiQq9YsfxptZqJIU1wimKwg2xQuIxlLFuIAb600cSoh42Y2tfsjcKXSyG0gNr2uvEbjG/X0VGyO
uOa+XZuqNQykhRewJOzqrLIpLMMALHbhjjQZspGC4eDwUth0qLbyWNQs4zzPmCIMccMB+Nc+dlkF
gcgJCLfdh2j9VGM5gL34AFGwdFqCRs4IN8W6j/MaEnCb7G7Dixt2lH20w1DCSJioEg7SEXwcffRl
29Nji+b7/toMOBMouxW9r33LQWA3KkFg6lLXBtvbbtqaNkQyCPUqGsN5e2Nr760rIbE5huOGHTXv
LC8wBYN1re2GzdQ5hzW2GwG3wUge6wAWuVAW1sMbUjSMpIuO1bceg1kN3tjYAfcKLTME5ea6sQDe
972PhoSzspdxftWyo2xRY+VtNNHE6hUCgm4NgCMAN5tRZohI4a2ZySdg+irMkRHQSPxoju+4jHZQ
DMp6crG++n954TsCyAJmGOZTs/Km0ksl9OSWhY2HCL2GbpUis2jjvGosVtzFzjE9PTeg0CBXJsci
3NuvbWoZr80Jqd2N+K2FaZM2Wwc3tfork5r4EZrdN91f3n+r+de5Wtbhz7exvt9FL+5v83qPXRmv
zL8Nuz1339FRLbLzmXOL3wtdqZs2U4G1r3zbBQ0at2SQWttYbT9NFb5rm97WoPmzXNrWtu8NRw5L
42zX6T4KjlDZc1w2F+LDHxUEDWMcnatuN1b6wKKhr5+K9rY9nr6qxixG3i/KtRPltwahrX6A2/6K
036X+1aChiFzJw3NsbUnJJFr5rG3RbfRlYFbbWuL4+A0rRsxGa3atu6zTrKc6hGID8Qv02NRJlUS
ZXC8PlGM5cbUDKbAtHbAnYeqjIxsmZjfw3rMhuAbX2fbWRbPYXsR+IpmhSy4ZbEDdUfMdgWfh4r7
FN9hplht7yUTECzZs634vHTJPdndWABObbl37rUzTICmWwvY43FToAAuScZbYYhq036X+1aH6k+6
kyAHNe9+q1APhnAJt46WKKxVjmu2JuQRut0UWUAki2NQzMOKN0zgdAsrfVRUM1hgDcbPJOzooSZm
zDBxcYMPo30IorEEZiWxNzhut0VzYiWY8JDYixx3W6K7K+I/jSobZYbgEb2a2bxWqMLYlmvj5qXv
9Zo4LZcNh/V01YbKn60n/tVpmYEghxh4Vrst4h+NdlvEPxrst4h+NLwtt6B0Hrpf1D7DRgYG0oZS
cLZjs3770IDiR/dHz083wrupeSQGZFGPZIFjY1xkRn6WHjC0FVzcG/ZJ3HoocsFFAYs3lkAnZ0U+
W6LHbOxAwvst19AqXWTKRiwSMbQuIVaLKCLi7ZtuYhSenppf1D7DWsub2TUgeia0v+l91LJIuONz
cjYT11tX0/zqy5STsAYn76RUFgRfeceLpoK4uAb7x9lNCg4b5Qu3aBQh1SkA9iQi1z+NIk7Z4QLc
1QL2AwzjC/h20BBMjLlxsQDe53PagYiga+P7inCx/mNLFnDsQQUQ22k7Xa1vormSOi48MStdQfpJ
uakaYjIxewvgL3sb9JocsogCgHiBudl8T1UFkViAb9m32CtXmUgyR6llG+2Vl+6tJh52z6KO3svu
PXX5Gk279x6DUdgTw/j01xbPNH30Jw1rFTlA823X1VGMG7WG/dSxoSoN7AjMMBfqNfuDN1hQf7Qo
OI8xJy2ygf2jVkXIOoXP3CmbEMtgWbrv14VjLfqVfvvXbFzt4fzoPlDXNrbKkntYcnUm1/NMg2/R
Wm1OXNIuoEYN7cLpIx+tRS67SOGMqS8uFrKzMrOmW5OXEjea/wDXN/xoPaVGNTpjpouLNKzwuF4T
bCOQticNlQ6a/PLwLIWPDiXkWwGPm0up7w1UsMLuI1bKHu5BYC0cbHYppY9NOz908yINqCGB5ZCc
1smQHDHyaj/+Wv3nyL+958sPLz25Vuesd82Vtl9lJDr9a+n7whUJqoliZuXMoyyoHSEg2a4uCabU
93a2aaFHMbNbJZwAxFpI1OxhUuj1buI0gaUcQbiV0XylPnVN3XHqXbvfLkg0xQgNNIoMKczl5BmL
Ljmw31w93WvttPD/ALdHumGEtrld4zDzFHHFmLjMTlwynfS6bvCEwzOgkVeYr3QkqDeMsNqmkHcy
tqNUZRnV2jUCPK92BbJje2+n7smjy94HT6pBHmUnPK0pTjDZccw31p/m09XNUXd+mh07ww5srSK5
c52aQ3KyKNrdFfD6T0JPbV8PpPQk9tSazWJGkiRiICIMq5VZn8tmx4qTR6x5EjSQSgxFVbMqsnlq
2HFSdxxvIdK0+niLsV5mWYRlsQoW/GbYVqPcpJpPecmfnMrW5ea2XIiefU+sln1Qk1EjyuFeMKGk
YubXiOGNPo9G8jxvIZSZSrNmZVTyFXDhrUfKP6yGp9ZEAZNPJp5UDXKlo4onF7EYYV8PpPQk9tWl
/wAUGSb37VJ73JHmXkiTVIS4VcmbKOYbcXjrT/KJ6yavh9J6EntqfvyRIxqlg1EoRQ3LzQmQLgWL
W4BfH/Iv/9k=">
</image>
</svg>

After

Width:  |  Height:  |  Size: 6.8 KiB

View file

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QQrDecoder</class>
<widget class="QMainWindow" name="QQrDecoder">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>640</height>
</rect>
</property>
<property name="windowTitle">
<string>QQrDecoder</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1,8">
<item>
<widget class="QPushButton" name="startDecode">
<property name="text">
<string>Capture And Decode</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="resultLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>No result</string>
</property>
</widget>
</item>
<item>
<widget class="QCameraControllerWidget" name="cameraWidget" native="true"/>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>QCameraControllerWidget</class>
<extends>QWidget</extends>
<header>qcameracontrollerwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

Binary file not shown.

View file

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

View file

@ -0,0 +1,241 @@
/*
* ============================================================================
* Name : cameraengine.h
* Part of : CameraWrapper
* Description : Camera engine class declaration
* Version : %version: 2 %
*
* Copyright (c) 2009 Nokia Corporation.
* This material, including documentation and any related
* computer programs, is protected by copyright controlled by
* Nokia Corporation.
* ==============================================================================
*/
#ifndef CCAMERAENGINE_H
#define CCAMERAENGINE_H
// INCLUDES
#include <e32base.h>
#include <ecam.h>
// FORWARD DECLARATIONS
class CCameraEnginePrivate;
class MCameraEngineObserver;
class CCameraAdvancedSettings;
NONSHARABLE_CLASS( CCameraEngine ) : public CBase
{
public:
enum TCameraEngineState
{
EEngineNotReady,
EEngineIdle,
EEngineViewFinding,
EEngineCapturing,
EEngineFocusing
};
IMPORT_C static CCameraEngine* NewL( TInt aCameraHandle,
TInt aPriority,
MCameraEngineObserver* aObserver );
IMPORT_C ~CCameraEngine();
public:
/**
* Returns the current state (TCameraEngineState)
* of the camera engine.
*/
IMPORT_C TCameraEngineState State() const;
/**
* Returns true if the camera has been reserved and
* powered on.
*/
IMPORT_C TBool IsCameraReady() const;
/**
* Returns true if the camera supports AutoFocus.
*/
IMPORT_C TBool IsAutoFocusSupported() const;
/**
* Captures an image. When complete, observer will receive
* MceoCapturedDataReady() or MceoCapturedBitmapReady() callback,
* depending on which image format was used in PrepareL().
* @leave May leave with KErrNotReady if camera is not
* reserved or prepared for capture.
*/
IMPORT_C void CaptureL();
/**
* Reserves and powers on the camera. When complete,
* observer will receive MceoCameraReady() callback
*
*/
IMPORT_C void ReserveAndPowerOn();
/**
* Releases and powers off the camera
*
*/
IMPORT_C void ReleaseAndPowerOff();
/**
* Prepares for image capture.
* @param aCaptureSize requested capture size. On return,
* contains the selected size (closest match)
* @param aFormat Image format to use. Default is JPEG with
* EXIF information as provided by the camera module
* @leave KErrNotSupported, KErrNoMemory, KErrNotReady
*/
IMPORT_C void PrepareL( TSize& aCaptureSize,
CCamera::TFormat aFormat = CCamera::EFormatExif );
/**
* Starts the viewfinder. Observer will receive
* MceoViewFinderFrameReady() callbacks periodically.
* @param aSize requested viewfinder size. On return,
* contains the selected size.
*
* @leave KErrNotSupported is viewfinding with bitmaps is not
* supported, KErrNotReady
*/
IMPORT_C void StartViewFinderL( TSize& aSize );
/**
* Stops the viewfinder if active.
*/
IMPORT_C void StopViewFinder();
/**
* Releases memory for the last received viewfinder frame.
* Client must call this in response to MceoViewFinderFrameReady()
* callback, after drawing the viewfinder frame is complete.
*/
IMPORT_C void ReleaseViewFinderBuffer();
/**
* Releases memory for the last captured image.
* Client must call this in response to MceoCapturedDataReady()
* or MceoCapturedBitmapReady()callback, after processing the
* data/bitmap is complete.
*/
IMPORT_C void ReleaseImageBuffer();
/**
* Starts focusing. Does nothing if AutoFocus is not supported.
* When complete, observer will receive MceoFocusComplete()
* callback.
* @leave KErrInUse, KErrNotReady
*/
IMPORT_C void StartFocusL();
/**
* Cancels the ongoing focusing operation.
*/
IMPORT_C void FocusCancel();
/**
* Gets a bitfield of supported focus ranges.
* @param aSupportedRanges a bitfield of either TAutoFocusRange
* (S60 3.0/3.1 devices) or TFocusRange (S60 3.2 and onwards) values
*/
IMPORT_C void SupportedFocusRanges( TInt& aSupportedRanges ) const;
/**
* Sets the focus range
* @param aFocusRange one of the values returned by
* SupportedFocusRanges().
*/
IMPORT_C void SetFocusRange( TInt aFocusRange );
/**
* Returns a pointer to CCamera object used by the engine.
* Allows getting access to additional functionality
* from CCamera - do not use for functionality already provided
* by CCameraEngine methods.
*/
IMPORT_C CCamera* Camera();
/**
* Returns a pointer to CCameraAdvancedSettings object used by
* the engine. May be NULL if adv. settings is not available.
* Allows getting access to additional functionality
* from CCameraAdvancedSettings - do not use for functionality already
* provided by CCameraEngine methods.
*/
IMPORT_C CCamera::CCameraAdvancedSettings* AdvancedSettings();
/**
* Static function that returns the number of cameras on the device.
*/
IMPORT_C static TInt CamerasAvailable();
/**
* Maximum digital zoom value. 0 if digital zoom is not supported
*/
IMPORT_C TInt MaxDigitalZoom();
/**
* Current digital zoom value
*/
IMPORT_C TInt DigitalZoom();
/**
* Adjust digital zoom. set aTele to ETrue to increase zoom (tele)
* or EFalse to decrease zoom (wide)
* @return Returns the new zoom level or KErrNotSupported
*/
IMPORT_C TInt AdjustDigitalZoom( TBool aTele );
/**
* Returns a bitfield of supported exposure modes
* See CCamera::TExposure
*/
IMPORT_C TInt SupportedExposureModes();
/**
* Returns the current exposure mode
* See CCamera::TExposure
*/
IMPORT_C TInt Exposure();
/**
* Set camera exposure mode
* See CCamera::TExposure
* @param aExposure One of the modes from SupportedExposureModes
* @return KErrNone or KErrNotSupported
*/
IMPORT_C TInt SetExposure( TInt aExposure );
/**
* Returns a bitfield of supported flash modes
* See CCamera::TFlash
*/
IMPORT_C TInt SupportedFlashModes();
/**
* Returns the current flash mode
* See CCamera::TFlash
*/
IMPORT_C TInt Flash();
/**
* Set camera flash mode
* See CCamera::TFlash
* @param aFlash One of the modes from SupportedFlashModes
* @return KErrNone or KErrNotSupported
*/
IMPORT_C TInt SetFlash( TInt aFlash );
protected:
CCameraEngine();
private:
CCameraEnginePrivate* iPimpl;
};
#endif //CCAMERAENGINE_H

View file

@ -0,0 +1,92 @@
/*
* ============================================================================
* Name : cameraengineobserver.h
* Part of : CameraWrapper
* Description : Observer interface for camera engine (wrapper DLL)
* Version : %version: 1 %
*
* Copyright (c) 2009 Nokia Corporation.
* This material, including documentation and any related
* computer programs, is protected by copyright controlled by
* Nokia Corporation.
* ==============================================================================
*/
#ifndef __CCAMERAENGINEOBSERVER_H__
#define __CCAMERAENGINEOBSERVER_H__
// FORWARD DECLARATIONS
class CFbsBitmap;
class TECAMEvent;
enum TCameraEngineError
{
EErrReserve,
EErrPowerOn,
EErrViewFinderReady,
EErrImageReady,
EErrAutoFocusInit,
EErrAutoFocusMode,
EErrAutoFocusArea,
EErrAutoFocusRange,
EErrAutoFocusType,
EErrOptimisedFocusComplete,
};
class MCameraEngineObserver
{
public:
/**
* Camera is ready to use for capturing images.
*/
virtual void MceoCameraReady() = 0;
/**
* Camera AF lens has attained optimal focus
*/
virtual void MceoFocusComplete() = 0;
/**
* Captured data is ready - call CCameraEngine::ReleaseImageBuffer()
* after processing/saving the data (typically, JPG-encoded image)
* @param aData Pointer to a descriptor containing a frame of camera data.
*/
virtual void MceoCapturedDataReady( TDesC8* aData ) = 0;
/**
* Captured bitmap is ready.
* after processing/saving the image, call
* CCameraEngine::ReleaseImageBuffer() to free the bitmap.
* @param aBitmap Pointer to an FBS bitmap containing a captured image.
*/
virtual void MceoCapturedBitmapReady( CFbsBitmap* aBitmap ) = 0;
/**
* A new viewfinder frame is ready.
* after displaying the frame, call
* CCameraEngine::ReleaseViewFinderBuffer()
* to free the bitmap.
* @param aFrame Pointer to an FBS bitmap containing a viewfinder frame.
*/
virtual void MceoViewFinderFrameReady( CFbsBitmap& aFrame ) = 0;
/**
* Notifies clients about errors in camera engine
* @param aErrorType type of error (see TCameraEngineError)
* @param aError Symbian system-wide error code
*/
virtual void MceoHandleError( TCameraEngineError aErrorType, TInt aError ) = 0;
/**
* Notifies client about other events not recognized by camera engine.
* The default implementation is empty.
* @param aEvent camera event (see MCameraObserver2::HandleEvent())
*/
virtual void MceoHandleOtherEvent( const TECAMEvent& /*aEvent*/ ) {}
};
#endif // __CCAMERAENGINEOBSERVER_H__
// eof

View file

@ -0,0 +1,431 @@
ARM Linker, RVCT2.2 [Build 616]
================================================================================
Image Symbol Table
Local Symbols
Symbol Name Value Ov Type Size Object(Section)
[Anonymous Symbol] 0x00000000 Number 0 FBSCLI{000a0000}-130.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 drtaeabi{000a0000}-184.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 FBSCLI{000a0000}-25.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-2123.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 scppnwdl{000a0000}-3.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 FBSCLI{000a0000}-30.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-2125.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-2061.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 FBSCLI{000a0000}-31.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-593.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-208.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 ecamadvsettings{000a0000}-120.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-649.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-2082.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 ecamadvsettings{000a0000}-125.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-654.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 ecamadvsettings{000a0000}-64.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 ecamadvsettings{000a0000}-26.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-669.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 drtaeabi{000a0000}-158.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 ecamadvsettings{000a0000}-28.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 ecam{000a0000}-2.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 drtaeabi{000a0000}-180.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 ecamadvsettings{000a0000}-41.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 ecam{000a0000}-3.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 drtaeabi{000a0000}-183.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 ecamadvsettings{000a0000}-42.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-1356.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-205.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-1657.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-1601.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-2060.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-1659.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-1311.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-1308.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-1838.o ABSOLUTE
[Anonymous Symbol] 0x00000000 Number 0 euser{000a0000}-1169.o ABSOLUTE
..\..\..\..\..\..\EPOC32\BUILD\src\common\generic\COMMS-INFRAS\Flogger\GROUP\FLOGGER\ARMV5\VtblExports.s 0x00000000 Number 0 VtblExports.o ABSOLUTE
..\src\Ccamautofocus.cpp 0x00000000 Number 0 CCamAutoFocus.o ABSOLUTE
..\src\Ccamautofocusimpl.cpp 0x00000000 Number 0 CCamAutoFocusImpl.o ABSOLUTE
\EPOC32\BUILD\src\cedar\generic\BASE\E32\EDLL\ARMV5\UREL\uc_dll_.cpp 0x00000000 Number 0 uc_dll_.o ABSOLUTE
\EPOC32\BUILD\src\cedar\generic\BASE\E32\EUSER\ARMV5\VtblExports.s 0x00000000 Number 0 VtblExports.o ABSOLUTE
\EPOC32\BUILD\src\cedar\generic\BASE\E32\compsupp\DRTAEABI\ARMV5\VtblExports.s 0x00000000 Number 0 VtblExports.o ABSOLUTE
\EPOC32\BUILD\src\common\generic\GRAPHICS\Fbserv\GROUP\FBSCLI\ARMV5\VtblExports.s 0x00000000 Number 0 VtblExports.o ABSOLUTE
\EPOC32\BUILD\src\common\generic\MULTIMEDIA\ECAM\GROUP\ECAMADVSETTINGS\ARMV5\VtblExports.s 0x00000000 Number 0 VtblExports.o ABSOLUTE
\EPOC32\BUILD\src\common\generic\MULTIMEDIA\ECAM\GROUP\ECAM\ARMV5\VtblExports.s 0x00000000 Number 0 VtblExports.o ABSOLUTE
\S60\S60_3rd_FP1\EPOC32\BUILD\S60\proj\CameraWrapper\group\CAMERAWRAPPER\ARMV5\camerawrapper{000a0000}.s 0x00000000 Number 0 camerawrapper{000a0000}.exp ABSOLUTE
\S60\proj\CameraWrapper\src\cameraengine.cpp 0x00000000 Number 0 camerawrapper.in ABSOLUTE
\S60\proj\CameraWrapper\src\cameraengineprivate.cpp 0x00000000 Number 0 camerawrapper.in ABSOLUTE
\\EPOC32\\BUILD\\src\\cedar\\generic\\BASE\\E32\\EDLL\\ARMV5\\UREL\\uc_dll_.cpp 0x00000000 Number 0 uc_dll_.o ABSOLUTE
\\src\\cedar\\generic\\BASE\\E32\\compsupp\\RVCT2_2\\ucppinit_aeabi.cpp 0x00000000 Number 0 ucppinit_aeabi.o ABSOLUTE
\src\cedar\generic\BASE\E32\EUSER\epoc\arm\uc_dll.cpp 0x00000000 Number 0 uc_dll.o ABSOLUTE
\src\cedar\generic\BASE\E32\compsupp\RVCT2_2\ucppinit_aeabi.cpp 0x00000000 Number 0 ucppinit_aeabi.o ABSOLUTE
.emb_text 0x00008000 Section 40 uc_dll_.o(.emb_text)
.emb_text 0x00008028 Section 72 ucppinit_aeabi.o(.emb_text)
skip 0x0000803c ARM Code 0 ucppinit_aeabi.o(.emb_text)
loop 0x0000804c ARM Code 0 ucppinit_aeabi.o(.emb_text)
fpinit 0x00008064 Data 0 ucppinit_aeabi.o(.emb_text)
base 0x00008068 Data 0 ucppinit_aeabi.o(.emb_text)
limit 0x0000806c Data 0 ucppinit_aeabi.o(.emb_text)
.text 0x00008070 Section 348 camerawrapper.in(.text)
.text 0x000081cc Section 2104 camerawrapper.in(.text)
.text 0x00008a04 Section 40 uc_dll.o(.text)
.text 0x00008a2c Section 188 CCamAutoFocus.o(.text)
.text 0x00008ae8 Section 304 CCamAutoFocusImpl.o(.text)
.text.clean 0x00008c18 Section 10 camerawrapper.in(.text.clean)
.text.clean 0x00008c22 Section 76 camerawrapper.in(.text.clean)
.text.clean 0x00008c6e Section 10 CCamAutoFocus.o(.text.clean)
.text.clean 0x00008c78 Section 10 CCamAutoFocusImpl.o(.text.clean)
ExportTable 0x00008c84 Section 140 camerawrapper{000a0000}.exp(ExportTable)
StubCode 0x00008d10 Section 8 euser{000a0000}-1169.o(StubCode)
theImportedSymbol 0x00008d14 Data 0 euser{000a0000}-1169.o(StubCode)
StubCode 0x00008d18 Section 8 euser{000a0000}-1308.o(StubCode)
theImportedSymbol 0x00008d1c Data 0 euser{000a0000}-1308.o(StubCode)
StubCode 0x00008d20 Section 8 euser{000a0000}-1311.o(StubCode)
theImportedSymbol 0x00008d24 Data 0 euser{000a0000}-1311.o(StubCode)
StubCode 0x00008d28 Section 8 euser{000a0000}-1356.o(StubCode)
theImportedSymbol 0x00008d2c Data 0 euser{000a0000}-1356.o(StubCode)
StubCode 0x00008d30 Section 8 euser{000a0000}-1601.o(StubCode)
theImportedSymbol 0x00008d34 Data 0 euser{000a0000}-1601.o(StubCode)
StubCode 0x00008d38 Section 8 euser{000a0000}-1657.o(StubCode)
theImportedSymbol 0x00008d3c Data 0 euser{000a0000}-1657.o(StubCode)
StubCode 0x00008d40 Section 8 euser{000a0000}-1659.o(StubCode)
theImportedSymbol 0x00008d44 Data 0 euser{000a0000}-1659.o(StubCode)
StubCode 0x00008d48 Section 8 euser{000a0000}-1838.o(StubCode)
theImportedSymbol 0x00008d4c Data 0 euser{000a0000}-1838.o(StubCode)
StubCode 0x00008d50 Section 8 euser{000a0000}-205.o(StubCode)
theImportedSymbol 0x00008d54 Data 0 euser{000a0000}-205.o(StubCode)
StubCode 0x00008d58 Section 8 euser{000a0000}-2060.o(StubCode)
theImportedSymbol 0x00008d5c Data 0 euser{000a0000}-2060.o(StubCode)
StubCode 0x00008d60 Section 8 euser{000a0000}-2061.o(StubCode)
theImportedSymbol 0x00008d64 Data 0 euser{000a0000}-2061.o(StubCode)
StubCode 0x00008d68 Section 8 euser{000a0000}-208.o(StubCode)
theImportedSymbol 0x00008d6c Data 0 euser{000a0000}-208.o(StubCode)
StubCode 0x00008d70 Section 8 euser{000a0000}-2082.o(StubCode)
theImportedSymbol 0x00008d74 Data 0 euser{000a0000}-2082.o(StubCode)
StubCode 0x00008d78 Section 8 euser{000a0000}-2123.o(StubCode)
theImportedSymbol 0x00008d7c Data 0 euser{000a0000}-2123.o(StubCode)
StubCode 0x00008d80 Section 8 euser{000a0000}-2125.o(StubCode)
theImportedSymbol 0x00008d84 Data 0 euser{000a0000}-2125.o(StubCode)
StubCode 0x00008d88 Section 8 euser{000a0000}-593.o(StubCode)
theImportedSymbol 0x00008d8c Data 0 euser{000a0000}-593.o(StubCode)
StubCode 0x00008d90 Section 8 euser{000a0000}-649.o(StubCode)
theImportedSymbol 0x00008d94 Data 0 euser{000a0000}-649.o(StubCode)
StubCode 0x00008d98 Section 8 euser{000a0000}-654.o(StubCode)
theImportedSymbol 0x00008d9c Data 0 euser{000a0000}-654.o(StubCode)
StubCode 0x00008da0 Section 8 euser{000a0000}-669.o(StubCode)
theImportedSymbol 0x00008da4 Data 0 euser{000a0000}-669.o(StubCode)
StubCode 0x00008da8 Section 8 ecam{000a0000}-2.o(StubCode)
theImportedSymbol 0x00008dac Data 0 ecam{000a0000}-2.o(StubCode)
StubCode 0x00008db0 Section 8 ecam{000a0000}-3.o(StubCode)
theImportedSymbol 0x00008db4 Data 0 ecam{000a0000}-3.o(StubCode)
StubCode 0x00008db8 Section 8 FBSCLI{000a0000}-130.o(StubCode)
theImportedSymbol 0x00008dbc Data 0 FBSCLI{000a0000}-130.o(StubCode)
StubCode 0x00008dc0 Section 8 FBSCLI{000a0000}-25.o(StubCode)
theImportedSymbol 0x00008dc4 Data 0 FBSCLI{000a0000}-25.o(StubCode)
StubCode 0x00008dc8 Section 8 FBSCLI{000a0000}-30.o(StubCode)
theImportedSymbol 0x00008dcc Data 0 FBSCLI{000a0000}-30.o(StubCode)
StubCode 0x00008dd0 Section 8 FBSCLI{000a0000}-31.o(StubCode)
theImportedSymbol 0x00008dd4 Data 0 FBSCLI{000a0000}-31.o(StubCode)
StubCode 0x00008dd8 Section 8 ecamadvsettings{000a0000}-120.o(StubCode)
theImportedSymbol 0x00008ddc Data 0 ecamadvsettings{000a0000}-120.o(StubCode)
StubCode 0x00008de0 Section 8 ecamadvsettings{000a0000}-125.o(StubCode)
theImportedSymbol 0x00008de4 Data 0 ecamadvsettings{000a0000}-125.o(StubCode)
StubCode 0x00008de8 Section 8 ecamadvsettings{000a0000}-26.o(StubCode)
theImportedSymbol 0x00008dec Data 0 ecamadvsettings{000a0000}-26.o(StubCode)
StubCode 0x00008df0 Section 8 ecamadvsettings{000a0000}-28.o(StubCode)
theImportedSymbol 0x00008df4 Data 0 ecamadvsettings{000a0000}-28.o(StubCode)
StubCode 0x00008df8 Section 8 ecamadvsettings{000a0000}-41.o(StubCode)
theImportedSymbol 0x00008dfc Data 0 ecamadvsettings{000a0000}-41.o(StubCode)
StubCode 0x00008e00 Section 8 ecamadvsettings{000a0000}-42.o(StubCode)
theImportedSymbol 0x00008e04 Data 0 ecamadvsettings{000a0000}-42.o(StubCode)
StubCode 0x00008e08 Section 8 ecamadvsettings{000a0000}-64.o(StubCode)
theImportedSymbol 0x00008e0c Data 0 ecamadvsettings{000a0000}-64.o(StubCode)
StubCode 0x00008e10 Section 8 drtaeabi{000a0000}-158.o(StubCode)
theImportedSymbol 0x00008e14 Data 0 drtaeabi{000a0000}-158.o(StubCode)
StubCode 0x00008e18 Section 8 drtaeabi{000a0000}-180.o(StubCode)
theImportedSymbol 0x00008e1c Data 0 drtaeabi{000a0000}-180.o(StubCode)
StubCode 0x00008e20 Section 8 drtaeabi{000a0000}-183.o(StubCode)
theImportedSymbol 0x00008e24 Data 0 drtaeabi{000a0000}-183.o(StubCode)
StubCode 0x00008e28 Section 8 drtaeabi{000a0000}-184.o(StubCode)
theImportedSymbol 0x00008e2c Data 0 drtaeabi{000a0000}-184.o(StubCode)
StubCode 0x00008e30 Section 8 scppnwdl{000a0000}-3.o(StubCode)
theImportedSymbol 0x00008e34 Data 0 scppnwdl{000a0000}-3.o(StubCode)
i._ZN20CCameraEnginePrivate16FrameBufferReadyEP12MFrameBufferi 0x00008e38 Section 2 camerawrapper.in(i._ZN20CCameraEnginePrivate16FrameBufferReadyEP12MFrameBufferi)
i._ZN20CCameraEnginePrivate16VideoBufferReadyER13MCameraBufferi 0x00008e3a Section 2 camerawrapper.in(i._ZN20CCameraEnginePrivate16VideoBufferReadyER13MCameraBufferi)
i._ZThn4_N20CCameraEnginePrivate16FrameBufferReadyEP12MFrameBufferi 0x00008e3c Section 2 camerawrapper.in(i._ZThn4_N20CCameraEnginePrivate16FrameBufferReadyEP12MFrameBufferi)
i._ZThn8_N20CCameraEnginePrivate16VideoBufferReadyER13MCameraBufferi 0x00008e3e Section 2 camerawrapper.in(i._ZThn8_N20CCameraEnginePrivate16VideoBufferReadyER13MCameraBufferi)
.extab._ZN13CCameraEngineD1Ev 0x00008e40 Data 0 camerawrapper.in(.ARM.extab)
.extab._ZN20CCameraEnginePrivate10ConstructLEv 0x00008e50 Data 0 camerawrapper.in(.ARM.extab)
.extab._ZN20CCameraEnginePrivateC1EiiP21MCameraEngineObserver 0x00008eb8 Data 0 camerawrapper.in(.ARM.extab)
.extab._ZN20CCameraEnginePrivateD1Ev 0x00008ec8 Data 0 camerawrapper.in(.ARM.extab)
.extab._ZN20CCameraEnginePrivate13SetFocusRangeEi 0x00008ed8 Data 0 camerawrapper.in(.ARM.extab)
.extab._ZN20CCameraEnginePrivate17AdjustDigitalZoomEi 0x00008f00 Data 0 camerawrapper.in(.ARM.extab)
.extab._ZN20CCameraEnginePrivate11SetExposureEi 0x00008f28 Data 0 camerawrapper.in(.ARM.extab)
.extab._ZN20CCameraEnginePrivate8SetFlashEi 0x00008f50 Data 0 camerawrapper.in(.ARM.extab)
.extab._ZN20CCameraEnginePrivate16ImageBufferReadyER13MCameraBufferi 0x00008f78 Data 0 camerawrapper.in(.ARM.extab)
.extab._ZN20CCameraEnginePrivate15PowerOnCompleteEi 0x00008fc0 Data 0 camerawrapper.in(.ARM.extab)
.extab._ZN13CCamAutoFocusD1Ev 0x00008fe8 Data 0 CCamAutoFocus.o(.ARM.extab)
.extab._ZN17CCamAutoFocusImplD1Ev 0x00008ff8 Data 0 CCamAutoFocusImpl.o(.ARM.extab)
.constdata$1 0x00009008 Data 0 camerawrapper.in(.constdata)
KUidECamEventReserveComplete 0x00009008 Data 4 camerawrapper.in(.constdata)
.constdata 0x00009008 Section 16 camerawrapper.in(.constdata)
KUidECamEventPowerOnComplete 0x0000900c Data 4 camerawrapper.in(.constdata)
KNullDesC 0x00009010 Data 8 camerawrapper.in(.constdata)
.constdata$1 0x00009018 Data 0 CCamAutoFocusImpl.o(.constdata)
KCameraAutoFocusUid 0x00009018 Data 4 CCamAutoFocusImpl.o(.constdata)
.constdata 0x00009018 Section 4 CCamAutoFocusImpl.o(.constdata)
.constdata__ZTI13CCamAutoFocus 0x0000901c Section 12 CCamAutoFocus.o(.constdata__ZTI13CCamAutoFocus)
.constdata__ZTI13CCameraEngine 0x00009028 Section 12 camerawrapper.in(.constdata__ZTI13CCameraEngine)
.constdata__ZTI15MCameraObserver 0x00009034 Section 8 camerawrapper.in(.constdata__ZTI15MCameraObserver)
.constdata__ZTI16MCameraObserver2 0x0000903c Section 8 camerawrapper.in(.constdata__ZTI16MCameraObserver2)
.constdata__ZTI17CCamAutoFocusImpl 0x00009044 Section 32 CCamAutoFocusImpl.o(.constdata__ZTI17CCamAutoFocusImpl)
.constdata__ZTI20CCameraEnginePrivate 0x00009064 Section 48 camerawrapper.in(.constdata__ZTI20CCameraEnginePrivate)
.constdata__ZTI21MCamAutoFocusObserver 0x00009094 Section 8 camerawrapper.in(.constdata__ZTI21MCamAutoFocusObserver)
.constdata__ZTI24MCameraAutoFocusObserver 0x0000909c Section 8 CCamAutoFocusImpl.o(.constdata__ZTI24MCameraAutoFocusObserver)
.constdata__ZTS13CCamAutoFocus 0x000090a4 Section 16 CCamAutoFocus.o(.constdata__ZTS13CCamAutoFocus)
.constdata__ZTS13CCameraEngine 0x000090b4 Section 16 camerawrapper.in(.constdata__ZTS13CCameraEngine)
.constdata__ZTS15MCameraObserver 0x000090c4 Section 18 camerawrapper.in(.constdata__ZTS15MCameraObserver)
.constdata__ZTS16MCameraObserver2 0x000090d6 Section 19 camerawrapper.in(.constdata__ZTS16MCameraObserver2)
.constdata__ZTS17CCamAutoFocusImpl 0x000090e9 Section 20 CCamAutoFocusImpl.o(.constdata__ZTS17CCamAutoFocusImpl)
.constdata__ZTS20CCameraEnginePrivate 0x000090fd Section 23 camerawrapper.in(.constdata__ZTS20CCameraEnginePrivate)
.constdata__ZTS21MCamAutoFocusObserver 0x00009114 Section 24 camerawrapper.in(.constdata__ZTS21MCamAutoFocusObserver)
.constdata__ZTS24MCameraAutoFocusObserver 0x0000912c Section 27 CCamAutoFocusImpl.o(.constdata__ZTS24MCameraAutoFocusObserver)
.constdata__ZTV13CCamAutoFocus 0x00009148 Section 20 CCamAutoFocus.o(.constdata__ZTV13CCamAutoFocus)
.constdata__ZTV13CCameraEngine 0x0000915c Section 20 camerawrapper.in(.constdata__ZTV13CCameraEngine)
.constdata__ZTV17CCamAutoFocusImpl 0x00009170 Section 44 CCamAutoFocusImpl.o(.constdata__ZTV17CCamAutoFocusImpl)
.constdata__ZTV20CCameraEnginePrivate 0x0000919c Section 132 camerawrapper.in(.constdata__ZTV20CCameraEnginePrivate)
.ARM.exidx 0x00009220 Section 8 ucppinit_aeabi.o(.ARM.exidx)
Global Symbols
Symbol Name Value Ov Type Size Object(Section)
BuildAttributes$$THUMB_ISAv2$ARM_ISAv5$M$PE$A:L22$X:L11$S22$IEEE1$IW$USESV6$~STKCKD$USESV7$~SHL$OSPACE$IEEEJ$EBA8$UX$REQ8$PRES8$EABIv2 0x00000000 Number 0 anon$$obj.o ABSOLUTE
#<DLL>FBSCLI{000a0000}[10003a15].DLL#<\DLL>19 - Undefined Reference
#<DLL>FBSCLI{000a0000}[10003a15].DLL#<\DLL>1e - Undefined Reference
#<DLL>FBSCLI{000a0000}[10003a15].DLL#<\DLL>1f - Undefined Reference
#<DLL>FBSCLI{000a0000}[10003a15].DLL#<\DLL>82 - Undefined Reference
#<DLL>drtaeabi{000a0000}.dll#<\DLL>9e - Undefined Reference
#<DLL>drtaeabi{000a0000}.dll#<\DLL>b4 - Undefined Reference
#<DLL>drtaeabi{000a0000}.dll#<\DLL>b7 - Undefined Reference
#<DLL>drtaeabi{000a0000}.dll#<\DLL>b8 - Undefined Reference
#<DLL>ecamadvsettings{000a0000}[1020e76b].dll#<\DLL>1a - Undefined Reference
#<DLL>ecamadvsettings{000a0000}[1020e76b].dll#<\DLL>1c - Undefined Reference
#<DLL>ecamadvsettings{000a0000}[1020e76b].dll#<\DLL>29 - Undefined Reference
#<DLL>ecamadvsettings{000a0000}[1020e76b].dll#<\DLL>2a - Undefined Reference
#<DLL>ecamadvsettings{000a0000}[1020e76b].dll#<\DLL>40 - Undefined Reference
#<DLL>ecamadvsettings{000a0000}[1020e76b].dll#<\DLL>78 - Undefined Reference
#<DLL>ecamadvsettings{000a0000}[1020e76b].dll#<\DLL>7d - Undefined Reference
#<DLL>ecam{000a0000}[101fb4c3].dll#<\DLL>2 - Undefined Reference
#<DLL>ecam{000a0000}[101fb4c3].dll#<\DLL>3 - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>251 - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>289 - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>28e - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>29d - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>491 - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>51c - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>51f - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>54c - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>641 - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>679 - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>67b - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>72e - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>80c - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>80d - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>822 - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>84b - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>84d - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>cd - Undefined Reference
#<DLL>euser{000a0000}[100039e5].dll#<\DLL>d0 - Undefined Reference
#<DLL>scppnwdl{000a0000}.dll#<\DLL>3 - Undefined Reference
SHT$$INIT_ARRAY$$Base - Undefined Weak Reference
SHT$$INIT_ARRAY$$Limit - Undefined Weak Reference
typeinfo for XLeaveException - Undefined Reference
typeinfo for CBase - Undefined Reference
vtable for __cxxabiv1::__class_type_info - Undefined Reference
vtable for __cxxabiv1::__si_class_type_info - Undefined Reference
vtable for __cxxabiv1::__vmi_class_type_info - Undefined Reference
_fp_init - Undefined Weak Reference
run_static_dtors - Undefined Weak Reference
Image$$ER_RO$$Base 0x00008000 Number 0 anon$$obj.o(linker$$defined$$symbols)
_E32Dll 0x00008000 ARM Code 40 uc_dll_.o(.emb_text)
Symbian$$CPP$$Exception$$Descriptor 0x00008014 Data 0 uc_dll_.o(.emb_text)
__cpp_initialize__aeabi_ 0x00008028 ARM Code 72 ucppinit_aeabi.o(.emb_text)
CCameraEngine::CCameraEngine() 0x00008071 Thumb Code 6 camerawrapper.in(.text)
CCameraEngine::CCameraEngine__sub_object() 0x00008071 Thumb Code 0 camerawrapper.in(.text)
std::nothrow 0x00008071 Thumb Code 0 ucppinit_aeabi.o(.emb_text)
CCameraEngine::NewL(int, int, MCameraEngineObserver*) 0x00008077 Thumb Code 44 camerawrapper.in(.text)
CCameraEngine::~CCameraEngine() 0x000080a3 Thumb Code 28 camerawrapper.in(.text)
CCameraEngine::~CCameraEngine__sub_object() 0x000080a3 Thumb Code 0 camerawrapper.in(.text)
CCameraEngine::~CCameraEngine__deallocating() 0x000080bf Thumb Code 16 camerawrapper.in(.text)
CCameraEngine::State() const 0x000080cf Thumb Code 6 camerawrapper.in(.text)
CCameraEngine::IsCameraReady() const 0x000080d5 Thumb Code 6 camerawrapper.in(.text)
CCameraEngine::IsAutoFocusSupported() const 0x000080db Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::CaptureL() 0x000080e5 Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::ReserveAndPowerOn() 0x000080ef Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::ReleaseAndPowerOff() 0x000080f9 Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::PrepareL(TSize&, CCamera::TFormat) 0x00008103 Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::StartViewFinderL(TSize&) 0x0000810d Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::StopViewFinder() 0x00008117 Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::ReleaseViewFinderBuffer() 0x00008121 Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::ReleaseImageBuffer() 0x0000812b Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::StartFocusL() 0x00008135 Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::FocusCancel() 0x0000813f Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::SupportedFocusRanges(int&) const 0x00008149 Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::SetFocusRange(int) 0x00008153 Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::Camera() 0x0000815d Thumb Code 6 camerawrapper.in(.text)
CCameraEngine::AdvancedSettings() 0x00008163 Thumb Code 8 camerawrapper.in(.text)
CCameraEngine::CamerasAvailable() 0x0000816b Thumb Code 8 camerawrapper.in(.text)
CCameraEngine::MaxDigitalZoom() 0x00008173 Thumb Code 6 camerawrapper.in(.text)
CCameraEngine::DigitalZoom() 0x00008179 Thumb Code 8 camerawrapper.in(.text)
CCameraEngine::AdjustDigitalZoom(int) 0x00008181 Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::SupportedExposureModes() 0x0000818b Thumb Code 6 camerawrapper.in(.text)
CCameraEngine::Exposure() 0x00008191 Thumb Code 14 camerawrapper.in(.text)
CCameraEngine::SetExposure(int) 0x0000819f Thumb Code 10 camerawrapper.in(.text)
CCameraEngine::SupportedFlashModes() 0x000081a9 Thumb Code 6 camerawrapper.in(.text)
CCameraEngine::Flash() 0x000081af Thumb Code 14 camerawrapper.in(.text)
CCameraEngine::SetFlash(int) 0x000081bd Thumb Code 10 camerawrapper.in(.text)
CCameraEnginePrivate::ConstructL() 0x000081cd Thumb Code 268 camerawrapper.in(.text)
CCameraEnginePrivate::CCameraEnginePrivate(int, int, MCameraEngineObserver*) 0x000082d9 Thumb Code 48 camerawrapper.in(.text)
CCameraEnginePrivate::CCameraEnginePrivate__sub_object(int, int, MCameraEngineObserver*) 0x000082d9 Thumb Code 0 camerawrapper.in(.text)
CCameraEnginePrivate::NewL(int, int, MCameraEngineObserver*) 0x00008309 Thumb Code 44 camerawrapper.in(.text)
CCameraEnginePrivate::ReleaseImageBuffer() 0x00008335 Thumb Code 40 camerawrapper.in(.text)
CCameraEnginePrivate::ReleaseViewFinderBuffer() 0x0000835d Thumb Code 22 camerawrapper.in(.text)
CCameraEnginePrivate::StopViewFinder() 0x00008373 Thumb Code 30 camerawrapper.in(.text)
CCameraEnginePrivate::~CCameraEnginePrivate() 0x00008391 Thumb Code 98 camerawrapper.in(.text)
CCameraEnginePrivate::~CCameraEnginePrivate__sub_object() 0x00008391 Thumb Code 0 camerawrapper.in(.text)
CCameraEnginePrivate::~CCameraEnginePrivate__deallocating() 0x000083f3 Thumb Code 16 camerawrapper.in(.text)
CCameraEnginePrivate::IsAutoFocusSupported() const 0x00008403 Thumb Code 34 camerawrapper.in(.text)
CCameraEnginePrivate::CaptureL() 0x00008425 Thumb Code 34 camerawrapper.in(.text)
CCameraEnginePrivate::ReserveAndPowerOn() 0x00008447 Thumb Code 8 camerawrapper.in(.text)
CCameraEnginePrivate::FocusCancel() 0x0000844f Thumb Code 38 camerawrapper.in(.text)
CCameraEnginePrivate::ReleaseAndPowerOff() 0x00008475 Thumb Code 44 camerawrapper.in(.text)
CCameraEnginePrivate::PrepareL(TSize&, CCamera::TFormat) 0x000084a1 Thumb Code 118 camerawrapper.in(.text)
CCameraEnginePrivate::StartViewFinderL(TSize&) 0x00008517 Thumb Code 62 camerawrapper.in(.text)
CCameraEnginePrivate::StartFocusL() 0x00008555 Thumb Code 88 camerawrapper.in(.text)
CCameraEnginePrivate::SupportedFocusRanges(int&) const 0x000085ad Thumb Code 36 camerawrapper.in(.text)
CCameraEnginePrivate::SetFocusRange(int) 0x000085d1 Thumb Code 98 camerawrapper.in(.text)
CCameraEnginePrivate::AdjustDigitalZoom(int) 0x00008633 Thumb Code 110 camerawrapper.in(.text)
CCameraEnginePrivate::SetExposure(int) 0x000086a1 Thumb Code 62 camerawrapper.in(.text)
CCameraEnginePrivate::SetFlash(int) 0x000086df Thumb Code 62 camerawrapper.in(.text)
CCameraEnginePrivate::HandleEvent(const TECAMEvent&) 0x0000871d Thumb Code 196 camerawrapper.in(.text)
thunk{-8} to CCameraEnginePrivate::HandleEvent(const TECAMEvent&) 0x000087e1 Thumb Code 4 camerawrapper.in(.text)
CCameraEnginePrivate::ViewFinderReady(MCameraBuffer&, int) 0x000087e5 Thumb Code 46 camerawrapper.in(.text)
thunk{-8} to CCameraEnginePrivate::ViewFinderReady(MCameraBuffer&, int) 0x00008813 Thumb Code 4 camerawrapper.in(.text)
CCameraEnginePrivate::HandleImageReady(CFbsBitmap*, TDesC8*, int) 0x00008817 Thumb Code 60 camerawrapper.in(.text)
CCameraEnginePrivate::ImageBufferReady(MCameraBuffer&, int) 0x00008853 Thumb Code 126 camerawrapper.in(.text)
thunk{-8} to CCameraEnginePrivate::ImageBufferReady(MCameraBuffer&, int) 0x000088d1 Thumb Code 4 camerawrapper.in(.text)
CCameraEnginePrivate::ReserveComplete(int) 0x000088d5 Thumb Code 24 camerawrapper.in(.text)
thunk{-4} to CCameraEnginePrivate::ReserveComplete(int) 0x000088ed Thumb Code 4 camerawrapper.in(.text)
CCameraEnginePrivate::PowerOnComplete(int) 0x000088f1 Thumb Code 142 camerawrapper.in(.text)
thunk{-4} to CCameraEnginePrivate::PowerOnComplete(int) 0x0000897f Thumb Code 4 camerawrapper.in(.text)
CCameraEnginePrivate::ViewFinderFrameReady(CFbsBitmap&) 0x00008983 Thumb Code 8 camerawrapper.in(.text)
thunk{-4} to CCameraEnginePrivate::ViewFinderFrameReady(CFbsBitmap&) 0x0000898b Thumb Code 4 camerawrapper.in(.text)
CCameraEnginePrivate::ImageReady(CFbsBitmap*, HBufC8*, int) 0x0000898f Thumb Code 48 camerawrapper.in(.text)
thunk{-4} to CCameraEnginePrivate::ImageReady(CFbsBitmap*, HBufC8*, int) 0x000089bf Thumb Code 4 camerawrapper.in(.text)
CCameraEnginePrivate::InitComplete(int) 0x000089c3 Thumb Code 18 camerawrapper.in(.text)
thunk{-12} to CCameraEnginePrivate::InitComplete(int) 0x000089d5 Thumb Code 4 camerawrapper.in(.text)
CCameraEnginePrivate::OptimisedFocusComplete(int) 0x000089d9 Thumb Code 26 camerawrapper.in(.text)
thunk{-12} to CCameraEnginePrivate::OptimisedFocusComplete(int) 0x000089f3 Thumb Code 4 camerawrapper.in(.text)
_E32Dll_Body 0x00008a05 Thumb Code 34 uc_dll.o(.text)
CCamAutoFocus::ConstructL(CCamera*) 0x00008a2d Thumb Code 26 CCamAutoFocus.o(.text)
CCamAutoFocus::CCamAutoFocus() 0x00008a47 Thumb Code 6 CCamAutoFocus.o(.text)
CCamAutoFocus::CCamAutoFocus__sub_object() 0x00008a47 Thumb Code 0 CCamAutoFocus.o(.text)
CCamAutoFocus::NewL(CCamera*) 0x00008a4d Thumb Code 36 CCamAutoFocus.o(.text)
CCamAutoFocus::~CCamAutoFocus() 0x00008a71 Thumb Code 28 CCamAutoFocus.o(.text)
CCamAutoFocus::~CCamAutoFocus__sub_object() 0x00008a71 Thumb Code 0 CCamAutoFocus.o(.text)
CCamAutoFocus::~CCamAutoFocus__deallocating() 0x00008a8d Thumb Code 16 CCamAutoFocus.o(.text)
CCamAutoFocus::InitL(MCamAutoFocusObserver&) 0x00008a9d Thumb Code 10 CCamAutoFocus.o(.text)
CCamAutoFocus::AttemptOptimisedFocusL() 0x00008aa7 Thumb Code 10 CCamAutoFocus.o(.text)
CCamAutoFocus::SetFocusRangeL(CCamAutoFocus::TAutoFocusRange) 0x00008ab1 Thumb Code 10 CCamAutoFocus.o(.text)
CCamAutoFocus::FocusRange(CCamAutoFocus::TAutoFocusRange&) 0x00008abb Thumb Code 10 CCamAutoFocus.o(.text)
CCamAutoFocus::Cancel() 0x00008ac5 Thumb Code 10 CCamAutoFocus.o(.text)
CCamAutoFocus::ResetToIdleL() 0x00008acf Thumb Code 10 CCamAutoFocus.o(.text)
CCamAutoFocus::Close() 0x00008ad9 Thumb Code 10 CCamAutoFocus.o(.text)
CCamAutoFocusImpl::CCamAutoFocusImpl(CCamera*) 0x00008ae9 Thumb Code 22 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::CCamAutoFocusImpl__sub_object(CCamera*) 0x00008ae9 Thumb Code 0 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::ConstructL() 0x00008aff Thumb Code 2 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::Close() 0x00008b01 Thumb Code 22 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::~CCamAutoFocusImpl() 0x00008b17 Thumb Code 26 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::~CCamAutoFocusImpl__sub_object() 0x00008b17 Thumb Code 0 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::~CCamAutoFocusImpl__deallocating() 0x00008b31 Thumb Code 16 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::InitL(MCamAutoFocusObserver&) 0x00008b41 Thumb Code 60 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::AttemptOptimisedFocusL() 0x00008b7d Thumb Code 28 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::SetFocusRangeL(int) 0x00008b99 Thumb Code 34 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::FocusRange(int&) 0x00008bbb Thumb Code 6 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::Cancel() 0x00008bc1 Thumb Code 14 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::ResetToIdleL() 0x00008bcf Thumb Code 28 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::InitComplete(int) 0x00008beb Thumb Code 14 CCamAutoFocusImpl.o(.text)
thunk{-4} to CCamAutoFocusImpl::InitComplete(int) 0x00008bf9 Thumb Code 4 CCamAutoFocusImpl.o(.text)
CCamAutoFocusImpl::OptimisedFocusComplete(int) 0x00008bfd Thumb Code 14 CCamAutoFocusImpl.o(.text)
thunk{-4} to CCamAutoFocusImpl::OptimisedFocusComplete(int) 0x00008c0b Thumb Code 4 CCamAutoFocusImpl.o(.text)
__DLL_Export_Table__ 0x00008c84 ARM Code 0 camerawrapper{000a0000}.exp(ExportTable)
DLL##ExportTableSize 0x00008c88 Data 0 camerawrapper{000a0000}.exp(ExportTable)
DLL##ExportTable 0x00008c8c Data 0 camerawrapper{000a0000}.exp(ExportTable)
TPtrC16::TPtrC16(const unsigned short*) 0x00008d10 ARM Code 0 euser{000a0000}-1169.o(StubCode)
RLibrary::Load(const TDesC16&, const TDesC16&) 0x00008d18 ARM Code 0 euser{000a0000}-1308.o(StubCode)
RLibrary::Close() 0x00008d20 ARM Code 0 euser{000a0000}-1311.o(StubCode)
TVersion::TVersion() 0x00008d28 ARM Code 0 euser{000a0000}-1356.o(StubCode)
TUid::operator ==(const TUid&) const 0x00008d30 ARM Code 0 euser{000a0000}-1601.o(StubCode)
TSize::operator ==(const TSize&) const 0x00008d38 ARM Code 0 euser{000a0000}-1657.o(StubCode)
TSize::operator -(const TSize&) const 0x00008d40 ARM Code 0 euser{000a0000}-1659.o(StubCode)
RLibrary::Lookup(int) const 0x00008d48 ARM Code 0 euser{000a0000}-1838.o(StubCode)
CleanupStack::Pop() 0x00008d50 ARM Code 0 euser{000a0000}-205.o(StubCode)
User::MarkCleanupStack() 0x00008d58 ARM Code 0 euser{000a0000}-2060.o(StubCode)
User::UnMarkCleanupStack(TTrapHandler*) 0x00008d60 ARM Code 0 euser{000a0000}-2061.o(StubCode)
CleanupStack::PushL(CBase*) 0x00008d68 ARM Code 0 euser{000a0000}-208.o(StubCode)
XLeaveException::GetReason() const 0x00008d70 ARM Code 0 euser{000a0000}-2082.o(StubCode)
CBase::Extension_(unsigned, void*&, void*) 0x00008d78 ARM Code 0 euser{000a0000}-2123.o(StubCode)
CBase::~CBase() 0x00008d80 ARM Code 0 euser{000a0000}-2125.o(StubCode)
User::LeaveIfError(int) 0x00008d88 ARM Code 0 euser{000a0000}-593.o(StubCode)
User::Leave(int) 0x00008d90 ARM Code 0 euser{000a0000}-649.o(StubCode)
User::AllocZL(int) 0x00008d98 ARM Code 0 euser{000a0000}-654.o(StubCode)
User::Invariant() 0x00008da0 ARM Code 0 euser{000a0000}-669.o(StubCode)
CCamera::CamerasAvailable() 0x00008da8 ARM Code 0 ecam{000a0000}-2.o(StubCode)
CCamera::NewL(MCameraObserver&, int) 0x00008db0 ARM Code 0 ecam{000a0000}-3.o(StubCode)
CFbsBitmap::Handle() const 0x00008db8 ARM Code 0 FBSCLI{000a0000}-130.o(StubCode)
CFbsBitmap::Reset() 0x00008dc0 ARM Code 0 FBSCLI{000a0000}-25.o(StubCode)
CFbsBitmap::Duplicate(int) 0x00008dc8 ARM Code 0 FBSCLI{000a0000}-30.o(StubCode)
CFbsBitmap::CFbsBitmap() 0x00008dd0 ARM Code 0 FBSCLI{000a0000}-31.o(StubCode)
CCamera::CCameraAdvancedSettings::SupportedFocusModes() const 0x00008dd8 ARM Code 0 ecamadvsettings{000a0000}-120.o(StubCode)
CCamera::CCameraAdvancedSettings::SupportedFocusRanges() const 0x00008de0 ARM Code 0 ecamadvsettings{000a0000}-125.o(StubCode)
CCamera::CCameraAdvancedSettings::SetFocusMode(CCamera::CCameraAdvancedSettings::TFocusMode) 0x00008de8 ARM Code 0 ecamadvsettings{000a0000}-26.o(StubCode)
CCamera::CCameraAdvancedSettings::SetFocusRange(CCamera::CCameraAdvancedSettings::TFocusRange) 0x00008df0 ARM Code 0 ecamadvsettings{000a0000}-28.o(StubCode)
CCamera::CCameraAdvancedSettings::SetAutoFocusArea(CCamera::CCameraAdvancedSettings::TAutoFocusArea) 0x00008df8 ARM Code 0 ecamadvsettings{000a0000}-41.o(StubCode)
CCamera::CCameraAdvancedSettings::SetAutoFocusType(CCamera::CCameraAdvancedSettings::TAutoFocusType) 0x00008e00 ARM Code 0 ecamadvsettings{000a0000}-42.o(StubCode)
CCamera::CCameraAdvancedSettings::NewL(CCamera&) 0x00008e08 ARM Code 0 ecamadvsettings{000a0000}-64.o(StubCode)
__aeabi_unwind_cpp_pr0 0x00008e10 ARM Code 0 drtaeabi{000a0000}-158.o(StubCode)
__cxa_begin_catch 0x00008e18 ARM Code 0 drtaeabi{000a0000}-180.o(StubCode)
__cxa_end_catch 0x00008e20 ARM Code 0 drtaeabi{000a0000}-183.o(StubCode)
__cxa_end_cleanup 0x00008e28 ARM Code 0 drtaeabi{000a0000}-184.o(StubCode)
operator delete (void*) 0x00008e30 ARM Code 0 scppnwdl{000a0000}-3.o(StubCode)
CCameraEnginePrivate::FrameBufferReady(MFrameBuffer*, int) 0x00008e39 Thumb Code 2 camerawrapper.in(i._ZN20CCameraEnginePrivate16FrameBufferReadyEP12MFrameBufferi)
CCameraEnginePrivate::VideoBufferReady(MCameraBuffer&, int) 0x00008e3b Thumb Code 2 camerawrapper.in(i._ZN20CCameraEnginePrivate16VideoBufferReadyER13MCameraBufferi)
thunk{-4} to CCameraEnginePrivate::FrameBufferReady(MFrameBuffer*, int) 0x00008e3d Thumb Code 2 camerawrapper.in(i._ZThn4_N20CCameraEnginePrivate16FrameBufferReadyEP12MFrameBufferi)
thunk{-8} to CCameraEnginePrivate::VideoBufferReady(MCameraBuffer&, int) 0x00008e3f Thumb Code 2 camerawrapper.in(i._ZThn8_N20CCameraEnginePrivate16VideoBufferReadyER13MCameraBufferi)
typeinfo for CCamAutoFocus 0x0000901c Data 12 CCamAutoFocus.o(.constdata__ZTI13CCamAutoFocus)
typeinfo for CCameraEngine 0x00009028 Data 12 camerawrapper.in(.constdata__ZTI13CCameraEngine)
typeinfo for MCameraObserver 0x00009034 Data 8 camerawrapper.in(.constdata__ZTI15MCameraObserver)
typeinfo for MCameraObserver2 0x0000903c Data 8 camerawrapper.in(.constdata__ZTI16MCameraObserver2)
typeinfo for CCamAutoFocusImpl 0x00009044 Data 32 CCamAutoFocusImpl.o(.constdata__ZTI17CCamAutoFocusImpl)
typeinfo for CCameraEnginePrivate 0x00009064 Data 48 camerawrapper.in(.constdata__ZTI20CCameraEnginePrivate)
typeinfo for MCamAutoFocusObserver 0x00009094 Data 8 camerawrapper.in(.constdata__ZTI21MCamAutoFocusObserver)
typeinfo for MCameraAutoFocusObserver 0x0000909c Data 8 CCamAutoFocusImpl.o(.constdata__ZTI24MCameraAutoFocusObserver)
typeinfo name for CCamAutoFocus 0x000090a4 Data 16 CCamAutoFocus.o(.constdata__ZTS13CCamAutoFocus)
typeinfo name for CCameraEngine 0x000090b4 Data 16 camerawrapper.in(.constdata__ZTS13CCameraEngine)
typeinfo name for MCameraObserver 0x000090c4 Data 18 camerawrapper.in(.constdata__ZTS15MCameraObserver)
typeinfo name for MCameraObserver2 0x000090d6 Data 19 camerawrapper.in(.constdata__ZTS16MCameraObserver2)
typeinfo name for CCamAutoFocusImpl 0x000090e9 Data 20 CCamAutoFocusImpl.o(.constdata__ZTS17CCamAutoFocusImpl)
typeinfo name for CCameraEnginePrivate 0x000090fd Data 23 camerawrapper.in(.constdata__ZTS20CCameraEnginePrivate)
typeinfo name for MCamAutoFocusObserver 0x00009114 Data 24 camerawrapper.in(.constdata__ZTS21MCamAutoFocusObserver)
typeinfo name for MCameraAutoFocusObserver 0x0000912c Data 27 CCamAutoFocusImpl.o(.constdata__ZTS24MCameraAutoFocusObserver)
vtable for CCamAutoFocus 0x00009148 Data 20 CCamAutoFocus.o(.constdata__ZTV13CCamAutoFocus)
vtable for CCameraEngine 0x0000915c Data 20 camerawrapper.in(.constdata__ZTV13CCameraEngine)
vtable for CCamAutoFocusImpl 0x00009170 Data 44 CCamAutoFocusImpl.o(.constdata__ZTV17CCamAutoFocusImpl)
vtable for CCameraEnginePrivate 0x0000919c Data 132 camerawrapper.in(.constdata__ZTV20CCameraEnginePrivate)
.ARM.exidx$$Base 0x00009220 Number 0 ucppinit_aeabi.o(.ARM.exidx)
.ARM.exidx$$Limit 0x00009338 Number 0 camerawrapper.in(.ARM.exidx)
Image$$ER_RO$$Limit 0x00009338 Number 0 anon$$obj.o(linker$$defined$$symbols)

View file

@ -0,0 +1,42 @@
/****************************************************************************
**
** Trolltech hereby grants a license to use the Qt/Eclipse Integration
** plug-in (the software contained herein), in binary form, solely for the
** purpose of creating code to be used with Trolltech's Qt software.
**
** Qt Designer is licensed under the terms of the GNU General Public
** License versions 2.0 and 3.0 ("GPL License"). Trolltech offers users the
** right to use certain no GPL licensed software under the terms of its GPL
** Exception version 1.2 (http://trolltech.com/products/qt/gplexception).
**
** THIS SOFTWARE IS PROVIDED BY TROLLTECH AND ITS CONTRIBUTORS (IF ANY) "AS
** IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
** OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** Since we now have the GPL exception I think that the "special exception
** is no longer needed. The license text proposed above (other than the
** special exception portion of it) is the BSD license and we have added
** the BSD license as a permissible license under the exception.
**
****************************************************************************/
#include "QQrDecoder.h"
#include <QtGui>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QQrDecoder w;
w.showMaximized();
return a.exec();
}

View file

@ -0,0 +1,22 @@
/*
* BarcodeFormat.cpp
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 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 <zxing/BarcodeFormat.h>

View file

@ -0,0 +1,42 @@
#ifndef __BARCODE_FORMAT_H__
#define __BARCODE_FORMAT_H__
/*
* BarcodeFormat.h
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Modified by Lukasz Warchol on 02/02/2010
* Copyright 2008 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.
*/
namespace zxing {
typedef enum BarcodeFormat {
BarcodeFormat_None = 0,
BarcodeFormat_QR_CODE,
BarcodeFormat_DATA_MATRIX,
BarcodeFormat_UPC_E,
BarcodeFormat_UPC_A,
BarcodeFormat_EAN_8,
BarcodeFormat_EAN_13,
BarcodeFormat_CODE_128,
BarcodeFormat_CODE_39,
BarcodeFormat_ITF
} BarcodeFormat;
}
#endif // __BARCODE_FORMAT_H__

View file

@ -0,0 +1,48 @@
/*
* Binarizer.cpp
* zxing
*
* Created by Ralf Kistner on 16/10/2009.
* Copyright 2008 ZXing authors All rights reserved.
* Modified by Lukasz Warchol on 02/02/2010.
*
* 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 <zxing/Binarizer.h>
namespace zxing {
Binarizer::Binarizer(Ref<LuminanceSource> source) : source_(source) {
}
Binarizer::~Binarizer() {
}
Ref<BitArray> Binarizer::getBlackRow(int y, Ref<BitArray> row){
if (array_ == NULL)
array_ = estimateBlackRow(y, row);
return array_;
}
Ref<BitMatrix> Binarizer::getBlackMatrix() {
if (matrix_ == NULL)
matrix_ = estimateBlackMatrix();
return matrix_;
}
Ref<LuminanceSource> Binarizer::getSource() {
return source_;
}
}

View file

@ -0,0 +1,51 @@
/*
* Binarizer.h
* zxing
*
* Created by Ralf Kistner on 16/10/2009.
* Copyright 2008 ZXing authors All rights reserved.
* Modified by Lukasz Warchol on 02/02/2010.
*
* 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.
*/
#ifndef BINARIZER_H_
#define BINARIZER_H_
#include <zxing/LuminanceSource.h>
#include <zxing/common/BitArray.h>
#include <zxing/common/BitMatrix.h>
#include <zxing/common/Counted.h>
namespace zxing {
class Binarizer : public Counted {
private:
Ref<LuminanceSource> source_;
Ref<BitMatrix> matrix_;
Ref<BitArray> array_;
public:
Binarizer(Ref<LuminanceSource> source);
virtual ~Binarizer();
virtual Ref<BitArray> estimateBlackRow(int y, Ref<BitArray> row)=0;
Ref<BitArray> getBlackRow(int y, Ref<BitArray> row);
virtual Ref<BitMatrix> estimateBlackMatrix() = 0;
Ref<BitMatrix> getBlackMatrix();
Ref<LuminanceSource> getSource();
};
}
#endif /* BINARIZER_H_ */

View file

@ -0,0 +1,57 @@
/*
* BinaryBitmap.cpp
* zxing
*
* Created by Ralf Kistner on 19/10/2009.
* Copyright 2008 ZXing authors All rights reserved.
* Modified by Lukasz Warchol on 02/02/2010.
*
* 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 <zxing/BinaryBitmap.h>
namespace zxing {
BinaryBitmap::BinaryBitmap(Ref<Binarizer> binarizer) : bits_(NULL), binarizer_(binarizer) {
}
BinaryBitmap::~BinaryBitmap() {
}
Ref<BitArray> BinaryBitmap::getBlackRow(int y, Ref<BitArray> row) {
if (array_bits_ == NULL) {
array_bits_ = binarizer_->getBlackRow(y, row);
}
return array_bits_;
}
Ref<BitMatrix> BinaryBitmap::getBlackMatrix() {
if (bits_ == NULL) {
bits_ = binarizer_->getBlackMatrix();
}
return bits_;
}
int BinaryBitmap::getWidth() {
return getSource()->getWidth();
}
int BinaryBitmap::getHeight() {
return getSource()->getHeight();
}
Ref<LuminanceSource> BinaryBitmap::getSource() {
return binarizer_->getSource();
}
}

View file

@ -0,0 +1,51 @@
/*
* BinaryBitmap.h
* zxing
*
* Created by Ralf Kistner on 19/10/2009.
* Copyright 2008 ZXing authors All rights reserved.
* Modified by Lukasz Warchol on 02/02/2010.
*
* 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.
*/
#ifndef BINARYBITMAP_H_
#define BINARYBITMAP_H_
#include <zxing/common/Counted.h>
#include <zxing/common/BitMatrix.h>
#include <zxing/common/BitArray.h>
#include <zxing/Binarizer.h>
namespace zxing {
class BinaryBitmap : public Counted {
private:
Ref<BitMatrix> bits_;
Ref<BitArray> array_bits_;
Ref<Binarizer> binarizer_;
public:
BinaryBitmap(Ref<Binarizer> binarizer);
virtual ~BinaryBitmap();
Ref<BitArray> getBlackRow(int y, Ref<BitArray> row);
Ref<BitMatrix> getBlackMatrix();
Ref<LuminanceSource> getSource();
int getWidth();
int getHeight();
};
}
#endif /* BINARYBITMAP_H_ */

View file

@ -0,0 +1,25 @@
/*
* Exception.cpp
* ZXing
*
* Created by Christian Brunschen on 03/06/2008.
* Copyright 2008 ZXing authors All rights reserved.
*
*/
#include <zxing/Exception.h>
namespace zxing {
Exception::Exception(const char *msg) :
message(msg) {
}
const char* Exception::what() const throw() {
return message;
}
Exception::~Exception() throw() {
}
}

View file

@ -0,0 +1,40 @@
#ifndef __EXCEPTION_H__
#define __EXCEPTION_H__
/*
* Exception.h
* ZXing
*
* Created by Christian Brunschen on 03/06/2008.
* Copyright 2008 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 <string>
#include <exception>
namespace zxing {
class Exception : public std::exception {
private:
const char * message;
public:
Exception(const char *msg);
virtual const char* what() const throw();
virtual ~Exception() throw();
};
}
#endif // __EXCEPTION_H__

View file

@ -0,0 +1,43 @@
/*
* LuminanceSource.cpp
* zxing
*
* Created by Ralf Kistner on 16/10/2009.
* Copyright 2008 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 <zxing/LuminanceSource.h>
namespace zxing {
LuminanceSource::LuminanceSource() {
}
LuminanceSource::~LuminanceSource() {
}
unsigned char* LuminanceSource::copyMatrix() {
int width = getWidth();
int height = getHeight();
unsigned char* matrix = new unsigned char[width*height];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
matrix[y*width+x] = getPixel(x, y);
}
}
return matrix;
}
}

View file

@ -0,0 +1,42 @@
/*
* LuminanceSource.h
* zxing
*
* Created by Ralf Kistner on 16/10/2009.
* Copyright 2008 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.
*/
#ifndef LUMINANCESOURCE_H_
#define LUMINANCESOURCE_H_
#include <zxing/common/Counted.h>
namespace zxing {
class LuminanceSource : public Counted {
public:
LuminanceSource();
virtual ~LuminanceSource();
virtual int getWidth() = 0;
virtual int getHeight() = 0;
virtual unsigned char getPixel(int x, int y) = 0;
virtual unsigned char* copyMatrix();
};
}
#endif /* LUMINANCESOURCE_H_ */

View file

@ -0,0 +1,54 @@
/*
* MultiFormatBarcodeReader.cpp
* ZXing
*
* Created by Lukasz Warchol on 10-01-26.
* Modified by Luiz Silva on 09/02/2010.
* 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 "MultiFormatReader.h"
#include <zxing/qrcode/QRCodeReader.h>
//#include <zxing/datamatrix/DataMatrixReader.h>
#include <zxing/oned/MultiFormatUPCEANReader.h>
#include <zxing/oned/MultiFormatOneDReader.h>
#include <zxing/ReaderException.h>
namespace zxing {
MultiFormatReader::MultiFormatReader(){
readers = new std::vector<Reader*>();
readers->push_back(new zxing::qrcode::QRCodeReader());
// readers->push_back(new zxing::datamatrix::DataMatrixReader());
readers->push_back(new zxing::oned::MultiFormatUPCEANReader());
readers->push_back(new zxing::oned::MultiFormatOneDReader());
}
Ref<Result> MultiFormatReader::decode(Ref<BinaryBitmap> image){
int size = readers->size();
for (int i = 0; i < size; i++) {
Reader* reader = (*readers)[i];
try {
return reader->decode(image);
} catch (ReaderException re) {
// continue
}
}
throw ReaderException("No code detected");
}
MultiFormatReader::~MultiFormatReader(){
delete readers;
}
}

View file

@ -0,0 +1,38 @@
/*
* MultiFormatBarcodeReader.h
* ZXing
*
* Created by Lukasz Warchol on 10-01-26.
* 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 <zxing/Reader.h>
#include <zxing/common/BitArray.h>
#include <zxing/Result.h>
namespace zxing {
class MultiFormatReader : public Reader {
private:
std::vector<Reader*>* readers;
public:
MultiFormatReader();
Ref<Result> decode(Ref<BinaryBitmap> image);
~MultiFormatReader();
};
}

View file

@ -0,0 +1,27 @@
/*
* Reader.cpp
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 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 <zxing/Reader.h>
namespace zxing {
Reader::~Reader() { }
}

View file

@ -0,0 +1,38 @@
#ifndef __READER_H__
#define __READER_H__
/*
* Reader.h
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 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 <map>
#include <zxing/BinaryBitmap.h>
#include <zxing/Result.h>
namespace zxing {
class Reader {
public:
virtual Ref<Result> decode(Ref<BinaryBitmap> image) = 0;
virtual ~Reader();
};
}
#endif // __READER_H__

View file

@ -0,0 +1,32 @@
/*
* ReaderException.cpp
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 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 <zxing/ReaderException.h>
namespace zxing {
ReaderException::ReaderException(const char *msg) :
Exception(msg) {
}
ReaderException::~ReaderException() throw() {
}
}

View file

@ -0,0 +1,35 @@
#ifndef __READER_EXCEPTION_H__
#define __READER_EXCEPTION_H__
/*
* ReaderException.h
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 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 <zxing/Exception.h>
namespace zxing {
class ReaderException : public Exception {
public:
ReaderException(const char *msg);
~ReaderException() throw();
};
}
#endif // __READER_EXCEPTION_H__

View file

@ -0,0 +1,59 @@
/*
* Result.cpp
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 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 <zxing/Result.h>
namespace zxing {
using namespace std;
Result::Result(Ref<String> text, ArrayRef<unsigned char> rawBytes, std::vector<Ref<ResultPoint> > resultPoints,
BarcodeFormat format) :
text_(text), rawBytes_(rawBytes), resultPoints_(resultPoints), format_(format) {
}
Result::~Result() {
}
Ref<String> Result::getText() {
return text_;
}
ArrayRef<unsigned char> Result::getRawBytes() {
return rawBytes_;
}
std::vector<Ref<ResultPoint> > Result::getResultPoints() {
return resultPoints_;
}
BarcodeFormat Result::getBarcodeFormat() {
return format_;
}
ostream& operator<<(ostream &out, Result& result) {
if (result.text_ != 0) {
out << result.text_->getText();
} else {
out << "[" << result.rawBytes_->size() << " bytes]";
}
return out;
}
}

View file

@ -0,0 +1,54 @@
#ifndef __RESULT_H__
#define __RESULT_H__
/*
* Result.h
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 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 <string>
#include <vector>
#include <zxing/common/Array.h>
#include <zxing/common/Counted.h>
#include <zxing/common/Str.h>
#include <zxing/ResultPoint.h>
#include <zxing/BarcodeFormat.h>
namespace zxing {
class Result : public Counted {
private:
Ref<String> text_;
ArrayRef<unsigned char> rawBytes_;
std::vector<Ref<ResultPoint> > resultPoints_;
BarcodeFormat format_;
public:
Result(Ref<String> text, ArrayRef<unsigned char> rawBytes, std::vector<Ref<ResultPoint> > resultPoints,
BarcodeFormat format);
~Result();
Ref<String> getText();
ArrayRef<unsigned char> getRawBytes();
std::vector<Ref<ResultPoint> > getResultPoints();
BarcodeFormat getBarcodeFormat();
friend std::ostream& operator<<(std::ostream &out, Result& result);
};
}
#endif // __RESULT_H__

View file

@ -0,0 +1,22 @@
/*
* ResultPoint.cpp
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 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 <zxing/ResultPoint.h>

View file

@ -0,0 +1,36 @@
#ifndef __RESULT_POINT_H__
#define __RESULT_POINT_H__
/*
* ResultPoint.h
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 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 <zxing/common/Counted.h>
namespace zxing {
class ResultPoint : public Counted {
public:
virtual float getX() = 0;
virtual float getY() = 0;
};
}
#endif // __RESULT_POINT_H__

View file

@ -0,0 +1,22 @@
/*
* Array.cpp
* zxing
*
* Created by Christian Brunschen on 07/05/2008.
* Copyright 2008 Google UK. 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 <zxing/common/Array.h>

View file

@ -0,0 +1,209 @@
#ifndef __ARRAY_H__
#define __ARRAY_H__
/*
* Array.h
* zxing
*
* Created by Christian Brunschen on 07/05/2008.
* Copyright 2008 Google UK. 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 <valarray>
#include <cstdarg>
#ifdef DEBUG_COUNTING
#include <iostream>
#include <typeinfo>
#endif
#include <zxing/common/Counted.h>
namespace zxing {
template<typename T> class Array : public Counted {
protected:
public:
std::valarray<T> values_;
Array(size_t n) :
Counted(), values_(T(), n) {
}
Array(T *ts, size_t n) :
Counted(), values_(ts, n) {
}
Array(T v, size_t n) :
Counted(), values_(v, n) {
}
Array(std::valarray<T> &v) :
Counted(), values_(v) {
}
Array(Array<T> &other) :
Counted(), values_(other.values_) {
}
Array(Array<T> *other) :
Counted(), values_(other->values_) {
}
virtual ~Array() {
}
Array<T>& operator=(const Array<T> &other) {
#ifdef DEBUG_COUNTING
cout << "assigning values from Array " << &other << " to this Array " << this << ", ";
#endif
values_ = other.values_;
#ifdef DEBUG_COUNTING
cout << "new size = " << values_.size() << "\n";
#endif
return *this;
}
Array<T>& operator=(const std::valarray<T> &array) {
#ifdef DEBUG_COUNTING
cout << "assigning values from Array " << &array << " to this Array " << this << ", ";
#endif
values_ = array;
#ifdef DEBUG_COUNTING
cout << "new size = " << values_.size() << "\n";
#endif
return *this;
}
T operator[](size_t i) const {
return values_[i];
}
T& operator[](size_t i) {
return values_[i];
}
size_t size() const {
return values_.size();
}
std::valarray<T> values() const {
return values_;
}
std::valarray<T>& values() {
return values_;
}
};
template<typename T> class ArrayRef {
private:
public:
Array<T> *array_;
ArrayRef() :
array_(0) {
#ifdef DEBUG_COUNTING
cout << "instantiating empty ArrayRef " << this << "\n";
#endif
}
ArrayRef(size_t n) :
array_(0) {
#ifdef DEBUG_COUNTING
cout << "instantiating ArrayRef " << this << "with size " << n << "\n";
#endif
reset(new Array<T> (n));
}
ArrayRef(T *ts, size_t n) :
array_(0) {
#ifdef DEBUG_COUNTING
cout << "instantiating ArrayRef " << this << "with " << n << " elements at " << (void *)ts << "\n";
#endif
reset(new Array<T> (ts, n));
}
ArrayRef(Array<T> *a) :
array_(0) {
#ifdef DEBUG_COUNTING
cout << "instantiating ArrayRef " << this << " from pointer:\n";
#endif
reset(a);
}
ArrayRef(const Array<T> &a) :
array_(0) {
#ifdef DEBUG_COUNTING
cout << "instantiating ArrayRef " << this << " from reference to Array " << (void *)&a << ":\n";
#endif
reset(const_cast<Array<T> *>(&a));
}
ArrayRef(const ArrayRef &other) :
array_(0) {
#ifdef DEBUG_COUNTING
cout << "instantiating ArrayRef " << this << " from ArrayRef " << &other << ":\n";
#endif
reset(other.array_);
}
template<class Y>
ArrayRef(const ArrayRef<Y> &other) :
array_(0) {
#ifdef DEBUG_COUNTING
cout << "instantiating ArrayRef " << this << " from ArrayRef " << &other << ":\n";
#endif
reset(static_cast<const Array<T> *>(other.array_));
}
~ArrayRef() {
#ifdef DEBUG_COUNTING
cout << "destroying ArrayRef " << this << " with " << (array_ ? typeid(*array_).name() : "NULL") << " "
<< array_ << "\n";
#endif
if (array_) {
array_->release();
}
array_ = 0;
}
T operator[](size_t i) const {
return (*array_)[i];
}
T& operator[](size_t i) {
return (*array_)[i];
}
size_t size() const {
return array_->size();
}
void reset(Array<T> *a) {
#ifdef DEBUG_COUNTING
cout << "resetting ArrayRef " << this << " from " << (array_ ? typeid(*array_).name() : "NULL") << " "
<< array_ << " to " << (a ? typeid(*a).name() : "NULL") << " " << a << "\n";
#endif
if (a) {
a->retain();
}
if (array_) {
array_->release();
}
array_ = a;
}
void reset(const ArrayRef<T> &other) {
reset(other.array_);
}
ArrayRef<T>& operator=(const ArrayRef<T> &other) {
reset(other);
return *this;
}
ArrayRef<T>& operator=(Array<T> *a) {
reset(a);
return *this;
}
Array<T>& operator*() {
return *array_;
}
Array<T>* operator->() {
return array_;
}
};
} // namespace zxing
#endif // __ARRAY_H__

View file

@ -0,0 +1,118 @@
/*
* BitArray.cpp
* zxing
*
* Created by Christian Brunschen on 09/05/2008.
* Copyright 2008 Google UK. 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 <zxing/common/BitArray.h>
#include <iostream>
using namespace std;
namespace zxing {
static unsigned int logDigits(unsigned digits) {
unsigned log = 0;
unsigned val = 1;
while (val < digits) {
log++;
val <<= 1;
}
return log;
}
const unsigned int BitArray::bitsPerWord_ = numeric_limits<unsigned int>::digits;
const unsigned int BitArray::logBits_ = logDigits(bitsPerWord_);
const unsigned int BitArray::bitsMask_ = (1 << logBits_) - 1;
size_t BitArray::wordsForBits(size_t bits) {
int arraySize = bits >> logBits_;
if (bits - (arraySize << logBits_) != 0) {
arraySize++;
}
return arraySize;
}
BitArray::BitArray() {
cout << "hey! don't use this BitArrayConstructor!\n";
}
BitArray::BitArray(size_t size) :
size_(size), bits_((const unsigned int)0, wordsForBits(size)) {
}
BitArray::~BitArray() {
}
size_t BitArray::getSize() {
return size_;
}
bool BitArray::get(size_t i) {
return (bits_[i >> logBits_] & (1 << (i & bitsMask_))) != 0;
}
void BitArray::set(size_t i) {
bits_[i >> logBits_] |= 1 << (i & bitsMask_);
}
void BitArray::setBulk(size_t i, unsigned int newBits) {
bits_[i >> logBits_] = newBits;
}
void BitArray::clear() {
size_t max = bits_.size();
for (size_t i = 0; i < max; i++) {
bits_[i] = 0;
}
}
bool BitArray::isRange(size_t start, size_t end, bool value) {
if (end < start) {
throw IllegalArgumentException("end must be after start");
}
if (end == start) {
return true;
}
// treat the 'end' as inclusive, rather than exclusive
end--;
size_t firstWord = start >> logBits_;
size_t lastWord = end >> logBits_;
for (size_t i = firstWord; i <= lastWord; i++) {
size_t firstBit = i > firstWord ? 0 : start & bitsMask_;
size_t lastBit = i < lastWord ? logBits_ : end & bitsMask_;
unsigned int mask;
if (firstBit == 0 && lastBit == logBits_) {
mask = numeric_limits<unsigned int>::max();
} else {
mask = 0;
for (size_t j = firstBit; j <= lastBit; j++) {
mask |= 1 << j;
}
}
if (value) {
if ((bits_[i] & mask) != mask) {
return false;
}
} else {
if ((bits_[i] & mask) != 0) {
return false;
}
}
}
return true;
}
valarray<unsigned int>& BitArray::getBitArray() {
return bits_;
}
void BitArray::reverse() {
unsigned int allBits = numeric_limits<unsigned int>::max();
size_t max = bits_.size();
for (size_t i = 0; i < max; i++) {
bits_[i] = bits_[i] ^ allBits;
}
}
}

View file

@ -0,0 +1,57 @@
#ifndef __BIT_ARRAY_H__
#define __BIT_ARRAY_H__
/*
* BitArray.h
* zxing
*
* Created by Christian Brunschen on 09/05/2008.
* Copyright 2008 Google UK. 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 <zxing/common/Counted.h>
#include <zxing/common/IllegalArgumentException.h>
#include <valarray>
#include <limits>
#include <iostream>
namespace zxing {
class BitArray : public Counted {
private:
size_t size_;
std::valarray<unsigned int> bits_;
static const unsigned int bitsPerWord_;
static const unsigned int logBits_;
static const unsigned int bitsMask_;
static size_t wordsForBits(size_t bits);
explicit BitArray();
public:
BitArray(size_t size);
~BitArray();
size_t getSize();
bool get(size_t i);
void set(size_t i);
void setBulk(size_t i, unsigned int newBits);
void clear();
bool isRange(size_t start, size_t end, bool value);
std::valarray<unsigned int>& getBitArray();
void reverse();
};
}
#endif // __BIT_ARRAY_H__

View file

@ -0,0 +1,148 @@
/*
* BitMatrix.cpp
* zxing
*
* Created by Christian Brunschen on 12/05/2008.
* Copyright 2008 Google UK. 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 <zxing/common/BitMatrix.h>
#include <zxing/common/IllegalArgumentException.h>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
namespace zxing {
using namespace std;
unsigned int logDigits(unsigned digits) {
unsigned log = 0;
unsigned val = 1;
while (val < digits) {
log++;
val <<= 1;
}
return log;
}
const unsigned int bitsPerWord = std::numeric_limits<unsigned int>::digits;
const unsigned int logBits = logDigits(bitsPerWord);
const unsigned int bitsMask = (1 << logBits) - 1;
static size_t wordsForSize(size_t width, size_t height) {
size_t bits = width * height;
int arraySize = bits >> logBits;
if (bits - (arraySize << logBits) != 0) {
arraySize++;
}
return arraySize;
}
BitMatrix::BitMatrix(size_t dimension) :
width_(dimension), height_(dimension), bits_(NULL) {
words_ = wordsForSize(width_, height_);
bits_ = new unsigned int[words_];
clear();
}
BitMatrix::BitMatrix(size_t width, size_t height) :
width_(width), height_(height), bits_(NULL) {
words_ = wordsForSize(width_, height_);
bits_ = new unsigned int[words_];
clear();
}
BitMatrix::~BitMatrix() {
delete[] bits_;
}
bool BitMatrix::get(size_t x, size_t y) const {
size_t offset = x + width_ * y;
return ((bits_[offset >> logBits] >> (offset & bitsMask)) & 0x01) != 0;
}
void BitMatrix::set(size_t x, size_t y) {
size_t offset = x + width_ * y;
bits_[offset >> logBits] |= 1 << (offset & bitsMask);
}
void BitMatrix::flip(size_t x, size_t y) {
size_t offset = x + width_ * y;
bits_[offset >> logBits] ^= 1 << (offset & bitsMask);
}
void BitMatrix::clear() {
std::memset(bits_, 0, sizeof(unsigned int) * words_);
}
void BitMatrix::setRegion(size_t left, size_t top, size_t width, size_t height) {
if (top < 0 || left < 0) {
throw IllegalArgumentException("topI and leftJ must be nonnegative");
}
if (height < 1 || width < 1) {
throw IllegalArgumentException("height and width must be at least 1");
}
size_t right = left + width;
size_t bottom = top + height;
if (right > width_ || bottom > height_) {
throw IllegalArgumentException("top + height and left + width must be <= matrix dimension");
}
for (size_t y = top; y < bottom; y++) {
int yOffset = width_ * y;
for (size_t x = left; x < right; x++) {
size_t offset = x + yOffset;
bits_[offset >> logBits] |= 1 << (offset & bitsMask);
}
}
}
size_t BitMatrix::getWidth() const {
return width_;
}
size_t BitMatrix::getHeight() const {
return height_;
}
size_t BitMatrix::getDimension() const {
return width_;
}
unsigned int* BitMatrix::getBits() {
return bits_;
}
ostream& operator<<(ostream &out, BitMatrix &bm) {
for (size_t y = 0; y < bm.height_; y++) {
for (size_t x = 0; x < bm.width_; x++) {
out << (bm.get(x, y) ? "X " : " ");
}
out << "\n";
}
return out;
}
const char *BitMatrix::description() {
ostringstream out;
out << *this;
return out.str().c_str();
}
}

View file

@ -0,0 +1,61 @@
#ifndef __BIT_MATRIX_H__
#define __BIT_MATRIX_H__
/*
* BitMatrix.h
* zxing
*
* Created by Christian Brunschen on 12/05/2008.
* Copyright 2008 Google UK. 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 <zxing/common/Counted.h>
#include <valarray>
#include <limits>
namespace zxing {
class BitMatrix : public Counted {
private:
size_t width_;
size_t height_;
size_t words_;
unsigned int* bits_;
public:
BitMatrix(size_t dimension);
BitMatrix(size_t width, size_t height);
~BitMatrix();
// Inlining this does not really improve performance.
bool get(size_t x, size_t y) const;
void set(size_t x, size_t y);
void flip(size_t x, size_t y);
void clear();
void setRegion(size_t left, size_t top, size_t width, size_t height);
size_t getDimension() const;
size_t getWidth() const;
size_t getHeight() const;
unsigned int* getBits();
friend std::ostream& operator<<(std::ostream &out, BitMatrix &bm);
const char *description();
};
}
#endif // __BIT_MATRIX_H__

View file

@ -0,0 +1,75 @@
/*
* BitSource.cpp
* zxing
*
* Created by Christian Brunschen on 09/05/2008.
* Copyright 2008 Google UK. 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 <zxing/common/BitSource.h>
#include <zxing/common/IllegalArgumentException.h>
namespace zxing {
int BitSource::readBits(int numBits) {
if (numBits < 0 || numBits > 32) {
throw IllegalArgumentException("cannot read <1 or >32 bits");
} else if (numBits > available()) {
throw IllegalArgumentException("reading more bits than are available");
}
int result = 0;
// First, read remainder from current byte
if (bitOffset_ > 0) {
int bitsLeft = 8 - bitOffset_;
int toRead = numBits < bitsLeft ? numBits : bitsLeft;
int bitsToNotRead = bitsLeft - toRead;
int mask = (0xFF >> (8 - toRead)) << bitsToNotRead;
result = (bytes_[byteOffset_] & mask) >> bitsToNotRead;
numBits -= toRead;
bitOffset_ += toRead;
if (bitOffset_ == 8) {
bitOffset_ = 0;
byteOffset_++;
}
}
// Next read whole bytes
if (numBits > 0) {
while (numBits >= 8) {
result = (result << 8) | (bytes_[byteOffset_] & 0xFF);
byteOffset_++;
numBits -= 8;
}
// Finally read a partial byte
if (numBits > 0) {
int bitsToNotRead = 8 - numBits;
int mask = (0xFF >> bitsToNotRead) << bitsToNotRead;
result = (result << numBits) | ((bytes_[byteOffset_] & mask) >> bitsToNotRead);
bitOffset_ += numBits;
}
}
return result;
}
int BitSource::available() {
return 8 * (bytes_.size() - byteOffset_) - bitOffset_;
}
}

View file

@ -0,0 +1,68 @@
#ifndef __BIT_SOURCE_H__
#define __BIT_SOURCE_H__
/*
* BitSource.h
* zxing
*
* Created by Christian Brunschen on 09/05/2008.
* Copyright 2008 Google UK. 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 <zxing/common/Array.h>
namespace zxing {
/**
* <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the
* number of bits read is not often a multiple of 8.</p>
*
* <p>This class is not thread-safe.</p>
*
* @author srowen@google.com (Sean Owen)
* @author christian.brunschen@gmail.com (Christian Brunschen)
*/
class BitSource : public Counted {
typedef unsigned char byte;
private:
ArrayRef<byte> bytes_;
int byteOffset_;
int bitOffset_;
public:
/**
* @param bytes bytes from which this will read bits. Bits will be read from the first byte first.
* Bits are read within a byte from most-significant to least-significant bit.
*/
BitSource(ArrayRef<byte> &bytes) :
bytes_(bytes), byteOffset_(0), bitOffset_(0) {
}
/**
* @param numBits number of bits to read
* @return int representing the bits read. The bits will appear as the least-significant
* bits of the int
* @throws IllegalArgumentException if numBits isn't in [1,32]
*/
int readBits(int numBits);
/**
* @return number of bits that can be read successfully
*/
int available();
};
}
#endif // __BIT_SOURCE_H__

View file

@ -0,0 +1,32 @@
/*
* Counted.cpp
* zxing
*
* Created by Christian Brunschen on 07/05/2008.
* Copyright 2008 Google UK. 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 <zxing/common/Counted.h>
namespace zxing {
using namespace std;
template<class T>
ostream& operator<<(ostream &out, Ref<T>& ref) {
out << "Ref(" << (ref.object_ ? (*ref.object_) : "NULL") << ")";
return out;
}
}

View file

@ -0,0 +1,204 @@
#ifndef __COUNTED_H__
#define __COUNTED_H__
/*
* Counted.h
* zxing
*
* Created by Christian Brunschen on 07/05/2008.
* Copyright 2008 Google UK. 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.
*/
//#define DEBUG_COUNTING
//using namespace std;
#include <iostream>
#ifdef DEBUG_COUNTING
#include <typeinfo>
using namespace std;
#endif
namespace zxing {
/* base class for reference-counted objects */
class Counted {
private:
unsigned int count_;
public:
Counted() :
count_(0) {
#ifdef DEBUG_COUNTING
cout << "instantiating " << typeid(*this).name() << " " << this <<
" @ " << count_ << "\n";
#endif
}
virtual ~Counted() {
}
virtual Counted *retain() {
#ifdef DEBUG_COUNTING
cout << "retaining " << typeid(*this).name() << " " << this <<
" @ " << count_;
#endif
count_++;
#ifdef DEBUG_COUNTING
cout << "->" << count_ << "\n";
#endif
return this;
}
virtual void release() {
#ifdef DEBUG_COUNTING
cout << "releasing " << typeid(*this).name() << " " << this <<
" @ " << count_;
#endif
if (count_ == 0 || count_ == 54321) {
#ifdef DEBUG_COUNTING
cout << "\nOverreleasing already-deleted object " << this << "!!!\n";
#endif
throw 4711;
}
count_--;
#ifdef DEBUG_COUNTING
cout << "->" << count_ << "\n";
#endif
if (count_ == 0) {
#ifdef DEBUG_COUNTING
cout << "deleting " << typeid(*this).name() << " " << this << "\n";
#endif
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) {
#ifdef DEBUG_COUNTING
cout << "instantiating Ref " << this << " from pointer" << o << "\n";
#endif
reset(o);
}
explicit Ref(const T &o) :
object_(0) {
#ifdef DEBUG_COUNTING
cout << "instantiating Ref " << this << " from reference\n";
#endif
reset(const_cast<T *>(&o));
}
Ref(const Ref &other) :
object_(0) {
#ifdef DEBUG_COUNTING
cout << "instantiating Ref " << this << " from Ref " << &other << "\n";
#endif
reset(other.object_);
}
template<class Y>
Ref(const Ref<Y> &other) :
object_(0) {
#ifdef DEBUG_COUNTING
cout << "instantiating Ref " << this << " from reference\n";
#endif
reset(other.object_);
}
~Ref() {
#ifdef DEBUG_COUNTING
cout << "destroying Ref " << this << " with " <<
(object_ ? typeid(*object_).name() : "NULL") << " " << object_ << "\n";
#endif
if (object_) {
object_->release();
}
}
void reset(T *o) {
#ifdef DEBUG_COUNTING
cout << "resetting Ref " << this << " from " <<
(object_ ? typeid(*object_).name() : "NULL") << " " << object_ <<
" to " << (o ? typeid(*o).name() : "NULL") << " " << o << "\n";
#endif
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->() {
return object_;
}
operator T*() {
return object_;
}
bool operator==(const int x) {
return x == 0 ? object_ == 0 : false;
}
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 int x) {
return x == 0 ? object_ != 0 : true;
}
template<class Y>
friend std::ostream& operator<<(std::ostream &out, Ref<Y>& ref);
};
}
#endif // __COUNTED_H__

View file

@ -0,0 +1,37 @@
/*
* DecoderResult.cpp
* zxing
*
* Created by Christian Brunschen on 20/05/2008.
* Copyright 2008 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 <zxing/common/DecoderResult.h>
namespace zxing {
DecoderResult::DecoderResult(ArrayRef<unsigned char> rawBytes, Ref<String> text) :
rawBytes_(rawBytes), text_(text) {
}
ArrayRef<unsigned char> DecoderResult::getRawBytes() {
return rawBytes_;
}
Ref<String> DecoderResult::getText() {
return text_;
}
}

View file

@ -0,0 +1,44 @@
#ifndef __DECODER_RESULT_H__
#define __DECODER_RESULT_H__
/*
* DecoderResult.h
* zxing
*
* Created by Christian Brunschen on 20/05/2008.
* Copyright 2008 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 <zxing/common/Counted.h>
#include <zxing/common/Array.h>
#include <string>
#include <zxing/common/Str.h>
namespace zxing {
class DecoderResult : public Counted {
private:
ArrayRef<unsigned char> rawBytes_;
Ref<String> text_;
public:
DecoderResult(ArrayRef<unsigned char> rawBytes, Ref<String> text);
ArrayRef<unsigned char> getRawBytes();
Ref<String> getText();
};
}
#endif // __DECODER_RESULT_H__

View file

@ -0,0 +1,41 @@
/*
* DetectorResult.cpp
* zxing
*
* Created by Christian Brunschen on 14/05/2008.
* Copyright 2008 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 <zxing/common/DetectorResult.h>
namespace zxing {
DetectorResult::DetectorResult(Ref<BitMatrix> bits, std::vector<Ref<ResultPoint> > points, Ref<PerspectiveTransform> transform) :
bits_(bits), points_(points), transform_(transform) {
}
Ref<BitMatrix> DetectorResult::getBits() {
return bits_;
}
std::vector<Ref<ResultPoint> > DetectorResult::getPoints() {
return points_;
}
Ref<PerspectiveTransform> DetectorResult::getTransform() {
return transform_;
}
}

View file

@ -0,0 +1,47 @@
#ifndef __DETECTOR_RESULT_H__
#define __DETECTOR_RESULT_H__
/*
* DetectorResult.h
* zxing
*
* Created by Christian Brunschen on 14/05/2008.
* Copyright 2008 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 <vector>
#include <zxing/common/Counted.h>
#include <zxing/common/Array.h>
#include <zxing/common/BitMatrix.h>
#include <zxing/ResultPoint.h>
#include <zxing/common/PerspectiveTransform.h>
namespace zxing {
class DetectorResult : public Counted {
private:
Ref<BitMatrix> bits_;
std::vector<Ref<ResultPoint> > points_;
Ref<PerspectiveTransform> transform_;
public:
DetectorResult(Ref<BitMatrix> bits, std::vector<Ref<ResultPoint> > points, Ref<PerspectiveTransform> transform);
Ref<BitMatrix> getBits();
std::vector<Ref<ResultPoint> > getPoints();
Ref<PerspectiveTransform> getTransform();
};
}
#endif // __DETECTOR_RESULT_H__

View file

@ -0,0 +1,190 @@
/*
* EdgeDetector.cpp
* zxing
*
* Created by Ralf Kistner on 7/12/2009.
* Copyright 2008 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 <zxing/common/EdgeDetector.h>
#include <algorithm>
using namespace std;
namespace zxing {
namespace EdgeDetector {
void findEdgePoints(std::vector<Point>& points, const BitMatrix& image, Point start, Point end, bool invert, int skip, float deviation) {
float xdist = end.x - start.x;
float ydist = end.y - start.y;
float length = sqrt(xdist * xdist + ydist * ydist);
int var;
if (abs(xdist) > abs(ydist)) {
// Horizontal
if (xdist < 0)
skip = -skip;
var = int(abs(deviation * length / xdist));
float dy = ydist / xdist * skip;
bool left = (skip < 0) ^ invert;
int x = int(start.x);
int steps = int(xdist / skip);
for (int i = 0; i < steps; i++) {
x += skip;
if (x < 0 || x >= (int)image.getWidth())
continue; // In case we start off the edge
int my = int(start.y + dy * i);
int ey = min(my + var + 1, (int)image.getHeight() - 1);
int sy = max(my - var, 0);
for (int y = sy + 1; y < ey; y++) {
if (left) {
if (image.get(x, y) && !image.get(x, y + 1)) {
points.push_back(Point(x, y + 0.5f));
}
} else {
if (!image.get(x, y) && image.get(x, y + 1)) {
points.push_back(Point(x, y + 0.5f));
}
}
}
}
} else {
// Vertical
if (ydist < 0)
skip = -skip;
var = int(abs(deviation * length / ydist));
float dx = xdist / ydist * skip;
bool down = (skip > 0) ^ invert;
int y = int(start.y);
int steps = int(ydist / skip);
for (int i = 0; i < steps; i++) {
y += skip;
if (y < 0 || y >= (int)image.getHeight())
continue; // In case we start off the edge
int mx = int(start.x + dx * i);
int ex = min(mx + var + 1, (int)image.getWidth() - 1);
int sx = max(mx - var, 0);
for (int x = sx + 1; x < ex; x++) {
if (down) {
if (image.get(x, y) && !image.get(x + 1, y)) {
points.push_back(Point(x + 0.5f, y));
}
} else {
if (!image.get(x, y) && image.get(x + 1, y)) {
points.push_back(Point(x + 0.5f, y));
}
}
}
}
}
}
Line findLine(const BitMatrix& image, Line estimate, bool invert, int deviation, float threshold, int skip) {
float t = threshold * threshold;
Point start = estimate.start;
Point end = estimate.end;
vector<Point> edges;
edges.clear();
findEdgePoints(edges, image, start, end, invert, skip, deviation);
int n = edges.size();
float xdist = end.x - start.x;
float ydist = end.y - start.y;
bool horizontal = abs(xdist) > abs(ydist);
float max = 0;
Line bestLine(start, end); // prepopulate with the given line, in case we can't find any line for some reason
for (int i = -deviation; i < deviation; i++) {
float x1, y1;
if (horizontal) {
y1 = start.y + i;
x1 = start.x - i * ydist / xdist;
} else {
y1 = start.y - i * xdist / ydist;
x1 = start.x + i;
}
for (int j = -deviation; j < deviation; j++) {
float x2, y2;
if (horizontal) {
y2 = end.y + j;
x2 = end.x - j * ydist / xdist;
} else {
y2 = end.y - j * xdist / ydist;
x2 = end.x + j;
}
float dx = x1 - x2;
float dy = y1 - y2;
float length = sqrt(dx * dx + dy * dy);
float score = 0;
for(int k = 0; k < n; k++) {
const Point& edge = edges[k];
float dist = ((x1 - edge.x) * dy - (y1 - edge.y) * dx) / length;
// Similar to least squares method
float s = t - dist * dist;
if (s > 0)
score += s;
}
if (score > max) {
max = score;
bestLine.start = Point(x1, y1);
bestLine.end = Point(x2, y2);
}
}
}
return bestLine;
}
Point intersection(Line a, Line b) {
float dxa = a.start.x - a.end.x;
float dxb = b.start.x - b.end.x;
float dya = a.start.y - a.end.y;
float dyb = b.start.y - b.end.y;
float p = a.start.x * a.end.y - a.start.y * a.end.x;
float q = b.start.x * b.end.y - b.start.y * b.end.x;
float denom = dxa * dyb - dya * dxb;
if(denom == 0) // Lines don't intersect
return Point(INFINITY, INFINITY);
float x = (p * dxb - dxa * q) / denom;
float y = (p * dyb - dya * q) / denom;
return Point(x, y);
}
} // namespace EdgeDetector
} // namespace zxing

View file

@ -0,0 +1,38 @@
/*
* EdgeDetector.h
* zxing
*
* Created by Ralf Kistner on 7/12/2009.
* Copyright 2008 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.
*/
#ifndef EDGEDETECTOR_H_
#define EDGEDETECTOR_H_
#include <vector>
#include <zxing/common/BitMatrix.h>
#include <zxing/common/Point.h>
namespace zxing {
namespace EdgeDetector {
void findEdgePoints(std::vector<Point>& points, const BitMatrix& image, Point start, Point end, bool invert, int skip, float deviation);
Line findLine(const BitMatrix& image, Line estimate, bool invert, int deviation, float threshold, int skip);
Point intersection(Line a, Line b);
}
}
#endif /* EDGEDETECTOR_H_ */

View file

@ -0,0 +1,177 @@
/*
* GlobalHistogramBinarizer.cpp
* zxing
*
* Created by Ralf Kistner on 16/10/2009.
* Copyright 2008 ZXing authors All rights reserved.
* Modified by Lukasz Warchol on 02/02/2010.
*
* 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 <zxing/common/GlobalHistogramBinarizer.h>
#include <zxing/common/IllegalArgumentException.h>
namespace zxing {
using namespace std;
const int LUMINANCE_BITS = 5;
const int LUMINANCE_SHIFT = 8 - LUMINANCE_BITS;
const int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS;
GlobalHistogramBinarizer::GlobalHistogramBinarizer(Ref<LuminanceSource> source) :
Binarizer(source) {
}
GlobalHistogramBinarizer::~GlobalHistogramBinarizer() {
}
Ref<BitArray> GlobalHistogramBinarizer::estimateBlackRow(int y, Ref<BitArray> row){
valarray<int> histogram(0, LUMINANCE_BUCKETS);
LuminanceSource& source = *getSource();
int width = source.getWidth();
if (row == NULL || row->getSize() < width) {
row = new BitArray(width);
} else {
row->clear();
}
for (int x = 0; x < width; x++) {
unsigned char pixel = source.getPixel(x, y);
histogram[pixel >> LUMINANCE_SHIFT]++;
}
int blackPoint = estimate(histogram) << LUMINANCE_SHIFT;
Ref<BitArray> array_ref(new BitArray(width));
BitArray& array = *array_ref;
int left = source.getPixel(0, y);
int center = source.getPixel(1, y);
for (int x = 1; x < width - 1; x++) {
int right = source.getPixel(x+1, y);
// A simple -1 4 -1 box filter with a weight of 2.
int luminance = ((center << 2) - left - right) >> 1;
if (luminance < blackPoint) {
array.set(x);
}
left = center;
center = right;
}
return array_ref;
}
Ref<BitMatrix> GlobalHistogramBinarizer::estimateBlackMatrix() {
// Faster than working with the reference
LuminanceSource& source = *getSource();
int width = source.getWidth();
int height = source.getHeight();
valarray<int> histogram(0, LUMINANCE_BUCKETS);
// Quickly calculates the histogram by sampling four rows from the image. This proved to be
// more robust on the blackbox tests than sampling a diagonal as we used to do.
for (int y = 1; y < 5; y++) {
int row = height * y / 5;
int right = (width << 2) / 5;
int sdf;
for (int x = width / 5; x < right; x++) {
unsigned char pixel = source.getPixel(x, row);
histogram[pixel >> LUMINANCE_SHIFT]++;
sdf = histogram[pixel >> LUMINANCE_SHIFT];
}
}
int blackPoint = estimate(histogram) << LUMINANCE_SHIFT;
Ref<BitMatrix> matrix_ref(new BitMatrix(width, height));
BitMatrix& matrix = *matrix_ref;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (source.getPixel(x, y) <= blackPoint)
matrix.set(x, y);
}
}
return matrix_ref;
}
int GlobalHistogramBinarizer::estimate(valarray<int> &histogram) {
int numBuckets = histogram.size();
int maxBucketCount = 0;
// Find tallest peak in histogram
int firstPeak = 0;
int firstPeakSize = 0;
for (int i = 0; i < numBuckets; i++) {
if (histogram[i] > firstPeakSize) {
firstPeak = i;
firstPeakSize = histogram[i];
}
if (histogram[i] > maxBucketCount) {
maxBucketCount = histogram[i];
}
}
// Find second-tallest peak -- well, another peak that is tall and not
// so close to the first one
int secondPeak = 0;
int secondPeakScore = 0;
for (int i = 0; i < numBuckets; i++) {
int distanceToBiggest = i - firstPeak;
// Encourage more distant second peaks by multiplying by square of distance
int score = histogram[i] * distanceToBiggest * distanceToBiggest;
if (score > secondPeakScore) {
secondPeak = i;
secondPeakScore = score;
}
}
// Put firstPeak first
if (firstPeak > secondPeak) {
int temp = firstPeak;
firstPeak = secondPeak;
secondPeak = temp;
}
// Kind of arbitrary; if the two peaks are very close, then we figure there is so little
// dynamic range in the image, that discriminating black and white is too error-prone.
// Decoding the image/line is either pointless, or may in some cases lead to a false positive
// for 1D formats, which are relatively lenient.
// We arbitrarily say "close" is "<= 1/16 of the total histogram buckets apart"
if (secondPeak - firstPeak <= numBuckets >> 4) {
throw IllegalArgumentException("Too little dynamic range in luminance");
}
// Find a valley between them that is low and closer to the white peak
int bestValley = secondPeak - 1;
int bestValleyScore = -1;
for (int i = secondPeak - 1; i > firstPeak; i--) {
int fromFirst = i - firstPeak;
// Favor a "valley" that is not too close to either peak -- especially not the black peak --
// and that has a low value of course
int score = fromFirst * fromFirst * (secondPeak - i) * (maxBucketCount - histogram[i]);
if (score > bestValleyScore) {
bestValley = i;
bestValleyScore = score;
}
}
return bestValley;
}
}

View file

@ -0,0 +1,44 @@
/*
* GlobalHistogramBinarizer.h
* zxing
*
* Created by Ralf Kistner on 16/10/2009.
* Copyright 2008 ZXing authors All rights reserved.
* Modified by Lukasz Warchol on 02/02/2010.
*
* 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.
*/
#ifndef GLOBALHISTOGRAMBINARIZER_H_
#define GLOBALHISTOGRAMBINARIZER_H_
#include <valarray>
#include <zxing/Binarizer.h>
#include <zxing/common/BitArray.h>
#include <zxing/common/BitMatrix.h>
namespace zxing {
class GlobalHistogramBinarizer : public Binarizer {
public:
GlobalHistogramBinarizer(Ref<LuminanceSource> source);
virtual ~GlobalHistogramBinarizer();
virtual Ref<BitArray> estimateBlackRow(int y, Ref<BitArray> row);
virtual Ref<BitMatrix> estimateBlackMatrix();
static int estimate(std::valarray<int> &histogram);
};
}
#endif /* GLOBALHISTOGRAMBINARIZER_H_ */

View file

@ -0,0 +1,101 @@
/*
* GridSampler.cpp
* zxing
*
* Created by Christian Brunschen on 18/05/2008.
* Copyright 2008 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 <zxing/common/GridSampler.h>
#include <zxing/common/PerspectiveTransform.h>
#include <zxing/ReaderException.h>
#include <iostream>
#include <sstream>
namespace zxing {
using namespace std;
GridSampler GridSampler::gridSampler;
GridSampler::GridSampler() {
}
Ref<BitMatrix> GridSampler::sampleGrid(Ref<BitMatrix> image, int dimension, Ref<PerspectiveTransform> transform) {
Ref<BitMatrix> bits(new BitMatrix(dimension));
valarray<float> points((const float)0.0f, dimension << 1);
for (int y = 0; y < dimension; y++) {
int max = points.size();
float yValue = (float)y + 0.5f;
for (int x = 0; x < max; x += 2) {
points[x] = (float)(x >> 1) + 0.5f;
points[x + 1] = yValue;
}
transform->transformPoints(points);
checkAndNudgePoints(image, points);
for (int x = 0; x < max; x += 2) {
if (image->get((int)points[x], (int)points[x + 1])) {
bits->set(x >> 1, y);
}
}
}
return bits;
}
Ref<BitMatrix> GridSampler::sampleGrid(Ref<BitMatrix> image, int dimension, float p1ToX, float p1ToY, float p2ToX,
float p2ToY, float p3ToX, float p3ToY, float p4ToX, float p4ToY, float p1FromX, float p1FromY, float p2FromX,
float p2FromY, float p3FromX, float p3FromY, float p4FromX, float p4FromY) {
Ref<PerspectiveTransform> transform(PerspectiveTransform::quadrilateralToQuadrilateral(p1ToX, p1ToY, p2ToX, p2ToY,
p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY));
return sampleGrid(image, dimension, transform);
}
void GridSampler::checkAndNudgePoints(Ref<BitMatrix> image, valarray<float> &points) {
int width = image->getWidth();
int height = image->getHeight();
// The Java code assumes that if the start and end points are in bounds, the rest will also be.
// However, in some unusual cases points in the middle may also be out of bounds.
// Since we can't rely on an ArrayIndexOutOfBoundsException like Java, we check every point.
for (size_t offset = 0; offset < points.size(); offset += 2) {
int x = (int)points[offset];
int y = (int)points[offset + 1];
if (x < -1 || x > width || y < -1 || y > height) {
ostringstream s;
s << "Transformed point out of bounds at " << x << "," << y;
throw ReaderException(s.str().c_str());
}
if (x == -1) {
points[offset] = 0.0f;
} else if (x == width) {
points[offset] = width - 1;
}
if (y == -1) {
points[offset + 1] = 0.0f;
} else if (y == height) {
points[offset + 1] = height - 1;
}
}
}
GridSampler &GridSampler::getInstance() {
return gridSampler;
}
}

View file

@ -0,0 +1,44 @@
#ifndef __GRID_SAMPLER_H__
#define __GRID_SAMPLER_H__
/*
* GridSampler.h
* zxing
*
* Created by Christian Brunschen on 18/05/2008.
* Copyright 2008 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 <zxing/common/Counted.h>
#include <zxing/common/BitMatrix.h>
#include <zxing/common/PerspectiveTransform.h>
namespace zxing {
class GridSampler {
private:
static GridSampler gridSampler;
GridSampler();
public:
Ref<BitMatrix> sampleGrid(Ref<BitMatrix> image, int dimension, Ref<PerspectiveTransform> transform);
Ref<BitMatrix> sampleGrid(Ref<BitMatrix> image, int dimension, float p1ToX, float p1ToY, float p2ToX, float p2ToY,
float p3ToX, float p3ToY, float p4ToX, float p4ToY, float p1FromX, float p1FromY, float p2FromX,
float p2FromY, float p3FromX, float p3FromY, float p4FromX, float p4FromY);
static void checkAndNudgePoints(Ref<BitMatrix> image, std::valarray<float> &points);
static GridSampler &getInstance();
};
}
#endif // __GRID_SAMPLER_H__

View file

@ -0,0 +1,31 @@
/*
* IllegalArgumentException.cpp
* zxing
*
* Created by Christian Brunschen on 06/05/2008.
* Copyright 2008 Google UK. 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 <zxing/common/IllegalArgumentException.h>
namespace zxing {
IllegalArgumentException::IllegalArgumentException(const char *msg) :
Exception(msg) {
}
IllegalArgumentException::~IllegalArgumentException() throw() {
}
}

View file

@ -0,0 +1,34 @@
#ifndef __ILLEGAL_ARGUMENT_EXCEPTION_H__
#define __ILLEGAL_ARGUMENT_EXCEPTION_H__
/*
* IllegalArgumentException.h
* zxing
*
* Created by Christian Brunschen on 06/05/2008.
* Copyright 2008 Google UK. 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 <zxing/Exception.h>
namespace zxing {
class IllegalArgumentException : public zxing::Exception {
public:
IllegalArgumentException(const char *msg);
~IllegalArgumentException() throw();
};
}
#endif // __ILLEGAL_ARGUMENT_EXCEPTION_H__

View file

@ -0,0 +1,196 @@
/*
* LocalBlockBinarizer.cpp
* zxing
*
* Created by Ralf Kistner on 17/10/2009.
* Copyright 2008 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 <zxing/common/LocalBlockBinarizer.h>
namespace zxing {
const int GLOBAL = 0;
const int THRESHOLD = 1;
LocalBlockBinarizer::LocalBlockBinarizer(Ref<LuminanceSource> source) :
Binarizer(source) {
}
LocalBlockBinarizer::~LocalBlockBinarizer() {
}
Ref<BitArray> LocalBlockBinarizer::estimateBlackRow(int y, Ref<BitArray> row) {
//TODO: implement
return Ref<BitArray>();
}
// Calculates the final BitMatrix once for all requests. This could be called once from the
// constructor instead, but there are some advantages to doing it lazily, such as making
// profiling easier, and not doing heavy lifting when callers don't expect it.
Ref<BitMatrix> LocalBlockBinarizer::estimateBlackMatrix() {
Ref<LuminanceSource> source = getSource();
unsigned char* luminances = source->copyMatrix();
int width = source->getWidth();
int height = source->getHeight();
// Sharpening does not really help for 2d barcodes
// sharpenRow(luminances, width, height);
int subWidth = width >> 3;
int subHeight = height >> 3;
unsigned char* averages = new unsigned char[subWidth * subHeight];
unsigned char* types = new unsigned char[subWidth * subHeight];
calculateBlackPoints(luminances, averages, types, subWidth, subHeight, width);
Ref<BitMatrix> matrix(new BitMatrix(width, height));
calculateThresholdForBlock(luminances, subWidth, subHeight, width, averages, types, *matrix);
delete[] averages;
delete[] types;
delete[] luminances;
return matrix;
}
// For each 8x8 block in the image, calculate the average black point using a 5x5 grid
// of the blocks around it. Also handles the corner cases, but will ignore up to 7 pixels
// on the right edge and 7 pixels at the bottom of the image if the overall dimensions are not
// multiples of eight. In practice, leaving those pixels white does not seem to be a problem.
void LocalBlockBinarizer::calculateThresholdForBlock(const unsigned char* luminances, int subWidth, int subHeight,
int stride, const unsigned char* averages, const unsigned char* types, BitMatrix& matrix) {
// Calculate global average
int global = 0;
for (int y = 0; y < subHeight; y++) {
for (int x = 0; x < subWidth; x++) {
global += averages[y * subWidth + x];
}
}
global /= subWidth * subHeight;
for (int y = 0; y < subHeight; y++) {
for (int x = 0; x < subWidth; x++) {
int left = (x > 0) ? x : 1;
left = (left < subWidth - 1) ? left : subWidth - 2;
int top = (y > 0) ? y : 1;
top = (top < subHeight - 1) ? top : subHeight - 2;
int sum = 0;
int contrast = 0;
for (int z = -1; z <= 1; z++) {
// sum += averages[(top + z) * subWidth + left - 2];
sum += averages[(top + z) * subWidth + left - 1];
sum += averages[(top + z) * subWidth + left];
sum += averages[(top + z) * subWidth + left + 1];
// sum += averages[(top + z) * subWidth + left + 2];
// type += types[(top + z) * subWidth + left - 2];
contrast += types[(top + z) * subWidth + left - 1];
contrast += types[(top + z) * subWidth + left];
contrast += types[(top + z) * subWidth + left + 1];
// type += types[(top + z) * subWidth + left + 2];
}
int average = sum / 9;
if (contrast > 2)
threshold8x8Block(luminances, x << 3, y << 3, average, stride, matrix);
// else if(average < global) // Black
// matrix.setRegion(x << 3, y << 3, 8, 8);
// If white, we don't need to do anything - the block is already cleared.
}
}
}
// Applies a single threshold to an 8x8 block of pixels.
void LocalBlockBinarizer::threshold8x8Block(const unsigned char* luminances, int xoffset, int yoffset, int threshold,
int stride, BitMatrix& matrix) {
for (int y = 0; y < 8; y++) {
int offset = (yoffset + y) * stride + xoffset;
for (int x = 0; x < 8; x++) {
int pixel = luminances[offset + x];
if (pixel < threshold) {
matrix.set(xoffset + x, yoffset + y);
}
}
}
}
// Calculates a single black point for each 8x8 block of pixels and saves it away.
void LocalBlockBinarizer::calculateBlackPoints(const unsigned char* luminances, unsigned char* averages,
unsigned char* types, int subWidth, int subHeight, int stride) {
for (int y = 0; y < subHeight; y++) {
for (int x = 0; x < subWidth; x++) {
int sum = 0;
int min = 255;
int max = 0;
for (int yy = 0; yy < 8; yy++) {
int offset = ((y << 3) + yy) * stride + (x << 3);
const unsigned char* lumo = luminances + offset;
for (int xx = 0; xx < 8; xx++) {
int pixel = lumo[xx];
sum += pixel;
if (pixel < min) {
min = pixel;
}
if (pixel > max) {
max = pixel;
}
}
}
// If the contrast is inadequate, we treat the block as white.
// An arbitrary value is chosen here. Higher values mean less noise, but may also reduce
// the ability to recognise some barcodes.
int average = sum >> 6;
int type;
if (max - min > 30)
type = THRESHOLD;
else
type = GLOBAL;
// int average = (max - min > 24) ? (sum >> 6) : (min-1);
averages[y * subWidth + x] = average;
types[y * subWidth + x] = type;
}
}
}
// Applies a simple -1 4 -1 box filter with a weight of 2 to each row.
void LocalBlockBinarizer::sharpenRow(unsigned char* luminances, int width, int height) {
for (int y = 0; y < height; y++) {
int offset = y * width;
int left = luminances[offset];
int center = luminances[offset + 1];
for (int x = 1; x < width - 1; x++) {
unsigned char right = luminances[offset + x + 1];
int pixel = ((center << 2) - left - right) >> 1;
// Must clamp values to 0..255 so they will fit in a byte.
if (pixel > 255) {
pixel = 255;
} else if (pixel < 0) {
pixel = 0;
}
luminances[offset + x] = (unsigned char)pixel;
left = center;
center = right;
}
}
}
}

View file

@ -0,0 +1,47 @@
/*
* LocalBlockBinarizer.h
* zxing
*
* Created by Ralf Kistner on 17/10/2009.
* Copyright 2008 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.
*/
#ifndef LOCALBLOCKBINARIZER_H_
#define LOCALBLOCKBINARIZER_H_
#include <zxing/Binarizer.h>
#include <zxing/common/BitMatrix.h>
namespace zxing {
class LocalBlockBinarizer : public Binarizer {
public:
LocalBlockBinarizer(Ref<LuminanceSource> source);
virtual ~LocalBlockBinarizer();
virtual Ref<BitMatrix> estimateBlackMatrix();
Ref<BitArray> estimateBlackRow(int y, Ref<BitArray> row);
private:
void calculateThresholdForBlock(const unsigned char* luminances, int subWidth, int subHeight,
int stride, const unsigned char* averages, const unsigned char* types, BitMatrix& matrix);
void sharpenRow(unsigned char* luminances, int width, int height);
void calculateBlackPoints(const unsigned char* luminances, unsigned char* averages, unsigned char* types, int subWidth, int subHeight, int stride);
void threshold8x8Block(const unsigned char* luminances, int xoffset, int yoffset, int threshold,
int stride, BitMatrix& matrix);
};
}
#endif /* LOCALBLOCKBINARIZER_H_ */

View file

@ -0,0 +1,121 @@
/*
* PerspectiveTransform.cpp
* zxing
*
* Created by Christian Brunschen on 12/05/2008.
* Copyright 2008 Google UK. 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 <zxing/common/PerspectiveTransform.h>
namespace zxing {
using namespace std;
PerspectiveTransform::PerspectiveTransform(float a11, float a21, float a31, float a12, float a22, float a32, float a13,
float a23, float a33) {
this->a11 = a11;
this->a12 = a12;
this->a13 = a13;
this->a21 = a21;
this->a22 = a22;
this->a23 = a23;
this->a31 = a31;
this->a32 = a32;
this->a33 = a33;
}
Ref<PerspectiveTransform> PerspectiveTransform::quadrilateralToQuadrilateral(float x0, float y0, float x1, float y1,
float x2, float y2, float x3, float y3, float x0p, float y0p, float x1p, float y1p, float x2p, float y2p,
float x3p, float y3p) {
Ref<PerspectiveTransform> qToS = PerspectiveTransform::quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3);
Ref<PerspectiveTransform> sToQ =
PerspectiveTransform::squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p);
return sToQ->times(qToS);
}
Ref<PerspectiveTransform> PerspectiveTransform::squareToQuadrilateral(float x0, float y0, float x1, float y1, float x2,
float y2, float x3, float y3) {
float dy2 = y3 - y2;
float dy3 = y0 - y1 + y2 - y3;
if (dy2 == 0.0f && dy3 == 0.0f) {
Ref<PerspectiveTransform> result(new PerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, y2 - y1, y0, 0.0f,
0.0f, 1.0f));
return result;
} else {
float dx1 = x1 - x2;
float dx2 = x3 - x2;
float dx3 = x0 - x1 + x2 - x3;
float dy1 = y1 - y2;
float denominator = dx1 * dy2 - dx2 * dy1;
float a13 = (dx3 * dy2 - dx2 * dy3) / denominator;
float a23 = (dx1 * dy3 - dx3 * dy1) / denominator;
Ref<PerspectiveTransform> result(new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0
+ a13 * y1, y3 - y0 + a23 * y3, y0, a13, a23, 1.0f));
return result;
}
}
Ref<PerspectiveTransform> PerspectiveTransform::quadrilateralToSquare(float x0, float y0, float x1, float y1, float x2,
float y2, float x3, float y3) {
// Here, the adjoint serves as the inverse:
return squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3)->buildAdjoint();
}
Ref<PerspectiveTransform> PerspectiveTransform::buildAdjoint() {
// Adjoint is the transpose of the cofactor matrix:
Ref<PerspectiveTransform> result(new PerspectiveTransform(a22 * a33 - a23 * a32, a23 * a31 - a21 * a33, a21 * a32
- a22 * a31, a13 * a32 - a12 * a33, a11 * a33 - a13 * a31, a12 * a31 - a11 * a32, a12 * a23 - a13 * a22,
a13 * a21 - a11 * a23, a11 * a22 - a12 * a21));
return result;
}
Ref<PerspectiveTransform> PerspectiveTransform::times(Ref<PerspectiveTransform> other) {
Ref<PerspectiveTransform> result(new PerspectiveTransform(a11 * other->a11 + a21 * other->a12 + a31 * other->a13,
a11 * other->a21 + a21 * other->a22 + a31 * other->a23, a11 * other->a31 + a21 * other->a32 + a31
* other->a33, a12 * other->a11 + a22 * other->a12 + a32 * other->a13, a12 * other->a21 + a22
* other->a22 + a32 * other->a23, a12 * other->a31 + a22 * other->a32 + a32 * other->a33, a13
* other->a11 + a23 * other->a12 + a33 * other->a13, a13 * other->a21 + a23 * other->a22 + a33
* other->a23, a13 * other->a31 + a23 * other->a32 + a33 * other->a33));
return result;
}
void PerspectiveTransform::transformPoints(valarray<float> &points) {
int max = points.size();
float a11 = this->a11;
float a12 = this->a12;
float a13 = this->a13;
float a21 = this->a21;
float a22 = this->a22;
float a23 = this->a23;
float a31 = this->a31;
float a32 = this->a32;
float a33 = this->a33;
for (int i = 0; i < max; i += 2) {
float x = points[i];
float y = points[i + 1];
float denominator = a13 * x + a23 * y + a33;
points[i] = (a11 * x + a21 * y + a31) / denominator;
points[i + 1] = (a12 * x + a22 * y + a32) / denominator;
}
}
ostream& operator<<(ostream& out, PerspectiveTransform &pt) {
out << pt.a11 << ", " << pt.a12 << ", " << pt.a13 << ", \n";
out << pt.a21 << ", " << pt.a22 << ", " << pt.a23 << ", \n";
out << pt.a31 << ", " << pt.a32 << ", " << pt.a33 << "\n";
return out;
}
}

View file

@ -0,0 +1,50 @@
#ifndef __PERSPECTIVE_TANSFORM_H__
#define __PERSPECTIVE_TANSFORM_H__
/*
* PerspectiveTransform.h
* zxing
*
* Created by Christian Brunschen on 12/05/2008.
* Copyright 2008 Google UK. 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 <zxing/common/Counted.h>
#include <valarray>
namespace zxing {
class PerspectiveTransform : public Counted {
private:
float a11, a12, a13, a21, a22, a23, a31, a32, a33;
PerspectiveTransform(float a11, float a21, float a31, float a12, float a22, float a32, float a13, float a23,
float a33);
public:
static Ref<PerspectiveTransform>
quadrilateralToQuadrilateral(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3,
float x0p, float y0p, float x1p, float y1p, float x2p, float y2p, float x3p, float y3p);
static Ref<PerspectiveTransform> squareToQuadrilateral(float x0, float y0, float x1, float y1, float x2, float y2,
float x3, float y3);
static Ref<PerspectiveTransform> quadrilateralToSquare(float x0, float y0, float x1, float y1, float x2, float y2,
float x3, float y3);
Ref<PerspectiveTransform> buildAdjoint();
Ref<PerspectiveTransform> times(Ref<PerspectiveTransform> other);
void transformPoints(std::valarray<float> &points);
friend std::ostream& operator<<(std::ostream& out, PerspectiveTransform &pt);
};
}
#endif // __PERSPECTIVE_TANSFORM_H__

View file

@ -0,0 +1,47 @@
/*
* Point.h
* zxing
*
* Created by Ralf Kistner on 7/12/2009.
* Copyright 2008 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.
*/
#ifndef ZXING_POINT_H_
#define ZXING_POINT_H_
namespace zxing {
class PointI {
public:
int x;
int y;
};
class Point {
public:
Point(float x_, float y_) : x(x_), y(y_) {};
float x;
float y;
};
class Line {
public:
Line(Point start_, Point end_) : start(start_), end(end_) {};
Point start;
Point end;
};
}
#endif // POINT_H_

View file

@ -0,0 +1,38 @@
/*
* String.cpp
* zxing
*
* Created by Christian Brunschen on 20/05/2008.
* Copyright 2008 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 <zxing/common/Str.h>
namespace zxing {
using namespace std;
String::String(const std::string &text) :
text_(text) {
}
std::string& String::getText() {
return text_;
}
ostream &operator<<(ostream &out, const String &s) {
out << s.text_;
return out;
}
}

View file

@ -0,0 +1,41 @@
#ifndef __COMMON__STRING_H__
#define __COMMON__STRING_H__
/*
* String.h
* zxing
*
* Created by Christian Brunschen on 20/05/2008.
* Copyright 2008 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 <string>
#include <iostream>
#include <zxing/common/Counted.h>
namespace zxing {
class String : public Counted {
private:
std::string text_;
public:
String(const std::string &text);
std::string &getText();
friend std::ostream &operator<<(std::ostream &out, const String &s);
};
}
#endif // __COMMON__STRING_H__

View file

@ -0,0 +1,140 @@
/*
* GF256.cpp
* zxing
*
* Created by Christian Brunschen on 05/05/2008.
* Copyright 2008 Google UK. 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 <valarray>
#include <vector>
#include <iostream>
#include <zxing/common/reedsolomon/GF256.h>
#include <zxing/common/reedsolomon/GF256Poly.h>
#include <zxing/common/IllegalArgumentException.h>
#include <zxing/common/Array.h>
#include <zxing/common/Counted.h>
namespace zxing {
using namespace std;
static inline ArrayRef<int> makeArray(int value) {
ArrayRef<int> valuesRef(new Array<int> (value, 1));
return valuesRef;
}
static inline Ref<GF256Poly> refPoly(GF256 &field, int value) {
ArrayRef<int> values(makeArray(value));
Ref<GF256Poly> result(new GF256Poly(field, values));
return result;
}
GF256::GF256(int primitive) :
exp_((const int)0, 256), log_((const int)0, 256), zero_(refPoly(*this, 0)), one_(refPoly(*this, 1)) {
int x = 1;
for (int i = 0; i < 256; i++) {
exp_[i] = x;
x <<= 1;
if (x >= 0x100) {
x ^= primitive;
}
}
// log(0) == 0, but should never be used
log_[0] = 0;
for (int i = 0; i < 255; i++) {
log_[exp_[i]] = i;
}
}
Ref<GF256Poly> GF256::getZero() {
return zero_;
}
Ref<GF256Poly> GF256::getOne() {
return one_;
}
Ref<GF256Poly> GF256::buildMonomial(int degree, int coefficient) {
#ifdef DEBUG
cout << __FUNCTION__ << "\n";
#endif
if (degree < 0) {
throw IllegalArgumentException("Degree must be non-negative");
}
if (coefficient == 0) {
return zero_;
}
int nCoefficients = degree + 1;
ArrayRef<int> coefficients(new Array<int> (nCoefficients));
coefficients[0] = coefficient;
Ref<GF256Poly> result(new GF256Poly(*this, coefficients));
return result;
}
int GF256::addOrSubtract(int a, int b) {
return a ^ b;
}
int GF256::exp(int a) {
return exp_[a];
}
int GF256::log(int a) {
if (a == 0) {
throw IllegalArgumentException("Cannot take the logarithm of 0");
}
return log_[a];
}
int GF256::inverse(int a) {
if (a == 0) {
throw IllegalArgumentException("Cannot calculate the inverse of 0");
}
return exp_[255 - log_[a]];
}
int GF256::multiply(int a, int b) {
if (a == 0 || b == 0) {
return 0;
}
if (a == 1) {
return b;
}
if (b == 1) {
return a;
}
return exp_[(log_[a] + log_[b]) % 255];
}
GF256 GF256::QR_CODE_FIELD(0x011D); // x^8 + x^4 + x^3 + x^2 + 1
GF256 GF256::DATA_MATRIX_FIELD(0x012D); // x^8 + x^5 + x^3 + x^2 + 1
ostream& operator<<(ostream& out, const GF256& field) {
out << "Field[\nexp=(";
out << field.exp_[0];
for (int i = 1; i < 256; i++) {
out << "," << field.exp_[i];
}
out << "),\nlog=(";
out << field.log_[0];
for (int i = 1; i < 256; i++) {
out << "," << field.log_[i];
}
out << ")\n]";
return out;
}
}

View file

@ -0,0 +1,69 @@
#ifndef __GF256_H__
#define __GF256_H__
/*
* GF256.h
* zxing
*
* Created by Christian Brunschen on 05/05/2008.
* Copyright 2008 Google UK. 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 <memory>
#include <valarray>
#include <zxing/common/Counted.h>
namespace zxing {
class GF256Poly;
class GF256 {
/**
* <p>This class contains utility methods for performing mathematical
* operations over the Galois Field GF(256). Operations use a given
* primitive polynomial in calculations.</p>
*
* <p>Throughout this package, elements of GF(256) are represented as an
* <code>int</code> for convenience and speed (but at the cost of memory).
* Only the bottom 8 bits are really used.</p>
*
* @author srowen@google.com (Sean Owen)
* @author christian.brunschen@gmail.com (Christian Brunschen)
*/
private:
std::valarray<int> exp_;
std::valarray<int> log_;
Ref<GF256Poly> zero_;
Ref<GF256Poly> one_;
GF256(int primitive);
public:
Ref<GF256Poly> getZero();
Ref<GF256Poly> getOne();
Ref<GF256Poly> buildMonomial(int degree, int coefficient);
static int addOrSubtract(int a, int b);
int exp(int a);
int log(int a);
int inverse(int a);
int multiply(int a, int b);
static GF256 QR_CODE_FIELD;
static GF256 DATA_MATRIX_FIELD;
friend std::ostream& operator<<(std::ostream& out, const GF256& field);
};
}
#endif // __GF256_H__

View file

@ -0,0 +1,198 @@
/*
* GF256Poly.cpp
* zxing
*
* Created by Christian Brunschen on 05/05/2008.
* Copyright 2008 Google UK. 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>
#include <sstream>
#include <zxing/common/reedsolomon/GF256Poly.h>
#include <zxing/common/reedsolomon/GF256.h>
#include <zxing/common/IllegalArgumentException.h>
namespace zxing {
using namespace std;
void GF256Poly::fixCoefficients() {
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) {
coefficientsLength = field.getZero()->coefficients.size();
coefficients.reset(new Array<int> (coefficientsLength));
*coefficients = *(field.getZero()->coefficients);
} else {
ArrayRef<int> c(coefficients);
coefficientsLength -= firstNonZero;
coefficients.reset(new Array<int> (coefficientsLength));
for (int i = 0; i < coefficientsLength; i++) {
coefficients[i] = c[i + firstNonZero];
}
}
}
}
GF256Poly::GF256Poly(GF256 &f, ArrayRef<int> c) :
Counted(), field(f), coefficients(c) {
fixCoefficients();
}
GF256Poly::~GF256Poly() {
}
int GF256Poly::getDegree() {
return coefficients.size() - 1;
}
bool GF256Poly::isZero() {
return coefficients[0] == 0;
}
int GF256Poly::getCoefficient(int degree) {
return coefficients[coefficients.size() - 1 - degree];
}
int GF256Poly::evaluateAt(int a) {
if (a == 0) {
return getCoefficient(0);
}
int size = coefficients.size();
if (a == 1) {
// Just the sum of the coefficients
int result = 0;
for (int i = 0; i < size; i++) {
result = GF256::addOrSubtract(result, coefficients[i]);
}
return result;
}
int result = coefficients[0];
for (int i = 1; i < size; i++) {
result = GF256::addOrSubtract(field.multiply(a, result), coefficients[i]);
}
return result;
}
Ref<GF256Poly> GF256Poly::addOrSubtract(Ref<GF256Poly> b) {
if (&field != &b->field) {
throw IllegalArgumentException("Fields must be the same");
}
if (isZero()) {
return b;
}
if (b->isZero()) {
return Ref<GF256Poly>(this);
}
ArrayRef<int> largerCoefficients = coefficients;
ArrayRef<int> smallerCoefficients = b->coefficients;
if (smallerCoefficients.size() > largerCoefficients.size()) {
ArrayRef<int> tmp(smallerCoefficients);
smallerCoefficients = largerCoefficients;
largerCoefficients = tmp;
}
ArrayRef<int> sumDiff(new Array<int> (largerCoefficients.size()));
unsigned lengthDiff = largerCoefficients.size() - smallerCoefficients.size();
for (unsigned i = 0; i < lengthDiff; i++) {
sumDiff[i] = largerCoefficients[i];
}
for (unsigned i = lengthDiff; i < largerCoefficients.size(); i++) {
sumDiff[i] = GF256::addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]);
}
return Ref<GF256Poly>(new GF256Poly(field, sumDiff));
}
Ref<GF256Poly> GF256Poly::multiply(Ref<GF256Poly> b) {
if (&field != &b->field) {
throw IllegalArgumentException("Fields must be the same");
}
if (isZero() || b->isZero()) {
return field.getZero();
}
ArrayRef<int> aCoefficients = coefficients;
int aLength = aCoefficients.size();
ArrayRef<int> bCoefficients = b->coefficients;
int bLength = bCoefficients.size();
int productLength = aLength + bLength - 1;
ArrayRef<int> product(new Array<int> (productLength));
for (int i = 0; i < aLength; i++) {
int aCoeff = aCoefficients[i];
for (int j = 0; j < bLength; j++) {
product[i + j] = GF256::addOrSubtract(product[i + j], field.multiply(aCoeff, bCoefficients[j]));
}
}
return Ref<GF256Poly>(new GF256Poly(field, product));
}
Ref<GF256Poly> GF256Poly::multiply(int scalar) {
if (scalar == 0) {
return field.getZero();
}
if (scalar == 1) {
return Ref<GF256Poly>(this);
}
int size = coefficients.size();
ArrayRef<int> product(new Array<int> (size));
for (int i = 0; i < size; i++) {
product[i] = field.multiply(coefficients[i], scalar);
}
return Ref<GF256Poly>(new GF256Poly(field, product));
}
Ref<GF256Poly> GF256Poly::multiplyByMonomial(int degree, int coefficient) {
if (degree < 0) {
throw IllegalArgumentException("Degree must be non-negative");
}
if (coefficient == 0) {
return field.getZero();
}
int size = coefficients.size();
ArrayRef<int> product(new Array<int> (size + degree));
for (int i = 0; i < size; i++) {
product[i] = field.multiply(coefficients[i], coefficient);
}
return Ref<GF256Poly>(new GF256Poly(field, product));
}
const char *GF256Poly::description() const {
ostringstream result;
result << *this;
return result.str().c_str();
}
ostream& operator<<(ostream& out, const GF256Poly& p) {
GF256Poly &poly = const_cast<GF256Poly&>(p);
out << "Poly[" << poly.coefficients.size() << "]";
if (poly.coefficients.size() > 0) {
out << "(" << poly.coefficients[0];
for (unsigned i = 1; i < poly.coefficients.size(); i++) {
out << "," << poly.coefficients[i];
}
out << ")";
}
return out;
}
}

View file

@ -0,0 +1,54 @@
#ifndef __GF256_POLY_H__
#define __GF256_POLY_H__
/*
* GF256Poly.h
* zxing
*
* Created by Christian Brunschen on 05/05/2008.
* Copyright 2008 Google UK. 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 <memory>
#include <zxing/common/Counted.h>
#include <zxing/common/Array.h>
namespace zxing {
class GF256;
class GF256Poly : public Counted {
private:
GF256 &field;
ArrayRef<int> coefficients;
void fixCoefficients();
public:
GF256Poly(GF256 &field, ArrayRef<int> c);
~GF256Poly();
int getDegree();
bool isZero();
int getCoefficient(int degree);
int evaluateAt(int a);
Ref<GF256Poly> addOrSubtract(Ref<GF256Poly> other);
Ref<GF256Poly> multiply(Ref<GF256Poly> other);
Ref<GF256Poly> multiply(int scalar);
Ref<GF256Poly> multiplyByMonomial(int degree, int coefficient);
const char *description() const;
friend std::ostream& operator<<(std::ostream& out, const GF256Poly& poly);
};
}
#endif // __GF256_POLY_H__

View file

@ -0,0 +1,193 @@
/*
* ReedSolomonDecoder.cpp
* zxing
*
* Created by Christian Brunschen on 05/05/2008.
* Copyright 2008 Google UK. 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>
#include <memory>
#include <zxing/common/reedsolomon/ReedSolomonDecoder.h>
#include <zxing/common/reedsolomon/GF256.h>
#include <zxing/common/reedsolomon/GF256Poly.h>
#include <zxing/common/reedsolomon/ReedSolomonException.h>
#include <zxing/common/IllegalArgumentException.h>
using namespace std;
namespace zxing {
ReedSolomonDecoder::ReedSolomonDecoder(GF256 &fld) :
field(fld) {
}
ReedSolomonDecoder::~ReedSolomonDecoder() {
}
void ReedSolomonDecoder::decode(ArrayRef<int> received, int twoS) {
Ref<GF256Poly> poly(new GF256Poly(field, received));
#ifdef DEBUG
cout << "decoding with poly " << *poly << "\n";
#endif
ArrayRef<int> syndromeCoefficients(new Array<int> (twoS));
#ifdef DEBUG
cout << "syndromeCoefficients array = " <<
syndromeCoefficients.array_ << "\n";
#endif
bool noError = true;
for (int i = 0; i < twoS; i++) {
int eval = poly->evaluateAt(field.exp(i));
syndromeCoefficients[syndromeCoefficients->size() - 1 - i] = eval;
if (eval != 0) {
noError = false;
}
}
if (noError) {
return;
}
Ref<GF256Poly> syndrome(new GF256Poly(field, syndromeCoefficients));
Ref<GF256Poly> monomial(field.buildMonomial(twoS, 1));
vector<Ref<GF256Poly> > sigmaOmega(runEuclideanAlgorithm(monomial, syndrome, twoS));
ArrayRef<int> errorLocations = findErrorLocations(sigmaOmega[0]);
ArrayRef<int> errorMagitudes = findErrorMagnitudes(sigmaOmega[1], errorLocations);
for (unsigned i = 0; i < errorLocations->size(); i++) {
int position = received->size() - 1 - field.log(errorLocations[i]);
//TODO: check why the position would be invalid
if (position < 0 || (size_t)position >= received.size())
throw IllegalArgumentException("Invalid position (ReedSolomonDecoder)");
received[position] = GF256::addOrSubtract(received[position], errorMagitudes[i]);
}
}
vector<Ref<GF256Poly> > ReedSolomonDecoder::runEuclideanAlgorithm(Ref<GF256Poly> a, Ref<GF256Poly> b, int R) {
// Assume a's degree is >= b's
if (a->getDegree() < b->getDegree()) {
Ref<GF256Poly> tmp = a;
a = b;
b = tmp;
}
Ref<GF256Poly> rLast(a);
Ref<GF256Poly> r(b);
Ref<GF256Poly> sLast(field.getOne());
Ref<GF256Poly> s(field.getZero());
Ref<GF256Poly> tLast(field.getZero());
Ref<GF256Poly> t(field.getOne());
// Run Euclidean algorithm until r's degree is less than R/2
while (r->getDegree() >= R / 2) {
Ref<GF256Poly> rLastLast(rLast);
Ref<GF256Poly> sLastLast(sLast);
Ref<GF256Poly> tLastLast(tLast);
rLast = r;
sLast = s;
tLast = t;
// Divide rLastLast by rLast, with quotient q and remainder r
if (rLast->isZero()) {
// Oops, Euclidean algorithm already terminated?
throw ReedSolomonException("r_{i-1} was zero");
}
r = rLastLast;
Ref<GF256Poly> q(field.getZero());
int denominatorLeadingTerm = rLast->getCoefficient(rLast->getDegree());
int dltInverse = field.inverse(denominatorLeadingTerm);
while (r->getDegree() >= rLast->getDegree() && !r->isZero()) {
int degreeDiff = r->getDegree() - rLast->getDegree();
int scale = field.multiply(r->getCoefficient(r->getDegree()), dltInverse);
q = q->addOrSubtract(field.buildMonomial(degreeDiff, scale));
r = r->addOrSubtract(rLast->multiplyByMonomial(degreeDiff, scale));
}
s = q->multiply(sLast)->addOrSubtract(sLastLast);
t = q->multiply(tLast)->addOrSubtract(tLastLast);
}
int sigmaTildeAtZero = t->getCoefficient(0);
if (sigmaTildeAtZero == 0) {
throw ReedSolomonException("sigmaTilde(0) was zero");
}
int inverse = field.inverse(sigmaTildeAtZero);
Ref<GF256Poly> sigma(t->multiply(inverse));
Ref<GF256Poly> omega(r->multiply(inverse));
#ifdef DEBUG
cout << "t = " << *t << "\n";
cout << "r = " << *r << "\n";
cout << "sigma = " << *sigma << "\n";
cout << "omega = " << *omega << "\n";
#endif
vector<Ref<GF256Poly> > result(2);
result[0] = sigma;
result[1] = omega;
return result;
}
ArrayRef<int> ReedSolomonDecoder::findErrorLocations(Ref<GF256Poly> errorLocator) {
// This is a direct application of Chien's search
int numErrors = errorLocator->getDegree();
if (numErrors == 1) { // shortcut
ArrayRef<int> result(1);
result[0] = errorLocator->getCoefficient(1);
return result;
}
ArrayRef<int> result(numErrors);
int e = 0;
for (int i = 1; i < 256 && e < numErrors; i++) {
// cout << "errorLocator(" << i << ") == " << errorLocator->evaluateAt(i) << "\n";
if (errorLocator->evaluateAt(i) == 0) {
result[e] = field.inverse(i);
e++;
}
}
if (e != numErrors) {
throw ReedSolomonException("Error locator degree does not match number of roots");
}
return result;
}
ArrayRef<int> ReedSolomonDecoder::findErrorMagnitudes(Ref<GF256Poly> errorEvaluator, ArrayRef<int> errorLocations) {
// This is directly applying Forney's Formula
int s = errorLocations.size();
ArrayRef<int> result(s);
for (int i = 0; i < s; i++) {
int xiInverse = field.inverse(errorLocations[i]);
int denominator = 1;
for (int j = 0; j < s; j++) {
if (i != j) {
denominator = field.multiply(denominator, GF256::addOrSubtract(1, field.multiply(errorLocations[j],
xiInverse)));
}
}
result[i] = field.multiply(errorEvaluator->evaluateAt(xiInverse), field.inverse(denominator));
}
return result;
}
}

View file

@ -0,0 +1,47 @@
#ifndef __REED_SOLOMON_DECODER_H__
#define __REED_SOLOMON_DECODER_H__
/*
* ReedSolomonDecoder.h
* zxing
*
* Created by Christian Brunschen on 05/05/2008.
* Copyright 2008 Google UK. 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 <memory>
#include <vector>
#include <zxing/common/Counted.h>
#include <zxing/common/Array.h>
namespace zxing {
class GF256;
class GF256Poly;
class ReedSolomonDecoder {
private:
GF256 &field;
public:
ReedSolomonDecoder(GF256 &fld);
~ReedSolomonDecoder();
void decode(ArrayRef<int> received, int twoS);
private:
std::vector<Ref<GF256Poly> > runEuclideanAlgorithm(Ref<GF256Poly> a, Ref<GF256Poly> b, int R);
ArrayRef<int> findErrorLocations(Ref<GF256Poly> errorLocator);
ArrayRef<int> findErrorMagnitudes(Ref<GF256Poly> errorEvaluator, ArrayRef<int> errorLocations);
};
}
#endif // __REED_SOLOMON_DECODER_H__

View file

@ -0,0 +1,30 @@
/*
* ReedSolomonException.cpp
* zxing
*
* Created by Christian Brunschen on 06/05/2008.
* Copyright 2008 Google UK. 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 <zxing/common/reedsolomon/ReedSolomonException.h>
namespace zxing {
ReedSolomonException::ReedSolomonException(const char *msg) throw() :
Exception(msg) {
}
ReedSolomonException::~ReedSolomonException() throw() {
}
}

View file

@ -0,0 +1,34 @@
#ifndef __REED_SOLOMON_EXCEPTION_H__
#define __REED_SOLOMON_EXCEPTION_H__
/*
* ReedSolomonException.h
* zxing
*
* Created by Christian Brunschen on 06/05/2008.
* Copyright 2008 Google UK. 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 <zxing/Exception.h>
namespace zxing {
class ReedSolomonException : public Exception {
public:
ReedSolomonException(const char *msg) throw();
~ReedSolomonException() throw();
};
}
#endif // __REED_SOLOMON_EXCEPTION_H__

View file

@ -0,0 +1,478 @@
/*
* Code128Reader.cpp
* ZXing
*
* Created by Lukasz Warchol on 10-01-15.
* 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 "Code128Reader.h"
#include <zxing/oned/OneDResultPoint.h>
#include <zxing/common/Array.h>
#include <zxing/ReaderException.h>
#include <math.h>
#include <string.h>
namespace zxing {
namespace oned {
const int CODE_PATTERNS_LENGHT = 107;
const int countersLenght = 6;
static const int CODE_PATTERNS[CODE_PATTERNS_LENGHT][countersLenght] = {
{2, 1, 2, 2, 2, 2}, /* 0 */
{2, 2, 2, 1, 2, 2},
{2, 2, 2, 2, 2, 1},
{1, 2, 1, 2, 2, 3},
{1, 2, 1, 3, 2, 2},
{1, 3, 1, 2, 2, 2}, /* 5 */
{1, 2, 2, 2, 1, 3},
{1, 2, 2, 3, 1, 2},
{1, 3, 2, 2, 1, 2},
{2, 2, 1, 2, 1, 3},
{2, 2, 1, 3, 1, 2}, /* 10 */
{2, 3, 1, 2, 1, 2},
{1, 1, 2, 2, 3, 2},
{1, 2, 2, 1, 3, 2},
{1, 2, 2, 2, 3, 1},
{1, 1, 3, 2, 2, 2}, /* 15 */
{1, 2, 3, 1, 2, 2},
{1, 2, 3, 2, 2, 1},
{2, 2, 3, 2, 1, 1},
{2, 2, 1, 1, 3, 2},
{2, 2, 1, 2, 3, 1}, /* 20 */
{2, 1, 3, 2, 1, 2},
{2, 2, 3, 1, 1, 2},
{3, 1, 2, 1, 3, 1},
{3, 1, 1, 2, 2, 2},
{3, 2, 1, 1, 2, 2}, /* 25 */
{3, 2, 1, 2, 2, 1},
{3, 1, 2, 2, 1, 2},
{3, 2, 2, 1, 1, 2},
{3, 2, 2, 2, 1, 1},
{2, 1, 2, 1, 2, 3}, /* 30 */
{2, 1, 2, 3, 2, 1},
{2, 3, 2, 1, 2, 1},
{1, 1, 1, 3, 2, 3},
{1, 3, 1, 1, 2, 3},
{1, 3, 1, 3, 2, 1}, /* 35 */
{1, 1, 2, 3, 1, 3},
{1, 3, 2, 1, 1, 3},
{1, 3, 2, 3, 1, 1},
{2, 1, 1, 3, 1, 3},
{2, 3, 1, 1, 1, 3}, /* 40 */
{2, 3, 1, 3, 1, 1},
{1, 1, 2, 1, 3, 3},
{1, 1, 2, 3, 3, 1},
{1, 3, 2, 1, 3, 1},
{1, 1, 3, 1, 2, 3}, /* 45 */
{1, 1, 3, 3, 2, 1},
{1, 3, 3, 1, 2, 1},
{3, 1, 3, 1, 2, 1},
{2, 1, 1, 3, 3, 1},
{2, 3, 1, 1, 3, 1}, /* 50 */
{2, 1, 3, 1, 1, 3},
{2, 1, 3, 3, 1, 1},
{2, 1, 3, 1, 3, 1},
{3, 1, 1, 1, 2, 3},
{3, 1, 1, 3, 2, 1}, /* 55 */
{3, 3, 1, 1, 2, 1},
{3, 1, 2, 1, 1, 3},
{3, 1, 2, 3, 1, 1},
{3, 3, 2, 1, 1, 1},
{3, 1, 4, 1, 1, 1}, /* 60 */
{2, 2, 1, 4, 1, 1},
{4, 3, 1, 1, 1, 1},
{1, 1, 1, 2, 2, 4},
{1, 1, 1, 4, 2, 2},
{1, 2, 1, 1, 2, 4}, /* 65 */
{1, 2, 1, 4, 2, 1},
{1, 4, 1, 1, 2, 2},
{1, 4, 1, 2, 2, 1},
{1, 1, 2, 2, 1, 4},
{1, 1, 2, 4, 1, 2}, /* 70 */
{1, 2, 2, 1, 1, 4},
{1, 2, 2, 4, 1, 1},
{1, 4, 2, 1, 1, 2},
{1, 4, 2, 2, 1, 1},
{2, 4, 1, 2, 1, 1}, /* 75 */
{2, 2, 1, 1, 1, 4},
{4, 1, 3, 1, 1, 1},
{2, 4, 1, 1, 1, 2},
{1, 3, 4, 1, 1, 1},
{1, 1, 1, 2, 4, 2}, /* 80 */
{1, 2, 1, 1, 4, 2},
{1, 2, 1, 2, 4, 1},
{1, 1, 4, 2, 1, 2},
{1, 2, 4, 1, 1, 2},
{1, 2, 4, 2, 1, 1}, /* 85 */
{4, 1, 1, 2, 1, 2},
{4, 2, 1, 1, 1, 2},
{4, 2, 1, 2, 1, 1},
{2, 1, 2, 1, 4, 1},
{2, 1, 4, 1, 2, 1}, /* 90 */
{4, 1, 2, 1, 2, 1},
{1, 1, 1, 1, 4, 3},
{1, 1, 1, 3, 4, 1},
{1, 3, 1, 1, 4, 1},
{1, 1, 4, 1, 1, 3}, /* 95 */
{1, 1, 4, 3, 1, 1},
{4, 1, 1, 1, 1, 3},
{4, 1, 1, 3, 1, 1},
{1, 1, 3, 1, 4, 1},
{1, 1, 4, 1, 3, 1}, /* 100 */
{3, 1, 1, 1, 4, 1},
{4, 1, 1, 1, 3, 1},
{2, 1, 1, 4, 1, 2},
{2, 1, 1, 2, 1, 4},
{2, 1, 1, 2, 3, 2}, /* 105 */
{2, 3, 3, 1, 1, 1}
};
Code128Reader::Code128Reader(){
}
int* Code128Reader::findStartPattern(Ref<BitArray> row){
int width = row->getSize();
int rowOffset = 0;
while (rowOffset < width) {
if (row->get(rowOffset)) {
break;
}
rowOffset++;
}
int counterPosition = 0;
int counters[countersLenght] = {0,0,0,0,0,0};
int patternStart = rowOffset;
bool isWhite = false;
int patternLength = sizeof(counters) / sizeof(int);
for (int i = rowOffset; i < width; i++) {
bool pixel = row->get(i);
if (pixel ^ isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
int bestVariance = MAX_AVG_VARIANCE;
int bestMatch = -1;
for (int startCode = CODE_START_A; startCode <= CODE_START_C; startCode++) {
int variance = patternMatchVariance(counters, sizeof(counters)/sizeof(int), CODE_PATTERNS[startCode], MAX_INDIVIDUAL_VARIANCE);
if (variance < bestVariance) {
bestVariance = variance;
bestMatch = startCode;
}
}
if (bestMatch >= 0) {
// Look for whitespace before start pattern, >= 50% of width of start pattern
if (row->isRange(fmaxl(0, patternStart - (i - patternStart) / 2), patternStart, false)) {
int* resultValue = new int[3];
resultValue[0] = patternStart;
resultValue[1] = i;
resultValue[2] = bestMatch;
return resultValue;
}
}
patternStart += counters[0] + counters[1];
for (int y = 2; y < patternLength; y++) {
counters[y - 2] = counters[y];
}
counters[patternLength - 2] = 0;
counters[patternLength - 1] = 0;
counterPosition--;
} else {
counterPosition++;
}
counters[counterPosition] = 1;
isWhite = !isWhite;
}
}
throw ReaderException("");
}
int Code128Reader::decodeCode(Ref<BitArray> row, int counters[], int countersCount, int rowOffset){
recordPattern(row, rowOffset, counters, countersCount);
int bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
int bestMatch = -1;
for (int d = 0; d < CODE_PATTERNS_LENGHT; d++) {
int pattern[countersLenght];
for(int ind = 0; ind< countersLenght; ind++){
pattern[ind] = CODE_PATTERNS[d][ind];
}
// memcpy(pattern, CODE_PATTERNS[d], countersLenght);
int variance = patternMatchVariance(counters, countersCount, pattern, MAX_INDIVIDUAL_VARIANCE);
if (variance < bestVariance) {
bestVariance = variance;
bestMatch = d;
}
}
// TODO We're overlooking the fact that the STOP pattern has 7 values, not 6.
if (bestMatch >= 0) {
return bestMatch;
} else {
throw ReaderException("");
}
}
Ref<Result> Code128Reader::decodeRow(int rowNumber, Ref<BitArray> row){
int* startPatternInfo = findStartPattern(row);
int startCode = startPatternInfo[2];
int codeSet;
switch (startCode) {
case CODE_START_A:
codeSet = CODE_CODE_A;
break;
case CODE_START_B:
codeSet = CODE_CODE_B;
break;
case CODE_START_C:
codeSet = CODE_CODE_C;
break;
default:
throw ReaderException("");
}
bool done = false;
bool isNextShifted = false;
std::string tmpResultString;
int lastStart = startPatternInfo[0];
int nextStart = startPatternInfo[1];
int counters[countersLenght] = {0,0,0,0,0,0};
int lastCode = 0;
int code = 0;
int checksumTotal = startCode;
int multiplier = 0;
bool lastCharacterWasPrintable = true;
while (!done) {
bool unshift = isNextShifted;
isNextShifted = false;
// Save off last code
lastCode = code;
// Decode another code from image
code = decodeCode(row, counters, sizeof(counters)/sizeof(int), nextStart);
// Remember whether the last code was printable or not (excluding CODE_STOP)
if (code != CODE_STOP) {
lastCharacterWasPrintable = true;
}
// Add to checksum computation (if not CODE_STOP of course)
if (code != CODE_STOP) {
multiplier++;
checksumTotal += multiplier * code;
}
// Advance to where the next code will to start
lastStart = nextStart;
int _countersLenght = sizeof(counters) / sizeof(int);
for (int i = 0; i < _countersLenght; i++) {
nextStart += counters[i];
}
// Take care of illegal start codes
switch (code) {
case CODE_START_A:
case CODE_START_B:
case CODE_START_C:
throw ReaderException("");
}
switch (codeSet) {
case CODE_CODE_A:
if (code < 64) {
tmpResultString.append(1, (char) (' ' + code));
} else if (code < 96) {
tmpResultString.append(1, (char) (code - 64));
} else {
// Don't let CODE_STOP, which always appears, affect whether whether we think the last
// code was printable or not.
if (code != CODE_STOP) {
lastCharacterWasPrintable = false;
}
switch (code) {
case CODE_FNC_1:
case CODE_FNC_2:
case CODE_FNC_3:
case CODE_FNC_4_A:
// do nothing?
break;
case CODE_SHIFT:
isNextShifted = true;
codeSet = CODE_CODE_B;
break;
case CODE_CODE_B:
codeSet = CODE_CODE_B;
break;
case CODE_CODE_C:
codeSet = CODE_CODE_C;
break;
case CODE_STOP:
done = true;
break;
}
}
break;
case CODE_CODE_B:
if (code < 96) {
tmpResultString.append(1, (char) (' ' + code));
} else {
if (code != CODE_STOP) {
lastCharacterWasPrintable = false;
}
switch (code) {
case CODE_FNC_1:
case CODE_FNC_2:
case CODE_FNC_3:
case CODE_FNC_4_B:
// do nothing?
break;
case CODE_SHIFT:
isNextShifted = true;
codeSet = CODE_CODE_C;
break;
case CODE_CODE_A:
codeSet = CODE_CODE_A;
break;
case CODE_CODE_C:
codeSet = CODE_CODE_C;
break;
case CODE_STOP:
done = true;
break;
}
}
break;
case CODE_CODE_C:
if (code < 100) {
if (code < 10) {
tmpResultString.append(1, '0');
}
tmpResultString.append(1, code);
} else {
if (code != CODE_STOP) {
lastCharacterWasPrintable = false;
}
switch (code) {
case CODE_FNC_1:
// do nothing?
break;
case CODE_CODE_A:
codeSet = CODE_CODE_A;
break;
case CODE_CODE_B:
codeSet = CODE_CODE_B;
break;
case CODE_STOP:
done = true;
break;
}
}
break;
}
// Unshift back to another code set if we were shifted
if (unshift) {
switch (codeSet) {
case CODE_CODE_A:
codeSet = CODE_CODE_C;
break;
case CODE_CODE_B:
codeSet = CODE_CODE_A;
break;
case CODE_CODE_C:
codeSet = CODE_CODE_B;
break;
}
}
}
// Check for ample whitespace following pattern, but, to do this we first need to remember that
// we fudged decoding CODE_STOP since it actually has 7 bars, not 6. There is a black bar left
// to read off. Would be slightly better to properly read. Here we just skip it:
int width = row->getSize();
while (nextStart < width && row->get(nextStart)) {
nextStart++;
}
if (!row->isRange(nextStart, fminl(width, nextStart + (nextStart - lastStart) / 2), false)) {
throw ReaderException("");
}
// Pull out from sum the value of the penultimate check code
checksumTotal -= multiplier * lastCode;
// lastCode is the checksum then:
if (checksumTotal % 103 != lastCode) {
throw ReaderException("");
}
// Need to pull out the check digits from string
int resultLength = tmpResultString.length();
// Only bother if the result had at least one character, and if the checksum digit happened to
// be a printable character. If it was just interpreted as a control code, nothing to remove.
if (resultLength > 0 && lastCharacterWasPrintable) {
if (codeSet == CODE_CODE_C) {
tmpResultString.erase(resultLength - 2, resultLength);
} else {
tmpResultString.erase(resultLength - 1, resultLength);
}
}
Ref<String> resultString(new String(tmpResultString));
// String resultString(tmpResultString);
if (tmpResultString.length() == 0) {
// Almost surely a false positive
throw ReaderException("");
}
float left = (float) (startPatternInfo[1] + startPatternInfo[0]) / 2.0f;
float right = (float) (nextStart + lastStart) / 2.0f;
std::vector< Ref<ResultPoint> > resultPoints(2);
Ref<OneDResultPoint> resultPoint1(new OneDResultPoint(left, (float) rowNumber));
Ref<OneDResultPoint> resultPoint2(new OneDResultPoint(right, (float) rowNumber));
resultPoints[0] = resultPoint1;
resultPoints[1] = resultPoint2;
ArrayRef<unsigned char> resultBytes(1);
delete [] startPatternInfo;
startPatternInfo = NULL;
Ref<Result> res(new Result(resultString, resultBytes, resultPoints, BarcodeFormat_CODE_128));
return res;
}
void Code128Reader::append(char* s, char c){
int len = strlen(s);
s[len] = c;
s[len + 1] = '\0';
}
Code128Reader::~Code128Reader(){
}
}
}

View file

@ -0,0 +1,61 @@
/*
* Code128Reader.h
* ZXing
*
* Created by Lukasz Warchol on 10-01-15.
* 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 <zxing/oned/OneDReader.h>
#include <zxing/common/BitArray.h>
#include <zxing/Result.h>
namespace zxing {
namespace oned {
class Code128Reader : public OneDReader {
private:
static const int MAX_AVG_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.25f);
static const int MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.7f);
static const int CODE_SHIFT = 98;
static const int CODE_CODE_C = 99;
static const int CODE_CODE_B = 100;
static const int CODE_CODE_A = 101;
static const int CODE_FNC_1 = 102;
static const int CODE_FNC_2 = 97;
static const int CODE_FNC_3 = 96;
static const int CODE_FNC_4_A = 101;
static const int CODE_FNC_4_B = 100;
static const int CODE_START_A = 103;
static const int CODE_START_B = 104;
static const int CODE_START_C = 105;
static const int CODE_STOP = 106;
static int* findStartPattern(Ref<BitArray> row);
static int decodeCode(Ref<BitArray> row, int counters[], int countersCount, int rowOffset);
void append(char* s, char c);
public:
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
Code128Reader();
~Code128Reader();
};
}
}

View file

@ -0,0 +1,340 @@
/*
* Code39Reader.cpp
* ZXing
*
* Created by Lukasz Warchol on 10-01-26.
* 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 "Code39Reader.h"
#include <zxing/oned/OneDResultPoint.h>
#include <zxing/common/Array.h>
#include <zxing/ReaderException.h>
#include <math.h>
#include <limits.h>
namespace zxing {
namespace oned {
static const char* ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%";
/**
* These represent the encodings of characters, as patterns of wide and narrow bars.
* The 9 least-significant bits of each int correspond to the pattern of wide and narrow,
* with 1s representing "wide" and 0s representing narrow.
*/
const int CHARACTER_ENCODINGS_LEN = 44;
static int CHARACTER_ENCODINGS[CHARACTER_ENCODINGS_LEN] = {
0x034, 0x121, 0x061, 0x160, 0x031, 0x130, 0x070, 0x025, 0x124, 0x064, // 0-9
0x109, 0x049, 0x148, 0x019, 0x118, 0x058, 0x00D, 0x10C, 0x04C, 0x01C, // A-J
0x103, 0x043, 0x142, 0x013, 0x112, 0x052, 0x007, 0x106, 0x046, 0x016, // K-T
0x181, 0x0C1, 0x1C0, 0x091, 0x190, 0x0D0, 0x085, 0x184, 0x0C4, 0x094, // U-*
0x0A8, 0x0A2, 0x08A, 0x02A // $-%
};
static int ASTERISK_ENCODING = 0x094;
/**
* Creates a reader that assumes all encoded data is data, and does not treat the final
* character as a check digit. It will not decoded "extended Code 39" sequences.
*/
Code39Reader::Code39Reader(){
ALPHABET_STRING = new std::string("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%");
usingCheckDigit = false;
extendedMode = false;
}
/**
* Creates a reader that can be configured to check the last character as a check digit.
* It will not decoded "extended Code 39" sequences.
*
* @param usingCheckDigit if true, treat the last data character as a check digit, not
* data, and verify that the checksum passes.
*/
Code39Reader::Code39Reader(bool usingCheckDigit_){
ALPHABET_STRING = new std::string("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%");
usingCheckDigit = usingCheckDigit_;
extendedMode = false;
}
Ref<Result> Code39Reader::decodeRow(int rowNumber, Ref<BitArray> row){
int* start = findAsteriskPattern(row);
int nextStart = start[1];
int end = row->getSize();
// Read off white space
while (nextStart < end && !row->get(nextStart)) {
nextStart++;
}
std::string tmpResultString;
int countersLen = 9;
int* counters = new int[countersLen];
for (int i=0; i<countersLen; i++) {
counters[i] = 0;
}
char decodedChar;
int lastStart;
do {
recordPattern(row, nextStart, counters, countersLen);
int pattern = toNarrowWidePattern(counters, countersLen);
if (pattern < 0) {
throw ReaderException("pattern < 0");
}
decodedChar = patternToChar(pattern);
tmpResultString.append(1, decodedChar);
lastStart = nextStart;
for (int i = 0; i < countersLen; i++) {
nextStart += counters[i];
}
// Read off white space
while (nextStart < end && !row->get(nextStart)) {
nextStart++;
}
} while (decodedChar != '*');
tmpResultString.erase(tmpResultString.length()-1, 1);// remove asterisk
// Look for whitespace after pattern:
int lastPatternSize = 0;
for (int i = 0; i < countersLen; i++) {
lastPatternSize += counters[i];
}
int whiteSpaceAfterEnd = nextStart - lastStart - lastPatternSize;
// If 50% of last pattern size, following last pattern, is not whitespace, fail
// (but if it's whitespace to the very end of the image, that's OK)
if (nextStart != end && whiteSpaceAfterEnd / 2 < lastPatternSize) {
throw ReaderException("too short end white space");
}
if (usingCheckDigit) {
int max = tmpResultString.length() - 1;
int total = 0;
for (int i = 0; i < max; i++) {
total += ALPHABET_STRING->find_first_of(tmpResultString[i], 0);
}
if (total % 43 != ALPHABET_STRING->find_first_of(tmpResultString[max], 0)) {
throw ReaderException("");
}
tmpResultString.erase(max, 1);
}
Ref<String> resultString(new String(tmpResultString));
if (extendedMode) {
delete resultString;
resultString = decodeExtended(tmpResultString);
}
if (tmpResultString.length() == 0) {
// Almost surely a false positive
throw ReaderException("");
}
float left = (float) (start[1] + start[0]) / 2.0f;
float right = (float) (nextStart + lastStart) / 2.0f;
std::vector< Ref<ResultPoint> > resultPoints(2);
Ref<OneDResultPoint> resultPoint1(new OneDResultPoint(left, (float) rowNumber));
Ref<OneDResultPoint> resultPoint2(new OneDResultPoint(right, (float) rowNumber));
resultPoints[0] = resultPoint1;
resultPoints[1] = resultPoint2;
ArrayRef<unsigned char> resultBytes(1);
delete [] start;
Ref<Result> res(new Result(resultString, resultBytes, resultPoints, BarcodeFormat_CODE_39));
return res;
}
int* Code39Reader::findAsteriskPattern(Ref<BitArray> row){
int width = row->getSize();
int rowOffset = 0;
while (rowOffset < width) {
if (row->get(rowOffset)) {
break;
}
rowOffset++;
}
int counterPosition = 0;
int countersLen = 9;
int* counters = new int[countersLen];
for (int i=0; i<countersLen; i++) {
counters[i] = 0;
}
int patternStart = rowOffset;
bool isWhite = false;
int patternLength = countersLen;
for (int i = rowOffset; i < width; i++) {
bool pixel = row->get(i);
if (pixel ^ isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
if (toNarrowWidePattern(counters, countersLen) == ASTERISK_ENCODING) {
// Look for whitespace before start pattern, >= 50% of width of start pattern
if (row->isRange(fmaxl(0, patternStart - (i - patternStart) / 2), patternStart, false)) {
int* resultValue = new int[2];
resultValue[0] = patternStart;
resultValue[1] = i;
return resultValue;
}
}
patternStart += counters[0] + counters[1];
for (int y = 2; y < patternLength; y++) {
counters[y - 2] = counters[y];
}
counters[patternLength - 2] = 0;
counters[patternLength - 1] = 0;
counterPosition--;
} else {
counterPosition++;
}
counters[counterPosition] = 1;
isWhite = !isWhite;
}
}
throw ReaderException("");
}
// For efficiency, returns -1 on failure. Not throwing here saved as many as 700 exceptions
// per image when using some of our blackbox images.
int Code39Reader::toNarrowWidePattern(int counters[], int countersLen){
int numCounters = countersLen;
int maxNarrowCounter = 0;
int wideCounters;
do {
int minCounter = INT_MAX;
for (int i = 0; i < numCounters; i++) {
int counter = counters[i];
if (counter < minCounter && counter > maxNarrowCounter) {
minCounter = counter;
}
}
maxNarrowCounter = minCounter;
wideCounters = 0;
int totalWideCountersWidth = 0;
int pattern = 0;
for (int i = 0; i < numCounters; i++) {
int counter = counters[i];
if (counters[i] > maxNarrowCounter) {
pattern |= 1 << (numCounters - 1 - i);
wideCounters++;
totalWideCountersWidth += counter;
}
}
if (wideCounters == 3) {
// Found 3 wide counters, but are they close enough in width?
// We can perform a cheap, conservative check to see if any individual
// counter is more than 1.5 times the average:
for (int i = 0; i < numCounters && wideCounters > 0; i++) {
int counter = counters[i];
if (counters[i] > maxNarrowCounter) {
wideCounters--;
// totalWideCountersWidth = 3 * average, so this checks if counter >= 3/2 * average
if ((counter << 1) >= totalWideCountersWidth) {
return -1;
}
}
}
return pattern;
}
} while (wideCounters > 3);
return -1;
}
char Code39Reader::patternToChar(int pattern){
for (int i = 0; i < CHARACTER_ENCODINGS_LEN; i++) {
if (CHARACTER_ENCODINGS[i] == pattern) {
return ALPHABET[i];
}
}
throw ReaderException("");
}
Ref<String> Code39Reader::decodeExtended(std::string encoded){
int length = encoded.length();
std::string tmpDecoded;
for (int i = 0; i < length; i++) {
char c = encoded[i];
if (c == '+' || c == '$' || c == '%' || c == '/') {
char next = encoded[i + 1];
char decodedChar = '\0';
switch (c) {
case '+':
// +A to +Z map to a to z
if (next >= 'A' && next <= 'Z') {
decodedChar = (char) (next + 32);
} else {
throw ReaderException("");
}
break;
case '$':
// $A to $Z map to control codes SH to SB
if (next >= 'A' && next <= 'Z') {
decodedChar = (char) (next - 64);
} else {
throw ReaderException("");
}
break;
case '%':
// %A to %E map to control codes ESC to US
if (next >= 'A' && next <= 'E') {
decodedChar = (char) (next - 38);
} else if (next >= 'F' && next <= 'W') {
decodedChar = (char) (next - 11);
} else {
throw ReaderException("");
}
break;
case '/':
// /A to /O map to ! to , and /Z maps to :
if (next >= 'A' && next <= 'O') {
decodedChar = (char) (next - 32);
} else if (next == 'Z') {
decodedChar = ':';
} else {
throw ReaderException("");
}
break;
}
tmpDecoded.append(1, decodedChar);
// bump up i again since we read two characters
i++;
} else {
tmpDecoded.append(1, c);
}
}
Ref<String> decoded(new String(tmpDecoded));
return decoded;
}
Code39Reader::~Code39Reader(){
delete ALPHABET_STRING;
}
}
}

View file

@ -0,0 +1,57 @@
/*
* Code39Reader.h
* ZXing
*
* Created by Lukasz Warchol on 10-01-26.
* 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 <zxing/oned/OneDReader.h>
#include <zxing/common/BitArray.h>
#include <zxing/Result.h>
namespace zxing {
namespace oned {
/**
* <p>Decodes Code 39 barcodes. This does not support "Full ASCII Code 39" yet.</p>
* Ported form Java (author Sean Owen)
* @author Lukasz Warchol
*/
class Code39Reader : public OneDReader {
private:
std::string* ALPHABET_STRING;
bool usingCheckDigit;
bool extendedMode;
static int* findAsteriskPattern(Ref<BitArray> row); //throws ReaderException
static int toNarrowWidePattern(int counters[], int countersLen);
static char patternToChar(int pattern); //throws ReaderException
static Ref<String> decodeExtended(std::string encoded); //throws ReaderException
void append(char* s, char c);
public:
Code39Reader();
Code39Reader(bool usingCheckDigit_);
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
~Code39Reader();
};
}
}

View file

@ -0,0 +1,95 @@
/*
* EAN13Reader.cpp
* ZXing
*
* Created by Lukasz Warchol on 10-01-22.
* 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 "EAN13Reader.h"
#include <zxing/ReaderException.h>
namespace zxing {
namespace oned {
static const int FIRST_DIGIT_ENCODINGS[10] = {0x00, 0x0B, 0x0D, 0xE, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A};
EAN13Reader::EAN13Reader(){
decodeMiddleCounters = new int[4];
for (int i=0; i<4; i++) {
decodeMiddleCounters[i] = 0;
}
}
int EAN13Reader::decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString){
int countersLen = 4;
int* counters = decodeMiddleCounters;
counters[0] = 0;
counters[1] = 0;
counters[2] = 0;
counters[3] = 0;
int end = row->getSize();
int rowOffset = startRange[1];
int lgPatternFound = 0;
for (int x = 0; x < 6 && rowOffset < end; x++) {
int bestMatch = decodeDigit(row, counters, countersLen, rowOffset, UPC_EAN_PATTERNS_L_AND_G_PATTERNS);
resultString.append(1, (char) ('0' + bestMatch % 10));
for (int i = 0; i < countersLen; i++) {
rowOffset += counters[i];
}
if (bestMatch >= 10) {
lgPatternFound |= 1 << (5 - x);
}
}
determineFirstDigit(resultString, lgPatternFound);
int* middleRange = findGuardPattern(row, rowOffset, true, (int*)getMIDDLE_PATTERN(), getMIDDLE_PATTERN_LEN());
rowOffset = middleRange[1];
for (int x = 0; x < 6 && rowOffset < end; x++) {
int bestMatch = decodeDigit(row, counters, countersLen, rowOffset, UPC_EAN_PATTERNS_L_PATTERNS);
resultString.append(1, (char) ('0' + bestMatch));
for (int i = 0; i < countersLen; i++) {
rowOffset += counters[i];
}
}
return rowOffset;
}
void EAN13Reader::determineFirstDigit(std::string& resultString, int lgPatternFound){
for (int d = 0; d < 10; d++) {
if (lgPatternFound == FIRST_DIGIT_ENCODINGS[d]) {
resultString.insert((size_t)0, (size_t)1, (char) ('0' + d));
return;
}
}
throw ReaderException("determineFirstDigit");
}
BarcodeFormat EAN13Reader::getBarcodeFormat(){
return BarcodeFormat_EAN_13;
}
EAN13Reader::~EAN13Reader(){
delete [] decodeMiddleCounters;
}
}
}

View file

@ -0,0 +1,41 @@
/*
* EAN13Reader.h
* ZXing
*
* Created by Lukasz Warchol on 10-01-22.
* 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 <zxing/oned/UPCEANReader.h>
#include <zxing/Result.h>
namespace zxing {
namespace oned {
class EAN13Reader : public UPCEANReader {
private:
int* decodeMiddleCounters;
static void determineFirstDigit(std::string& resultString, int lgPatternFound); //throws ReaderException
public:
EAN13Reader();
int decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString); //throws ReaderException
BarcodeFormat getBarcodeFormat();
~EAN13Reader();
};
}
}

View file

@ -0,0 +1,75 @@
/*
* EAN8Reader.cpp
* ZXing
*
* Created by Lukasz Warchol on 10-01-25.
* 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 "EAN8Reader.h"
#include <zxing/ReaderException.h>
namespace zxing {
namespace oned {
EAN8Reader::EAN8Reader(){
decodeMiddleCounters = new int[4];
for (int i=0; i<4; i++) {
decodeMiddleCounters[i] = 0;
}
}
int EAN8Reader::decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString){
int countersLen = 4;
int* counters = decodeMiddleCounters;
counters[0] = 0;
counters[1] = 0;
counters[2] = 0;
counters[3] = 0;
int end = row->getSize();
int rowOffset = startRange[1];
for (int x = 0; x < 4 && rowOffset < end; x++) {
int bestMatch = decodeDigit(row, counters, countersLen, rowOffset, UPC_EAN_PATTERNS_L_PATTERNS);
resultString.append(1, (char) ('0' + bestMatch));
for (int i = 0; i < countersLen; i++) {
rowOffset += counters[i];
}
}
int* middleRange = findGuardPattern(row, rowOffset, true, (int*)getMIDDLE_PATTERN(), getMIDDLE_PATTERN_LEN());
rowOffset = middleRange[1];
for (int x = 0; x < 4 && rowOffset < end; x++) {
int bestMatch = decodeDigit(row, counters, countersLen, rowOffset, UPC_EAN_PATTERNS_L_PATTERNS);
resultString.append(1, (char) ('0' + bestMatch));
for (int i = 0; i < countersLen; i++) {
rowOffset += counters[i];
}
}
return rowOffset;
}
BarcodeFormat EAN8Reader::getBarcodeFormat(){
return BarcodeFormat_EAN_8;
}
EAN8Reader::~EAN8Reader(){
delete [] decodeMiddleCounters;
}
}
}

View file

@ -0,0 +1,40 @@
/*
* EAN8Reader.h
* ZXing
*
* Created by Lukasz Warchol on 10-01-25.
* 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 <zxing/oned/UPCEANReader.h>
#include <zxing/Result.h>
namespace zxing {
namespace oned {
class EAN8Reader : public UPCEANReader {
private:
int* decodeMiddleCounters;
public:
EAN8Reader();
int decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString); //throws ReaderException
BarcodeFormat getBarcodeFormat();
~EAN8Reader();
};
}
}

View file

@ -0,0 +1,355 @@
/*
* ITFReader.cpp
* ZXing
*
* Created by Lukasz Warchol on 10-01-26.
* 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 "ITFReader.h"
#include <zxing/oned/OneDResultPoint.h>
#include <zxing/common/Array.h>
#include <zxing/ReaderException.h>
#include <math.h>
namespace zxing {
namespace oned {
static const int W = 3; // Pixel width of a wide line
static const int N = 1; // Pixed width of a narrow line
const int DEFAULT_ALLOWED_LENGTHS[4] = { 6, 10, 14, 44 };
/**
* Start/end guard pattern.
*
* Note: The end pattern is reversed because the row is reversed before
* searching for the END_PATTERN
*/
static const int START_PATTERN_LEN = 4;
static const int START_PATTERN[START_PATTERN_LEN] = {N, N, N, N};
static const int END_PATTERN_REVERSED_LEN = 3;
static const int END_PATTERN_REVERSED[END_PATTERN_REVERSED_LEN] = {N, N, W};
/**
* Patterns of Wide / Narrow lines to indicate each digit
*/
static const int PATTERNS_LEN = 10;
static const int PATTERNS[PATTERNS_LEN][5] = {
{N, N, W, W, N}, // 0
{W, N, N, N, W}, // 1
{N, W, N, N, W}, // 2
{W, W, N, N, N}, // 3
{N, N, W, N, W}, // 4
{W, N, W, N, N}, // 5
{N, W, W, N, N}, // 6
{N, N, N, W, W}, // 7
{W, N, N, W, N}, // 8
{N, W, N, W, N} // 9
};
ITFReader::ITFReader(){
narrowLineWidth = -1;
}
Ref<Result> ITFReader::decodeRow(int rowNumber, Ref<BitArray> row){
// Find out where the Middle section (payload) starts & ends
int* startRange = decodeStart(row);
int* endRange = decodeEnd(row);
std::string tmpResult;
decodeMiddle(row, startRange[1], endRange[0], tmpResult);
// To avoid false positives with 2D barcodes (and other patterns), make
// an assumption that the decoded string must be 6, 10 or 14 digits.
int length = tmpResult.length();
bool lengthOK = false;
if (length == 6 || length == 10 || length == 14) {
lengthOK = true;
}
if (!lengthOK) {
throw ReaderException("not enought characters count");
}
Ref<String> resultString(new String(tmpResult));
std::vector< Ref<ResultPoint> > resultPoints(2);
Ref<OneDResultPoint> resultPoint1(new OneDResultPoint(startRange[1], (float) rowNumber));
Ref<OneDResultPoint> resultPoint2(new OneDResultPoint(endRange[0], (float) rowNumber));
resultPoints[0] = resultPoint1;
resultPoints[1] = resultPoint2;
ArrayRef<unsigned char> resultBytes(1);
delete [] startRange;
delete [] endRange;
Ref<Result> res(new Result(resultString, resultBytes, resultPoints, BarcodeFormat_ITF));
return res;
}
/**
* @param row row of black/white values to search
* @param payloadStart offset of start pattern
* @param resultString {@link StringBuffer} to append decoded chars to
* @throws ReaderException if decoding could not complete successfully
*/
void ITFReader::decodeMiddle(Ref<BitArray> row, int payloadStart, int payloadEnd, std::string& resultString){
// Digits are interleaved in pairs - 5 black lines for one digit, and the
// 5
// interleaved white lines for the second digit.
// Therefore, need to scan 10 lines and then
// split these into two arrays
int counterDigitPairLen = 10;
int* counterDigitPair = new int[counterDigitPairLen];
for (int i=0; i<counterDigitPairLen; i++) {
counterDigitPair[i] = 0;
}
int* counterBlack = new int[5];
int* counterWhite = new int[5];
for (int i=0; i<5; i++) {
counterBlack[i] = 0;
counterWhite[i] = 0;
}
while (payloadStart < payloadEnd) {
// Get 10 runs of black/white.
recordPattern(row, payloadStart, counterDigitPair, counterDigitPairLen);
// Split them into each array
for (int k = 0; k < 5; k++) {
int twoK = k << 1;
counterBlack[k] = counterDigitPair[twoK];
counterWhite[k] = counterDigitPair[twoK + 1];
}
int bestMatch = decodeDigit(counterBlack, 5);
resultString.append(1, (char) ('0' + bestMatch));
bestMatch = decodeDigit(counterWhite, 5);
resultString.append(1, (char) ('0' + bestMatch));
for (int i = 0; i < counterDigitPairLen; i++) {
payloadStart += counterDigitPair[i];
}
}
delete [] counterDigitPair;
delete [] counterBlack;
delete [] counterWhite;
}
/**
* Identify where the start of the middle / payload section starts.
*
* @param row row of black/white values to search
* @return Array, containing index of start of 'start block' and end of
* 'start block'
* @throws ReaderException
*/
int* ITFReader::decodeStart(Ref<BitArray> row){
int endStart = skipWhiteSpace(row);
/// static int* findGuardPattern(Ref<BitArray> row, int rowOffset, bool whiteFirst, const int pattern[], int patternLen);
int* startPattern = findGuardPattern(row, endStart, START_PATTERN, START_PATTERN_LEN);
// Determine the width of a narrow line in pixels. We can do this by
// getting the width of the start pattern and dividing by 4 because its
// made up of 4 narrow lines.
narrowLineWidth = (startPattern[1] - startPattern[0]) >> 2;
validateQuietZone(row, startPattern[0]);
return startPattern;
}
/**
* Identify where the end of the middle / payload section ends.
*
* @param row row of black/white values to search
* @return Array, containing index of start of 'end block' and end of 'end
* block'
* @throws ReaderException
*/
int* ITFReader::decodeEnd(Ref<BitArray> row){
// For convenience, reverse the row and then
// search from 'the start' for the end block
row->reverse();
try {
int endStart = skipWhiteSpace(row);
int* endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED, END_PATTERN_REVERSED_LEN);
// The start & end patterns must be pre/post fixed by a quiet zone. This
// zone must be at least 10 times the width of a narrow line.
// ref: http://www.barcode-1.net/i25code.html
validateQuietZone(row, endPattern[0]);
// Now recalculate the indices of where the 'endblock' starts & stops to
// accommodate
// the reversed nature of the search
int temp = endPattern[0];
endPattern[0] = row->getSize() - endPattern[1];
endPattern[1] = row->getSize() - temp;
return endPattern;
}catch (Exception e) {
row->reverse();
throw e;
}
}
/**
* The start & end patterns must be pre/post fixed by a quiet zone. This
* zone must be at least 10 times the width of a narrow line. Scan back until
* we either get to the start of the barcode or match the necessary number of
* quiet zone pixels.
*
* Note: Its assumed the row is reversed when using this method to find
* quiet zone after the end pattern.
*
* ref: http://www.barcode-1.net/i25code.html
*
* @param row bit array representing the scanned barcode.
* @param startPattern index into row of the start or end pattern.
* @throws ReaderException if the quiet zone cannot be found, a ReaderException is thrown.
*/
void ITFReader::validateQuietZone(Ref<BitArray> row, int startPattern){
#pragma mark needs some corrections
// int quietCount = narrowLineWidth * 10; // expect to find this many pixels of quiet zone
//
// for (int i = startPattern - 1; quietCount > 0 && i >= 0; i--) {
// if (row->get(i)) {
// break;
// }
// quietCount--;
// }
// if (quietCount != 0) {
// // Unable to find the necessary number of quiet zone pixels.
// throw ReaderException("Unable to find the necessary number of quiet zone pixels");
// }
}
/**
* Skip all whitespace until we get to the first black line.
*
* @param row row of black/white values to search
* @return index of the first black line.
* @throws ReaderException Throws exception if no black lines are found in the row
*/
int ITFReader::skipWhiteSpace(Ref<BitArray> row){
int width = row->getSize();
int endStart = 0;
while (endStart < width) {
if (row->get(endStart)) {
break;
}
endStart++;
}
if (endStart == width) {
throw ReaderException("");
}
return endStart;
}
/**
* @param row row of black/white values to search
* @param rowOffset position to start search
* @param pattern pattern of counts of number of black and white pixels that are
* being searched for as a pattern
* @return start/end horizontal offset of guard pattern, as an array of two
* ints
* @throws ReaderException if pattern is not found
*/
int* ITFReader::findGuardPattern(Ref<BitArray> row, int rowOffset, const int pattern[], int patternLen){
// TODO: This is very similar to implementation in UPCEANReader. Consider if they can be
// merged to a single method.
int patternLength = patternLen;
int* counters = new int[patternLength];
for (int i=0; i<patternLength; i++) {
counters[i] = 0;
}
int width = row->getSize();
bool isWhite = false;
int counterPosition = 0;
int patternStart = rowOffset;
for (int x = rowOffset; x < width; x++) {
bool pixel = row->get(x);
if (pixel ^ isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
if (patternMatchVariance(counters, patternLength, pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) {
int* resultValue = new int[2];
resultValue[0] = patternStart;
resultValue[1] = x;
return resultValue;
}
patternStart += counters[0] + counters[1];
for (int y = 2; y < patternLength; y++) {
counters[y - 2] = counters[y];
}
counters[patternLength - 2] = 0;
counters[patternLength - 1] = 0;
counterPosition--;
} else {
counterPosition++;
}
counters[counterPosition] = 1;
isWhite = !isWhite;
}
}
throw ReaderException("");
}
/**
* Attempts to decode a sequence of ITF black/white lines into single
* digit.
*
* @param counters the counts of runs of observed black/white/black/... values
* @return The decoded digit
* @throws ReaderException if digit cannot be decoded
*/
int ITFReader::decodeDigit(int counters[], int countersLen){
int bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
int bestMatch = -1;
int max = PATTERNS_LEN;
for (int i = 0; i < max; i++) {
//int pattern[countersLen];
int* pattern = new int(countersLen);
for(int ind = 0; ind<countersLen; ind++){
pattern[ind] = PATTERNS[i][ind];
}
int variance = patternMatchVariance(counters, countersLen, pattern, MAX_INDIVIDUAL_VARIANCE);
if (variance < bestVariance) {
bestVariance = variance;
bestMatch = i;
}
delete pattern;
}
if (bestMatch >= 0) {
return bestMatch;
} else {
throw ReaderException("digit didint found");
}
}
ITFReader::~ITFReader(){
}
}
}

View file

@ -0,0 +1,53 @@
/*
* ITFReader.h
* ZXing
*
* Created by Lukasz Warchol on 10-01-26.
* 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 <zxing/oned/OneDReader.h>
#include <zxing/common/BitArray.h>
#include <zxing/Result.h>
namespace zxing {
namespace oned {
class ITFReader : public OneDReader {
private:
static const int MAX_AVG_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f);
static const int MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.8f);
// Stores the actual narrow line width of the image being decoded.
int narrowLineWidth;
int* decodeStart(Ref<BitArray> row); //throws ReaderException
int* decodeEnd(Ref<BitArray> row); //throws ReaderException
static void decodeMiddle(Ref<BitArray> row, int payloadStart, int payloadEnd, std::string& resultString); //throws ReaderException
void validateQuietZone(Ref<BitArray> row, int startPattern); //throws ReaderException
static int skipWhiteSpace(Ref<BitArray> row); //throws ReaderException
static int* findGuardPattern(Ref<BitArray> row, int rowOffset, const int pattern[], int patternLen); //throws ReaderException
static int decodeDigit(int counters[], int countersLen); //throws ReaderException
void append(char* s, char c);
public:
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row); ///throws ReaderException
ITFReader();
~ITFReader();
};
}
}

View file

@ -0,0 +1,55 @@
/*
* MultiFormatOneDReader.cpp
* ZXing
*
* Created by Lukasz Warchol on 10-01-25.
* 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 "MultiFormatOneDReader.h"
#include <zxing/oned/MultiFormatUPCEANReader.h>
#include <zxing/oned/Code39Reader.h>
#include <zxing/oned/Code128Reader.h>
#include <zxing/oned/ITFReader.h>
#include <zxing/ReaderException.h>
namespace zxing {
namespace oned {
MultiFormatOneDReader::MultiFormatOneDReader(){
readers = new std::vector<OneDReader*>();
readers->push_back(new MultiFormatUPCEANReader());
readers->push_back(new Code39Reader());
readers->push_back(new Code128Reader());
readers->push_back(new ITFReader());
}
Ref<Result> MultiFormatOneDReader::decodeRow(int rowNumber, Ref<BitArray> row){
int size = readers->size();
for (int i = 0; i < size; i++) {
OneDReader* reader = (*readers)[i];
try {
return reader->decodeRow(rowNumber, row);
} catch (ReaderException re) {
// continue
}
}
throw ReaderException("No code detected");
}
MultiFormatOneDReader::~MultiFormatOneDReader(){
delete readers;
}
}
}

View file

@ -0,0 +1,39 @@
/*
* MultiFormatOneDReader.h
* ZXing
*
* Created by Lukasz Warchol on 10-01-25.
* 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 <zxing/oned/OneDReader.h>
#include <zxing/common/BitArray.h>
#include <zxing/Result.h>
namespace zxing {
namespace oned {
class MultiFormatOneDReader : public OneDReader {
private:
std::vector<OneDReader*>* readers;
public:
MultiFormatOneDReader();
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
~MultiFormatOneDReader();
};
}
}

View file

@ -0,0 +1,79 @@
/*
* MultiFormatUPCEANReader.cpp
* ZXing
*
* Created by Lukasz Warchol on 10-01-25.
* 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 "MultiFormatUPCEANReader.h"
#include <zxing/oned/EAN13Reader.h>
#include <zxing/oned/EAN8Reader.h>
#include <zxing/oned/UPCEReader.h>
#include <zxing/oned/OneDResultPoint.h>
#include <zxing/common/Array.h>
#include <zxing/ReaderException.h>
#include <math.h>
namespace zxing {
namespace oned {
MultiFormatUPCEANReader::MultiFormatUPCEANReader(){
readers = new std::vector<OneDReader*>();
readers->push_back(new EAN13Reader());
// UPC-A is covered by EAN-13
readers->push_back(new EAN8Reader());
readers->push_back(new UPCEReader());
}
Ref<Result> MultiFormatUPCEANReader::decodeRow(int rowNumber, Ref<BitArray> row){
// Compute this location once and reuse it on multiple implementations
int size = readers->size();
for (int i = 0; i < size; i++) {
OneDReader* reader = (*readers)[i];
Ref<Result> result;
try {
result = reader->decodeRow(rowNumber, row);//decodeRow(rowNumber, row, startGuardPattern);
} catch (ReaderException re) {
continue;
}
// Special case: a 12-digit code encoded in UPC-A is identical to a "0"
// followed by those 12 digits encoded as EAN-13. Each will recognize such a code,
// UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0".
// Individually these are correct and their readers will both read such a code
// and correctly call it EAN-13, or UPC-A, respectively.
//
// In this case, if we've been looking for both types, we'd like to call it
// a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read
// UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A
// result if appropriate.
if (result->getBarcodeFormat() == BarcodeFormat_EAN_13) {
std::string& text = (result->getText())->getText();
if (text[0] == '0') {
Ref<String> resultString(new String(text.substr(1)));
Ref<Result> res(new Result(resultString, result->getRawBytes(), result->getResultPoints(), BarcodeFormat_UPC_A));
return res;
}
}
return result;
}
throw ReaderException("No EAN code detected");
}
MultiFormatUPCEANReader::~MultiFormatUPCEANReader(){
delete readers;
}
}
}

View file

@ -0,0 +1,41 @@
/*
* MultiFormatUPCEANReader.h
* ZXing
*
* Created by Lukasz Warchol on 10-01-25.
* 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 <zxing/oned/OneDReader.h>
#include <zxing/common/BitArray.h>
#include <zxing/Result.h>
namespace zxing {
namespace oned {
class MultiFormatUPCEANReader : public OneDReader {
private:
std::vector<OneDReader*>* readers;
public:
MultiFormatUPCEANReader();
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
~MultiFormatUPCEANReader();
};
}
}

View file

@ -0,0 +1,194 @@
/*
* OneDReader.cpp
* ZXing
*
* Created by Lukasz Warchol on 10-01-15.
* 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 "OneDReader.h"
#include <zxing/ReaderException.h>
#include <math.h>
#include <limits.h>
namespace zxing {
namespace oned {
using namespace std;
OneDReader::OneDReader() {
}
Ref<Result> OneDReader::decode(Ref<BinaryBitmap> image) {
try {
return doDecode(image);
}catch (ReaderException re) {
if (false /*tryHarder && image.isRotateSupported()*/) {
/*
BinaryBitmap rotatedImage = image.rotateCounterClockwise();
Result result = doDecode(rotatedImage, hints);
// Record that we found it rotated 90 degrees CCW / 270 degrees CW
Hashtable metadata = result.getResultMetadata();
int orientation = 270;
if (metadata != null && metadata.containsKey(ResultMetadataType.ORIENTATION)) {
// But if we found it reversed in doDecode(), add in that result here:
orientation = (orientation +
((Integer) metadata.get(ResultMetadataType.ORIENTATION)).intValue()) % 360;
}
result.putMetadata(ResultMetadataType.ORIENTATION, new Integer(orientation));
// Update result points
ResultPoint[] points = result.getResultPoints();
int height = rotatedImage.getHeight();
for (int i = 0; i < points.length; i++) {
points[i] = new ResultPoint(height - points[i].getY() - 1, points[i].getX());
}
return result;
*/
} else {
throw re;
}
}
}
Ref<Result> OneDReader::doDecode(Ref<BinaryBitmap> image){
int width = image->getWidth();
int height = image->getHeight();
Ref<BitArray> row(new BitArray(width));
// BitArray row = new BitArray(width);
int middle = height >> 1;
bool tryHarder = true;//hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
int rowStep = (int)fmax(1, height >> (tryHarder ? 7 : 4));
int maxLines;
if (tryHarder) {
maxLines = height; // Look at the whole image, not just the center
} else {
maxLines = 9; // Nine rows spaced 1/16 apart is roughly the middle half of the image
}
for (int x = 0; x < maxLines; x++) {
// Scanning from the middle out. Determine which row we're looking at next:
int rowStepsAboveOrBelow = (x + 1) >> 1;
bool isAbove = (x & 0x01) == 0; // i.e. is x even?
int rowNumber = middle + rowStep * (isAbove ? rowStepsAboveOrBelow : -rowStepsAboveOrBelow);
if (rowNumber < 0 || rowNumber >= height) {
// Oops, if we run off the top or bottom, stop
break;
}
// Estimate black point for this row and load it:
try {
row = image->getBlackRow(rowNumber, row);
}catch (ReaderException re) {
continue;
}
// While we have the image data in a BitArray, it's fairly cheap to reverse it in place to
// handle decoding upside down barcodes.
for (int attempt = 0; attempt < 2; attempt++) {
if (attempt == 1) { // trying again?
row->reverse(); // reverse the row and continue
}
try {
// Look for a barcode
Ref<Result> result = decodeRow(rowNumber, row);
// We found our barcode
if (attempt == 1) {
// // But it was upside down, so note that
// result.putMetadata(ResultMetadataType.ORIENTATION, new Integer(180));
// // And remember to flip the result points horizontally.
// ResultPoint[] points = result.getResultPoints();
// points[0] = new ResultPoint(width - points[0].getX() - 1, points[0].getY());
// points[1] = new ResultPoint(width - points[1].getX() - 1, points[1].getY());
}
return result;
} catch (ReaderException re) {
// continue -- just couldn't decode this row
}
}
}
throw ReaderException("");
}
int OneDReader::patternMatchVariance(int counters[], int countersSize, const int pattern[], int maxIndividualVariance) {
int numCounters = countersSize;
int total = 0;
int patternLength = 0;
for (int i = 0; i < numCounters; i++) {
total += counters[i];
patternLength += pattern[i];
}
if (total < patternLength) {
// If we don't even have one pixel per unit of bar width, assume this is too small
// to reliably match, so fail:
return INT_MAX;
}
// We're going to fake floating-point math in integers. We just need to use more bits.
// Scale up patternLength so that intermediate values below like scaledCounter will have
// more "significant digits"
int unitBarWidth = (total << INTEGER_MATH_SHIFT) / patternLength;
maxIndividualVariance = (maxIndividualVariance * unitBarWidth) >> INTEGER_MATH_SHIFT;
int totalVariance = 0;
for (int x = 0; x < numCounters; x++) {
int counter = counters[x] << INTEGER_MATH_SHIFT;
int scaledPattern = pattern[x] * unitBarWidth;
int variance = counter > scaledPattern ? counter - scaledPattern : scaledPattern - counter;
if (variance > maxIndividualVariance) {
return INT_MAX;
}
totalVariance += variance;
}
return totalVariance / total;
}
void OneDReader::recordPattern(Ref<BitArray> row, int start, int counters[], int countersCount){
int numCounters = countersCount;//sizeof(counters) / sizeof(int);
for (int i = 0; i < numCounters; i++) {
counters[i] = 0;
}
int end = row->getSize();
if (start >= end) {
throw ReaderException("recordPattern: start >= end");
}
bool isWhite = !row->get(start);
int counterPosition = 0;
int i = start;
while (i < end) {
bool pixel = row->get(i);
if (pixel ^ isWhite) { // that is, exactly one is true
counters[counterPosition]++;
} else {
counterPosition++;
if (counterPosition == numCounters) {
break;
} else {
counters[counterPosition] = 1;
isWhite ^= true; // isWhite = !isWhite;
}
}
i++;
}
// If we read fully the last section of pixels and filled up our counters -- or filled
// the last counter but ran off the side of the image, OK. Otherwise, a problem.
if (!(counterPosition == numCounters || (counterPosition == numCounters - 1 && i == end))) {
throw ReaderException("recordPattern");
}
}
OneDReader::~OneDReader() {
}
}
}

View file

@ -0,0 +1,46 @@
/*
* OneDReader.h
* ZXing
*
* Created by Lukasz Warchol on 10-01-15.
* 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.
*/
#pragma once
#include <zxing/Reader.h>
#include <zxing/common/BitArray.h>
#include <zxing/BinaryBitmap.h>
namespace zxing {
namespace oned {
class OneDReader : public Reader {
private:
static const int INTEGER_MATH_SHIFT = 8;
Ref<Result> doDecode(Ref<BinaryBitmap> image);
public:
static const int PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 << INTEGER_MATH_SHIFT;
OneDReader();
virtual Ref<Result> decode(Ref<BinaryBitmap> image);
virtual Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row) = 0;
static int patternMatchVariance(int counters[], int countersSize, const int pattern[], int maxIndividualVariance);
static void recordPattern(Ref<BitArray> row, int start, int counters[], int countersCount);
virtual ~OneDReader();
};
}
}

View file

@ -0,0 +1,39 @@
/*
* OneDResultPoint.cpp
* ZXing
*
* Created by Lukasz Warchol on 10-01-20.
* 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 "OneDResultPoint.h"
namespace zxing {
namespace oned {
using namespace std;
OneDResultPoint::OneDResultPoint(float posX, float posY) : posX_(posX), posY_(posY){
}
float OneDResultPoint::getX() {
return posX_;
}
float OneDResultPoint::getY() {
return posY_;
}
}
}

Some files were not shown because too many files have changed in this diff Show more