Updated Symbian project QQrDecoder. It now supports the latest devices and Symbian OSs (Symbian^3, Belle, Anna).

Uses Qt SDK + Camera APIs from Qt Mobility.

Updated the tutorial which shows how to use it.

Updated the installation file included to test without compiling (also advice the tutorial for details).

git-svn-id: https://zxing.googlecode.com/svn/trunk@1920 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
ftylitak@gmail.com 2011-09-19 10:32:17 +00:00
parent 5596e81085
commit e1aab01022
131 changed files with 4522 additions and 3757 deletions

View file

@ -8,47 +8,47 @@ CameraImageWrapper::CameraImageWrapper() : LuminanceSource()
}
CameraImageWrapper::CameraImageWrapper(CameraImageWrapper& otherInstance) : LuminanceSource()
{
{
image = otherInstance.getOriginalImage().copy();
}
}
CameraImageWrapper::~CameraImageWrapper()
{
}
int CameraImageWrapper::getWidth() const
{
{
return image.width();
}
}
int CameraImageWrapper::getHeight() const
{
{
return image.height();
}
}
unsigned char CameraImageWrapper::getPixel(int x, int y) const
{
{
QRgb pixel = image.pixel(x,y);
return qGray(pixel);//((qRed(pixel) + qGreen(pixel) + qBlue(pixel)) / 3);
}
}
unsigned char* CameraImageWrapper::copyMatrix() const
{
unsigned char* newMatrix = (unsigned char*)malloc(image.width()*image.height()*sizeof(unsigned char));
int cnt = 0;
for(int i=0; i<image.width(); i++)
{
unsigned char* newMatrix = (unsigned char*)malloc(image.width()*image.height()*sizeof(unsigned char));
int cnt = 0;
for(int i=0; i<image.width(); i++)
for(int j=0; j<image.height(); j++)
{
for(int j=0; j<image.height(); j++)
{
newMatrix[cnt++] = getPixel(i,j);
}
newMatrix[cnt++] = getPixel(i,j);
}
return newMatrix;
}
return newMatrix;
}
void CameraImageWrapper::setImage(QString fileName)
{
image.load(fileName);
@ -91,3 +91,38 @@ QImage CameraImageWrapper::getOriginalImage()
}
unsigned char* CameraImageWrapper::getRow(int y, unsigned char* row)
{
int width = getWidth();
if (row == NULL)
{
row = new unsigned char[width];
pRow = row;
}
for (int x = 0; x < width; x++)
row[x] = getPixel(x,y);
return row;
}
unsigned char* CameraImageWrapper::getMatrix()
{
int width = getWidth();
int height = getHeight();
unsigned char* matrix = new unsigned char[width*height];
unsigned char* m = matrix;
for(int y=0; y<height; y++)
{
unsigned char* tmpRow;
memcpy(m, tmpRow = getRow(y, NULL), width);
m += width * sizeof(unsigned char);
delete tmpRow;
}
pMatrix = matrix;
return matrix;
}

View file

@ -24,9 +24,16 @@ public:
void setImage(QImage newImage);
QImage grayScaleImage(QImage::Format f);
QImage getOriginalImage();
// Callers take ownership of the returned memory and must call delete [] on it themselves.
unsigned char* getRow(int y, unsigned char* row);
unsigned char* getMatrix();
private:
QImage image;
unsigned char* pRow;
unsigned char* pMatrix;
};
#endif //CAMERAIMAGE_H

View file

@ -0,0 +1,79 @@
#include "myvideosurface.h"
MyVideoSurface::MyVideoSurface(QWidget* widget, VideoIF* target, QObject* parent)
: QAbstractVideoSurface(parent)
{
m_targetWidget = widget;
m_target = target;
m_imageFormat = QImage::Format_Invalid;
}
MyVideoSurface::~MyVideoSurface()
{
}
bool MyVideoSurface::start(const QVideoSurfaceFormat &format)
{
m_videoFormat = format;
const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
const QSize size = format.frameSize();
if (imageFormat != QImage::Format_Invalid && !size.isEmpty()) {
m_imageFormat = imageFormat;
QAbstractVideoSurface::start(format);
return true;
} else {
return false;
}
}
bool MyVideoSurface::present(const QVideoFrame &frame)
{
m_frame = frame;
if (surfaceFormat().pixelFormat() != m_frame.pixelFormat() ||
surfaceFormat().frameSize() != m_frame.size()) {
stop();
return false;
} else {
m_target->updateVideo();
return true;
}
}
void MyVideoSurface::paint(QPainter *painter)
{
if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) {
QImage image(
m_frame.bits(),
m_frame.width(),
m_frame.height(),
m_frame.bytesPerLine(),
m_imageFormat);
QRect r = m_targetWidget->rect();
QPoint centerPic((qAbs(r.size().width() - image.size().width())) / 2, (qAbs(
r.size().height() - image.size().height())) / 2);
if (!image.isNull()) {
painter->drawImage(centerPic,image);
}
m_frame.unmap();
}
}
QList<QVideoFrame::PixelFormat> MyVideoSurface::supportedPixelFormats(
QAbstractVideoBuffer::HandleType handleType) const
{
if (handleType == QAbstractVideoBuffer::NoHandle) {
return QList<QVideoFrame::PixelFormat>()
<< QVideoFrame::Format_RGB32
<< QVideoFrame::Format_ARGB32
<< QVideoFrame::Format_ARGB32_Premultiplied
<< QVideoFrame::Format_RGB565
<< QVideoFrame::Format_RGB555;
} else {
return QList<QVideoFrame::PixelFormat>();
}
}

View file

@ -1,31 +1,39 @@
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.
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the demonstration applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "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."
** $QT_END_LICENSE$
**
****************************************************************************/

View file

@ -1,322 +1,354 @@
#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);
}
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the demonstration applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "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."
** $QT_END_LICENSE$
**
****************************************************************************/
#include "QCameraControllerWidget.h"
//#include <QDebug>
/*****************************************************************************
* QCameraControllerWidget
*/
QCameraControllerWidget::QCameraControllerWidget(QWidget *parent) :
QWidget(parent)
{
setWindowTitle("QCameraControllerWidget");
// Opitimizations for screen update and drawing qwidget
setAutoFillBackground(false);
// Prevent to screensaver to activate
// m_systemScreenSaver = new QSystemScreenSaver(this);
// m_systemScreenSaver->setScreenSaverInhibit();
m_myVideoSurface = 0;
pictureCaptured = false;
showViewFinder = false;
m_focusing = false;
// Black background
QPalette palette = this->palette();
palette.setColor(QPalette::Background, Qt::black);
setPalette(palette);
// Main widget & layout
// QWidget* mainWidget = new QWidget(this);
setPalette(palette);
QHBoxLayout* hboxl = new QHBoxLayout;
hboxl->setSpacing(0);
hboxl->setMargin(0);
// UI stack
m_stackedWidget = new QStackedWidget();
m_stackedWidget->setPalette(palette);
// First widget to stack
m_videoWidget = new QWidget();
m_videoWidget->setPalette(palette);
m_stackedWidget->addWidget(m_videoWidget);
// Second widget to stack
QWidget* secondWidget = new QWidget(this);
secondWidget->setPalette(palette);
m_stackedWidget->addWidget(secondWidget);
m_stackedWidget->setCurrentIndex(0);
hboxl->addWidget(m_stackedWidget);
// Buttons
QSize iconSize(80, 80);
QVBoxLayout* vboxl = new QVBoxLayout;
vboxl->setSpacing(0);
vboxl->setMargin(0);
// Exit button
m_exit = new Button(this);
QObject::connect(m_exit, SIGNAL(pressed()), qApp, SLOT(quit()));
QPixmap p = QPixmap(":/icons/exit.png");
m_exit->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
vboxl->addWidget(m_exit);
vboxl->setAlignment(m_exit,Qt::AlignHCenter | Qt::AlignTop);
// Camera button
m_cameraBtn = new Button(this);
QObject::connect(m_cameraBtn, SIGNAL(pressed()), this, SLOT(searchAndLock()));
p = QPixmap(":/icons/camera.png");
m_cameraBtn->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
vboxl->addWidget(m_cameraBtn);
vboxl->setAlignment(m_cameraBtn, Qt::AlignBottom);
hboxl->addLayout(vboxl);
setLayout(hboxl);
// Enable camera after 1s, so that the application is started
// and widget is created to landscape orientation
QTimer::singleShot(1000,this,SLOT(enableCamera()));
}
QCameraControllerWidget::~QCameraControllerWidget()
{
if (m_myVideoSurface)
m_myVideoSurface->stop();
m_camera->stop();
delete m_stackedWidget;
delete m_stillImageCapture;
delete m_camera;
}
void QCameraControllerWidget::enableCamera()
{
m_camera = new QCamera();
m_camera->setCaptureMode(QCamera::CaptureStillImage);
connect(m_camera, SIGNAL(error(QCamera::Error)), this, SLOT(error(QCamera::Error)));
connect(m_camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)), this, SLOT(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)));
// Own video output drawing that shows camera view finder pictures
//! [0]
QMediaService* ms = m_camera->service();
QVideoRendererControl* vrc = ms->requestControl<QVideoRendererControl*>();
m_myVideoSurface = new MyVideoSurface(this,this,this);
vrc->setSurface(m_myVideoSurface);
//! [0]
// Image capturer
m_stillImageCapture = new QCameraImageCapture(m_camera);
connect(m_stillImageCapture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(onImageCaptured(int,QImage)));
// Start camera
if (m_camera->state() == QCamera::ActiveState) {
m_camera->stop();
}
m_videoWidget->show();
m_camera->start();
showViewFinder = true;
}
void QCameraControllerWidget::mousePressEvent(QMouseEvent *event)
{
QWidget::mousePressEvent(event);
if (pictureCaptured) {
// Starting view finder
pictureCaptured = false;
m_stackedWidget->setCurrentIndex(0);
if (m_myVideoSurface) {
showViewFinder = true;
}
}
}
void QCameraControllerWidget::searchAndLock()
{
m_focusing = false;
m_focusMessage.clear();
if (pictureCaptured) {
// Starting view finder again
pictureCaptured = false;
m_stackedWidget->setCurrentIndex(0);
if (m_myVideoSurface) {
showViewFinder = true;
}
}
else {
// Search and lock picture (=focus)
if (m_camera->supportedLocks() & QCamera::LockFocus) {
m_focusing = true;
m_focusMessage = "Focusing...";
m_camera->searchAndLock(QCamera::LockFocus);
} else {
// No focus functionality, take picture right away
captureImage();
}
}
}
void QCameraControllerWidget::lockStatusChanged(QCamera::LockStatus status, QCamera::LockChangeReason reason)
{
if (status == QCamera::Locked) {
if (reason == QCamera::LockAcquired) {
// Focus locked
m_focusMessage.clear();
m_focusing = false;
// Capture new image
captureImage();
// Unlock camera
m_camera->unlock();
} else {
if (m_focusing)
m_focusMessage = "No focus, try again";
}
} else if (status == QCamera::Unlocked && m_focusing) {
m_focusMessage = "No focus, try again";
}
}
void QCameraControllerWidget::captureImage()
{
if (pictureCaptured) {
// Starting view finder again
pictureCaptured = false;
m_stackedWidget->setCurrentIndex(0);
showViewFinder = true;
}
else {
// Capturing image
showViewFinder = false;
// Get picture location where to store captured images
QString path(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
QDir dir(path);
// Get next filename
QStringList files = dir.entryList(QStringList() << "camera_*.jpg");
int lastImage = 0;
foreach ( QString fileName, files ) {
int imgNumber = fileName.mid(7, fileName.size() - 11).toInt();
lastImage = qMax(lastImage, imgNumber);
}
// Capture image
if (m_stillImageCapture->isReadyForCapture()) {
m_imageName = QString("camera_%1.jpg").arg(lastImage+1);
m_stillImageCapture->capture(m_imageName);
}
}
}
void QCameraControllerWidget::onImageCaptured(int id, const QImage &preview)
{
m_stillImageCapture->cancelCapture();
showViewFinder = false;
m_focusing = false;
// Image captured, show it to the user
m_stackedWidget->setCurrentIndex(1);
// Get picture location
QString path(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
m_imageName.prepend(path + "/");
m_capturedImage = preview;
// Set suitable size to the image
QSize s = m_videoWidget->size();
s = s - QSize(20, 20);
m_capturedImage = m_capturedImage.scaled(s, Qt::KeepAspectRatio, Qt::SmoothTransformation);
emit imageCaptured(preview);
pictureCaptured = true;
update();
}
void QCameraControllerWidget::error(QCamera::Error e)
{
switch (e) {
case QCamera::NoError:
{
break;
}
case QCamera::CameraError:
{
QMessageBox::warning(this, "QCameraControllerWidget", "General Camera error");
break;
}
case QCamera::InvalidRequestError:
{
QMessageBox::warning(this, "QCameraControllerWidget", "Camera invalid request error");
break;
}
case QCamera::ServiceMissingError:
{
QMessageBox::warning(this, "QCameraControllerWidget", "Camera service missing error");
break;
}
case QCamera::NotSupportedFeatureError :
{
QMessageBox::warning(this, "QCameraControllerWidget", "Camera not supported error");
break;
}
};
}
void QCameraControllerWidget::updateVideo()
{
if (showViewFinder) {
repaint();
}
}
void QCameraControllerWidget::paintEvent(QPaintEvent *event)
{
//QMainWindow::paintEvent(event);
QPainter painter(this);
QRect r = this->rect();
QFont font = painter.font();
font.setPixelSize(20);
painter.setFont(font);
painter.setPen(Qt::white);
if (showViewFinder && m_myVideoSurface && m_myVideoSurface->isActive()) {
// Show view finder
m_myVideoSurface->paint(&painter);
// Paint focus message
if (!m_focusMessage.isEmpty())
painter.drawText(r, Qt::AlignCenter, m_focusMessage);
} else {
// Draw black
painter.fillRect(event->rect(), palette().background());
// Show captured image
if (pictureCaptured) {
// Paint captured image
QPoint centerPic((qAbs(r.size().width() - m_capturedImage.size().width())) / 2, (qAbs(
r.size().height() - m_capturedImage.size().height())) / 2);
painter.drawImage(centerPic, m_capturedImage);
// Paint filename
// painter.drawText(r, Qt::AlignBottom | Qt::AlignCenter, m_imageName);
}
}
}

View file

@ -1,67 +1,108 @@
#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
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the demonstration applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "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."
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QCAMERAEXAMPLE_H
#define QCAMERAEXAMPLE_H
#include <QtGui>
// Multimedia API in QtMobility API
// Unlike the other APIs in Qt Mobility,
// the Multimedia API is not in the QtMobility namespace "QTM_USE_NAMESPACE"
#include <QCamera>
#include <QCameraImageCapture>
// QtMobility API
//#include <QSystemScreenSaver>
//QTM_USE_NAMESPACE
#include "myvideosurface.h"
#include "button.h"
class QCameraControllerWidget: public QWidget, public VideoIF
{
Q_OBJECT
public:
QCameraControllerWidget(QWidget *parent = 0);
~QCameraControllerWidget();
void paintEvent(QPaintEvent*);
void mousePressEvent(QMouseEvent *);
void updateVideo();
public slots:
void enableCamera();
void lockStatusChanged(QCamera::LockStatus status, QCamera::LockChangeReason reason);
void searchAndLock();
void captureImage();
void onImageCaptured(int id, const QImage &preview);
void error(QCamera::Error);
signals:
void imageCaptured(QImage image);
private:
QWidget* m_videoWidget;
QCamera* m_camera;
QCameraImageCapture* m_stillImageCapture;
QStackedWidget* m_stackedWidget;
Button* m_exit;
Button* m_cameraBtn;
Button* m_mms;
QImage m_capturedImage;
QString m_imageName;
QString m_focusMessage;
bool m_focusing;
QString m_phoneNumber;
bool pictureCaptured;
bool showViewFinder;
MyVideoSurface* m_myVideoSurface;
//QSystemScreenSaver* m_systemScreenSaver;
};
#endif // QCAMERA_H

View file

@ -40,6 +40,7 @@
#include <QPainter>
#include <QPoint>
#include <QPixmap>
#include <QMessageBox>
using namespace zxing;
//using namespace zxing::qrcode;
@ -47,9 +48,7 @@ using namespace zxing;
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)));
connect(ui.centralwidget, SIGNAL(imageCaptured(QImage)), this, SLOT(decodeImage(QImage)));
}
QQrDecoder::~QQrDecoder()
@ -61,11 +60,6 @@ void QQrDecoder::InitializeSymbianCamera()
}
void QQrDecoder::findAndDecode()
{
ui.cameraWidget->CaptureImage();
}
void QQrDecoder::decodeImage(QImage originalImage)
{
MultiFormatReader decoder;
@ -86,11 +80,11 @@ void QQrDecoder::decodeImage(QImage originalImage)
res = decoder.decode(ref);
QString string = QString(res->getText()->getText().c_str());
ui.resultLabel->setText(string);
QMessageBox::information((QWidget*)ui.centralwidget, QString("Decoding result") ,string);
}
catch(zxing::Exception& e)
{
ui.resultLabel->setText("Error");
// QMessageBox::information((QWidget*)ui.centralwidget, QString("Decoding result"), QString("Error"));
}
}

