readbarcode.cpp

来自「barcode readers [ from Image]」· C++ 代码 · 共 140 行

CPP
140
字号
/*
	CReadBarcode. Given an image, decode all the barcodes in it
	and show the first one found to the user.
	This code is a derivative work of the SnapShot example
	application distributed with the Symbian 6.0 SDK.
	Copyright (C) 2006  Jon A. Webb

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

*/

#include "ReadBarcode.h"

#include "Bars2SymFactory.h"
#include "Bars2SymUpc.h"
#include "CannyHoriz.h"
#include "Crop.h"
#include "Debug.h"
#include "GrayIndex.h"
#include "HistEq.h"
#include "ImageSize.h"
#include "ImageType.h"
#include "LineFitHough.h"
#include "RectStretch.h"
#include "Reduce.h"
#include "Replicate.h"
#include "Rgb4k216M.h"
#include "Rgb64k216M.h"
#include "RgbAvg2Gray.h"
#include "RgbSelectBand.h"
#include "Sequence.h"
#include "TrapezoidWarp.h"
#include "VerticalAverage.h"
#include "ZeroCrossingHoriz.h"

#include <aknnotewrappers.h>
#include <baclipb.h>
#include <gdi.h>
#include <w32std.h>

using namespace Algorithm;
using namespace Barcode;
using namespace Core;

//
// Cleanup Support functions
//
// Needed for CleanupDeletePushL to work
//
// Note: if you don't define these functions, the program will still compile
// and run on the emulator, but won't run on the phone -- annoying!
//
void CleanupDelete<CArray<CArrayFixFlat<TReal>*> >::Delete(TAny *ptr)
{
	CArray<CArrayFixFlat<TReal>*>* pArray = (CArray<CArrayFixFlat<TReal>*>*) ptr;
	TInt i;
	for (i=0; i<pArray->Count(); i++) {
		if ((*pArray)[i]) {
			(*pArray)[i]->Reset();
			delete (*pArray)[i];
			(*pArray)[i] = NULL;
		}
	}
	delete pArray;
}

void CleanupDelete<CArrayFixFlat<TPoint> >::Delete(TAny *ptr)
{
	CArrayFixFlat<TPoint>* pArray = (CArrayFixFlat<TPoint>*) ptr;
	pArray->Reset();
	delete pArray;
}

/*!
  @function CReadBarcode
  
  @discussion Perform the first phase of two phase construction 
  */
	CReadBarcode::CReadBarcode() :
		iBars2SymFactory(NULL)
	{
	}

/*!
  @function CReadBarcode
  
  @discussion Perform the second phase of two phase construction 
  */
	CReadBarcode* CReadBarcode::NewL()
	{
		CReadBarcode* pMe = new (ELeave) CReadBarcode;
		CleanupStack::PushL(pMe);
		pMe->ConstructL();
		CleanupStack::Pop(pMe);
		return pMe;
	}

	/*!
		@function ConstructL
		  
		@discussion  Perform the second phase construction of a CReadBarCAppView object
    */
	void CReadBarcode::ConstructL()
	{
		//iBars2SymFactory = Barcode::CBars2SymFactory::NewL();
		User::LeaveIfError(iFsSession.Connect());
	}


	/*!
		@function Destructor
		  
		@discussion Destructor
    */
	CReadBarcode::~CReadBarcode()
	{
		//delete iBars2SymFactory;
		iBars2SymFactory = NULL;
		iFsSession.Close();
	}

	/*! @function CropAndDetectEdgesL
	  @discussion
	   We begin by converting the image from the color image captured by the 
	   camera phone sensor to gray. This is done using an image processing pipeline.
	   The first stage of the pipeline uses the CRgbSelectBand class to select the 
	   green band of the image. The green band is used because inexpensive color sensors 
	   capture color images using a pixel layout called a 揃ayer mosaic

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?