#pragma once
|
|
#include "MosisAssem/MosisStrg.h"
|
|
class CMosisBuffer;
|
|
typedef CMosisBlock<int> CPitchBlock;
|
typedef CMosisBlock<int> CIntBlock;
|
|
|
#define SPR_SHIFT 4
|
#define SPR_MULTI 16
|
|
|
struct stPitchParam
|
{
|
enum PP_Dir{PP_HORIZONTAL= 0, PP_VERTICAL= 1};
|
public:
|
double PitchStart, PitchEnd; // ÇÇÄ¡ ã´Â ¹üÀ§
|
double TiltStart, TiltEnd; // Tilt ã´Â ¹üÀ§
|
int Width, Height; // ÇÇÄ¡ Æò°¡¸¦ À§ÇÑ ºñ±³ Å©±â.
|
int Direction; // 0- xÃà- Horizontal, 1- yÃà- Vertical
|
|
int Interval; // ¾ó¸¶ÀÇ °Å¸®¸¸Å ¶³¾îÁ®¼ °Ë»çÇÒ±î...
|
int Dist; // 2d °Ë»ç¸¦ À§ÇÑ cross ¹æÇâ Pitch interval
|
int ZeroBack; // 3ÀÌÇÏ Noise´Â ¹«½ÃÇÑ´Ù. ½ÇÁ¦ noiseÁ¦°Å½Ã ÇÇÄ¡ÀÇ ¶³¸² Çö»óÀÌ Àû¾îÁø´Ù.
|
int Expand; // Expand »çÀÌÁî ¸¸Å ÇÇÄ¡ µ¥ÀÌÅ͸¦ È®Àå½ÃŲ´Ù.
|
|
double ResultPitch; // Pitch °á°ú¹°
|
|
public:
|
stPitchParam()
|
{
|
PitchStart= 10;
|
PitchEnd= 300;
|
TiltStart= -1;
|
TiltEnd= 1;
|
Width= 128;
|
Height= 128;
|
Direction= PP_HORIZONTAL;
|
|
ZeroBack= 3;
|
Interval= 16;
|
Dist= 16;
|
Expand= 10000;
|
ResultPitch=0.;
|
}
|
|
void SetEnv(int interval, int width, int height, int zeroback, int expand, int dist= 16)
|
{
|
if(interval >= 16)
|
Interval= interval;
|
else
|
Interval= 16;
|
|
Interval= Interval>>4<<4; // IntervalÀº 16ÀÇ ¹è¼ö¸¸ °¡´É.
|
|
if(dist >= 16)
|
Dist= dist;
|
else
|
Dist= 16;
|
Dist= Dist>>4<<4; // Dist ´Â 16ÀÇ ¹è¼ö¸¸ °¡´É.
|
|
if(width >= 16)
|
Width= width;
|
else
|
Width= 16;
|
|
if(height >= 16)
|
Height= height;
|
else
|
Height= 16;
|
|
ZeroBack= zeroback;
|
|
Expand= expand;
|
}
|
|
void SetTiltRange(double tiltStart, double tiltEnd)
|
{
|
TiltStart= tiltStart;
|
TiltEnd= tiltEnd;
|
}
|
|
void SetPitchRange(double start, double end, double tiltStart=0, double tiltEnd=0)
|
{
|
if(start < 2)
|
start= 2;
|
if(end < 3)
|
end= 3;
|
|
if(end < start)
|
{
|
PitchStart = end;
|
PitchEnd = start;
|
}else
|
{
|
PitchStart = start;
|
PitchEnd = end;
|
}
|
|
if(tiltEnd < tiltStart)
|
{
|
TiltStart= tiltEnd;
|
TiltEnd= tiltStart;
|
}else
|
{
|
TiltStart= tiltStart;
|
TiltEnd= tiltEnd;
|
}
|
}
|
double GetMiddlePitch()
|
{
|
return (PitchEnd+ PitchStart)/2;
|
}
|
double GetPitchRange()
|
{
|
return (PitchEnd- PitchStart)/2;
|
}
|
double GetMiddleTilt()
|
{
|
return (TiltEnd+ TiltStart)/2;
|
}
|
double GetTiltRange()
|
{
|
return (TiltEnd- TiltStart)/2;
|
}
|
};
|
|
class CPitchStat;
|
|
class CPitchRepre
|
{
|
protected:
|
int m_iFrame;
|
int m_BasePitch16, m_MinPitch16, m_MaxPitch16;
|
int m_MinTilt16, m_MaxTilt16;
|
public:
|
double GetBasePitch(){return (double)m_BasePitch16/SPR_MULTI;}
|
double GetMinPitch(){return (double)m_MinPitch16/SPR_MULTI;}
|
double GetMaxPitch(){return (double)m_MaxPitch16/SPR_MULTI;}
|
double GetMinTilt(){return (double)m_MinTilt16/SPR_MULTI;}
|
double GetMaxTilt(){return (double)m_MaxTilt16/SPR_MULTI;}
|
friend CPitchStat;
|
};
|
|
class CPitchStat : public CPitchRepre, public CPitchBlock
|
{
|
public:
|
CPitchStat(void);
|
~CPitchStat(void);
|
int m_iStartEstmated, m_iEndEstmated;
|
int m_iStartPitch;
|
int m_iEndPitch;
|
int m_IntervalStore;
|
int m_IntervalSearch;
|
stPitchParam m_PitchParam;
|
|
CMosisBlock<CPitchRepre> m_PitchRepres;
|
|
CMosisBlock<short> m_ConvBlock;
|
CMosisBlock<short> m_ConvBlock2;
|
|
#define PITCHSTAT_PADDING 4
|
|
public:
|
BOOL SetRepreSpace(int n) { return m_PitchRepres.SetBlockSize(n);}
|
void ResetPitchRepre(){m_PitchRepres.ResetBlock(); m_MinPitch16= m_MinTilt16= INT_MAX; m_MaxPitch16= m_MaxTilt16= INT_MIN;}
|
BOOL CheckPitchNTiltRepre(CMosisBuffer &buff, CRect &rect, stPitchParam &pitchParam, int iFrame);
|
BOOL GetPitchRepre(CPitchRepre *pRepre);
|
BOOL GettiltRepre(CPitchRepre *pRepre);
|
|
public:
|
void ResetPitchStat(){m_iStartPitch= INT_MAX; m_iEndPitch= -INT_MAX;};
|
void VerifyPitchInfo(int left, int right, int expand, int rightOriginal);
|
void VerifyTiltInfo(int left, int right, int expand, int rightOriginal);
|
void SetPitchInfo(int x, int iPitch16);
|
void ResetConBuff(int nSize);
|
|
protected:
|
double CheckOnePitch(BYTE* pData, int BuffWidth, int BuffHeight, CRect &rect, stPitchParam &PitchParam);
|
BOOL CheckDynamicPitch(BYTE* pData, int BuffWidth, int BuffHeight, CRect &rect, stPitchParam &PitchParam);
|
|
BOOL CheckTilt(BYTE* pData, int BuffWidth, int BuffHeight, CRect &rect, stPitchParam &PitchParam, double &pitch, double &tilt);
|
BOOL CheckDynamicPitchWithTilt(BYTE* pData, int BuffWidth, int BuffHeight, CRect &rect, stPitchParam &PitchParam);
|
BOOL CheckDynamicTilt(BYTE* pData, int BuffWidth, int BuffHeight, CRect &rect, stPitchParam &PitchParam);
|
|
BOOL CheckFluidPitch(BYTE* pData, int BuffWidth, int BuffHeight, CRect &rect, stPitchParam &PitchParam);
|
|
public:
|
double CheckOnePitch(CMosisBuffer &buff, CRect &rect, stPitchParam &PitchParam);
|
BOOL CheckDynamicPitch(CMosisBuffer &buff, CRect &rect, stPitchParam &PitchParam);
|
void CheckPitch(CMosisBuffer Frame,CRect &InsRect, double pitch, CString &strGlassID, int iModel, int iRegion, int iFrame);
|
|
BOOL CheckTilt(CMosisBuffer &buff, CRect &rect, stPitchParam &PitchParam, double &pitch, double &tilt);
|
BOOL CheckDynamicPitchWithTilt(CMosisBuffer &buffer, CRect &rect, stPitchParam &PitchParam);
|
BOOL CheckDynamicTilt(CMosisBuffer &buffer, CRect &rect, stPitchParam &PitchParam);
|
|
BOOL CheckFluidPitch(CMosisBuffer &buff, CRect &rect, stPitchParam &PitchParam);
|
|
public:
|
void WritePitchStat(CString &fileName);
|
void WritePitchRepre(CString &fileName); // scan º° frame Àüü¿¡ ´ëÇÑ pitch statÀ» º¸¿©ÁÖ±â À§ÇÑ ±â´É
|
int* GetPitch() {return m_pData;}
|
double GetRealPitch(int i) {return (double)m_pData[i]/SPR_MULTI;}
|
int GetInterval() {return m_IntervalStore;}
|
void WriteToBuff(double *p, int &nData);
|
int GetPitchSection()
|
{
|
if(m_iEndPitch == m_iStartPitch) return 0;
|
|
int np;
|
np= m_IntervalSearch/m_IntervalStore;
|
return (m_iEndPitch-m_iStartPitch)/np;
|
}
|
};
|
|
class CPSControl
|
{
|
int m_nSpace;
|
int m_nModel;
|
int m_nThread;
|
CPitchStat *m_pPitchStat;
|
public:
|
CPSControl(){m_nSpace= m_nModel= 0; m_pPitchStat= NULL;};
|
~CPSControl(){ReleaseSpace();};
|
|
BOOL SetModelCount(int nModel,int nThread)
|
{
|
if(nModel*nThread <= m_nSpace)
|
{
|
m_nModel= nModel;
|
m_nThread= nThread;
|
return TRUE;
|
}
|
|
ReleaseSpace();
|
|
//yjm bug fix 20101021
|
m_pPitchStat = new CPitchStat[nModel*nThread];
|
|
if(! m_pPitchStat) return FALSE;
|
m_nSpace= nModel*nThread;
|
m_nModel= nModel;
|
m_nThread= nThread;
|
return TRUE;
|
}
|
void ReleaseSpace()
|
{
|
if(m_pPitchStat)
|
delete[] m_pPitchStat;
|
m_nModel= 0;
|
m_nSpace= 0;
|
m_nThread= 0;
|
m_pPitchStat= NULL;
|
}
|
void ResetPitchStatInfo();
|
CPitchStat* GetPitchStat(int iModel,int iThread)
|
{
|
if(iModel < 0 || iModel >= m_nModel)
|
{
|
// AfxMessageBox("GetDynamicPitch()");
|
return m_pPitchStat;
|
}
|
return m_pPitchStat+ (iModel*m_nThread+iThread);
|
}
|
void CheckPitch(class CScanGlass *pRecipe, int iFrame, int FrameHeight, CMosisBuffer Frame, int iThread);
|
};
|