View file

@ -49,7 +49,6 @@ private:
void InitializeSymbianCamera();
protected slots:
void findAndDecode();
void decodeImage(QImage originalImage);
void reloadFormatedPicture(int x);

View file

@ -1,158 +1,177 @@
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.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 \
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
}
DEFINES += ZXING_ICONV_CONST
ICON = QQrDecoder.svg
TEMPLATE = app
TARGET = QQrDecoder
QT += core \
gui
VERSION = 1.1.0
CONFIG += mobility
MOBILITY = multimedia #\
#systeminfo
RESOURCES += resources.qrc
HEADERS += CameraImageWrapper.h \
zxing/BarcodeFormat.h \
zxing/Binarizer.h \
zxing/BinaryBitmap.h \
zxing/DecodeHints.h \
zxing/Exception.h \
zxing/LuminanceSource.h \
zxing/MultiFormatReader.h \
zxing/Reader.h \
zxing/ReaderException.h \
zxing/Result.h \
zxing/ResultPoint.h \
zxing/ResultPointCallback.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/GreyscaleLuminanceSource.h \
zxing/common/GreyscaleRotatedLuminanceSource.h \
zxing/common/GridSampler.h \
zxing/common/HybridBinarizer.h \
zxing/common/IllegalArgumentException.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.h \
QCameraControllerWidget.h \
button.h \
myvideosurface.h
SOURCES += CameraImageWrapper.cpp \
zxing/BarcodeFormat.cpp \
zxing/Binarizer.cpp \
zxing/BinaryBitmap.cpp \
zxing/DecodeHints.cpp \
zxing/Exception.cpp \
zxing/LuminanceSource.cpp \
zxing/MultiFormatReader.cpp \
zxing/Reader.cpp \
zxing/ReaderException.cpp \
zxing/Result.cpp \
zxing/ResultPoint.cpp \
zxing/ResultPointCallback.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/GreyscaleLuminanceSource.cpp \
zxing/common/GreyscaleRotatedLuminanceSource.cpp \
zxing/common/GridSampler.cpp \
zxing/common/HybridBinarizer.cpp \
zxing/common/IllegalArgumentException.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 \
main.cpp \
QQrDecoder.cpp \
QCameraControllerWidget.cpp \
button.cpp \
myvideosurface.cpp
FORMS += QQrDecoder.ui
symbian{
TARGET.UID3 = 0xEF2CE79D
TARGET.EPOCSTACKSIZE = 0x14000
TARGET.EPOCHEAPSIZE = 0x20000 0x8000000
# Because landscape orientation lock
LIBS += -lcone -leikcore -lavkon
# Self-signing capabilities
TARGET.CAPABILITY += NetworkServices \
ReadUserData \
WriteUserData \
LocalServices \
UserEnvironment
}
else{
DEFINES += NO_ICONV
}
DEFINES += ZXING_ICONV_CONST
ICON = QQrDecoder.svg

Binary file not shown.

View file

@ -1,54 +1,30 @@
<?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>
<?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="QCameraControllerWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout" stretch=""/>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>QCameraControllerWidget</class>
<extends>QWidget</extends>
<header>qcameracontrollerwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,110 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the demonstration applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "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."
** $QT_END_LICENSE$
**
****************************************************************************/
#include "button.h"
#include <QMouseEvent>
#include <QPainter>
#include <QTimer>
Button::Button(QWidget *parent, Qt::WindowFlags f) :
QLabel(parent, f)
{
m_downPixmap = 0;
m_disabled = false;
}
Button::~Button()
{
}
void Button::disableBtn(bool b)
{
m_disabled = b;
if (m_disabled) {
setPixmap(m_downPixmap);
} else {
setPixmap(m_upPixmap);
}
}
void Button::mousePressEvent(QMouseEvent *event)
{
if (!m_disabled) {
event->accept();
setPixmap(m_downPixmap);
repaint();
// Lift button back to up after 300ms
QTimer::singleShot(300, this, SLOT(backToUp()));
}
}
void Button::backToUp()
{
setPixmap(m_upPixmap);
repaint();
emit pressed();
}
void Button::setPixmap(const QPixmap& p)
{
// Set up and down picture for the button
// Set pixmap
if (!p.isNull())
QLabel::setPixmap(p);
// Make down pixmap if it does not exists
if (m_downPixmap.isNull()) {
// Store up pixmap
m_upPixmap = *pixmap();
// Create down pixmap
// Make m_downPixmap as a transparent m_upPixmap
QPixmap transparent(m_upPixmap.size());
transparent.fill(Qt::transparent);
QPainter painter(&transparent);
painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.drawPixmap(0, 0, m_upPixmap);
painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
painter.fillRect(transparent.rect(), QColor(0, 0, 0, 150));
painter.end();
m_downPixmap = transparent;
}
}

View file

@ -0,0 +1,72 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the demonstration applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "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."
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef BUTTON_H
#define BUTTON_H
#include <QLabel>
#include <QPixmap>
class Button: public QLabel
{
Q_OBJECT
public:
Button(QWidget *parent = 0, Qt::WindowFlags f = 0);
~Button();
void mousePressEvent(QMouseEvent *);
void disableBtn(bool);
public slots:
void setPixmap(const QPixmap &);
void backToUp();
signals:
void pressed();
private:
QPixmap m_upPixmap;
QPixmap m_downPixmap;
bool m_disabled;
};
#endif // BUTTON_H

View file

@ -1,241 +0,0 @@
/*
* ============================================================================
* 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

@ -1,92 +0,0 @@
/*
* ============================================================================
* 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

@ -1,431 +0,0 @@
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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -0,0 +1,44 @@
#ifndef MYVIDEOSURFACE_H
#define MYVIDEOSURFACE_H
#include <QWidget>
#include <QVideoFrame>
#include <QImage>
#include <QVideoSurfaceFormat>
#include <QAbstractVideoSurface>
#include <QVideoRendererControl>
#include <QVideoSurfaceFormat>
#include <QPainter>
class VideoIF
{
public:
virtual void updateVideo() = 0;
};
class MyVideoSurface: public QAbstractVideoSurface
{
Q_OBJECT
public:
MyVideoSurface(QWidget* widget, VideoIF* target, QObject * parent = 0);
~MyVideoSurface();
bool start(const QVideoSurfaceFormat &format);
bool present(const QVideoFrame &frame);
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const;
void paint(QPainter*);
private:
QWidget* m_targetWidget;
VideoIF* m_target;
QVideoFrame m_frame;
QImage::Format m_imageFormat;
QVideoSurfaceFormat m_videoFormat;
};
#endif // MYVIDEOSURFACE_H

View file

@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/icons">
<file alias="camera.png">icons/camera.png</file>
<file alias="exit.png">icons/exit.png</file>
</qresource>
</RCC>

View file

@ -20,3 +20,19 @@
#include <zxing/BarcodeFormat.h>
namespace zxing {
const char *barcodeFormatNames[] = {
"None",
"QR_CODE",
"DATA_MATRIX",
"UPC_E",
"UPC_A",
"EAN_8",
"EAN_13",
"CODE_128",
"CODE_39",
"ITF"
};
}

View file

@ -5,9 +5,7 @@
* 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.
* 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.
@ -36,7 +34,9 @@ namespace zxing {
BarcodeFormat_CODE_39,
BarcodeFormat_ITF
} BarcodeFormat;
/* if you update the enum, please update the name in BarcodeFormat.cpp */
extern const char *barcodeFormatNames[];
}
#endif // __BARCODE_FORMAT_H__

View file

