You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
230 lines
5.7 KiB
230 lines
5.7 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: Filters.h
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Header file of Filters.h
|
|
//----------------------------------------------------------------------------
|
|
#ifndef __LGS__FILTERS__INCLUDED__
|
|
#define __LGS__FILTERS__INCLUDED__
|
|
|
|
#include "StdAfx.h"
|
|
#include "Tracker.h"
|
|
#include "..\LgLib\Comm\LgsM.h"
|
|
|
|
//////////////////////////
|
|
// FILTERS COMMON TYPES //
|
|
//////////////////////////
|
|
enum CEnumSunState
|
|
{
|
|
E_SUN_STATE_INCREASE,
|
|
E_SUN_STATE_DECREASE,
|
|
E_SUN_STATE_NORMAL
|
|
};
|
|
|
|
enum CEnumTargetType
|
|
{
|
|
E_TARGET_TYPE_NONE,
|
|
E_TARGET_TYPE_BLACK,
|
|
E_TARGET_TYPE_WHITE,
|
|
};
|
|
|
|
#ifndef INCLUDE_WINDOWS_DEFINITIONS
|
|
#define private public
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////
|
|
// FILTER "UNRELIABLE POINTS DETECTION BY SUN BIT" //
|
|
/////////////////////////////////////////////////////
|
|
class CFilterSun
|
|
{
|
|
public:
|
|
CFilterSun();
|
|
~CFilterSun();
|
|
|
|
public:
|
|
BOOL Create( CTracker *pTracker );
|
|
void Destroy();
|
|
void Reset();
|
|
|
|
public:
|
|
CEnumSunState OnAngle( INT nAngle, BOOL bSun, INT SUN );
|
|
void OnFlip();
|
|
|
|
public:
|
|
BOOL GetLastErrorSun() { BOOL bError = m_bErrorSun; m_bErrorSun = FALSE; return bError; }
|
|
|
|
private:
|
|
typedef struct SUN_DATA
|
|
{
|
|
BYTE bValue;
|
|
BOOL bWaitFlip;
|
|
}SUN_DATA, far* LPSUN_DATA;
|
|
|
|
INT m_nSun; // for checking number of sun bits for catching error of lasers
|
|
BOOL m_bErrorSun; // error flags
|
|
LPSUN_DATA m_lpSunData; // check sun
|
|
CTracker *m_pTracker; // holds pointer to target tracker
|
|
INT m_nClearLoop;
|
|
};
|
|
|
|
//////////////////////////////////////////////
|
|
// FILTER "BLIND DETECTION BY MEDIUM RANGE" //
|
|
//////////////////////////////////////////////
|
|
class CFilterMediumRange
|
|
{
|
|
public:
|
|
CFilterMediumRange();
|
|
~CFilterMediumRange();
|
|
|
|
public:
|
|
BOOL Create( CTracker *pTracker );
|
|
void Destroy();
|
|
void Reset();
|
|
|
|
public:
|
|
void OnAngle( INT nMinSAF, BOOL bSun );
|
|
void OnFlip();
|
|
|
|
private:
|
|
LONG m_nMedium; // medium range for curent SAF
|
|
INT m_nMediumCalculateLoop; // loops remainig for calculation of medium range
|
|
BOOL m_bBlind; // holds last BLIND condition
|
|
CTracker *m_pTracker; // holds pointer to target tracker
|
|
CFastHistorySum< INT, LONG, LGS_DETECTOR_MEDIUM_RANGE_HISTORY_LENGTH> m_MediumHistory;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////
|
|
// FILTER "PD CONDITION DETECTION BY UNSTABLE RANGES" //
|
|
////////////////////////////////////////////////////////
|
|
#define LGS_DETECTOR_PD_MIN_DELTA 20
|
|
#define LGS_DETECTOR_PD_MIN_UPDATE_VALUE 0
|
|
#define LGS_DETECTOR_PD_MAX_UPDATE_VALUE 99
|
|
#define LGS_DETECTOR_PD_HISTORY_LENGTH 5 // 2^5=32
|
|
#define LGS_DETECTOR_PD_HISTORY_DELTA 2
|
|
|
|
class CFilterPD
|
|
{
|
|
public:
|
|
CFilterPD();
|
|
~CFilterPD();
|
|
|
|
public:
|
|
BOOL Create( CTracker *pTracker );
|
|
void Destroy();
|
|
void Reset();
|
|
|
|
public:
|
|
void OnUpdateSAF( INT nAngle, LPBYTE pOffset, LPBYTE pOrder );
|
|
void OnBuildSAF( INT nAngle, LPINT pMinSAF, LPINT pMaxSAF );
|
|
BOOL OnCalculate( INT nAngle, INT nRange, LPINT pMinSAF, LPINT pMaxSAF, BOOL bSpike );
|
|
void OnFlip();
|
|
BOOL IsShowBlackTargets() { return m_bMediumShowBlack; }
|
|
|
|
private:
|
|
typedef struct SAF
|
|
{
|
|
INT nMin; // maximum
|
|
INT nMax; // minimum
|
|
}SAF, far* LPSAF;
|
|
|
|
typedef struct PD
|
|
{
|
|
BYTE nCountMin; // how many ranges near max per last saf
|
|
BYTE nCountMax; // how many ranges near min per last saf
|
|
BYTE nCountSpikes; // how many spikes per last saf
|
|
BYTE nValue; // current PD
|
|
}PD, far* LPPD;
|
|
|
|
typedef struct PDEX
|
|
{
|
|
BYTE nFlip; // amount of flips remaining to super flip
|
|
BYTE nActiveSAF; // current SAF
|
|
}PDEX, far* LPPDEX;
|
|
|
|
private:
|
|
LPSAF m_ppSAF[2]; // SAF data
|
|
LPPD m_lpPD; // PD data
|
|
LPPDEX m_lpPDEX; // PD data
|
|
INT m_nSAFUpdateLoop;
|
|
CTracker *m_pTracker;
|
|
BYTE m_bSmallFlip;
|
|
|
|
private:
|
|
INT m_nMediumPD;
|
|
INT m_nMediumLastPD;
|
|
BOOL m_bMediumShowBlack;
|
|
// fast history calculation
|
|
CFastHistorySum< BYTE, WORD, LGS_DETECTOR_PD_HISTORY_LENGTH > m_MediumHistory;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////
|
|
// FILTER "WIDTH" //
|
|
////////////////////////////////////////////////////////
|
|
class CFilterWidth
|
|
{
|
|
public:
|
|
CFilterWidth();
|
|
~CFilterWidth();
|
|
|
|
public:
|
|
BOOL Create( CTracker *pTracker, LPCTSTR pFileName );
|
|
void Destroy();
|
|
|
|
public:
|
|
LONG GetWidth( INT nTargetRange, INT nWidth );
|
|
|
|
public:
|
|
PLONG GetTable() { return m_pTable; }
|
|
|
|
private:
|
|
LONG m_pTable[LGS::WIDTH_TABLE_SIZE];
|
|
};
|
|
|
|
////////////////////////////////////////////////////////
|
|
// FILTER "LINEARIZATION" //
|
|
////////////////////////////////////////////////////////
|
|
class CFilterCalibration
|
|
{
|
|
public:
|
|
CFilterCalibration();
|
|
~CFilterCalibration();
|
|
|
|
public:
|
|
BOOL Create( LPCTSTR pFileName );
|
|
void Destroy();
|
|
|
|
public:
|
|
BOOL Load( LPCTSTR pFileName );
|
|
BOOL Save( LPCTSTR pFileName );
|
|
|
|
public:
|
|
inline INT Calibrate( INT nA2D ) { return m_lpLookupTable[ nA2D ]; }
|
|
|
|
public:
|
|
void OnCmdGetCalibrationTable( PBYTE& pReadBufferPtr, INT& nReadCount, PBYTE& pSendBufferPtr, INT& nSendCount );
|
|
BOOL OnCmdSetCalibrationTable( PBYTE& pReadBufferPtr, INT& nReadCount, PBYTE& pSendBufferPtr, INT& nSendCount );
|
|
|
|
private:
|
|
void UpdateLookupTable();
|
|
|
|
private:
|
|
typedef struct A2DRANGE
|
|
{
|
|
INT nA2D;
|
|
INT nReal;
|
|
}A2DRANGE, far*LPA2DRANGE;
|
|
|
|
LPA2DRANGE m_lpA2DRange;
|
|
INT m_nA2DRangeCount;
|
|
|
|
LPINT m_lpLookupTable;
|
|
};
|
|
|
|
#endif
|