#include "StdAfx.h"
|
#include "PitchStat.h"
|
|
#include "MosisBuffer/MosisBuffer.h"
|
#include "MosisAssem/AssemUtil.h"
|
#include "MosisAssem/AssemParam.h"
|
|
|
#define SPR_SHIFT 4
|
#define SPR_MULTI 16
|
|
CPitchStat::CPitchStat(void)
|
{
|
m_IntervalStore = 16;
|
m_iStartPitch = m_iEndPitch = 0;
|
m_IntervalStore = m_IntervalSearch = 16;
|
}
|
|
CPitchStat::~CPitchStat(void)
|
{
|
}
|
BOOL CPitchStat::CheckFluidPitch(CMosisBuffer &buff, CRect &rect, stPitchParam & PitchParam)
|
{
|
return CheckFluidPitch(buff.GetDataAddress(), buff.GetDataWidth(), buff.GetHeight(), rect, PitchParam);
|
}
|
BOOL CPitchStat::CheckDynamicPitch(CMosisBuffer &buff, CRect &rect, stPitchParam & PitchParam)
|
{
|
return CheckDynamicPitch(buff.GetDataAddress(), buff.GetDataWidth(), buff.GetHeight(), rect, PitchParam);
|
}
|
double CPitchStat::CheckOnePitch(CMosisBuffer &buff, CRect &rect, stPitchParam & PitchParam)
|
{
|
return CheckOnePitch(buff.GetDataAddress(), buff.GetDataWidth(), buff.GetHeight(), rect, PitchParam);
|
}
|
BOOL CPitchStat::CheckTilt(CMosisBuffer &buff, CRect &rect, stPitchParam &PitchParam, double &pitch, double &tilt)
|
{
|
return CheckTilt(buff.GetDataAddress(), buff.GetDataWidth(), buff.GetHeight(), rect, PitchParam, pitch, tilt);
|
}
|
BOOL CPitchStat::CheckDynamicPitchWithTilt(CMosisBuffer &buff, CRect &rect, stPitchParam &PitchParam)
|
{
|
return CheckDynamicPitchWithTilt(buff.GetDataAddress(), buff.GetDataWidth(), buff.GetHeight(), rect, PitchParam);
|
}
|
BOOL CPitchStat::CheckDynamicTilt(CMosisBuffer &buff, CRect &rect, stPitchParam &PitchParam)
|
{
|
return CheckDynamicTilt(buff.GetDataAddress(), buff.GetDataWidth(), buff.GetHeight(), rect, PitchParam);
|
}
|
|
|
BOOL CPitchStat::CheckTilt(BYTE* pData, int BuffWidth, int BuffHeight, CRect &rect, stPitchParam &PitchParam, double &pitch, double &tilt)
|
{
|
ResetPitchStat();
|
int pitch16, tilt16;
|
|
if (PitchParam.Direction == stPitchParam::PP_HORIZONTAL)
|
{
|
ResetConBuff(rect.Width());
|
return TRUE;
|
}
|
|
ResetConBuff(rect.Height());
|
|
m_BasePitch16 = (int)(PitchParam.PitchStart * 16);
|
CAssemUtil::CheckPitchSmallVPT16((int)(PitchParam.PitchStart * 16), (int)(PitchParam.PitchEnd * 16), (int)(PitchParam.TiltStart * 16), (int)(PitchParam.TiltEnd * 16), rect.left, rect.left + PitchParam.Width, rect.top, rect.top + PitchParam.Height, pData, BuffWidth, PitchParam.ZeroBack, m_ConvBlock.GetDataAddr(), m_ConvBlock2.GetDataAddr(), pitch16, tilt16);
|
|
pitch = (double)pitch16 / SPR_MULTI;
|
tilt = (double)tilt16 / SPR_MULTI;
|
|
return TRUE;
|
}
|
|
BOOL CPitchStat::CheckDynamicPitchWithTilt(BYTE* pData, int BuffWidth, int BuffHeight, CRect &rect, stPitchParam &PitchParam)
|
{
|
ResetPitchStat();
|
int pitch16;
|
int offset, start, end;
|
int Interval = PitchParam.Interval;
|
Interval = Interval >> 4 << 4;
|
if (Interval < 16)
|
Interval = 16;
|
|
m_IntervalSearch = Interval;
|
|
if (PitchParam.Direction == stPitchParam::PP_HORIZONTAL)
|
{
|
ResetConBuff(rect.Width());
|
SetBlockSize(BuffWidth / m_IntervalStore + PITCHSTAT_PADDING);
|
|
return TRUE;
|
}
|
|
ResetConBuff(rect.Height());
|
SetBlockSize(BuffHeight / m_IntervalStore + PITCHSTAT_PADDING);
|
|
// right= rect.bottom- PitchParam.Height- SearchCount/16- 2- PitchParam.PitchEnd- PitchParam.Interval;
|
|
start = rect.top;
|
end = (int)(rect.bottom - PitchParam.Height - 4 - PitchParam.PitchEnd);
|
|
m_BasePitch16 = (int)(PitchParam.PitchStart * 16);
|
|
//#define MOSIS_DEBUG_PITCH_STEP
|
#if defined(MOSIS_DEBUG_PITCH_STEP)
|
BOOL bGivenStep = CAssemUtil::CheckPitchSmallVT_P16(PitchParam.PitchStart * 16, PitchParam.PitchEnd * 16, PitchParam.TiltStart * 16, rect.left, rect.left + PitchParam.Width, rect.top, rect.top + PitchParam.Height, pData, BuffWidth, PitchParam.ZeroBack, m_ConvBlock.GetDataAddr(), m_ConvBlock2.GetDataAddr(), pitch16, 16);
|
|
if (bGivenStep)
|
{
|
CAssemUtil::CheckPitchSmallVT_P16(pitch16 - 16, pitch16 + 16, PitchParam.TiltStart * 16, rect.left, rect.left + PitchParam.Width, rect.top, rect.top + PitchParam.Height, pData, BuffWidth, PitchParam.ZeroBack, m_ConvBlock.GetDataAddr(), m_ConvBlock2.GetDataAddr(), pitch16);
|
}
|
#else
|
CAssemUtil::CheckPitchSmallVT_P16((int)(PitchParam.PitchStart * 16), (int)(PitchParam.PitchEnd * 16), (int)(PitchParam.TiltStart * 16), rect.left, rect.left + PitchParam.Width, rect.top, rect.top + PitchParam.Height, pData, BuffWidth, PitchParam.ZeroBack, m_ConvBlock.GetDataAddr(), m_ConvBlock2.GetDataAddr(), pitch16);
|
#endif
|
|
SetPitchInfo(start, pitch16);
|
offset = start + Interval;
|
for (; offset < end; offset += Interval)
|
{
|
CAssemUtil::CheckPitchSmallVT_P16(pitch16 - 1, pitch16 + 1, (int)(PitchParam.TiltStart * 16), rect.left, rect.left + PitchParam.Width, offset, offset + PitchParam.Height, pData, BuffWidth, PitchParam.ZeroBack, m_ConvBlock.GetDataAddr(), m_ConvBlock2.GetDataAddr(), pitch16);
|
SetPitchInfo(offset, pitch16);
|
}
|
|
VerifyPitchInfo(start, offset - Interval, PitchParam.Expand, rect.bottom);
|
|
|
return TRUE;
|
}
|
|
BOOL CPitchStat::CheckDynamicTilt(BYTE* pData, int BuffWidth, int BuffHeight, CRect &rect, stPitchParam &PitchParam)
|
{
|
ResetPitchStat();
|
int pitch16, tilt16;
|
int offset, start, end;
|
int Interval = PitchParam.Interval;
|
Interval = Interval >> 4 << 4;
|
if (Interval < 16)
|
Interval = 16;
|
|
m_IntervalSearch = Interval;
|
|
if (PitchParam.Direction == stPitchParam::PP_HORIZONTAL)
|
{
|
ResetConBuff(rect.Width());
|
SetBlockSize(BuffWidth / m_IntervalStore + 2);
|
|
return TRUE;
|
}
|
|
ResetConBuff(rect.Height());
|
SetBlockSize(BuffHeight / m_IntervalStore + 2);
|
|
// right= rect.bottom- PitchParam.Height- SearchCount/16- 2- PitchParam.PitchEnd- PitchParam.Interval;
|
|
start = rect.top;
|
end = (int)(rect.bottom - PitchParam.Height - 4 - PitchParam.PitchEnd);
|
|
m_BasePitch16 = (int)(PitchParam.PitchStart * 16);
|
CAssemUtil::CheckPitchSmallVPT16((int)(PitchParam.PitchStart * 16), (int)(PitchParam.PitchEnd * 16), (int)(PitchParam.TiltStart * 16), (int)(PitchParam.TiltEnd * 16), rect.left, rect.left + PitchParam.Width, rect.top, rect.top + PitchParam.Height, pData, BuffWidth, PitchParam.ZeroBack, m_ConvBlock.GetDataAddr(), m_ConvBlock2.GetDataAddr(), pitch16, tilt16);
|
SetPitchInfo(start, tilt16);
|
offset = start + Interval;
|
for (; offset < end; offset += Interval)
|
{
|
CAssemUtil::CheckPitchSmallVPT16(pitch16 - 1, pitch16 + 1, tilt16 - 1, tilt16 + 1, rect.left, rect.left + PitchParam.Width, offset, offset + PitchParam.Height, pData, BuffWidth, PitchParam.ZeroBack, m_ConvBlock.GetDataAddr(), m_ConvBlock2.GetDataAddr(), pitch16, tilt16);
|
SetPitchInfo(offset, tilt16);
|
}
|
|
VerifyTiltInfo(start, offset - Interval, PitchParam.Expand, rect.bottom);
|
|
|
return TRUE;
|
}
|
|
void CPitchStat::ResetConBuff(int nSize)
|
{
|
if (nSize < 1) nSize = 1;
|
nSize = (nSize + 32) * 16; // vertÀÇ °æ¿ì 16¹èÀÇ Conv Buff°¡ ÇÊ¿äÇÏ´Ù.
|
|
m_ConvBlock.SetBlockSize(nSize);
|
m_ConvBlock2.SetBlockSize(nSize);
|
// memset(m_ConvBlock.GetDataAddr(), 0, m_ConvBlock.GetValidDataSpace()*sizeof(short));
|
// memset(m_ConvBlock2.GetDataAddr(), 0, m_ConvBlock2.GetValidDataSpace()*sizeof(short));
|
}
|
|
double CPitchStat::CheckOnePitch(BYTE* pData, int BuffWidth, int BuffHeight, CRect &rect, stPitchParam &PitchParam)
|
{
|
ResetPitchStat();
|
int iPitch16, iPitch, spr;
|
int Interval = PitchParam.Interval;
|
int Width = PitchParam.Width;
|
int Height = PitchParam.Height;
|
int SearchCount = (int)(PitchParam.GetPitchRange()*SPR_MULTI);
|
|
|
m_BasePitch16 = iPitch16 = (int)(PitchParam.GetMiddlePitch()*SPR_MULTI);
|
|
|
if (PitchParam.Direction == stPitchParam::PP_HORIZONTAL)
|
{
|
CAssemUtil::CheckPitchSmall16(iPitch16, SearchCount, rect.left, rect.top, Width, Height, pData, BuffWidth, PitchParam.ZeroBack, iPitch16, iPitch, spr);
|
return (double)iPitch16 / SPR_MULTI;
|
}
|
|
iPitch = iPitch16 / SPR_MULTI;
|
if (rect.top + iPitch + 2 + Height > rect.bottom)
|
{
|
// ¿µ¿ª ¹®Á¦ ¹ß»ý.. °Ë»ç¿¡ ¾²ÀÏ °ÍÀ̹ǷΠ·Î±× ³²±âÁö ¸øÇÔ.
|
return iPitch16 / SPR_MULTI;
|
}
|
|
|
CAssemUtil::CheckPitchSmallVert16(iPitch16, SearchCount, rect.left, rect.top, Width, Height, pData, BuffWidth, PitchParam.ZeroBack, iPitch16, iPitch, spr);
|
return (double)iPitch16 / SPR_MULTI;
|
|
}
|
BOOL CPitchStat::CheckDynamicPitch(BYTE* pData, int BuffWidth, int BuffHeight, CRect &rect, stPitchParam & PitchParam)
|
{
|
ResetPitchStat();
|
|
int right;
|
int iPitch16, iPitch, spr;
|
int x, left;
|
int Interval = PitchParam.Interval;
|
int Width = PitchParam.Width;
|
int Height = PitchParam.Height;
|
int SearchCount = (int)(PitchParam.GetPitchRange()*SPR_MULTI);
|
|
if (Interval < 1)
|
Interval = 1;
|
Interval = Interval >> 4 << 4;
|
m_IntervalSearch = Interval;
|
|
m_BasePitch16 = iPitch16 = (int)(PitchParam.GetMiddlePitch()*SPR_MULTI);
|
|
if (PitchParam.Direction == stPitchParam::PP_HORIZONTAL)
|
{
|
SetBlockSize(BuffWidth / m_IntervalStore + PITCHSTAT_PADDING);
|
right = (int)(rect.right - PitchParam.Width - SearchCount / SPR_MULTI - 2 - PitchParam.PitchEnd);//- PitchParam.Interval;
|
x = left = (rect.left) >> SPR_SHIFT << SPR_SHIFT;
|
|
CAssemUtil::CheckPitchSmall16(iPitch16, SearchCount, x, rect.top, Width, Height, pData, BuffWidth, PitchParam.ZeroBack, iPitch16, iPitch, spr);
|
SetPitchInfo(x, iPitch16);
|
|
for (x += Interval; x < right; x += Interval)
|
{
|
CAssemUtil::CheckPitchSmall16(iPitch16, 2, x, rect.top, Width, Height, pData, BuffWidth, PitchParam.ZeroBack, iPitch16, iPitch, spr);
|
SetPitchInfo(x, iPitch16);
|
}
|
VerifyPitchInfo(left, x - Interval, PitchParam.Expand, rect.right);
|
return TRUE;
|
}
|
|
// Vertical
|
SetBlockSize(BuffHeight / m_IntervalStore + PITCHSTAT_PADDING);
|
right = (int)(rect.bottom - PitchParam.Height - SearchCount / SPR_MULTI - 2 - PitchParam.PitchEnd);
|
x = left = (rect.top) >> SPR_SHIFT << SPR_SHIFT;
|
|
CAssemUtil::CheckPitchSmallVert16(iPitch16, SearchCount, rect.left, x, Width, Height, pData, BuffWidth, PitchParam.ZeroBack, iPitch16, iPitch, spr);
|
SetPitchInfo(x, iPitch16);
|
|
for (x += Interval; x < right; x += Interval)
|
{
|
CAssemUtil::CheckPitchSmallVert16(iPitch16, 2, rect.left, x, Width, Height, pData, BuffWidth, PitchParam.ZeroBack, iPitch16, iPitch, spr);
|
SetPitchInfo(x, iPitch16);
|
}
|
VerifyPitchInfo(left, x - Interval, PitchParam.Expand, rect.bottom);
|
return TRUE;
|
}
|
|
|
BOOL CPitchStat::CheckFluidPitch(BYTE* pData, int BuffWidth, int BuffHeight, CRect &rect, stPitchParam & PitchParam)
|
{
|
ResetPitchStat();
|
|
int right;
|
int iPitch16, iPitch, spr;
|
int x, left;
|
int Interval = PitchParam.Interval;
|
int Width = PitchParam.Width;
|
int Height = PitchParam.Height;
|
int SearchCount = (int)(PitchParam.GetPitchRange()*SPR_MULTI);
|
|
if (Interval < 16)
|
Interval = 16;
|
Interval = Interval >> 4 << 4;
|
m_IntervalSearch = Interval;
|
|
m_BasePitch16 = iPitch16 = (int)(PitchParam.GetMiddlePitch()*SPR_MULTI);
|
|
if (PitchParam.Direction == stPitchParam::PP_HORIZONTAL)
|
{
|
SetBlockSize(BuffHeight / m_IntervalStore + PITCHSTAT_PADDING);
|
right = (int)(rect.bottom - PitchParam.Height - SearchCount / SPR_MULTI - 2 - PitchParam.PitchEnd);//- PitchParam.Interval;
|
x = left = (rect.top) >> SPR_SHIFT << SPR_SHIFT;
|
|
CAssemUtil::CheckPitchSmall16(iPitch16, SearchCount, rect.left, x, Width, Height, pData, BuffWidth, PitchParam.ZeroBack, iPitch16, iPitch, spr);
|
SetPitchInfo(x, iPitch16);
|
|
for (x += Interval; x < right; x += Interval)
|
{
|
CAssemUtil::CheckPitchSmall16(iPitch16, 2, rect.left, x, Width, Height, pData, BuffWidth, PitchParam.ZeroBack, iPitch16, iPitch, spr);
|
SetPitchInfo(x, iPitch16);
|
}
|
VerifyPitchInfo(left, x - Interval, PitchParam.Expand, rect.bottom);
|
return TRUE;
|
}
|
SetBlockSize(BuffWidth / m_IntervalStore + PITCHSTAT_PADDING);
|
right = (int)(rect.right - PitchParam.Width - SearchCount / SPR_MULTI - 2 - PitchParam.PitchEnd);
|
x = left = (rect.left) >> SPR_SHIFT << SPR_SHIFT;
|
|
CAssemUtil::CheckPitchSmallVert16(iPitch16, SearchCount, x, rect.top, Width, Height, pData, BuffWidth, PitchParam.ZeroBack, iPitch16, iPitch, spr);
|
SetPitchInfo(x, iPitch16);
|
|
for (x += Interval; x < right; x += Interval)
|
{
|
CAssemUtil::CheckPitchSmallVert16(iPitch16, 2, x, rect.top, Width, Height, pData, BuffWidth, PitchParam.ZeroBack, iPitch16, iPitch, spr);
|
SetPitchInfo(x, iPitch16);
|
}
|
VerifyPitchInfo(left, x - Interval, PitchParam.Expand, rect.right);
|
return TRUE;
|
}
|
|
void CPitchStat::VerifyPitchInfo(int left, int right, int expand, int rightOriginal)
|
{
|
int i;
|
int left2, right2;
|
|
|
left /= m_IntervalStore;
|
right /= m_IntervalStore;
|
rightOriginal /= m_IntervalStore;
|
expand /= m_IntervalStore;
|
expand += PITCHSTAT_PADDING;
|
|
m_iStartEstmated = left;
|
m_iEndEstmated = right;
|
|
if (left - expand < 0)
|
left2 = 0;
|
else
|
left2 = left - expand;
|
for (i = left; i >= left2; i--)
|
{
|
m_pData[i] = m_pData[left];
|
}
|
|
if (rightOriginal + expand >= m_nData)
|
right2 = m_nData - 1;
|
else
|
right2 = rightOriginal + expand;
|
|
for (i = right; i < right2; i++)
|
{
|
m_pData[i] = m_pData[right];
|
}
|
|
if (m_iStartPitch > left2)
|
m_iStartPitch = left2;
|
|
if (m_iEndPitch < right2)
|
m_iEndPitch = right2;
|
|
}
|
|
void CPitchStat::VerifyTiltInfo(int left, int right, int expand, int rightOriginal)
|
{
|
int i;
|
int left2, right2;
|
|
|
left /= m_IntervalStore;
|
right /= m_IntervalStore;
|
rightOriginal /= m_IntervalStore;
|
expand /= m_IntervalStore;
|
expand += PITCHSTAT_PADDING;
|
|
m_iStartEstmated = left;
|
m_iEndEstmated = right;
|
|
if (left - expand < 0)
|
left2 = 0;
|
else
|
left2 = left - expand;
|
for (i = left; i >= left2; i--)
|
{
|
m_pData[i] = m_pData[left];
|
}
|
|
if (rightOriginal + expand >= m_nData)
|
right2 = m_nData - 1;
|
else
|
right2 = rightOriginal + expand;
|
|
for (i = right; i < right2; i++)
|
{
|
m_pData[i] = m_pData[right];
|
}
|
|
if (m_iStartPitch > left2)
|
m_iStartPitch = left2;
|
|
if (m_iEndPitch < right2)
|
m_iEndPitch = right2;
|
|
}
|
|
BOOL CPitchStat::GetPitchRepre(CPitchRepre *pRepre)
|
{
|
pRepre->m_BasePitch16 = m_BasePitch16;
|
|
int minPitch, maxPitch;
|
|
minPitch = maxPitch = m_pData[m_iStartEstmated];
|
for (int i = m_iStartEstmated; i < m_iEndEstmated; i++)
|
{
|
if (minPitch > m_pData[i])
|
minPitch = m_pData[i];
|
if (maxPitch < m_pData[i])
|
maxPitch = m_pData[i];
|
}
|
|
if (minPitch < m_MinPitch16)
|
m_MinPitch16 = minPitch;
|
if (maxPitch > m_MaxPitch16)
|
m_MaxPitch16 = maxPitch;
|
|
pRepre->m_MinPitch16 = minPitch;
|
pRepre->m_MaxPitch16 = maxPitch;
|
|
return TRUE;
|
}
|
|
BOOL CPitchStat::GettiltRepre(CPitchRepre *pRepre)
|
{
|
int minTilt, maxTilt;
|
minTilt = maxTilt = m_pData[m_iStartEstmated];
|
for (int i = m_iStartEstmated; i < m_iEndEstmated; i++)
|
{
|
if (minTilt > m_pData[i])
|
minTilt = m_pData[i];
|
if (maxTilt < m_pData[i])
|
maxTilt = m_pData[i];
|
}
|
|
if (minTilt < m_MinTilt16)
|
m_MinTilt16 = minTilt;
|
if (maxTilt > m_MaxTilt16)
|
m_MaxTilt16 = maxTilt;
|
|
pRepre->m_MinTilt16 = minTilt;
|
pRepre->m_MaxTilt16 = maxTilt;
|
|
return TRUE;
|
}
|
|
void CPitchStat::SetPitchInfo(int x, int iPitch16)
|
{
|
int np = m_IntervalSearch / m_IntervalStore;
|
x /= m_IntervalStore;
|
for (int ip = 0; ip <= np; ip++)
|
{
|
m_pData[x++] = iPitch16;
|
}
|
}
|
|
void CPitchStat::WritePitchStat(CString &fileName)
|
{
|
FILE *pFile = NULL;
|
char name[100];
|
|
_tfopen_s(&pFile, fileName, _T("w"));
|
|
if (pFile == NULL)
|
return;
|
|
float pitch;
|
|
int np = m_IntervalSearch / m_IntervalStore;
|
for (int i = m_iStartPitch; i < m_iEndPitch; i += np)
|
{
|
pitch = (float)(((double)m_pData[i]) / SPR_MULTI);
|
//sprintf(name, "%d : %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", i, m_pPitch[i], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++], m_psSPR[i++]);
|
sprintf_s(name, "%d\t%.3f\n", i*m_IntervalStore, pitch);
|
fprintf(pFile, name);
|
}
|
fclose(pFile);
|
}
|
|
BOOL CPitchStat::CheckPitchNTiltRepre(CMosisBuffer &buff, CRect &rect, stPitchParam &pitchParam, int iFrame)
|
{
|
CPitchRepre *pRepre = m_PitchRepres.GetCurData();
|
|
pRepre->m_iFrame = iFrame;
|
CheckDynamicTilt(buff, rect, pitchParam);
|
GettiltRepre(pRepre);
|
CheckDynamicPitchWithTilt(buff, rect, pitchParam);
|
GetPitchRepre(pRepre);
|
m_PitchRepres.AddDataCount();
|
|
return TRUE;
|
}
|
|
void CPitchStat::WritePitchRepre(CString &fileName)
|
{
|
FILE *pFile = NULL;
|
char name[100];
|
_tfopen_s(&pFile, fileName, _T("w"));
|
|
if (pFile == NULL)
|
return;
|
|
int nRepre = m_PitchRepres.GetDataCount();
|
CPitchRepre *pRepre;
|
|
sprintf_s(name, "Frame\tBasePitch\tMinPitch\tMaxPitch\tMinTilt\tMaxTilt\r\n");
|
fprintf(pFile, name);
|
sprintf_s(name, "Total\t%.3f\t%.3f\t%.3f\t%.3f\t%.3f\r\n", GetBasePitch(), GetMinPitch(), GetMaxPitch(), GetMinTilt(), GetMaxTilt());
|
fprintf(pFile, name);
|
for (int i = 0; i < nRepre; i++)
|
{
|
pRepre = m_PitchRepres.GetData(i);
|
sprintf_s(name, "%d\t%.3f\t%.3f\t%.3f\t%.3f\t%.3f\r\n", pRepre->m_iFrame, pRepre->GetBasePitch(), pRepre->GetMinPitch(), pRepre->GetMaxPitch(), pRepre->GetMinTilt(), pRepre->GetMaxTilt());
|
fprintf(pFile, name);
|
}
|
|
fclose(pFile);
|
}
|
|
void CPitchStat::CheckPitch(CMosisBuffer Frame, CRect &InsRect, double pitch, CString &strGlassID, int iModel, int iRegion, int iFrame)
|
{
|
// CString fileName;
|
m_PitchParam.Direction = ConvDir_Vert;
|
m_PitchParam.SetPitchRange(pitch - 1.5, pitch + 1.5, -1, 1);
|
|
|
double tilt;
|
CheckTilt(Frame, InsRect, m_PitchParam, pitch, tilt);
|
m_PitchParam.ResultPitch = (double)pitch;
|
m_PitchParam.TiltStart = (double)tilt;
|
// g_pLog->DisplayMessage(TRUE, "TiltM%dR%dF%d[%f]", iModel, iRegion, iFrame, tilt);
|
|
CheckDynamicPitchWithTilt(Frame, InsRect, m_PitchParam);
|
// fileName.Format("%s%s\\M%dR%dF%dPitchDynamicTilt.txt",PATH_LOGIMAGE,strGlassID, iModel, iRegion, iFrame);
|
// WritePitchStat(fileName);
|
|
}
|
|
void CPitchStat::WriteToBuff(double *p, int &nData)
|
{
|
if (nData > m_nData)
|
nData = m_nData;
|
|
int np = m_IntervalSearch / m_IntervalStore;
|
int id = 0;
|
for (int i = m_iStartPitch; i < m_iEndPitch; i += np)
|
{
|
p[id++] = (double)m_pData[i] / SPR_MULTI;
|
}
|
}
|
/*
|
void CPSControl::CheckPitch(CScanGlass *pRecipe, int iFrame, int FrameHeight, CMosisBuffer Frame, int iThread)
|
{
|
CScanModel *pModel;
|
CScanRegion *pRegion;
|
CScanCell *pCell;
|
CPitchStat *pPsc;
|
|
int iModel, iRegion, iCell;
|
int nModel, nRegion, nCell;
|
double dPitch;
|
CRect rect(0, 0, Frame.GetWidth(), Frame.GetHeight());
|
|
nModel= pRecipe->GetModelCount();
|
|
for(iModel= 0; iModel< nModel; iModel++)
|
{
|
pModel= pRecipe->GetScanModel(iModel);
|
pPsc= GetPitchStat(iModel,iThread);
|
if(pModel == NULL || pPsc == NULL)
|
continue;
|
|
if(pRecipe->GetInspectionDir() == ConvDir_Hori)
|
{
|
g_pLog->DisplayMessage(TRUE, "DPC Disabled!!! : Cause Horizotal.2");
|
continue;
|
}
|
|
if(! pModel->GetUseDPC())
|
{
|
g_pLog->DisplayMessage(TRUE, "DPC Disabled!!! : Cause Disabled.2");
|
continue;
|
}
|
|
nRegion= pModel->GetRegionCount();
|
for(iRegion= 0; iRegion < nRegion; iRegion++)
|
{
|
pRegion = pModel->GetScanRegion(iRegion);
|
if(pRegion == NULL)
|
continue;
|
nCell= pRegion->GetCellCount();
|
for(iCell= 0; iCell< nCell; iCell++)
|
{
|
pCell= pRegion->GetCellInfo(iCell);
|
if(pCell == NULL)
|
continue;
|
if((pCell->m_RectCellPat.top/FrameHeight) < iFrame && (pCell->m_RectCellPat.bottom/FrameHeight) > iFrame )
|
{
|
dPitch= (double)(pModel->GetScanPitch()*(double)pModel->GetScanCycle());
|
rect.left= pCell->m_RectCellPat.left;
|
rect.right= pCell->m_RectCellPat.right;
|
if((pCell->m_RectCellPat.top/g_pBase->m_nFrameHeight) + 1 == iFrame)
|
{
|
rect.top=pCell->m_RectCellPat.top%FrameHeight;
|
rect.bottom+=g_pBase->m_nFrameHeight;
|
Frame.SetBuffer(Frame.GetDataAddress(0,-FrameHeight),Frame.GetWidth(),Frame.GetHeight()+FrameHeight);
|
}
|
else if((pCell->m_RectCellPat.bottom/g_pBase->m_nFrameHeight)-1 == iFrame)
|
{
|
rect.bottom+=pCell->m_RectCellPat.bottom%FrameHeight;
|
Frame.SetSize(Frame.GetWidth(),Frame.GetHeight()+FrameHeight);
|
}
|
pPsc->CheckPitch(Frame,rect, dPitch, pRecipe->GetHPanelID(), iModel, iRegion, iFrame);
|
return;
|
}
|
|
}
|
}
|
}
|
}
|
|
void CPSControl::ResetPitchStatInfo()
|
{
|
for(int i= 0; i < m_nModel; i++)
|
{
|
for(int j= 0; j<m_nThread; j++)
|
GetPitchStat(i, j)->ResetPitchStat();
|
}
|
}
|
|
*/
|