@ -23,27 +23,13 @@
namespace zxing {
Binarizer::Binarizer(Ref<LuminanceSource> source) : source_(source), array_(NULL), matrix_(NULL), cached_y_(-1) {
Binarizer::Binarizer(Ref<LuminanceSource> source) : source_(source) {
}
Binarizer::~Binarizer() {
}
Ref<BitArray> Binarizer::getBlackRow(int y, Ref<BitArray> row){
if (array_ == NULL && cached_y_ != y) {
array_ = estimateBlackRow(y, row);
cached_y_ = y;
}
return array_;
}
Ref<BitMatrix> Binarizer::getBlackMatrix() {
if (matrix_ == NULL)
matrix_ = estimateBlackMatrix();
return matrix_;
}
Ref<LuminanceSource> Binarizer::getSource() {
Ref<LuminanceSource> Binarizer::getLuminanceSource() const {
return source_;
}

View file

@ -1,10 +1,11 @@
#ifndef BINARIZER_H_
#define BINARIZER_H_
/*
* 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.
* 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.
@ -19,9 +20,6 @@
* limitations under the License.
*/
#ifndef BINARIZER_H_
#define BINARIZER_H_
#include <zxing/LuminanceSource.h>
#include <zxing/common/BitArray.h>
#include <zxing/common/BitMatrix.h>
@ -32,20 +30,16 @@ namespace zxing {
class Binarizer : public Counted {
private:
Ref<LuminanceSource> source_;
Ref<BitArray> array_;
Ref<BitMatrix> matrix_;
int cached_y_;
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<BitArray> getBlackRow(int y, Ref<BitArray> row) = 0;
virtual Ref<BitMatrix> getBlackMatrix() = 0;
virtual Ref<BitMatrix> estimateBlackMatrix() = 0;
Ref<BitMatrix> getBlackMatrix();
Ref<LuminanceSource> getSource();
Ref<LuminanceSource> getLuminanceSource() const ;
virtual Ref<Binarizer> createBinarizer(Ref<LuminanceSource> source) = 0;
};
}

View file

@ -2,9 +2,7 @@
* 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.
* 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.
@ -23,7 +21,7 @@
namespace zxing {
BinaryBitmap::BinaryBitmap(Ref<Binarizer> binarizer) : bits_(NULL), array_bits_(NULL), binarizer_(binarizer), cached_y_(-1) {
BinaryBitmap::BinaryBitmap(Ref<Binarizer> binarizer) : binarizer_(binarizer) {
}
@ -31,28 +29,39 @@ namespace zxing {
}
Ref<BitArray> BinaryBitmap::getBlackRow(int y, Ref<BitArray> row) {
if (array_bits_ == NULL && cached_y_ != y) {
array_bits_ = binarizer_->getBlackRow(y, row);
cached_y_ = y;
}
return array_bits_;
return binarizer_->getBlackRow(y, row);
}
Ref<BitMatrix> BinaryBitmap::getBlackMatrix() {
if (bits_ == NULL) {
bits_ = binarizer_->getBlackMatrix();
}
return bits_;
}
int BinaryBitmap::getWidth() {
return getSource()->getWidth();
}
int BinaryBitmap::getHeight() {
return getSource()->getHeight();
return binarizer_->getBlackMatrix();
}
Ref<LuminanceSource> BinaryBitmap::getSource() {
return binarizer_->getSource();
int BinaryBitmap::getWidth() const {
return getLuminanceSource()->getWidth();
}
int BinaryBitmap::getHeight() const {
return getLuminanceSource()->getHeight();
}
Ref<LuminanceSource> BinaryBitmap::getLuminanceSource() const {
return binarizer_->getLuminanceSource();
}
bool BinaryBitmap::isCropSupported() const {
return getLuminanceSource()->isCropSupported();
}
Ref<BinaryBitmap> BinaryBitmap::crop(int left, int top, int width, int height) {
return Ref<BinaryBitmap> (new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->crop(left, top, width, height))));
}
bool BinaryBitmap::isRotateSupported() const {
return getLuminanceSource()->isRotateSupported();
}
Ref<BinaryBitmap> BinaryBitmap::rotateCounterClockwise() {
return Ref<BinaryBitmap> (new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->rotateCounterClockwise())));
}
}

View file

@ -1,10 +1,11 @@
#ifndef __BINARYBITMAP_H__
#define __BINARYBITMAP_H__
/*
* 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.
* 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.
@ -18,8 +19,6 @@
* 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>
@ -30,8 +29,6 @@ namespace zxing {
class BinaryBitmap : public Counted {
private:
Ref<BitMatrix> bits_;
Ref<BitArray> array_bits_;
Ref<Binarizer> binarizer_;
int cached_y_;
@ -41,10 +38,18 @@ namespace zxing {
Ref<BitArray> getBlackRow(int y, Ref<BitArray> row);
Ref<BitMatrix> getBlackMatrix();
Ref<LuminanceSource> getSource();
int getWidth();
int getHeight();
Ref<LuminanceSource> getLuminanceSource() const;
int getWidth() const;
int getHeight() const;
bool isRotateSupported() const;
Ref<BinaryBitmap> rotateCounterClockwise();
bool isCropSupported() const;
Ref<BinaryBitmap> crop(int left, int top, int width, int height);
};
}

View file

@ -0,0 +1,111 @@
/*
* DecodeHintType.cpp
* zxing
*
* 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/DecodeHints.h>
#include <zxing/common/IllegalArgumentException.h>
namespace zxing {
const DecodeHints DecodeHints::PRODUCT_HINT(
BARCODEFORMAT_UPC_E_HINT |
BARCODEFORMAT_UPC_A_HINT |
BARCODEFORMAT_EAN_8_HINT |
BARCODEFORMAT_EAN_13_HINT);
const DecodeHints DecodeHints::ONED_HINT(
BARCODEFORMAT_UPC_E_HINT |
BARCODEFORMAT_UPC_A_HINT |
BARCODEFORMAT_EAN_8_HINT |
BARCODEFORMAT_EAN_13_HINT |
BARCODEFORMAT_CODE_128_HINT |
BARCODEFORMAT_CODE_39_HINT |
BARCODEFORMAT_ITF_HINT);
const DecodeHints DecodeHints::DEFAULT_HINT(
BARCODEFORMAT_UPC_E_HINT |
BARCODEFORMAT_UPC_A_HINT |
BARCODEFORMAT_EAN_8_HINT |
BARCODEFORMAT_EAN_13_HINT |
BARCODEFORMAT_CODE_128_HINT |
BARCODEFORMAT_CODE_39_HINT |
BARCODEFORMAT_ITF_HINT |
// TODO: uncomment once this passes QA
// BARCODEFORMAT_DATA_MATRIX_HINT |
BARCODEFORMAT_QR_CODE_HINT);
DecodeHints::DecodeHints() {
hints = 0;
}
DecodeHints::DecodeHints(DecodeHintType init) {
hints = init;
}
void DecodeHints::addFormat(BarcodeFormat toadd) {
switch (toadd) {
case BarcodeFormat_QR_CODE: hints |= BARCODEFORMAT_QR_CODE_HINT; break;
case BarcodeFormat_DATA_MATRIX: hints |= BARCODEFORMAT_DATA_MATRIX_HINT; break;
case BarcodeFormat_UPC_E: hints |= BARCODEFORMAT_UPC_E_HINT; break;
case BarcodeFormat_UPC_A: hints |= BARCODEFORMAT_UPC_A_HINT; break;
case BarcodeFormat_EAN_8: hints |= BARCODEFORMAT_EAN_8_HINT; break;
case BarcodeFormat_EAN_13: hints |= BARCODEFORMAT_EAN_13_HINT; break;
case BarcodeFormat_CODE_128: hints |= BARCODEFORMAT_CODE_128_HINT; break;
case BarcodeFormat_CODE_39: hints |= BARCODEFORMAT_CODE_39_HINT; break;
case BarcodeFormat_ITF: hints |= BARCODEFORMAT_ITF_HINT; break;
default: throw IllegalArgumentException("Unrecognizd barcode format");
}
}
bool DecodeHints::containsFormat(BarcodeFormat tocheck) const {
DecodeHintType checkAgainst;
switch (tocheck) {
case BarcodeFormat_QR_CODE: checkAgainst = BARCODEFORMAT_QR_CODE_HINT; break;
case BarcodeFormat_DATA_MATRIX: checkAgainst = BARCODEFORMAT_DATA_MATRIX_HINT; break;
case BarcodeFormat_UPC_E: checkAgainst = BARCODEFORMAT_UPC_E_HINT; break;
case BarcodeFormat_UPC_A: checkAgainst = BARCODEFORMAT_UPC_A_HINT; break;
case BarcodeFormat_EAN_8: checkAgainst = BARCODEFORMAT_EAN_8_HINT; break;
case BarcodeFormat_EAN_13: checkAgainst = BARCODEFORMAT_EAN_13_HINT; break;
case BarcodeFormat_CODE_128: checkAgainst = BARCODEFORMAT_CODE_128_HINT; break;
case BarcodeFormat_CODE_39: checkAgainst = BARCODEFORMAT_CODE_39_HINT; break;
case BarcodeFormat_ITF: checkAgainst = BARCODEFORMAT_ITF_HINT; break;
default: throw IllegalArgumentException("Unrecognizd barcode format");
}
return (hints & checkAgainst);
}
void DecodeHints::setTryHarder(bool toset) {
if (toset) {
hints |= TRYHARDER_HINT;
} else {
hints &= ~TRYHARDER_HINT;
}
}
bool DecodeHints::getTryHarder() const {
return (hints & TRYHARDER_HINT);
}
void DecodeHints::setResultPointCallback(Ref<ResultPointCallback> const& _callback) {
callback = _callback;
}
Ref<ResultPointCallback> DecodeHints::getResultPointCallback() const {
return callback;
}
} /* namespace */

View file

@ -0,0 +1,69 @@
#ifndef __DECODEHINTS_H_
#define __DECODEHINTS_H_
/*
* DecodeHintType.h
* zxing
*
* 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/BarcodeFormat.h>
#include <zxing/ResultPointCallback.h>
namespace zxing {
typedef unsigned int DecodeHintType;
class DecodeHints {
private:
static const DecodeHintType BARCODEFORMAT_QR_CODE_HINT = 1 << BarcodeFormat_QR_CODE;
static const DecodeHintType BARCODEFORMAT_DATA_MATRIX_HINT = 1 << BarcodeFormat_DATA_MATRIX;
static const DecodeHintType BARCODEFORMAT_UPC_E_HINT = 1 << BarcodeFormat_UPC_E;
static const DecodeHintType BARCODEFORMAT_UPC_A_HINT = 1 << BarcodeFormat_UPC_A;
static const DecodeHintType BARCODEFORMAT_EAN_8_HINT = 1 << BarcodeFormat_EAN_8;
static const DecodeHintType BARCODEFORMAT_EAN_13_HINT = 1 << BarcodeFormat_EAN_13;
static const DecodeHintType BARCODEFORMAT_CODE_128_HINT = 1 << BarcodeFormat_CODE_128;
static const DecodeHintType BARCODEFORMAT_CODE_39_HINT = 1 << BarcodeFormat_CODE_39;
static const DecodeHintType BARCODEFORMAT_ITF_HINT = 1 << BarcodeFormat_ITF;
static const DecodeHintType TRYHARDER_HINT = 1 << 31;
DecodeHintType hints;
Ref<ResultPointCallback> callback;
public:
static const DecodeHints PRODUCT_HINT;
static const DecodeHints ONED_HINT;
static const DecodeHints DEFAULT_HINT;
DecodeHints();
DecodeHints(DecodeHintType init);
void addFormat(BarcodeFormat toadd);
bool containsFormat(BarcodeFormat tocheck) const;
void setTryHarder(bool toset);
bool getTryHarder() const;
void setResultPointCallback(Ref<ResultPointCallback> const&);
Ref<ResultPointCallback> getResultPointCallback() const;
};
}
#endif

View file

@ -5,8 +5,7 @@
* Exception.h
* ZXing
*
* Created by Christian Brunschen on 03/06/2008.
* Copyright 2008 ZXing authors All rights reserved.
* 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.

View file

@ -2,7 +2,6 @@
* 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");
@ -19,6 +18,7 @@
*/
#include <zxing/LuminanceSource.h>
#include <zxing/common/IllegalArgumentException.h>
namespace zxing {
@ -28,16 +28,20 @@ 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;
bool LuminanceSource::isCropSupported() const {
return false;
}
Ref<LuminanceSource> LuminanceSource::crop(int left, int top, int width, int height) {
throw IllegalArgumentException("This luminance source does not support cropping.");
}
bool LuminanceSource::isRotateSupported() const {
return false;
}
Ref<LuminanceSource> LuminanceSource::rotateCounterClockwise() {
throw IllegalArgumentException("This luminance source does not support rotation.");
}
}

View file

@ -1,9 +1,10 @@
#ifndef __LUMINANCESOURCE_H__
#define __LUMINANCESOURCE_H__
/*
* LuminanceSource.h
* zxing
*
* Created by Ralf Kistner on 16/10/2009.
* Copyright 2008 ZXing authors All rights reserved.
* 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.
@ -18,10 +19,8 @@
* limitations under the License.
*/
#ifndef LUMINANCESOURCE_H_
#define LUMINANCESOURCE_H_
#include <zxing/common/Counted.h>
#include <string.h>
namespace zxing {
@ -33,8 +32,16 @@ public:
virtual int getWidth() const = 0;
virtual int getHeight() const = 0;
virtual unsigned char getPixel(int x, int y) const = 0;
virtual unsigned char* copyMatrix();
// Callers take ownership of the returned memory and must call delete [] on it themselves.
virtual unsigned char* getRow(int y, unsigned char* row) = 0;
virtual unsigned char* getMatrix() = 0;
virtual bool isCropSupported() const;
virtual Ref<LuminanceSource> crop(int left, int top, int width, int height);
virtual bool isRotateSupported() const;
virtual Ref<LuminanceSource> rotateCounterClockwise();
};
}

View file

