Home » Source Code » QR code recognition » AlignmentPattern.cpp

AlignmentPattern.cpp ( File view )

  • By 鬼屋里的小鬼头 2013-11-28
  • View(s):159
  • Download(s):9
  • Point(s): 3
			// AlignmentPattern.cpp: implementation of the AlignmentPattern class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "QRcodeDecoder.h"
#include "AlignmentPattern.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

AlignmentPattern::AlignmentPattern()
{



}

AlignmentPattern::~AlignmentPattern()
{



}

//校正图形检测
void AlignmentPattern::findAlignmentPattern(BYTE ** mybitmap, int mynWidth, int mynHeight, FinderPattern * finderPattern, int myDECIMAL_POINT) 
{

	DECIMAL_POINT=myDECIMAL_POINT;
	bitmap=mybitmap;
	nWidth=mynWidth;
	nHeight=mynHeight;
	m_finderPattern=finderPattern;

	getLogicalCenter(m_finderPattern);

	logicalDistance = logicalCenters[1][0].x - logicalCenters[0][0].x;

	//With it converts in order to handle in the same way
	getCenter();

	//return new AlignmentPattern(centers, logicalDistance);


}

//get logical center coordinates of each alignment patterns
void AlignmentPattern::getLogicalCenter(FinderPattern * finderPattern)
{


	//get logical center coordinates of each alignment patterns
	int version = finderPattern->m_version;

	int logicalSeedsCnt;
	logicalSeedsCnt=QR_VersonInfo[version].ncAlignPoint+1;
	int * logicalSeeds=new int[logicalSeedsCnt];
	logicalSeeds[0]=6;
	for(int i=1;i<logicalSeedsCnt;i++)
		logicalSeeds[i]=QR_VersonInfo[version].nAlignPoint[i-1];
	
	logicalCenters = new Point *[logicalSeedsCnt];
	for(i=0;i<logicalSeedsCnt;i++)
		logicalCenters[i]=new Point[logicalSeedsCnt];
	//Point[][] logicalCenters = new Point[logicalSeeds.length][logicalSeeds.length];
	
	//create real relative coordinates
	for (int col = 0; col < logicalSeedsCnt; col++)
	{

		for (int row = 0; row < logicalSeedsCnt; row++)
		{

			logicalCenters[row][col] = Point(logicalSeeds[row], logicalSeeds[col]);
		
}
	
}
	logicalCentersCnt=logicalSeedsCnt;
	

}

void AlignmentPattern::getCenter() 
{

	int moduleSize = m_finderPattern->m_moduleSize[UL];

	int * angle=m_finderPattern->m_sincos;
	Axis axis = Axis(angle, moduleSize, DECIMAL_POINT);
	
	m_centersCnt = logicalCentersCnt;
	m_centers = new Point *[m_centersCnt];
	for(int i=0;i<m_centersCnt;i++)
		m_centers[i]=new Point[m_centersCnt];
	//Point[][] centers = new Point[m_centersCnt][m_centersCnt];
	
	axis.setOrigin(m_finderPattern->m_center[UL]);
	m_centers[0][0] = axis.translate(3, 3);

	axis.setOrigin(m_finderPattern->m_center[UR]);
	m_centers[m_centersCnt - 1][0] = axis.translate(-3, 3);

	axis.setOrigin(m_finderPattern->m_center[DL]);
	m_centers[0][m_centersCnt - 1] = axis.translate(3, -3);

	Point tmpPoint=m_centers[0][0];

	for (int y = 0; y < m_centersCnt; y++)
	{

		for (int x = 0; x < m_centersCnt; x++)
		{

			if ((x==0 && y==0) || (x==0 && y==m_centersCnt-1) || (x==m_centersCnt-1 && y==0))
			{

				continue;
			
}
			Point target;
			if (y == 0)
			{

				if (x > 0 && x < m_centersCnt - 1)
				{

					target = axis.translate(m_centers[x-1][y], logicalCenters[x][y].x-logicalCenters[x-1][y].x, 0);
					m_centers[x][y] = Point(target.x, target.y);
				
}
			
}
			else if (x == 0)
			{

				if (y > 0 && y < m_centersCnt - 1)
				{

					target = axis.translate(m_centers[x][y-1], 0, logicalCenters[x][y].y-logicalCenters[x][y-1].y);
					m_centers[x][y] = Point(target.x, target.y);
				
}
			
}
			else
			{

				Point t1 = axis.translate(m_centers[x-1][y], logicalCenters[x][y].x-logicalCenters[x-1][y].x, 0);
				Point t2 = axis.translate(m_centers[x][y-1], 0, logicalCenters[x][y].y-logicalCenters[x][y-1].y);
				m_centers[x][y] = Point((t1.x+t2.x)/2, (t1.y + t2.y)/2+1);
			
}
			if (m_finderPattern->m_version > 1)
			{

				Point precisionCenter = getPrecisionCenter(m_centers[x][y]);

				int dx = precisionCenter.x - m_centers[x][y].x;
				int dy = precisionCenter.y - 
...
...
(Please download the complete source code to view)
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 3

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
AlignmentPattern.cpp5.98 kB03-05-08|13:29
AlignmentPattern.h1.12 kB03-05-08|11:41
Axis.cpp1.98 kB03-05-08|01:14
Axis.h985.00 B03-05-08|08:47
ContentDecoder.cpp15.82 kB03-05-08|13:30
ContentDecoder.h2.19 kB03-05-08|13:11
FinderPattern.cpp15.89 kB03-05-08|10:35
FinderPattern.h1.58 kB03-05-08|10:34
Galois.cpp3.21 kB23-04-08|22:02
Galois.h950.00 B22-04-08|23:35
Line.cpp2.91 kB02-05-08|18:27
Line.h1.08 kB03-05-08|08:47
Point.cpp1.14 kB02-05-08|20:38
Point.h788.00 B02-05-08|20:39
QRcodeDecoder.aps21.07 kB04-05-08|12:13
QRcodeDecoder.clw2.15 kB04-05-08|12:14
QRcodeDecoder.cpp2.11 kB16-03-08|11:33
QRcodeDecoder.dsp5.46 kB03-05-08|10:58
QRcodeDecoder.dsw551.00 B16-03-08|11:33
QRcodeDecoder.h1.37 kB16-03-08|11:33
QRcodeDecoder.ncb145.00 kB04-05-08|12:14
QRcodeDecoder.opt60.50 kB04-05-08|12:14
QRcodeDecoder.plg3.74 kB04-05-08|12:14
QRcodeDecoder.rc5.64 kB04-05-08|12:12
QRcodeDecoderDlg.cpp5.97 kB03-05-08|13:05
QRcodeDecoderDlg.h1.76 kB03-05-08|12:41
QRcodeImage.cpp13.62 kB04-05-08|11:45
QRcodeImage.h1.39 kB04-05-08|11:44
ReadMe.txt3.62 kB16-03-08|11:33
QRcodeDecoder.ico1.05 kB04-05-08|12:12
QRcodeDecoder.rc2405.00 B16-03-08|11:33
resource.h921.00 B23-03-08|21:29
RsDecode.cpp6.83 kB23-04-08|23:25
RsDecode.h947.00 B03-05-08|08:48
SamplingGrid.cpp2.83 kB03-05-08|12:30
SamplingGrid.h1.85 kB03-05-08|11:19
StdAfx.cpp13.37 kB03-05-08|13:29
StdAfx.h2.16 kB03-05-08|09:27
res0.00 B03-05-08|13:31
QRcodeDecoder0.00 B04-05-08|12:14
...
Sponsored links

AlignmentPattern.cpp (73.97 kB)

Need 3 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D