@ -27,27 +27,76 @@
#include <zxing/ReaderException.h>
namespace zxing {
MultiFormatReader::MultiFormatReader() {
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){
for (unsigned int i = 0; i < readers.size(); i++) {
try {
return readers[i]->decode(image);
} catch (ReaderException re) {
// continue
}
}
throw ReaderException("No code detected");
}
MultiFormatReader::~MultiFormatReader(){
for (unsigned int i = 0; i < readers.size(); i++) {
delete readers[i];
}
}
MultiFormatReader::MultiFormatReader() {
}
Ref<Result> MultiFormatReader::decode(Ref<BinaryBitmap> image) {
setHints(DecodeHints::DEFAULT_HINT);
return decodeInternal(image);
}
Ref<Result> MultiFormatReader::decode(Ref<BinaryBitmap> image, DecodeHints hints) {
setHints(hints);
return decodeInternal(image);
}
Ref<Result> MultiFormatReader::decodeWithState(Ref<BinaryBitmap> image) {
// Make sure to set up the default state so we don't crash
if (readers_.size() == 0) {
setHints(DecodeHints::DEFAULT_HINT);
}
return decodeInternal(image);
}
void MultiFormatReader::setHints(DecodeHints hints) {
hints_ = hints;
readers_.clear();
bool tryHarder = hints.getTryHarder();
bool addOneDReader = hints.containsFormat(BarcodeFormat_UPC_E) ||
hints.containsFormat(BarcodeFormat_UPC_A) ||
hints.containsFormat(BarcodeFormat_EAN_8) ||
hints.containsFormat(BarcodeFormat_EAN_13) ||
hints.containsFormat(BarcodeFormat_CODE_128) ||
hints.containsFormat(BarcodeFormat_CODE_39) ||
hints.containsFormat(BarcodeFormat_ITF);
if (addOneDReader && !tryHarder) {
readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
}
if (hints.containsFormat(BarcodeFormat_QR_CODE)) {
readers_.push_back(Ref<Reader>(new zxing::qrcode::QRCodeReader()));
}
/* if (hints.containsFormat(BarcodeFormat_DATA_MATRIX)) {
readers_.push_back(Ref<Reader>(new zxing::datamatrix::DataMatrixReader()));
}*/
//TODO: add PDF417 here once PDF417 reader is implemented
if (addOneDReader && tryHarder) {
readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
}
if (readers_.size() == 0) {
if (!tryHarder) {
readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
}
readers_.push_back(Ref<Reader>(new zxing::qrcode::QRCodeReader()));
if (tryHarder) {
readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
}
}
}
Ref<Result> MultiFormatReader::decodeInternal(Ref<BinaryBitmap> image) {
for (unsigned int i = 0; i < readers_.size(); i++) {
try {
return readers_[i]->decode(image, hints_);
} catch (ReaderException& re) {
// continue
}
}
throw ReaderException("No code detected");
}
MultiFormatReader::~MultiFormatReader() {
}
}

View file

@ -1,9 +1,10 @@
#ifndef __MULTI_FORMAT_READER_H__
#define __MULTI_FORMAT_READER_H__
/*
* MultiFormatBarcodeReader.h
* 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");
@ -23,17 +24,26 @@
#include <zxing/Reader.h>
#include <zxing/common/BitArray.h>
#include <zxing/Result.h>
#include <zxing/DecodeHints.h>
namespace zxing {
class MultiFormatReader : public Reader {
private:
std::vector<Reader*>readers;
public:
MultiFormatReader();
Ref<Result> decode(Ref<BinaryBitmap> image);
class MultiFormatReader : public Reader {
private:
Ref<Result> decodeInternal(Ref<BinaryBitmap> image);
~MultiFormatReader();
};
std::vector<Ref<Reader> > readers_;
DecodeHints hints_;
public:
MultiFormatReader();
Ref<Result> decode(Ref<BinaryBitmap> image);
Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
Ref<Result> decodeWithState(Ref<BinaryBitmap> image);
void setHints(DecodeHints hints);
~MultiFormatReader();
};
}
#endif

View file

@ -24,4 +24,8 @@ namespace zxing {
Reader::~Reader() { }
Ref<Result> Reader::decode(Ref<BinaryBitmap> image) {
return decode(image, DecodeHints::DEFAULT_HINT);
}
}

View file

@ -5,8 +5,7 @@
* Reader.h
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 ZXing authors All rights reserved.
* 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.
@ -23,6 +22,7 @@
#include <zxing/BinaryBitmap.h>
#include <zxing/Result.h>
#include <zxing/DecodeHints.h>
namespace zxing {
@ -30,7 +30,8 @@ namespace zxing {
protected:
Reader() {}
public:
virtual Ref<Result> decode(Ref<BinaryBitmap> image) = 0;
virtual Ref<Result> decode(Ref<BinaryBitmap> image);
virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints) = 0;
virtual ~Reader();
};

View file

@ -5,8 +5,7 @@
* ReaderException.h
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 ZXing authors All rights reserved.
* 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.

View file

@ -5,8 +5,7 @@
* Result.h
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 ZXing authors All rights reserved.
* 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.

View file

@ -20,3 +20,8 @@
#include <zxing/ResultPoint.h>
namespace zxing {
ResultPoint::~ResultPoint() {}
}

View file

@ -5,8 +5,7 @@
* ResultPoint.h
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 ZXing authors All rights reserved.
* 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.
@ -29,6 +28,8 @@ class ResultPoint : public Counted {
protected:
ResultPoint() {}
public:
virtual ~ResultPoint();
virtual float getX() const = 0;
virtual float getY() const = 0;
};

View file

@ -0,0 +1,26 @@
/*
* ResultPointCallback.cpp
* zxing
*
* 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/ResultPointCallback.h>
namespace zxing {
ResultPointCallback::~ResultPointCallback() {}
}

View file

@ -0,0 +1,39 @@
#ifndef __RESULT_POINT_CALLBACK_H__
#define __RESULT_POINT_CALLBACK_H__
/*
* ResultPointCallback.h
* zxing
*
* 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/common/Counted.h>
namespace zxing {
class ResultPoint;
class ResultPointCallback : public Counted {
protected:
ResultPointCallback() {}
public:
virtual void foundPossibleResultPoint(ResultPoint const& point) = 0;
virtual ~ResultPointCallback();
};
}
#endif // __RESULT_POINT_CALLBACK_H__

View file

@ -5,8 +5,7 @@
* Array.h
* zxing
*
* Created by Christian Brunschen on 07/05/2008.
* Copyright 2008 Google UK. All rights reserved.
* 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.

View file

@ -2,8 +2,7 @@
* BitArray.cpp
* zxing
*
* Created by Christian Brunschen on 09/05/2008.
* Copyright 2008 Google UK. All rights reserved.
* 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.
@ -25,6 +24,7 @@
using namespace std;
namespace zxing {
static unsigned int logDigits(unsigned digits) {
unsigned log = 0;
unsigned val = 1;
@ -34,9 +34,11 @@ static unsigned int logDigits(unsigned digits) {
}
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) {
@ -48,26 +50,33 @@ size_t BitArray::wordsForBits(size_t bits) {
BitArray::BitArray(size_t size) :
size_(size), bits_(wordsForBits(size), (const unsigned int)0) {
}
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");
@ -81,9 +90,9 @@ bool BitArray::isRange(size_t start, size_t end, bool value) {
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_;
size_t lastBit = i < lastWord ? bitsPerWord_ - 1: end & bitsMask_;
unsigned int mask;
if (firstBit == 0 && lastBit == logBits_) {
if (firstBit == 0 && lastBit == bitsPerWord_ - 1) {
mask = numeric_limits<unsigned int>::max();
} else {
mask = 0;
@ -103,9 +112,11 @@ bool BitArray::isRange(size_t start, size_t end, bool value) {
}
return true;
}
vector<unsigned int>& BitArray::getBitArray() {
return bits_;
}
void BitArray::reverse() {
std::vector<unsigned int> newBits(bits_.size(),(const unsigned int) 0);
for (size_t i = 0; i < size_; i++) {

View file

@ -5,8 +5,7 @@
* BitArray.h
* zxing
*
* Created by Christian Brunschen on 09/05/2008.
* Copyright 2008 Google UK. All rights reserved.
* 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.

View file

@ -2,8 +2,7 @@
* BitMatrix.cpp
* zxing
*
* Created by Christian Brunschen on 12/05/2008.
* Copyright 2008 Google UK. All rights reserved.
* 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.
@ -38,7 +37,6 @@ unsigned int logDigits(unsigned digits) {
return log;
}
const unsigned int bitsPerWord = numeric_limits<unsigned int>::digits;
const unsigned int logBits = logDigits(bitsPerWord);
const unsigned int bitsMask = (1 << logBits) - 1;
@ -93,7 +91,7 @@ void BitMatrix::clear() {
}
void BitMatrix::setRegion(size_t left, size_t top, size_t width, size_t height) {
if (top < 0 || left < 0) {
if ((long)top < 0 || (long)left < 0) {
throw IllegalArgumentException("topI and leftJ must be nonnegative");
}
if (height < 1 || width < 1) {
@ -113,6 +111,39 @@ void BitMatrix::setRegion(size_t left, size_t top, size_t width, size_t height)
}
}
Ref<BitArray> BitMatrix::getRow(int y, Ref<BitArray> row) {
if (row.empty() || row->getSize() < width_) {
row = new BitArray(width_);
} else {
row->clear();
}
size_t start = y * width_;
size_t end = start + width_ - 1; // end is inclusive
size_t firstWord = start >> logBits;
size_t lastWord = end >> logBits;
size_t bitOffset = start & bitsMask;
for (size_t i = firstWord; i <= lastWord; i++) {
size_t firstBit = i > firstWord ? 0 : start & bitsMask;
size_t lastBit = i < lastWord ? bitsPerWord - 1 : 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;
}
}
row->setBulk((i - firstWord) << logBits, (bits_[i] & mask) >> bitOffset);
if (firstBit == 0 && bitOffset != 0) {
unsigned int prevBulk = row->getBitArray()[i - firstWord - 1];
prevBulk |= (bits_[i] & mask) << (bitsPerWord - bitOffset);
row->setBulk((i - firstWord - 1) << logBits, prevBulk);
}
}
return row;
}
size_t BitMatrix::getWidth() const {
return width_;
}

View file

@ -5,8 +5,7 @@
* BitMatrix.h
* zxing
*
* Created by Christian Brunschen on 12/05/2008.
* Copyright 2008 Google UK. All rights reserved.
* 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.
@ -22,6 +21,7 @@
*/
#include <zxing/common/Counted.h>
#include <zxing/common/BitArray.h>
#include <limits>
namespace zxing {
@ -44,6 +44,7 @@ public:
void flip(size_t x, size_t y);
void clear();
void setRegion(size_t left, size_t top, size_t width, size_t height);
Ref<BitArray> getRow(int y, Ref<BitArray> row);
size_t getDimension() const;
size_t getWidth() const;

View file

@ -5,8 +5,7 @@
* BitSource.h
* zxing
*
* Created by Christian Brunschen on 09/05/2008.
* Copyright 2008 Google UK. All rights reserved.
* 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.

View file

@ -5,8 +5,7 @@
* Counted.h
* zxing
*
* Created by Christian Brunschen on 07/05/2008.
* Copyright 2008 Google UK. All rights reserved.
* 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.
@ -194,6 +193,10 @@ public:
return x == 0 ? object_ != 0 : true;
}
bool empty() const {
return object_ == 0;
}
template<class Y>
friend std::ostream& operator<<(std::ostream &out, Ref<Y>& ref);
};

View file

@ -5,8 +5,7 @@
* DecoderResult.h
* zxing
*
* Created by Christian Brunschen on 20/05/2008.
* Copyright 2008 ZXing authors All rights reserved.
* 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.

View file

@ -5,8 +5,7 @@
* DetectorResult.h
* zxing
*
* Created by Christian Brunschen on 14/05/2008.
* Copyright 2008 ZXing authors All rights reserved.
* 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.

View file

@ -1,9 +1,10 @@
#ifndef __EDGEDETECTOR_H__
#define __EDGEDETECTOR_H__
/*
* EdgeDetector.h
* zxing
*
* Created by Ralf Kistner on 7/12/2009.
* Copyright 2008 ZXing authors All rights reserved.
* 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.
@ -18,8 +19,7 @@
* limitations under the License.
*/
#ifndef EDGEDETECTOR_H_
#define EDGEDETECTOR_H_
#include <vector>
#include <zxing/common/BitMatrix.h>

View file

@ -2,9 +2,7 @@
* 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.
* 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.
@ -31,7 +29,7 @@ const int LUMINANCE_SHIFT = 8 - LUMINANCE_BITS;
const int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS;
GlobalHistogramBinarizer::GlobalHistogramBinarizer(Ref<LuminanceSource> source) :
Binarizer(source) {
Binarizer(source), cached_matrix_(NULL), cached_row_(NULL), cached_row_num_(-1) {
}
@ -39,10 +37,17 @@ GlobalHistogramBinarizer::~GlobalHistogramBinarizer() {
}
Ref<BitArray> GlobalHistogramBinarizer::estimateBlackRow(int y,
Ref<BitArray> row){
Ref<BitArray> GlobalHistogramBinarizer::getBlackRow(int y, Ref<BitArray> row) {
if (y == cached_row_num_) {
if (cached_row_ != NULL) {
return cached_row_;
} else {
throw IllegalArgumentException("Too little dynamic range in luminance");
}
}
vector<int> histogram(LUMINANCE_BUCKETS, 0);
LuminanceSource& source = *getSource();
LuminanceSource& source = *getLuminanceSource();
int width = source.getWidth();
if (row == NULL || static_cast<int>(row->getSize()) < width) {
row = new BitArray(width);
@ -50,51 +55,66 @@ Ref<BitArray> GlobalHistogramBinarizer::estimateBlackRow(int y,
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);
//TODO(flyashi): cache this instead of allocating and deleting per row
unsigned char* row_pixels = NULL;
try {
row_pixels = new unsigned char[width];
row_pixels = source.getRow(y, row_pixels);
for (int x = 0; x < width; x++) {
histogram[row_pixels[x] >> LUMINANCE_SHIFT]++;
}
left = center;
center = right;
}
int blackPoint = estimate(histogram) << LUMINANCE_SHIFT;
return array_ref;
BitArray& array = *row;
int left = row_pixels[0];
int center = row_pixels[1];
for (int x = 1; x < width - 1; x++) {
int right = row_pixels[x + 1];
// 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;
}
cached_row_ = row;
cached_row_num_ = y;
delete [] row_pixels;
return row;
} catch (IllegalArgumentException const& iae) {
// Cache the fact that this row failed.
cached_row_ = NULL;
cached_row_num_ = y;
delete [] row_pixels;
throw iae;
}
}
Ref<BitMatrix> GlobalHistogramBinarizer::estimateBlackMatrix() {
Ref<BitMatrix> GlobalHistogramBinarizer::getBlackMatrix() {
if (cached_matrix_ != NULL) {
return cached_matrix_;
}
// Faster than working with the reference
LuminanceSource& source = *getSource();
LuminanceSource& source = *getLuminanceSource();
int width = source.getWidth();
int height = source.getHeight();
vector<int> histogram(LUMINANCE_BUCKETS, 0);
// 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.
unsigned char* row = new unsigned char[width];
for (int y = 1; y < 5; y++) {
int row = height * y / 5;
int rownum = height * y / 5;
int right = (width << 2) / 5;
int sdf;
row = source.getRow(rownum, row);
for (int x = width / 5; x < right; x++) {
unsigned char pixel = source.getPixel(x, row);
histogram[pixel >> LUMINANCE_SHIFT]++;
sdf = histogram[pixel >> LUMINANCE_SHIFT];
histogram[row[x] >> LUMINANCE_SHIFT]++;
sdf = histogram[row[x] >> LUMINANCE_SHIFT];
}
}
@ -103,11 +123,15 @@ Ref<BitMatrix> GlobalHistogramBinarizer::estimateBlackMatrix() {
Ref<BitMatrix> matrix_ref(new BitMatrix(width, height));
BitMatrix& matrix = *matrix_ref;
for (int y = 0; y < height; y++) {
row = source.getRow(y, row);
for (int x = 0; x < width; x++) {
if (source.getPixel(x, y) <= blackPoint)
if (row[x] <= blackPoint)
matrix.set(x, y);
}
}
cached_matrix_ = matrix_ref;
delete [] row;
return matrix_ref;
}
@ -115,7 +139,6 @@ int GlobalHistogramBinarizer::estimate(vector<int> &histogram) {
int numBuckets = histogram.size();
int maxBucketCount = 0;
// Find tallest peak in histogram
int firstPeak = 0;
int firstPeakSize = 0;
@ -179,5 +202,8 @@ int GlobalHistogramBinarizer::estimate(vector<int> &histogram) {
return bestValley;
}
} // namespace zxing
Ref<Binarizer> GlobalHistogramBinarizer::createBinarizer(Ref<LuminanceSource> source) {
return Ref<Binarizer> (new GlobalHistogramBinarizer(source));
}
} // namespace zxing

View file

@ -1,10 +1,10 @@
#ifndef __GLOBALHISTOGRAMBINARIZER_H__
#define __GLOBALHISTOGRAMBINARIZER_H__
/*
* 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.
* 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.
@ -19,9 +19,6 @@
* limitations under the License.
*/
#ifndef GLOBALHISTOGRAMBINARIZER_H_
#define GLOBALHISTOGRAMBINARIZER_H_
#include <vector>
#include <zxing/Binarizer.h>
#include <zxing/common/BitArray.h>
@ -30,13 +27,19 @@
namespace zxing {
class GlobalHistogramBinarizer : public Binarizer {
private:
Ref<BitMatrix> cached_matrix_;
Ref<BitArray> cached_row_;
int cached_row_num_;
public:
GlobalHistogramBinarizer(Ref<LuminanceSource> source);
virtual ~GlobalHistogramBinarizer();
virtual Ref<BitArray> estimateBlackRow(int y, Ref<BitArray> row);
virtual Ref<BitMatrix> estimateBlackMatrix();
virtual Ref<BitArray> getBlackRow(int y, Ref<BitArray> row);
virtual Ref<BitMatrix> getBlackMatrix();
static int estimate(std::vector<int> &histogram);
Ref<Binarizer> createBinarizer(Ref<LuminanceSource> source);
};
}

View file

@ -0,0 +1,70 @@
/*
* GreyscaleLuminanceSource.cpp
* zxing
*
* 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/common/GreyscaleLuminanceSource.h>
#include <zxing/common/GreyscaleRotatedLuminanceSource.h>
#include <zxing/common/IllegalArgumentException.h>
namespace zxing {
GreyscaleLuminanceSource::GreyscaleLuminanceSource(unsigned char* greyData, int dataWidth,
int dataHeight, int left, int top, int width, int height) : greyData_(greyData),
dataWidth_(dataWidth), dataHeight_(dataHeight), left_(left), top_(top), width_(width),
height_(height) {
if (left + width > dataWidth || top + height > dataHeight || top < 0 || left < 0) {
throw IllegalArgumentException("Crop rectangle does not fit within image data.");
}
}
unsigned char* GreyscaleLuminanceSource::getRow(int y, unsigned char* row) {
if (y < 0 || y >= this->getHeight()) {
throw IllegalArgumentException("Requested row is outside the image: " + y);
}
int width = getWidth();
// TODO(flyashi): determine if row has enough size.
if (row == NULL) {
row = new unsigned char[width_];
}
int offset = (y + top_) * dataWidth_ + left_;
memcpy(row, &greyData_[offset], width);
return row;
}
unsigned char* GreyscaleLuminanceSource::getMatrix() {
int size = width_ * height_;
unsigned char* result = new unsigned char[size];
if (left_ == 0 && top_ == 0 && dataWidth_ == width_ && dataHeight_ == height_) {
memcpy(result, greyData_, size);
} else {
for (int row = 0; row < height_; row++) {
memcpy(result + row * width_, greyData_ + (top_ + row) * dataWidth_ + left_, width_);
}
}
return result;
}
Ref<LuminanceSource> GreyscaleLuminanceSource::rotateCounterClockwise() {
// Intentionally flip the left, top, width, and height arguments as needed. dataWidth and
// dataHeight are always kept unrotated.
return Ref<LuminanceSource> (new GreyscaleRotatedLuminanceSource(greyData_, dataWidth_,
dataHeight_, top_, left_, height_, width_));
}
} /* namespace */

View file

@ -0,0 +1,62 @@
#ifndef __GREYSCALE_LUMINANCE_SOURCE__
#define __GREYSCALE_LUMINANCE_SOURCE__
/*
* GreyscaleLuminanceSource.h
* zxing
*
* 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/LuminanceSource.h>
namespace zxing {
class GreyscaleLuminanceSource : public LuminanceSource {
private:
unsigned char* greyData_;
int dataWidth_;
int dataHeight_;
int left_;
int top_;
int width_;
int height_;
public:
GreyscaleLuminanceSource(unsigned char* greyData, int dataWidth, int dataHeight, int left,
int top, int width, int height);
unsigned char* getRow(int y, unsigned char* row);
unsigned char* getMatrix();
bool isRotateSupported() const {
return true;
}
int getWidth() const {
return width_;
}
int getHeight() const {
return height_;
}
Ref<LuminanceSource> rotateCounterClockwise();
};
} /* namespace */
#endif

View file

@ -0,0 +1,65 @@
/*
* GreyscaleRotatedLuminanceSource.cpp
* zxing
*
* 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/common/GreyscaleRotatedLuminanceSource.h>
#include <zxing/common/IllegalArgumentException.h>
namespace zxing {
// Note that dataWidth and dataHeight are not reversed, as we need to be able to traverse the
// greyData correctly, which does not get rotated.
GreyscaleRotatedLuminanceSource::GreyscaleRotatedLuminanceSource(unsigned char* greyData,
int dataWidth, int dataHeight, int left, int top, int width, int height) : greyData_(greyData),
dataWidth_(dataWidth), dataHeight_(dataHeight), left_(left), top_(top), width_(width),
height_(height) {
// Intentionally comparing to the opposite dimension since we're rotated.
if (left + width > dataHeight || top + height > dataWidth) {
throw IllegalArgumentException("Crop rectangle does not fit within image data.");
}
}
// The API asks for rows, but we're rotated, so we return columns.
unsigned char* GreyscaleRotatedLuminanceSource::getRow(int y, unsigned char* row) {
if (y < 0 || y >= getHeight()) {
throw IllegalArgumentException("Requested row is outside the image: " + y);
}
int width = getWidth();
if (row == NULL) {
row = new unsigned char[width];
}
int offset = (left_ * dataWidth_) + (dataWidth_ - (y + top_));
for (int x = 0; x < width; x++) {
row[x] = greyData_[offset];
offset += dataWidth_;
}
return row;
}
unsigned char* GreyscaleRotatedLuminanceSource::getMatrix() {
unsigned char* result = new unsigned char[width_ * height_];
// This depends on getRow() honoring its second parameter.
for (int y = 0; y < height_; y++) {
getRow(y, &result[y * width_]);
}
return result;
}
} // namespace

View file

@ -0,0 +1,60 @@
#ifndef __GREYSCALE_ROTATED_LUMINANCE_SOURCE__
#define __GREYSCALE_ROTATED_LUMINANCE_SOURCE__
/*
* GreyscaleRotatedLuminanceSource.h
* zxing
*
* 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/LuminanceSource.h>
namespace zxing {
class GreyscaleRotatedLuminanceSource : public LuminanceSource {
private:
unsigned char* greyData_;
int dataWidth_;
int dataHeight_;
int left_;
int top_;
int width_;
int height_;
public:
GreyscaleRotatedLuminanceSource(unsigned char* greyData, int dataWidth, int dataHeight,
int left, int top, int width, int height);
unsigned char* getRow(int y, unsigned char* row);
unsigned char* getMatrix();
bool isRotateSupported() const {
return false;
}
int getWidth() const {
return width_;
}
int getHeight() const {
return height_;
}
};
} /* namespace */
#endif

View file

@ -5,8 +5,7 @@
* GridSampler.h
* zxing
*
* Created by Christian Brunschen on 18/05/2008.
* Copyright 2008 ZXing authors All rights reserved.
* 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.

View file

@ -0,0 +1,168 @@
/*
* HybridBinarizer.cpp
* zxing
*
* 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/common/HybridBinarizer.h>
#include <zxing/common/IllegalArgumentException.h>
namespace zxing {
using namespace std;
static const int MINIMUM_DIMENSION = 40;
static const int LUMINANCE_BITS = 5;
static const int LUMINANCE_SHIFT = 8 - LUMINANCE_BITS;
static const int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS;
HybridBinarizer::HybridBinarizer(Ref<LuminanceSource> source) :
GlobalHistogramBinarizer(source), cached_matrix_(NULL), cached_row_(NULL), cached_row_num_(-1) {
}
HybridBinarizer::~HybridBinarizer() {
}
Ref<BitMatrix> HybridBinarizer::getBlackMatrix() {
binarizeEntireImage();
return cached_matrix_;
}
Ref<Binarizer> HybridBinarizer::createBinarizer(Ref<LuminanceSource> source) {
return Ref<Binarizer> (new HybridBinarizer(source));
}
void HybridBinarizer::binarizeEntireImage() {
if (cached_matrix_ == NULL) {
Ref<LuminanceSource> source = getLuminanceSource();
if (source->getWidth() >= MINIMUM_DIMENSION && source->getHeight() >= MINIMUM_DIMENSION) {
unsigned char* luminances = source->getMatrix();
int width = source->getWidth();
int height = source->getHeight();
int subWidth = width >> 3;
if (width & 0x07) {
subWidth++;
}
int subHeight = height >> 3;
if (height & 0x07) {
subHeight++;
}
int *blackPoints = calculateBlackPoints(luminances, subWidth, subHeight, width, height);
cached_matrix_.reset(new BitMatrix(width,height));
calculateThresholdForBlock(luminances, subWidth, subHeight, width, height, blackPoints, cached_matrix_);
delete [] blackPoints;
delete [] luminances;
} else {
// If the image is too small, fall back to the global histogram approach.
cached_matrix_.reset(GlobalHistogramBinarizer::getBlackMatrix());
}
}
}
void HybridBinarizer::calculateThresholdForBlock(unsigned char* luminances, int subWidth, int subHeight,
int width, int height, int blackPoints[], Ref<BitMatrix> matrix) {
for (int y = 0; y < subHeight; y++) {
int yoffset = y << 3;
if (yoffset + 8 >= height) {
yoffset = height - 8;
}
for (int x = 0; x < subWidth; x++) {
int xoffset = x << 3;
if (xoffset + 8 >= width) {
xoffset = width - 8;
}
int left = (x > 1) ? x : 2;
left = (left < subWidth - 2) ? left : subWidth - 3;
int top = (y > 1) ? y : 2;
top = (top < subHeight - 2) ? top : subHeight - 3;
int sum = 0;
for (int z = -2; z <= 2; z++) {
int *blackRow = &blackPoints[(top + z) * subWidth];
sum += blackRow[left - 2];
sum += blackRow[left - 1];
sum += blackRow[left];
sum += blackRow[left + 1];
sum += blackRow[left + 2];
}
int average = sum / 25;
threshold8x8Block(luminances, xoffset, yoffset, average, width, matrix);
}
}
}
void HybridBinarizer::threshold8x8Block(unsigned char* luminances, int xoffset, int yoffset, int threshold,
int stride, Ref<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] & 0xff;
if (pixel < threshold) {
matrix->set(xoffset + x, yoffset + y);
}
}
}
}
int* HybridBinarizer::calculateBlackPoints(unsigned char* luminances, int subWidth, int subHeight,
int width, int height) {
int *blackPoints = new int[subHeight * subWidth];
for (int y = 0; y < subHeight; y++) {
int yoffset = y << 3;
if (yoffset + 8 >= height) {
yoffset = height - 8;
}
for (int x = 0; x < subWidth; x++) {
int xoffset = x << 3;
if (xoffset + 8 >= width) {
xoffset = width - 8;
}
int sum = 0;
int min = 255;
int max = 0;
for (int yy = 0; yy < 8; yy++) {
int offset = (yoffset + yy) * width + xoffset;
for (int xx = 0; xx < 8; xx++) {
int pixel = luminances[offset + xx] & 0xff;
sum += pixel;
if (pixel < min) {
min = pixel;
}
if (pixel > max) {
max = pixel;
}
}
}
// If the contrast is inadequate, use half the minimum, so that this block will be
// treated as part of the white background, but won't drag down neighboring blocks
// too much.
int average;
if (max - min > 24) {
average = (sum >> 6);
} else {
average = max == 0 ? 1 : (min >> 1);
}
blackPoints[y * subWidth + x] = average;
}
}
return blackPoints;
}
} // namespace zxing

View file

@ -0,0 +1,55 @@
#ifndef __HYBRIDBINARIZER_H__
#define __HYBRIDBINARIZER_H__
/*
* HybridBinarizer.h
* zxing
*
* 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 <vector>
#include <zxing/Binarizer.h>
#include <zxing/common/GlobalHistogramBinarizer.h>
#include <zxing/common/BitArray.h>
#include <zxing/common/BitMatrix.h>
namespace zxing {
class HybridBinarizer : public GlobalHistogramBinarizer {
private:
Ref<BitMatrix> cached_matrix_;
Ref<BitArray> cached_row_;
int cached_row_num_;
public:
HybridBinarizer(Ref<LuminanceSource> source);
virtual ~HybridBinarizer();
virtual Ref<BitMatrix> getBlackMatrix();
Ref<Binarizer> createBinarizer(Ref<LuminanceSource> source);
private:
void binarizeEntireImage();
// We'll be using one-D arrays because C++ can't dynamically allocate 2D arrays
int* calculateBlackPoints(unsigned char* luminances, int subWidth, int subHeight,
int width, int height);
void calculateThresholdForBlock(unsigned char* luminances, int subWidth, int subHeight,
int width, int height, int blackPoints[], Ref<BitMatrix> matrix);
void threshold8x8Block(unsigned char* luminances, int xoffset, int yoffset, int threshold,
int stride, Ref<BitMatrix> matrix);
};
}
#endif /* GLOBALHISTOGRAMBINARIZER_H_ */

View file

@ -5,8 +5,7 @@
* IllegalArgumentException.h
* zxing
*
* Created by Christian Brunschen on 06/05/2008.
* Copyright 2008 Google UK. All rights reserved.
* 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.

View file

@ -5,8 +5,7 @@
* PerspectiveTransform.h
* zxing
*
* Created by Christian Brunschen on 12/05/2008.
* Copyright 2008 Google UK. All rights reserved.
* 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.

View file

@ -1,9 +1,11 @@
#ifndef __POINT_H__
#define __POINT_H__
/*
* Point.h
* zxing
*
* Created by Ralf Kistner on 7/12/2009.
* Copyright 2008 ZXing authors All rights reserved.
* 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.
@ -18,9 +20,6 @@
* limitations under the License.
*/
#ifndef ZXING_POINT_H_
#define ZXING_POINT_H_
namespace zxing {
class PointI {
public:

View file

@ -1,12 +1,11 @@
#ifndef __COMMON__STRING_H__
#define __COMMON__STRING_H__
#ifndef __STR_H__
#define __STR_H__
/*
* String.h
* Str.h
* zxing
*
* Created by Christian Brunschen on 20/05/2008.
* Copyright 2008 ZXing authors All rights reserved.
* 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.

View file

@ -5,8 +5,7 @@
* GF256.h
* zxing
*
* Created by Christian Brunschen on 05/05/2008.
* Copyright 2008 Google UK. All rights reserved.
* 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.

View file

@ -5,8 +5,7 @@
* GF256Poly.h
* zxing
*
* Created by Christian Brunschen on 05/05/2008.
* Copyright 2008 Google UK. All rights reserved.
* 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.

View file

@ -5,8 +5,7 @@
* ReedSolomonDecoder.h
* zxing
*
* Created by Christian Brunschen on 05/05/2008.
* Copyright 2008 Google UK. All rights reserved.
* 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.

View file

@ -5,8 +5,7 @@
* ReedSolomonException.h
* zxing
*
* Created by Christian Brunschen on 06/05/2008.
* Copyright 2008 Google UK. All rights reserved.
* 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.

View file

@ -31,7 +31,7 @@ DataMatrixReader::DataMatrixReader() :
decoder_() {
}
Ref<Result> DataMatrixReader::decode(Ref<BinaryBitmap> image) {
Ref<Result> DataMatrixReader::decode(Ref<BinaryBitmap> image, DecodeHints hints) {
#ifdef DEBUG
cout << "decoding image " << image.object_ << ":\n" << flush;
#endif

View file

@ -22,6 +22,7 @@
*/
#include <zxing/Reader.h>
#include <zxing/DecodeHints.h>
#include <zxing/datamatrix/decoder/Decoder.h>
namespace zxing {
@ -33,7 +34,7 @@ private:
public:
DataMatrixReader();
virtual Ref<Result> decode(Ref<BinaryBitmap> image);
virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
virtual ~DataMatrixReader();
};

View file

@ -2,7 +2,6 @@
* 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");
@ -28,7 +27,7 @@
namespace zxing {
namespace oned {
const int CODE_PATTERNS_LENGTH = 107;
const int countersLength = 6;
static const int CODE_PATTERNS[CODE_PATTERNS_LENGTH][countersLength] = {
@ -140,11 +139,11 @@ namespace zxing {
{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;
@ -154,13 +153,13 @@ namespace zxing {
}
rowOffset++;
}
int counterPosition = 0;
int counters[countersLength] = {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) {
@ -170,7 +169,8 @@ namespace zxing {
unsigned int bestVariance = MAX_AVG_VARIANCE;
int bestMatch = -1;
for (int startCode = CODE_START_A; startCode <= CODE_START_C; startCode++) {
unsigned int variance = patternMatchVariance(counters, sizeof(counters)/sizeof(int), CODE_PATTERNS[startCode], MAX_INDIVIDUAL_VARIANCE);
unsigned int variance = patternMatchVariance(counters, sizeof(counters) / sizeof(int),
CODE_PATTERNS[startCode], MAX_INDIVIDUAL_VARIANCE);
if (variance < bestVariance) {
bestVariance = variance;
bestMatch = startCode;
@ -178,7 +178,8 @@ namespace zxing {
}
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)) {
if (row->isRange(fmaxl(0, patternStart - (i - patternStart) / 2), patternStart,
false)) {
int* resultValue = new int[3];
resultValue[0] = patternStart;
resultValue[1] = i;
@ -202,19 +203,23 @@ namespace zxing {
}
throw ReaderException("");
}
int Code128Reader::decodeCode(Ref<BitArray> row, int counters[], int countersCount, int rowOffset){
recordPattern(row, rowOffset, counters, countersCount);
int Code128Reader::decodeCode(Ref<BitArray> row, int counters[], int countersCount,
int rowOffset) {
if (!recordPattern(row, rowOffset, counters, countersCount)) {
throw ReaderException("");
}
unsigned int bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
int bestMatch = -1;
for (int d = 0; d < CODE_PATTERNS_LENGTH; d++) {
int pattern[countersLength];
for(int ind = 0; ind< countersLength; ind++){
pattern[ind] = CODE_PATTERNS[d][ind];
}
// memcpy(pattern, CODE_PATTERNS[d], countersLength);
unsigned int variance = patternMatchVariance(counters, countersCount, pattern, MAX_INDIVIDUAL_VARIANCE);
unsigned int variance = patternMatchVariance(counters, countersCount, pattern,
MAX_INDIVIDUAL_VARIANCE);
if (variance < bestVariance) {
bestVariance = variance;
bestMatch = d;
@ -227,265 +232,258 @@ namespace zxing {
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:
delete [] startPatternInfo;
throw ReaderException("");
Ref<Result> Code128Reader::decodeRow(int rowNumber, Ref<BitArray> row) {
int* startPatternInfo = NULL;
try {
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;
std::stringstream tmpResultSStr; // used if its Code 128C
int lastStart = startPatternInfo[0];
int nextStart = startPatternInfo[1];
int counters[countersLength] = {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
try {
code = decodeCode(row, counters, sizeof(counters)/sizeof(int), nextStart);
} catch (ReaderException& re) {
throw re;
}
// 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 _countersLength = sizeof(counters) / sizeof(int);
for (int i = 0; i < _countersLength; 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:
tmpResultSStr.str(std::string());
// the code read in this case is the number encoded directly
if (code < 100) {
if (code < 10) {
tmpResultSStr << '0';
}
tmpResultSStr << code;
tmpResultString.append(tmpResultSStr.str());
} 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));
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;
delete [] startPatternInfo;
ArrayRef<unsigned char> resultBytes(1);
return Ref<Result>(new Result(resultString, resultBytes, resultPoints,
BarcodeFormat_CODE_128));
} catch (ReaderException const& re) {
delete [] startPatternInfo;
return Ref<Result>();
}
bool done = false;
bool isNextShifted = false;
std::string tmpResultString;
std::stringstream tmpResultSStr; // used if its Code 128C
int lastStart = startPatternInfo[0];
int nextStart = startPatternInfo[1];
int counters[countersLength] = {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
try {
code = decodeCode(row, counters, sizeof(counters)/sizeof(int), nextStart);
} catch (ReaderException re) {
delete [] startPatternInfo;
throw re;
}
// 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 _countersLength = sizeof(counters) / sizeof(int);
for (int i = 0; i < _countersLength; i++) {
nextStart += counters[i];
}
// Take care of illegal start codes
switch (code) {
case CODE_START_A:
case CODE_START_B:
case CODE_START_C:
delete [] startPatternInfo;
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:
// the code read in this case is the number encoded directly
if (code < 100) {
if (code < 10)
tmpResultSStr << '0';
tmpResultSStr << 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)) {
delete [] startPatternInfo;
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) {
delete [] startPatternInfo;
throw ReaderException("");
}
if (codeSet == CODE_CODE_C)
tmpResultString.append(tmpResultSStr.str());
// 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) {
delete [] startPatternInfo;
// 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

@ -1,8 +1,9 @@
#ifndef __CODE_128_READER_H__
#define __CODE_128_READER_H__
/*
* 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");
@ -27,9 +28,10 @@ namespace zxing {
class Code128Reader : public OneDReader {
private:
static const unsigned int MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.25f);
static const int MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.7f);
//static const unsigned int MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.25f);
enum {MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.25f)};
//static const int MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.7f);
enum {MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.7f)};
static const int CODE_SHIFT = 98;
static const int CODE_CODE_C = 99;
@ -59,3 +61,4 @@ namespace zxing {
}
}
#endif

View file

@ -2,7 +2,6 @@
* 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");
@ -69,118 +68,116 @@ namespace oned {
* digit, not data, and verify that the checksum passes.
*/
Code39Reader::Code39Reader(bool usingCheckDigit_) :
alphabet_string(ALPHABET_STRING),
alphabet_string(ALPHABET_STRING),
usingCheckDigit(usingCheckDigit_),
extendedMode(false) {
}
Code39Reader::Code39Reader(bool usingCheckDigit_, bool extendedMode_) :
alphabet_string(ALPHABET_STRING),
usingCheckDigit(usingCheckDigit_),
extendedMode(extendedMode_) {
}
Ref<Result> Code39Reader::decodeRow(int rowNumber, Ref<BitArray> row){
int* start = findAsteriskPattern(row);
int nextStart = start[1];
int end = row->getSize();
Ref<Result> Code39Reader::decodeRow(int rowNumber, Ref<BitArray> row) {
int* start = NULL;
try {
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 {
try {
recordPattern(row, nextStart, counters, countersLen);
} catch (ReaderException re) {
delete [] start;
throw re;
}
int pattern = toNarrowWidePattern(counters, countersLen);
if (pattern < 0) {
delete [] start;
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];
}
// IS begin
delete [] counters;
// IS end
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) {
delete [] start;
throw ReaderException("too short end white space");
}
std::string tmpResultString;
if (usingCheckDigit) {
int max = tmpResultString.length() - 1;
unsigned int total = 0;
for (int i = 0; i < max; i++) {
total += alphabet_string.find_first_of(tmpResultString[i], 0);
const int countersLen = 9;
int counters[countersLen];
for (int i = 0; i < countersLen; i++) {
counters[i] = 0;
}
if (total % 43 != alphabet_string.find_first_of(tmpResultString[max], 0)) {
char decodedChar;
int lastStart;
do {
if (!recordPattern(row, nextStart, counters, countersLen)) {
throw ReaderException("");
}
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;
unsigned 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) {
resultString = decodeExtended(tmpResultString);
}
if (tmpResultString.length() == 0) {
// Almost surely a false positive
throw ReaderException("");
}
tmpResultString.erase(max, 1);
}
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);
Ref<String> resultString(new String(tmpResultString));
if (extendedMode) {
delete resultString;
resultString = decodeExtended(tmpResultString);
}
Ref<Result> res(new Result(
resultString, resultBytes, resultPoints, BarcodeFormat_CODE_39));
if (tmpResultString.length() == 0) {
delete [] start;
// Almost surely a false positive
throw ReaderException("");
return res;
} catch (ReaderException const& re) {
delete [] start;
return Ref<Result>();
}
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){
@ -194,9 +191,9 @@ namespace oned {
}
int counterPosition = 0;
int countersLen = 9;
int* counters = new int[countersLen];
for (int i=0; i<countersLen; i++) {
const int countersLen = 9;
int counters[countersLen];
for (int i = 0; i < countersLen; i++) {
counters[i] = 0;
}
int patternStart = rowOffset;
@ -235,9 +232,6 @@ namespace oned {
isWhite = !isWhite;
}
}
// IS begin
delete [] counters;
// IS end
throw ReaderException("");
}

View file

@ -1,8 +1,9 @@
#ifndef __CODE_39_READER_H__
#define __CODE_39_READER_H__
/*
* 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");
@ -47,9 +48,11 @@ namespace zxing {
public:
Code39Reader();
Code39Reader(bool usingCheckDigit_);
Code39Reader(bool usingCheckDigit_, bool extendedMode_);
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
};
}
}
#endif

View file

@ -2,7 +2,6 @@
* 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");
@ -22,62 +21,75 @@
#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() { }
int EAN13Reader::decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString){
const int countersLen = 4;
int counters[countersLen] = { 0, 0, 0, 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;
}
}
namespace oned {
static const int FIRST_DIGIT_ENCODINGS[10] = {
0x00, 0x0B, 0x0D, 0xE, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A
};
EAN13Reader::EAN13Reader() { }
int EAN13Reader::decodeMiddle(Ref<BitArray> row, int startGuardBegin, int startGuardEnd,
std::string& resultString) {
const int countersLen = 4;
int counters[countersLen] = { 0, 0, 0, 0 };
int end = row->getSize();
int rowOffset = startGuardEnd;
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);
if (bestMatch < 0) {
return -1;
}
resultString.append(1, (char) ('0' + bestMatch % 10));
for (int i = 0; i < countersLen; i++) {
rowOffset += counters[i];
}
if (bestMatch >= 10) {
lgPatternFound |= 1 << (5 - x);
}
}
if (!determineFirstDigit(resultString, lgPatternFound)) {
return -1;
}
int middleRangeStart;
int middleRangeEnd;
if (findGuardPattern(row, rowOffset, true, (int*)getMIDDLE_PATTERN(),
getMIDDLE_PATTERN_LEN(), &middleRangeStart, &middleRangeEnd)) {
rowOffset = middleRangeEnd;
for (int x = 0; x < 6 && rowOffset < end; x++) {
int bestMatch = decodeDigit(row, counters, countersLen, rowOffset,
UPC_EAN_PATTERNS_L_PATTERNS);
if (bestMatch < 0) {
return -1;
}
resultString.append(1, (char) ('0' + bestMatch));
for (int i = 0; i < countersLen; i++) {
rowOffset += counters[i];
}
}
return rowOffset;
}
return -1;
}
bool 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 true;
}
}
return false;
}
BarcodeFormat EAN13Reader::getBarcodeFormat(){
return BarcodeFormat_EAN_13;
}
}
}

View file

@ -1,8 +1,10 @@
#ifndef __EAN_13_READER_H__
#define __EAN_13_READER_H__
/*
* 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");
@ -22,18 +24,21 @@
#include <zxing/Result.h>
namespace zxing {
namespace oned {
class EAN13Reader : public UPCEANReader {
private:
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();
};
}
namespace oned {
class EAN13Reader : public UPCEANReader {
private:
static bool determineFirstDigit(std::string& resultString, int lgPatternFound);
public:
EAN13Reader();
int decodeMiddle(Ref<BitArray> row, int startGuardBegin, int startGuardEnd,
std::string& resultString);
BarcodeFormat getBarcodeFormat();
};
}
}
#endif

View file

@ -2,7 +2,6 @@
* 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");
@ -22,41 +21,53 @@
#include <zxing/ReaderException.h>
namespace zxing {
namespace oned {
EAN8Reader::EAN8Reader(){ }
int EAN8Reader::decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString){
const int countersLen = 4;
int counters[countersLen] = { 0, 0, 0, 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;
}
}
namespace oned {
EAN8Reader::EAN8Reader(){ }
int EAN8Reader::decodeMiddle(Ref<BitArray> row, int startGuardBegin, int startGuardEnd,
std::string& resultString){
const int countersLen = 4;
int counters[countersLen] = { 0, 0, 0, 0 };
int end = row->getSize();
int rowOffset = startGuardEnd;
for (int x = 0; x < 4 && rowOffset < end; x++) {
int bestMatch = decodeDigit(row, counters, countersLen, rowOffset,
UPC_EAN_PATTERNS_L_PATTERNS);
if (bestMatch < 0) {
return -1;
}
resultString.append(1, (char) ('0' + bestMatch));
for (int i = 0; i < countersLen; i++) {
rowOffset += counters[i];
}
}
int middleRangeStart;
int middleRangeEnd;
if (findGuardPattern(row, rowOffset, true, (int*)getMIDDLE_PATTERN(),
getMIDDLE_PATTERN_LEN(), &middleRangeStart, &middleRangeEnd)) {
rowOffset = middleRangeEnd;
for (int x = 0; x < 4 && rowOffset < end; x++) {
int bestMatch = decodeDigit(row, counters, countersLen, rowOffset,
UPC_EAN_PATTERNS_L_PATTERNS);
if (bestMatch < 0) {
return -1;
}
resultString.append(1, (char) ('0' + bestMatch));
for (int i = 0; i < countersLen; i++) {
rowOffset += counters[i];
}
}
return rowOffset;
}
return -1;
}
BarcodeFormat EAN8Reader::getBarcodeFormat(){
return BarcodeFormat_EAN_8;
}
}
}

View file

@ -1,8 +1,10 @@
#ifndef __EAN_8_READER_H__
#define __EAN_8_READER_H__
/*
* 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");
@ -22,15 +24,18 @@
#include <zxing/Result.h>
namespace zxing {
namespace oned {
class EAN8Reader : public UPCEANReader {
public:
EAN8Reader();
int decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString); //throws ReaderException
BarcodeFormat getBarcodeFormat();
};
}
namespace oned {
class EAN8Reader : public UPCEANReader {
public:
EAN8Reader();
int decodeMiddle(Ref<BitArray> row, int startGuardBegin, int startGuardEnd,
std::string& resultString);
BarcodeFormat getBarcodeFormat();
};
}
}
#endif

View file

@ -2,7 +2,6 @@
* 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");
@ -25,339 +24,344 @@
#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;
try {
endRange = decodeEnd(row);
} catch (Exception e) {
delete [] startRange;
throw e;
}
std::string tmpResult;
try {
decodeMiddle(row, startRange[1], endRange[0], tmpResult);
} catch (zxing::ReaderException re) {
delete [] startRange;
delete [] endRange;
throw re;
}
// 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) {
delete [] startRange;
delete [] endRange;
throw ReaderException("not enough 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[counterDigitPairLen];
for (int i=0; i<counterDigitPairLen; i++) {
counterDigitPair[i] = 0;
}
int counterBlack[5];
int counterWhite[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];
}
}
}
/**
* 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){
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_LEN = 10;
const int DEFAULT_ALLOWED_LENGTHS[DEFAULT_ALLOWED_LENGTHS_LEN] = { 44, 24, 20, 18, 16, 14, 12, 10, 8, 6 };
/**
* 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) {
int* startRange = 0;
int* endRange = 0;
try {
// Find out where the Middle section (payload) starts & ends
startRange = decodeStart(row);
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 a known length
int length = tmpResult.length();
bool lengthOK = false;
for (int i = 0; i < DEFAULT_ALLOWED_LENGTHS_LEN; i++) {
if (length == DEFAULT_ALLOWED_LENGTHS[i]) {
lengthOK = true;
break;
}
}
if (!lengthOK) {
throw ReaderException("not enough 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;
delete [] startRange;
delete [] endRange;
ArrayRef<unsigned char> resultBytes(1);
return Ref<Result>(new Result(resultString, resultBytes, resultPoints, BarcodeFormat_ITF));
} catch (ReaderException& re) {
delete [] startRange;
delete [] endRange;
return Ref<Result>();
}
}
/**
* @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[counterDigitPairLen];
for (int i=0; i<counterDigitPairLen; i++) {
counterDigitPair[i] = 0;
}
int counterBlack[5];
int counterWhite[5];
for (int i=0; i<5; i++) {
counterBlack[i] = 0;
counterWhite[i] = 0;
}
while (payloadStart < payloadEnd) {
// Get 10 runs of black/white.
if (!recordPattern(row, payloadStart, counterDigitPair, counterDigitPairLen)) {
throw ReaderException("");
}
// 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];
}
}
}
/**
* 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);
int* startPattern = 0;
try {
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;
} catch (ReaderException& re) {
delete [] startPattern;
throw re;
}
}
/**
* 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();
int* endPattern = 0;
try {
int endStart = skipWhiteSpace(row);
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;
row->reverse();
return endPattern;
} catch (ReaderException& re) {
delete [] endPattern;
row->reverse();
throw re;
}
}
/**
* 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[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){
unsigned 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];
for(int ind = 0; ind<countersLen; ind++){
pattern[ind] = PATTERNS[i][ind];
}
unsigned int variance = patternMatchVariance(counters, countersLen, pattern, MAX_INDIVIDUAL_VARIANCE);
if (variance < bestVariance) {
bestVariance = variance;
bestMatch = i;
}
}
if (bestMatch >= 0) {
return bestMatch;
} else {
throw ReaderException("digit didint found");
}
}
ITFReader::~ITFReader(){
}
}
// 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[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){
unsigned 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];
for(int ind = 0; ind<countersLen; ind++){
pattern[ind] = PATTERNS[i][ind];
}
unsigned int variance = patternMatchVariance(counters, countersLen, pattern,
MAX_INDIVIDUAL_VARIANCE);
if (variance < bestVariance) {
bestVariance = variance;
bestMatch = i;
}
}
if (bestMatch >= 0) {
return bestMatch;
} else {
throw ReaderException("digit didint found");
}
}
ITFReader::~ITFReader(){
}
}
}

View file

@ -1,8 +1,10 @@
#ifndef __ITF_READER_H__
#define __ITF_READER_H__
/*
* 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");
@ -27,9 +29,10 @@ namespace zxing {
class ITFReader : public OneDReader {
private:
static const unsigned int MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f);
static const int MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.8f);
//static const unsigned int MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f);
enum {MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f)};
//static const int MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.8f);
enum {MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.8f)};
// Stores the actual narrow line width of the image being decoded.
int narrowLineWidth;
@ -51,3 +54,4 @@ namespace zxing {
}
}
#endif

View file

@ -2,7 +2,6 @@
* 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");
@ -27,25 +26,41 @@
#include <zxing/ReaderException.h>
namespace zxing {
namespace oned {
MultiFormatOneDReader::MultiFormatOneDReader() : readers() {
readers.push_back(Ref<OneDReader>(new MultiFormatUPCEANReader()));
readers.push_back(Ref<OneDReader>(new Code39Reader()));
readers.push_back(Ref<OneDReader>(new Code128Reader()));
readers.push_back(Ref<OneDReader>(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");
}
}
namespace oned {
MultiFormatOneDReader::MultiFormatOneDReader(DecodeHints hints) : readers() {
if (hints.containsFormat(BarcodeFormat_EAN_13) ||
hints.containsFormat(BarcodeFormat_EAN_8) ||
hints.containsFormat(BarcodeFormat_UPC_A) ||
hints.containsFormat(BarcodeFormat_UPC_E)) {
readers.push_back(Ref<OneDReader>(new MultiFormatUPCEANReader(hints)));
}
if (hints.containsFormat(BarcodeFormat_CODE_39)) {
readers.push_back(Ref<OneDReader>(new Code39Reader()));
}
if (hints.containsFormat(BarcodeFormat_CODE_128)) {
readers.push_back(Ref<OneDReader>(new Code128Reader()));
}
if (hints.containsFormat(BarcodeFormat_ITF)) {
readers.push_back(Ref<OneDReader>(new ITFReader()));
}
if (readers.size() == 0) {
readers.push_back(Ref<OneDReader>(new MultiFormatUPCEANReader(hints)));
readers.push_back(Ref<OneDReader>(new Code39Reader()));
readers.push_back(Ref<OneDReader>(new Code128Reader()));
readers.push_back(Ref<OneDReader>(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];
Ref<Result> result = reader->decodeRow(rowNumber, row);
if (!result.empty()) {
return result;
}
}
return Ref<Result>();
}
}
}

View file

@ -1,9 +1,10 @@
#ifndef __MULTI_FORMAT_ONED_READER_H__
#define __MULTI_FORMAT_ONED_READER_H__
/*
* MultiFormatOneDReader.h
* ZXing
*
* Created by Lukasz Warchol on 10-01-25.
* Copyright 2010 ZXing authors All rights reserved.
* 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.
@ -19,19 +20,19 @@
*/
#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<Ref<OneDReader> > readers;
public:
MultiFormatOneDReader();
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
};
}
namespace oned {
class MultiFormatOneDReader : public OneDReader {
private:
std::vector<Ref<OneDReader> > readers;
public:
MultiFormatOneDReader(DecodeHints hints);
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
};
}
}
#endif

View file

@ -2,7 +2,6 @@
* 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");
@ -22,53 +21,67 @@
#include <zxing/oned/EAN13Reader.h>
#include <zxing/oned/EAN8Reader.h>
#include <zxing/oned/UPCEReader.h>
#include <zxing/oned/UPCAReader.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() {
readers.push_back(Ref<OneDReader>(new EAN13Reader()));
// UPC-A is covered by EAN-13
readers.push_back(Ref<OneDReader>(new EAN8Reader()));
readers.push_back(Ref<OneDReader>(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++) {
Ref<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) {
const 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");
}
}
namespace oned {
MultiFormatUPCEANReader::MultiFormatUPCEANReader(DecodeHints hints) : readers() {
if (hints.containsFormat(BarcodeFormat_EAN_13)) {
readers.push_back(Ref<OneDReader>(new EAN13Reader()));
} else if (hints.containsFormat(BarcodeFormat_UPC_A)) {
readers.push_back(Ref<OneDReader>(new UPCAReader()));
}
if (hints.containsFormat(BarcodeFormat_EAN_8)) {
readers.push_back(Ref<OneDReader>(new EAN8Reader()));
}
if (hints.containsFormat(BarcodeFormat_UPC_E)) {
readers.push_back(Ref<OneDReader>(new UPCEReader()));
}
if (readers.size() == 0) {
readers.push_back(Ref<OneDReader>(new EAN13Reader()));
// UPC-A is covered by EAN-13
readers.push_back(Ref<OneDReader>(new EAN8Reader()));
readers.push_back(Ref<OneDReader>(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++) {
Ref<OneDReader> reader = readers[i];
Ref<Result> result = reader->decodeRow(rowNumber, row);
if (result.empty()) {
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) {
const 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;
}
return Ref<Result>();
}
}
}

View file

@ -1,8 +1,9 @@
#ifndef __MULTI_FORMAT_UPC_EAN_READER_H__
#define __MULTI_FORMAT_UPC_EAN_READER_H__
/*
* 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");
@ -17,23 +18,21 @@
* 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<Ref<OneDReader> > readers;
public:
MultiFormatUPCEANReader();
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
namespace oned {
class MultiFormatUPCEANReader : public OneDReader {
private:
std::vector<Ref<OneDReader> > readers;
public:
MultiFormatUPCEANReader(DecodeHints hints);
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
};
}
}
}
#endif

View file

@ -2,7 +2,6 @@
* 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");
@ -25,181 +24,183 @@
#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;
}catch (IllegalArgumentException 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.
std::vector<Ref<ResultPoint> > points(result->getResultPoints());
if (points.size() == 2) {
Ref<ResultPoint> pointZero(new OneDResultPoint(width - points[0]->getX() - 1, points[0]->getY()));
points[0] = pointZero;
namespace oned {
using namespace std;
Ref<ResultPoint> pointOne(new OneDResultPoint(width - points[1]->getX() - 1, points[1]->getY()));
points[1] = pointOne;
OneDReader::OneDReader() {
}
result.reset(new Result(result->getText(),result->getRawBytes(),points,result->getBarcodeFormat()));
}
}
return result;
} catch (ReaderException re) {
// continue -- just couldn't decode this row
}
}
}
throw ReaderException("doDecode() failed");
}
unsigned int OneDReader::patternMatchVariance(int counters[], int countersSize, const int pattern[], int maxIndividualVariance) {
int numCounters = countersSize;
unsigned int total = 0;
unsigned 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"
unsigned int unitBarWidth = (total << INTEGER_MATH_SHIFT) / patternLength;
maxIndividualVariance = (maxIndividualVariance * unitBarWidth) >> INTEGER_MATH_SHIFT;
unsigned 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() {
}
}
Ref<Result> OneDReader::decode(Ref<BinaryBitmap> image, DecodeHints hints) {
Ref<Result> result = doDecode(image, hints);
if (result.empty() && hints.getTryHarder() && image->isRotateSupported()) {
Ref<BinaryBitmap> rotatedImage(image->rotateCounterClockwise());
result = doDecode(rotatedImage, hints);
if (!result.empty()) {
/*
// 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
std::vector<Ref<ResultPoint> > points (result->getResultPoints());
int height = rotatedImage->getHeight();
for (size_t i = 0; i < points.size(); i++) {
points[i].reset(new OneDResultPoint(height - points[i]->getY() - 1, points[i]->getX()));
}
}
}
if (result.empty()) {
throw ReaderException("");
}
return result;
}
Ref<Result> OneDReader::doDecode(Ref<BinaryBitmap> image, DecodeHints hints) {
int width = image->getWidth();
int height = image->getHeight();
Ref<BitArray> row(new BitArray(width));
int middle = height >> 1;
bool tryHarder = hints.getTryHarder();
int rowStep = (int)fmax(1, height >> (tryHarder ? 8 : 5));
int maxLines;
if (tryHarder) {
maxLines = height; // Look at the whole image, not just the center
} else {
maxLines = 15; // 15 rows spaced 1/32 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;
} catch (IllegalArgumentException& 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) {
row->reverse(); // reverse the row and continue
}
// Look for a barcode
Ref<Result> result = decodeRow(rowNumber, row);
// We found our barcode
if (!result.empty()) {
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.
std::vector<Ref<ResultPoint> > points(result->getResultPoints());
// if there's exactly two points (which there should be), flip the x coordinate
// if there's not exactly 2, I don't know what do do with it
if (points.size() == 2) {
Ref<ResultPoint> pointZero(new OneDResultPoint(width - points[0]->getX() - 1,
points[0]->getY()));
points[0] = pointZero;
Ref<ResultPoint> pointOne(new OneDResultPoint(width - points[1]->getX() - 1,
points[1]->getY()));
points[1] = pointOne;
result.reset(new Result(result->getText(), result->getRawBytes(), points,
result->getBarcodeFormat()));
}
}
return result;
}
}
}
return Ref<Result>();
}
unsigned int OneDReader::patternMatchVariance(int counters[], int countersSize,
const int pattern[], int maxIndividualVariance) {
int numCounters = countersSize;
unsigned int total = 0;
unsigned 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"
unsigned int unitBarWidth = (total << INTEGER_MATH_SHIFT) / patternLength;
maxIndividualVariance = (maxIndividualVariance * unitBarWidth) >> INTEGER_MATH_SHIFT;
unsigned 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;
}
bool 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) {
return false;
}
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))) {
return false;
}
return true;
}
OneDReader::~OneDReader() {
}
}
}

View file

@ -1,8 +1,10 @@
#ifndef __ONED_READER_H__
#define __ONED_READER_H__
/*
* 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");
@ -18,29 +20,31 @@
* 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);
Ref<Result> doDecode(Ref<BinaryBitmap> image, DecodeHints hints);
public:
static const int PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 << INTEGER_MATH_SHIFT;
OneDReader();
virtual Ref<Result> decode(Ref<BinaryBitmap> image);
virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
// Implementations must not throw any exceptions. If a barcode is not found on this row,
// a empty ref should be returned e.g. return Ref<Result>();
virtual Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row) = 0;
static unsigned int patternMatchVariance(int counters[], int countersSize, const int pattern[], int maxIndividualVariance);
static void recordPattern(Ref<BitArray> row, int start, int counters[], int countersCount);
static unsigned int patternMatchVariance(int counters[], int countersSize,
const int pattern[], int maxIndividualVariance);
static bool recordPattern(Ref<BitArray> row, int start, int counters[], int countersCount);
virtual ~OneDReader();
};
}
}
#endif

View file

@ -2,7 +2,6 @@
* 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");
@ -22,14 +21,14 @@
namespace zxing {
namespace oned {
OneDResultPoint::OneDResultPoint(float posX, float posY) : posX_(posX), posY_(posY){
OneDResultPoint::OneDResultPoint(float posX, float posY) : posX_(posX), posY_(posY) {
}
float OneDResultPoint::getX() const {
return posX_;
}
float OneDResultPoint::getY() const {
return posY_;
}

View file

@ -1,8 +1,9 @@
#ifndef __ONED_RESULT_POINT_H__
#define __ONED_RESULT_POINT_H__
/*
* OneDResultPoint.h
* 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");
@ -35,3 +36,5 @@ namespace zxing {
};
}
}
#endif

View file

@ -2,7 +2,6 @@
* UPCAReader.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");
@ -22,38 +21,45 @@
#include <zxing/ReaderException.h>
namespace zxing {
namespace oned {
UPCAReader::UPCAReader() : ean13Reader() {
}
Ref<Result> UPCAReader::decodeRow(int rowNumber, Ref<BitArray> row){
return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row));
}
Ref<Result> UPCAReader::decodeRow(int rowNumber, Ref<BitArray> row, int startGuardRange[]){
return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, startGuardRange));
}
Ref<Result> UPCAReader::decode(Ref<BinaryBitmap> image){
return maybeReturnResult(ean13Reader.decode(image));
}
int UPCAReader::decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString){
return ean13Reader.decodeMiddle(row, startRange, startRangeLen, resultString);
}
Ref<Result> UPCAReader::maybeReturnResult(Ref<Result> result){
const 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;
} else {
throw ReaderException("Not UPC-A barcode.");
}
}
namespace oned {
UPCAReader::UPCAReader() : ean13Reader() {
}
BarcodeFormat UPCAReader::getBarcodeFormat(){
return BarcodeFormat_UPC_A;
}
}
Ref<Result> UPCAReader::decodeRow(int rowNumber, Ref<BitArray> row) {
return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row));
}
Ref<Result> UPCAReader::decodeRow(int rowNumber, Ref<BitArray> row, int startGuardBegin,
int startGuardEnd) {
return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, startGuardBegin,
startGuardEnd));
}
Ref<Result> UPCAReader::decode(Ref<BinaryBitmap> image, DecodeHints hints) {
return maybeReturnResult(ean13Reader.decode(image, hints));
}
int UPCAReader::decodeMiddle(Ref<BitArray> row, int startGuardBegin, int startGuardEnd,
std::string& resultString) {
return ean13Reader.decodeMiddle(row, startGuardBegin, startGuardEnd, resultString);
}
Ref<Result> UPCAReader::maybeReturnResult(Ref<Result> result) {
if (result.empty()) {
return result;
}
const 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 Ref<Result>();
}
BarcodeFormat UPCAReader::getBarcodeFormat(){
return BarcodeFormat_UPC_A;
}
}
}

View file

@ -1,8 +1,9 @@
#ifndef __UPCA_READER_H__
#define __UPCA_READER_H__
/*
* UPCAReader.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");
@ -19,25 +20,30 @@
*/
#include <zxing/oned/EAN13Reader.h>
#include <zxing/DecodeHints.h>
namespace zxing {
namespace oned {
class UPCAReader : public UPCEANReader {
private:
EAN13Reader ean13Reader;
static Ref<Result> maybeReturnResult(Ref<Result> result); //throws ReaderException
public:
UPCAReader();
int decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString); //throws ReaderException
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row); //throws ReaderException
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row, int startGuardRange[]); //throws ReaderException
Ref<Result> decode(Ref<BinaryBitmap> image);
BarcodeFormat getBarcodeFormat();
};
}
namespace oned {
class UPCAReader : public UPCEANReader {
private:
EAN13Reader ean13Reader;
static Ref<Result> maybeReturnResult(Ref<Result> result);
public:
UPCAReader();
int decodeMiddle(Ref<BitArray> row, int startGuardBegin, int startGuardEnd,
std::string& resultString);
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row, int startGuardBegin,
int startGuardEnd);
Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
BarcodeFormat getBarcodeFormat();
};
}
}
#endif

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