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.
1076 lines
33 KiB
1076 lines
33 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: CalibrationDlg.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of CalibrationDlg.cpp
|
|
//----------------------------------------------------------------------------
|
|
// CalibrationDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "Calibration.h"
|
|
#include "CalibrationDlg.h"
|
|
#include "OptionsDlg.h"
|
|
#include "..\DLIB\SocketPTZ.h"
|
|
#include "..\DLIB\SocketLGS.h"
|
|
#include "..\Chicago\VideoBase.h"
|
|
#include "ParametersDlg.h"
|
|
#include "LoadDlg.h"
|
|
#include "RelationDlg.h"
|
|
#include "ReportDlg.h"
|
|
#include "SetupDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
enum
|
|
{
|
|
TAB_CAMERA = 0,
|
|
TAB_LINEARIZATION = 1
|
|
};
|
|
|
|
CCalibrationDlg::CCalibrationDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CCalibrationDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CCalibrationDlg)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
|
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
::ZeroMemory( &m_bPtzRun, sizeof(m_bPtzRun) );
|
|
m_pTarget[0].bValid = FALSE;
|
|
m_pTarget[1].bValid = FALSE;
|
|
m_bPtzReady = FALSE;
|
|
m_bTestMode = FALSE;
|
|
m_pVideoWnd = NULL;
|
|
m_pVideoBase = NULL;
|
|
::ZeroMemory( &m_Relation, sizeof( m_Relation ) );
|
|
m_bCtGetInProgress[0] = m_bCtGetInProgress[1] = FALSE;
|
|
m_bCtSetInProgress[0] = m_bCtSetInProgress[1] = FALSE;
|
|
}
|
|
|
|
void CCalibrationDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CCalibrationDlg)
|
|
// DDX_Control(pDX, IDC_BUTTON_TEST, m_Test);
|
|
DDX_Control(pDX, IDC_CHECK_FILTER, m_Filter);
|
|
//}}AFX_DATA_MAP
|
|
DDX_Control(pDX, IDC_TAB_MODE, m_TabMode);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CCalibrationDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CCalibrationDlg)
|
|
ON_WM_PAINT()
|
|
ON_WM_QUERYDRAGICON()
|
|
ON_WM_TIMER()
|
|
ON_WM_MOVE()
|
|
ON_BN_CLICKED(IDC_BUTTON_CLEAR, OnButtonClear)
|
|
ON_BN_CLICKED(IDC_CHECK_FILTER, OnCheckFilter)
|
|
ON_BN_CLICKED(IDC_BUTTON_RESET, OnButtonReset)
|
|
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_MODE, OnSelchangeTabMode)
|
|
ON_MESSAGE(WM_OPTIONS_CHANGED, OnOptionsChanged)
|
|
ON_MESSAGE(WM_CALIBRATION, OnWMCalibration)
|
|
ON_BN_CLICKED(IDC_BUTTON_OPTIONS, OnButtonOptions)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CCalibrationDlg message handlers
|
|
|
|
BOOL CCalibrationDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// Set the icon for this dialog. The framework does this automatically
|
|
// when the application's main window is not a dialog
|
|
SetIcon(m_hIcon, TRUE); // Set big icon
|
|
SetIcon(m_hIcon, FALSE); // Set small icon
|
|
|
|
// ShowWindow( SW_MAXIMIZE );
|
|
CSetupDlg SetupDlg;
|
|
if( SetupDlg.DoModal() != IDOK )
|
|
{
|
|
EndDialog( IDCANCEL );
|
|
return TRUE;
|
|
}
|
|
|
|
CRect rect;
|
|
m_TabMode.InsertItem( TAB_CAMERA, _T("Camera") );
|
|
m_TabMode.InsertItem( TAB_LINEARIZATION, _T("LRF") );
|
|
m_TabMode.GetClientRect( &rect );
|
|
m_TabMode.AdjustRect( FALSE, rect );
|
|
|
|
m_TabCameraDlg.SetCalibrationDlg( this );
|
|
m_TabCameraDlg.Create( CTabCameraDlg::IDD, &m_TabMode );
|
|
m_TabCameraDlg.MoveWindow( rect );
|
|
m_TabCameraDlg.ShowWindow( SW_SHOW );
|
|
m_TabLinearizationDlg.SetCalibrationDlg( this );
|
|
m_TabLinearizationDlg.Create( CTabLinearizationDlg::IDD, &m_TabMode );
|
|
m_TabLinearizationDlg.MoveWindow( rect );
|
|
m_TabLinearizationDlg.ShowWindow( SW_HIDE );
|
|
|
|
::SetWindowLong( GetDlgItem( IDC_BUTTON_RIGHT )->GetSafeHwnd(), GWL_USERDATA, (LONG)this );
|
|
::SetWindowLong( GetDlgItem( IDC_BUTTON_LEFT )->GetSafeHwnd(), GWL_USERDATA, (LONG)this );
|
|
::SetWindowLong( GetDlgItem( IDC_BUTTON_UP )->GetSafeHwnd(), GWL_USERDATA, (LONG)this );
|
|
::SetWindowLong( GetDlgItem( IDC_BUTTON_DOWN )->GetSafeHwnd(), GWL_USERDATA, (LONG)this );
|
|
::SetWindowLong( GetDlgItem( IDC_BUTTON_FAR )->GetSafeHwnd(), GWL_USERDATA, (LONG)this );
|
|
::SetWindowLong( GetDlgItem( IDC_BUTTON_NEAR )->GetSafeHwnd(), GWL_USERDATA, (LONG)this );
|
|
|
|
m_pWndProc = (WNDPROC)::SetWindowLong( GetDlgItem( IDC_BUTTON_RIGHT )->GetSafeHwnd(), GWL_WNDPROC, (LONG)WindowProcButton_ );
|
|
m_pWndProc = (WNDPROC)::SetWindowLong( GetDlgItem( IDC_BUTTON_LEFT )->GetSafeHwnd(), GWL_WNDPROC, (LONG)WindowProcButton_ );
|
|
m_pWndProc = (WNDPROC)::SetWindowLong( GetDlgItem( IDC_BUTTON_UP )->GetSafeHwnd(), GWL_WNDPROC, (LONG)WindowProcButton_ );
|
|
m_pWndProc = (WNDPROC)::SetWindowLong( GetDlgItem( IDC_BUTTON_DOWN )->GetSafeHwnd(), GWL_WNDPROC, (LONG)WindowProcButton_ );
|
|
m_pWndProc = (WNDPROC)::SetWindowLong( GetDlgItem( IDC_BUTTON_FAR )->GetSafeHwnd(), GWL_WNDPROC, (LONG)WindowProcButton_ );
|
|
m_pWndProc = (WNDPROC)::SetWindowLong( GetDlgItem( IDC_BUTTON_NEAR )->GetSafeHwnd(), GWL_WNDPROC, (LONG)WindowProcButton_ );
|
|
|
|
// m_Options.strLgsPortName = "com4";
|
|
// m_Options.strCameraPortName = "com3";
|
|
|
|
m_Settings.Create( _T("LaserGuard\\ISSC") );
|
|
|
|
m_Storage.SetEventQueue( &m_EventQueue );
|
|
m_Storage.Load( SetupDlg.GetSetupName(), 0, &m_Settings, FALSE );
|
|
|
|
// CRect rect;
|
|
GetDlgItem( IDC_STATIC_VIDEO )->GetWindowRect( &rect );
|
|
ScreenToClient( rect );
|
|
|
|
m_pVideoBase = new CVideoBase;
|
|
m_pVideoBase->SetSensorArray( &m_Storage );
|
|
m_pVideoBase->Create( this, &m_Settings );
|
|
/*
|
|
m_pVideoWnd = (CDDVideoWnd*)m_pVideoBase->AllocVideoWnd( 2, 0 );
|
|
if( m_pVideoWnd )
|
|
{
|
|
CWnd *pWnd = GetDlgItem(IDC_STATIC_VIDEO);
|
|
CRect rect;
|
|
pWnd->GetClientRect( &rect );
|
|
m_pVideoWnd->SetParent( pWnd );
|
|
m_pVideoWnd->ShowWindow( SW_SHOW );
|
|
m_pVideoWnd->MoveWindow( &rect );
|
|
}
|
|
*/
|
|
|
|
//#ifndef _DEBUG
|
|
// m_VideoWnd.Create( this, rect.left, rect.top, rect.Width(), rect.Height() );
|
|
// m_VideoWnd.ShowWindow( SW_SHOW );
|
|
MakeCrossTarget();
|
|
//#endif
|
|
|
|
GetDlgItem( IDC_STATIC_LOCATOR )->GetWindowRect( &rect );
|
|
ScreenToClient( rect );
|
|
m_PropertyLGSWnd.Create( this, rect.left, rect.top, rect.Width(), rect.Height() );
|
|
m_PropertyLGSWnd.SetSensor( (CSensorLGS*)m_Relation.pSensor/*m_Storage.GetSensor( 0 )*/ );
|
|
m_PropertyLGSWnd.ShowWindow( SW_SHOW );
|
|
|
|
CListCtrl *pListCtrl = &m_TabCameraDlg.m_ListTarget;
|
|
pListCtrl->SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT );
|
|
CRect lRect;
|
|
pListCtrl->GetClientRect(&lRect);
|
|
int nWidth = lRect.Width() / 7;
|
|
pListCtrl->InsertColumn( 0, _T("MA"), LVCFMT_LEFT, nWidth, 0 );
|
|
pListCtrl->InsertColumn( 1, _T("MR"), LVCFMT_LEFT, nWidth, 1 );
|
|
pListCtrl->InsertColumn( 2, _T("SA"), LVCFMT_LEFT, nWidth, 2 );
|
|
pListCtrl->InsertColumn( 3, _T("SR"), LVCFMT_LEFT, nWidth, 3 );
|
|
pListCtrl->InsertColumn( 4, _T("CP"), LVCFMT_LEFT, nWidth, 4 );
|
|
pListCtrl->InsertColumn( 5, _T("CT"), LVCFMT_LEFT, nWidth, 5 );
|
|
pListCtrl->InsertColumn( 6, _T("CR"), LVCFMT_LEFT, nWidth, 6 );
|
|
|
|
LPCTSTR pText = _T("n/a");
|
|
GetDlgItem( IDC_EDIT_CAMERA_PAN )->SetWindowText( pText );
|
|
GetDlgItem( IDC_EDIT_CAMERA_TILT )->SetWindowText( pText );
|
|
GetDlgItem( IDC_EDIT_CAMERA_ZOOM )->SetWindowText( pText );
|
|
|
|
SetTimer( 0, 250, NULL );
|
|
|
|
Communication();
|
|
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
}
|
|
|
|
// If you add a minimize button to your dialog, you will need the code below
|
|
// to draw the icon. For MFC applications using the document/view model,
|
|
// this is automatically done for you by the framework.
|
|
|
|
void CCalibrationDlg::OnPaint()
|
|
{
|
|
if (IsIconic())
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
|
|
|
|
// Center icon in client rectangle
|
|
int cxIcon = GetSystemMetrics(SM_CXICON);
|
|
int cyIcon = GetSystemMetrics(SM_CYICON);
|
|
CRect rect;
|
|
GetClientRect(&rect);
|
|
int x = (rect.Width() - cxIcon + 1) / 2;
|
|
int y = (rect.Height() - cyIcon + 1) / 2;
|
|
|
|
// Draw the icon
|
|
dc.DrawIcon(x, y, m_hIcon);
|
|
}
|
|
else
|
|
{
|
|
CDialog::OnPaint();
|
|
}
|
|
}
|
|
|
|
// The system calls this to obtain the cursor to display while the user drags
|
|
// the minimized window.
|
|
HCURSOR CCalibrationDlg::OnQueryDragIcon()
|
|
{
|
|
return (HCURSOR) m_hIcon;
|
|
}
|
|
|
|
BOOL CCalibrationDlg::DestroyWindow()
|
|
{
|
|
if( GetSafeHwnd() )
|
|
KillTimer( 0 );
|
|
|
|
if( m_pVideoBase )
|
|
{
|
|
m_pVideoBase->Destroy();
|
|
delete m_pVideoBase;
|
|
m_pVideoBase = NULL;
|
|
}
|
|
|
|
if( m_pVideoWnd )
|
|
{
|
|
// m_pVideoWnd->DestroyWindow();
|
|
// delete m_pVideoWnd;
|
|
m_pVideoWnd = NULL;
|
|
}
|
|
|
|
return CDialog::DestroyWindow();
|
|
}
|
|
|
|
static double cD2R = asin(1.0) * 2.0 / 180.0;
|
|
#define Degree2Radian(a) (a * cD2R)
|
|
|
|
BOOL CCalibrationDlg::InVisibleZone( double angle, double range )
|
|
{
|
|
double x, y, r;
|
|
if( m_PropertyLGSWnd.GetFilter( x, y, r ) && m_Relation.pSensor )
|
|
{
|
|
double max_range = 100.0;
|
|
double zero_shift = 0.0;
|
|
switch( m_Relation.pSensor->GetType() )
|
|
{
|
|
case CVisual::LGS:
|
|
max_range = static_cast<CSensorLGS*>(m_Relation.pSensor)->GetMaxRange();
|
|
zero_shift = static_cast<CSensorLGS*>(m_Relation.pSensor)->GetZeroShift();
|
|
break;
|
|
}
|
|
|
|
angle = angle + zero_shift;
|
|
while( angle >= 360.0 ) angle -= 360.0;
|
|
while( angle < 0.0 ) angle += 360.0;
|
|
|
|
x *= max_range;
|
|
y *= max_range;
|
|
r *= max_range;
|
|
double tx = cos( Degree2Radian( angle ) ) * range;
|
|
double ty = -sin( Degree2Radian( angle ) ) * range;
|
|
double tr = sqrt( pow( tx-x, 2.0 ) + pow( ty-y, 2.0 ) );
|
|
|
|
// LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CCalibrationDlg::InVisibleZone"), _T("%0.0f,%0.0f(%0.0f,%0.0f) %s %0.0f,%0.0f,%0.0f"), angle, range, tx, ty, ( tr < r )? "inside" : "outside", x, y, r );
|
|
|
|
if( tr > r )
|
|
return FALSE;
|
|
}
|
|
return TRUE; // filter disabled, so everythink in visible zone
|
|
}
|
|
|
|
BOOL CCalibrationDlg::GetTarget( INT nDevice, double *pAngle, double *pRange, double *pMaxRange )
|
|
{
|
|
if( !m_Relation.pSensor )
|
|
return FALSE;
|
|
|
|
*pAngle = m_pTarget[nDevice].angle;
|
|
*pRange = m_pTarget[nDevice].range;
|
|
*pMaxRange = static_cast<CSensorLGS*>(m_Relation.pSensor)->GetMaxRange();
|
|
return m_pTarget[nDevice].bValid;
|
|
}
|
|
|
|
void CCalibrationDlg::OnTimer(UINT nIDEvent)
|
|
{
|
|
m_Storage.CheckSensors();
|
|
m_Storage.CheckCameras();
|
|
CheckPtz();
|
|
CheckReady();
|
|
CheckCalibrationTable();
|
|
|
|
EVENT event;
|
|
while( m_EventQueue.GetEvent( event ) )
|
|
{
|
|
switch( event.id )
|
|
{
|
|
case LGS_EVENT_ALARM_SHOW:
|
|
if( event.pSensor == m_Relation.pSensor )
|
|
{
|
|
switch( event.target.bDevice )
|
|
{
|
|
case 0:
|
|
|
|
if( InVisibleZone( event.target.dAngle, event.target.dRange ) ) // either filter disabled or target in visible zone
|
|
{
|
|
m_pTarget[0].angle = event.target.dAngle;
|
|
m_pTarget[0].range = event.target.dRange;
|
|
m_pTarget[0].bValid = TRUE;
|
|
}
|
|
|
|
if( m_bTestMode && m_pTarget[0].bValid )
|
|
{
|
|
double pan, tilt, zoom;
|
|
event.pSensor->CameraTransform( 0, m_pTarget[0].angle, m_pTarget[0].range, &pan, &tilt, &zoom );
|
|
CVideoCameraPTZ *pCamera = (CVideoCameraPTZ*)m_Relation.pCamera;//m_Storage.GetVideoCamera(0);
|
|
if( pCamera && pCamera->IsReady() )
|
|
{
|
|
pCamera->CmdSetPTZ( pan, tilt, zoom );
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if( InVisibleZone( event.target.dAngle, event.target.dRange ) ) // either filter disabled or target in visible zone
|
|
{
|
|
m_pTarget[1].angle = event.target.dAngle;
|
|
m_pTarget[1].range = event.target.dRange;
|
|
m_pTarget[1].bValid = TRUE;
|
|
}
|
|
|
|
if( m_bTestMode && m_pTarget[1].bValid )
|
|
{
|
|
double pan, tilt, zoom;
|
|
event.pSensor->CameraTransform( 1, m_pTarget[1].angle, m_pTarget[1].range, &pan, &tilt, &zoom );
|
|
CVideoCameraPTZ *pCamera = (CVideoCameraPTZ*)m_Relation.pCamera;//m_Storage.GetVideoCamera(0);
|
|
if( pCamera && pCamera->IsReady() )
|
|
{
|
|
pCamera->CmdSetPTZ( pan, tilt, zoom );
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
CheckLocator();
|
|
|
|
m_PropertyLGSWnd.SendMessage( WM_TIMER );
|
|
|
|
CDialog::OnTimer(nIDEvent);
|
|
}
|
|
|
|
LRESULT CALLBACK CCalibrationDlg::WindowProcButton_( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|
{
|
|
CCalibrationDlg *pThis = (CCalibrationDlg*)::GetWindowLong( hWnd, GWL_USERDATA );
|
|
if( pThis )
|
|
return pThis->WindowProcButton( hWnd, uMsg, wParam, lParam );
|
|
return ::DefWindowProc( hWnd, uMsg, wParam, lParam );
|
|
}
|
|
|
|
LRESULT CCalibrationDlg::WindowProcButton( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|
{
|
|
BOOL bRun = FALSE;
|
|
BOOL bPerform = FALSE;
|
|
|
|
switch( uMsg )
|
|
{
|
|
case BM_SETSTATE:
|
|
bRun = wParam;
|
|
bPerform = TRUE;
|
|
break;
|
|
}
|
|
|
|
if( bPerform )
|
|
{
|
|
CVideoCameraPTZ *pCamera = (CVideoCameraPTZ*)m_Relation.pCamera;//m_Storage.GetVideoCamera(0);
|
|
if( pCamera )
|
|
{
|
|
const double speed = 0.15;
|
|
const double acceleration = 0.05;
|
|
UINT uID = ::GetWindowLong( hWnd, GWL_ID );
|
|
switch( uID )
|
|
{
|
|
case IDC_BUTTON_RIGHT: if( m_bPtzRun[0] != bRun ) { if( bRun ) pCamera->CmdPan( speed, PAN_RIGHT, acceleration ); else pCamera->CmdPan( 0.0, PAN_STOP ); m_bPtzRun[0] = bRun; } break;
|
|
case IDC_BUTTON_LEFT: if( m_bPtzRun[0] != bRun ) { if( bRun ) pCamera->CmdPan( speed, PAN_LEFT, acceleration ); else pCamera->CmdPan( 0.0, PAN_STOP ); m_bPtzRun[0] = bRun; } break;
|
|
case IDC_BUTTON_UP: if( m_bPtzRun[1] != bRun ) { if( bRun ) pCamera->CmdTilt( speed, TILT_UP, acceleration ); else pCamera->CmdTilt( 0.0, TILT_STOP ); m_bPtzRun[1] = bRun; } break;
|
|
case IDC_BUTTON_DOWN: if( m_bPtzRun[1] != bRun ) { if( bRun ) pCamera->CmdTilt( speed, TILT_DOWN, acceleration ); else pCamera->CmdTilt( 0.0, TILT_STOP ); m_bPtzRun[1] = bRun; } break;
|
|
case IDC_BUTTON_FAR: if( m_bPtzRun[2] != bRun ) { if( bRun ) pCamera->CmdZoom( speed, ZOOM_TELE, acceleration ); else pCamera->CmdZoom( 0.0, ZOOM_STOP ); m_bPtzRun[2] = bRun; } break;
|
|
case IDC_BUTTON_NEAR: if( m_bPtzRun[2] != bRun ) { if( bRun ) pCamera->CmdZoom( speed, ZOOM_WIDE, acceleration ); else pCamera->CmdZoom( 0.0, ZOOM_STOP ); m_bPtzRun[2] = bRun; } break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return ::CallWindowProc( m_pWndProc, hWnd, uMsg, wParam, lParam );
|
|
}
|
|
|
|
BOOL CCalibrationDlg::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
switch( pMsg->message )
|
|
{
|
|
case WM_KEYDOWN:
|
|
switch( pMsg->wParam )
|
|
{
|
|
case VK_UP: SendDlgItemMessage( IDC_BUTTON_UP, BM_SETSTATE, TRUE ); return TRUE;
|
|
case VK_DOWN: SendDlgItemMessage( IDC_BUTTON_DOWN, BM_SETSTATE, TRUE ); return TRUE;
|
|
case VK_LEFT: SendDlgItemMessage( IDC_BUTTON_LEFT, BM_SETSTATE, TRUE ); return TRUE;
|
|
case VK_RIGHT: SendDlgItemMessage( IDC_BUTTON_RIGHT, BM_SETSTATE, TRUE ); return TRUE;
|
|
case VK_ADD: SendDlgItemMessage( IDC_BUTTON_FAR, BM_SETSTATE, TRUE ); return TRUE;
|
|
case VK_SUBTRACT: SendDlgItemMessage( IDC_BUTTON_NEAR, BM_SETSTATE, TRUE ); return TRUE;
|
|
}
|
|
break;
|
|
case WM_KEYUP:
|
|
switch( pMsg->wParam )
|
|
{
|
|
case VK_UP: SendDlgItemMessage( IDC_BUTTON_UP, BM_SETSTATE, FALSE ); return TRUE;
|
|
case VK_DOWN: SendDlgItemMessage( IDC_BUTTON_DOWN, BM_SETSTATE, FALSE ); return TRUE;
|
|
case VK_LEFT: SendDlgItemMessage( IDC_BUTTON_LEFT, BM_SETSTATE, FALSE ); return TRUE;
|
|
case VK_RIGHT: SendDlgItemMessage( IDC_BUTTON_RIGHT, BM_SETSTATE, FALSE ); return TRUE;
|
|
case VK_ADD: SendDlgItemMessage( IDC_BUTTON_FAR, BM_SETSTATE, FALSE ); return TRUE;
|
|
case VK_SUBTRACT: SendDlgItemMessage( IDC_BUTTON_NEAR, BM_SETSTATE, FALSE ); return TRUE;
|
|
}
|
|
break;
|
|
}
|
|
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|
|
|
|
void CCalibrationDlg::CheckPtz()
|
|
{
|
|
CVideoCameraPTZ *pCamera = (CVideoCameraPTZ*)m_Relation.pCamera;//m_Storage.GetVideoCamera(0);
|
|
if( pCamera )
|
|
{
|
|
CString str;
|
|
if( pCamera->IsReady() )
|
|
str.Format( "Video camera <%s>", (LPCTSTR)*pCamera->GetName() );
|
|
else
|
|
str.Format( "Video camera <%s> busy", (LPCTSTR)*pCamera->GetName() );
|
|
|
|
GetDlgItem( IDC_STATIC_VIDEO_FRAME )->SetWindowText( str );
|
|
|
|
GetDlgItem( IDC_BUTTON_RIGHT )->EnableWindow( TRUE );
|
|
GetDlgItem( IDC_BUTTON_LEFT )->EnableWindow( TRUE );
|
|
GetDlgItem( IDC_BUTTON_UP )->EnableWindow( TRUE );
|
|
GetDlgItem( IDC_BUTTON_DOWN )->EnableWindow( TRUE );
|
|
GetDlgItem( IDC_BUTTON_FAR )->EnableWindow( TRUE );
|
|
GetDlgItem( IDC_BUTTON_NEAR )->EnableWindow( TRUE );
|
|
|
|
BOOL bRun = FALSE;
|
|
for( int i = 0; i < 3; i++ )
|
|
{
|
|
if( m_bPtzRun[i] )
|
|
{
|
|
bRun = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if( !bRun )
|
|
{
|
|
pCamera->CmdGetPTZ();
|
|
}
|
|
|
|
double pan, tilt, zoom;
|
|
if( pCamera->GetPTZ( pan, tilt, zoom ) )
|
|
{
|
|
zoom *= 100.0;
|
|
|
|
TCHAR pText[20];
|
|
_stprintf( pText, _T("%0.1f°"), pan );
|
|
GetDlgItem( IDC_EDIT_CAMERA_PAN )->SetWindowText( pText );
|
|
_stprintf( pText, _T("%0.1f°"), tilt );
|
|
GetDlgItem( IDC_EDIT_CAMERA_TILT )->SetWindowText( pText );
|
|
_stprintf( pText, _T("%0.1f%%"), zoom );
|
|
// _stprintf( pText, _T("-1.0") );
|
|
GetDlgItem( IDC_EDIT_CAMERA_ZOOM )->SetWindowText( pText );
|
|
GetDlgItem( IDC_EDIT_CAMERA_PAN )->EnableWindow( TRUE );
|
|
GetDlgItem( IDC_EDIT_CAMERA_TILT )->EnableWindow( TRUE );
|
|
GetDlgItem( IDC_EDIT_CAMERA_ZOOM )->EnableWindow( TRUE );
|
|
m_bPtzReady = TRUE;
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem( IDC_EDIT_CAMERA_PAN )->EnableWindow( FALSE );
|
|
GetDlgItem( IDC_EDIT_CAMERA_TILT )->EnableWindow( FALSE );
|
|
GetDlgItem( IDC_EDIT_CAMERA_ZOOM )->EnableWindow( FALSE );
|
|
m_bPtzReady = FALSE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem( IDC_STATIC_VIDEO_FRAME )->SetWindowText( "Video camera" );
|
|
GetDlgItem( IDC_BUTTON_RIGHT )->EnableWindow( FALSE );
|
|
GetDlgItem( IDC_BUTTON_LEFT )->EnableWindow( FALSE );
|
|
GetDlgItem( IDC_BUTTON_UP )->EnableWindow( FALSE );
|
|
GetDlgItem( IDC_BUTTON_DOWN )->EnableWindow( FALSE );
|
|
GetDlgItem( IDC_BUTTON_FAR )->EnableWindow( FALSE );
|
|
GetDlgItem( IDC_BUTTON_NEAR )->EnableWindow( FALSE );
|
|
}
|
|
}
|
|
|
|
void CCalibrationDlg::CheckLocator()
|
|
{
|
|
if( m_Relation.pSensor )
|
|
{
|
|
CString str;
|
|
str.Format( "Locator <%s>", (LPCTSTR)m_Relation.pSensor->GetName() );
|
|
GetDlgItem( IDC_STATIC_LOCATOR_FRAME )->SetWindowText( str );
|
|
}
|
|
|
|
if( m_pTarget[0].bValid && m_pTarget[1].bValid )
|
|
{
|
|
double tx1 = cos( Degree2Radian( m_pTarget[0].angle ) ) * m_pTarget[0].range;
|
|
double ty1 = -sin( Degree2Radian( m_pTarget[0].angle ) ) * m_pTarget[0].range;
|
|
double tx2 = cos( Degree2Radian( m_pTarget[1].angle ) ) * m_pTarget[1].range;
|
|
double ty2 = -sin( Degree2Radian( m_pTarget[1].angle ) ) * m_pTarget[1].range;
|
|
|
|
double tr = sqrt( pow( tx1-tx2, 2.0 ) + pow( ty1-ty2, 2.0 ) );
|
|
|
|
if( tr > 10.0 )
|
|
m_pTarget[0].bValid = m_pTarget[1].bValid = FALSE; // too big distance between targets
|
|
}
|
|
|
|
if( m_pTarget[0].bValid )
|
|
{
|
|
|
|
TCHAR pText[20];
|
|
_stprintf( pText, _T("%0.1f°"), m_pTarget[0].angle );
|
|
GetDlgItem( IDC_EDIT_MASTER_ANGLE )->SetWindowText( pText );
|
|
_stprintf( pText, _T("%0.1fm."), m_pTarget[0].range );
|
|
GetDlgItem( IDC_EDIT_MASTER_RANGE )->SetWindowText( pText );
|
|
GetDlgItem( IDC_EDIT_MASTER_ANGLE )->EnableWindow( TRUE );
|
|
GetDlgItem( IDC_EDIT_MASTER_RANGE )->EnableWindow( TRUE );
|
|
}
|
|
else
|
|
{
|
|
LPCTSTR pText = _T("n/a");
|
|
GetDlgItem( IDC_EDIT_MASTER_ANGLE )->SetWindowText( pText );
|
|
GetDlgItem( IDC_EDIT_MASTER_RANGE )->SetWindowText( pText );
|
|
GetDlgItem( IDC_EDIT_MASTER_ANGLE )->EnableWindow( FALSE );
|
|
GetDlgItem( IDC_EDIT_MASTER_RANGE )->EnableWindow( FALSE );
|
|
}
|
|
|
|
if( m_pTarget[1].bValid )
|
|
{
|
|
TCHAR pText[20];
|
|
_stprintf( pText, _T("%0.1f°"), m_pTarget[1].angle );
|
|
GetDlgItem( IDC_EDIT_SLAVE_ANGLE )->SetWindowText( pText );
|
|
_stprintf( pText, _T("%0.1fm."), m_pTarget[1].range );
|
|
GetDlgItem( IDC_EDIT_SLAVE_RANGE )->SetWindowText( pText );
|
|
GetDlgItem( IDC_EDIT_SLAVE_ANGLE )->EnableWindow( TRUE );
|
|
GetDlgItem( IDC_EDIT_SLAVE_RANGE )->EnableWindow( TRUE );
|
|
}
|
|
else
|
|
{
|
|
LPCTSTR pText = _T("n/a");
|
|
GetDlgItem( IDC_EDIT_SLAVE_ANGLE )->SetWindowText( pText );
|
|
GetDlgItem( IDC_EDIT_SLAVE_RANGE )->SetWindowText( pText );
|
|
GetDlgItem( IDC_EDIT_SLAVE_ANGLE )->EnableWindow( FALSE );
|
|
GetDlgItem( IDC_EDIT_SLAVE_RANGE )->EnableWindow( FALSE );
|
|
}
|
|
}
|
|
|
|
void CCalibrationDlg::OnButtonOptions()
|
|
{
|
|
CRelationDlg dlg;
|
|
dlg.SetSensorArray( &m_Storage );
|
|
dlg.SetRelation( &m_Relation );
|
|
if( dlg.DoModal() == IDOK )
|
|
{
|
|
RELATION relation;
|
|
dlg.GetRelation( &relation );
|
|
if( relation.pCamera != m_Relation.pCamera ||
|
|
relation.pSensor != m_Relation.pSensor )
|
|
{
|
|
m_Relation = relation;
|
|
m_PropertyLGSWnd.SetSensor( static_cast<CSensorLGS*>(m_Relation.pSensor) );
|
|
|
|
DownloadCalibrationTables();
|
|
|
|
OnButtonClear();
|
|
|
|
if( m_Relation.pCamera )
|
|
{
|
|
CVideoCamera *pVideoCamera = m_Relation.pCamera;
|
|
|
|
//find connected video input
|
|
CVideoPin *pOutputPin = pVideoCamera->GetOutput(0);
|
|
if( !pOutputPin )
|
|
{
|
|
// camera already exist in capturing jobs list
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, "CVideoCapture::Capture", "camera %p has no output pin", pVideoCamera );
|
|
return;
|
|
}
|
|
|
|
// search for video input device
|
|
while( pOutputPin )
|
|
{
|
|
// get conneted pin
|
|
CVideoPin *pInputPin = pOutputPin->GetCPin();
|
|
if( !pInputPin )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, "CVideoCapture::Capture", "camera %p has output pin that don't conneted to other pin", pVideoCamera );
|
|
return;
|
|
}
|
|
|
|
CVideoDevice *pVideoDevice = NULL;
|
|
INT nInputPin = 0;
|
|
pInputPin->GetVideoDevice( &pVideoDevice, &nInputPin );
|
|
|
|
if( !pVideoDevice )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, "CVideoCapture::Capture", "input pin don't belong to any device" );
|
|
return;
|
|
}
|
|
|
|
// if it is video capture device
|
|
for( INT i = 0; i < m_Storage.GetVideoCaptureDeviceCount(); i++ )
|
|
{
|
|
CVideoCaptureDevice *pVideoCaptureDevice = m_Storage.GetVideoCaptureDevice(i);
|
|
if( pVideoDevice == pVideoCaptureDevice )
|
|
{
|
|
CDDVideoWnd *pVideoWnd = static_cast<CDDVideoWnd*>(pVideoCaptureDevice->GetCaptureSource( nInputPin ));
|
|
|
|
if( pVideoWnd )
|
|
{
|
|
if( m_pVideoWnd )
|
|
m_pVideoWnd->ShowWindow( SW_HIDE );
|
|
|
|
m_pVideoWnd = pVideoWnd;
|
|
|
|
CRect rect;
|
|
CWnd *pWnd = GetDlgItem(IDC_STATIC_VIDEO);
|
|
pWnd->GetClientRect( &rect );
|
|
m_pVideoWnd->SetParent( pWnd );
|
|
m_pVideoWnd->ShowWindow( SW_SHOW );
|
|
m_pVideoWnd->MoveWindow( &rect );
|
|
|
|
MakeCrossTarget();
|
|
}
|
|
|
|
goto VIDEO_INPUT_FOUND;
|
|
}
|
|
}
|
|
|
|
// get associated pin
|
|
pOutputPin = pInputPin->GetAPin();
|
|
}
|
|
VIDEO_INPUT_FOUND:;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
BOOL CCalibrationDlg::Communication()
|
|
{
|
|
m_Storage.CommandLoop( MODE_HOST );
|
|
/* for( int i = 0; i < m_Storage.GetSocketCount(); i++ )
|
|
{
|
|
CSocket *pSocket = m_Storage.GetSocket( i );
|
|
switch( pSocket->GetType() )
|
|
{
|
|
case SOCKET_LGS:
|
|
((CSocketLGS*)pSocket)->Create( &m_Storage, (LPCTSTR)m_Options.strLgsPortName );
|
|
pSocket->CommandLoopStart();
|
|
break;
|
|
case SOCKET_PTZ:
|
|
((CSocketPTZ*)pSocket)->Create( &m_Storage, (LPCTSTR)m_Options.strCameraPortName );
|
|
m_Storage.GetVideoCamera(0 )->CmdInit();
|
|
break;
|
|
}
|
|
}
|
|
*/
|
|
// NEED TO BE CHANGED!!!
|
|
return TRUE;
|
|
}
|
|
|
|
LRESULT CCalibrationDlg::OnOptionsChanged( WPARAM wParam, LPARAM lParam )
|
|
{
|
|
return Communication();
|
|
}
|
|
|
|
void CCalibrationDlg::OnButtonDelete()
|
|
{
|
|
CListCtrl *pListCtrl = &m_TabCameraDlg.m_ListTarget;
|
|
|
|
while( TRUE )
|
|
{
|
|
POSITION pos = pListCtrl->GetFirstSelectedItemPosition();
|
|
if( pos )
|
|
pListCtrl->DeleteItem( pListCtrl->GetNextSelectedItem(pos) );
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
|
|
void CCalibrationDlg::OnButtonAdd()
|
|
{
|
|
TCHAR pBuffer[MAX_PATH];
|
|
CListCtrl *pListCtrl = &m_TabCameraDlg.m_ListTarget;
|
|
pListCtrl->InsertItem( 0, "" );
|
|
|
|
if( m_pTarget[0].bValid )
|
|
{
|
|
_stprintf( pBuffer, _T("%5.1f"), m_pTarget[0].angle );
|
|
pListCtrl->SetItemText( 0, 0, pBuffer );
|
|
_stprintf( pBuffer, _T("%5.1f"), m_pTarget[0].range );
|
|
pListCtrl->SetItemText( 0, 1, pBuffer );
|
|
}
|
|
else
|
|
{
|
|
pListCtrl->SetItemText( 0, 0, _T("-1.0") );
|
|
pListCtrl->SetItemText( 0, 1, _T("-1.0") );
|
|
}
|
|
|
|
if( m_pTarget[1].bValid )
|
|
{
|
|
_stprintf( pBuffer, _T("%5.1f"), m_pTarget[1].angle );
|
|
pListCtrl->SetItemText( 0, 2, pBuffer );
|
|
_stprintf( pBuffer, _T("%5.1f"), m_pTarget[1].range );
|
|
pListCtrl->SetItemText( 0, 3, pBuffer );
|
|
}
|
|
else
|
|
{
|
|
pListCtrl->SetItemText( 0, 2, _T("-1.0") );
|
|
pListCtrl->SetItemText( 0, 3, _T("-1.0") );
|
|
}
|
|
|
|
CVideoCameraPTZ *pCamera = (CVideoCameraPTZ*)m_Relation.pCamera;//m_Storage.GetVideoCamera(0);
|
|
ASSERT( pCamera );
|
|
double pan = -1.0, tilt = -1.0, zoom = -1.0;
|
|
pCamera->GetPTZ( pan, tilt, zoom );
|
|
_stprintf( pBuffer, _T("%5.1f"), pan );
|
|
pListCtrl->SetItemText( 0, 4, pBuffer );
|
|
_stprintf( pBuffer, _T("%5.1f"), tilt );
|
|
pListCtrl->SetItemText( 0, 5, pBuffer );
|
|
// _stprintf( pBuffer, _T("%5.1f"), zoom );
|
|
_stprintf( pBuffer, _T("-1.0") );
|
|
pListCtrl->SetItemText( 0, 6, pBuffer );
|
|
|
|
|
|
}
|
|
|
|
void CCalibrationDlg::CheckReady()
|
|
{
|
|
if( m_bPtzReady && ( m_pTarget[0].bValid || m_pTarget[1].bValid ))
|
|
m_TabCameraDlg.m_ButtonAdd.EnableWindow( TRUE );
|
|
else
|
|
m_TabCameraDlg.m_ButtonAdd.EnableWindow( FALSE );
|
|
}
|
|
|
|
void CCalibrationDlg::OnButtonParameters()
|
|
{
|
|
CParametersDlg dlg;
|
|
dlg.SetCalibrationData( &m_CalibrationData );
|
|
dlg.DoModal();
|
|
}
|
|
|
|
void CCalibrationDlg::OnButtonCalculate()
|
|
{
|
|
TCHAR pBuffer[ MAX_PATH ];
|
|
|
|
CListCtrl *pListCtrl = &m_TabCameraDlg.m_ListTarget;
|
|
int nCount = pListCtrl->GetItemCount();
|
|
|
|
if( !nCount )
|
|
return;
|
|
|
|
for( int i = 0; i < nCount; i++ )
|
|
{
|
|
pListCtrl->GetItemText( i, 0, pBuffer, MAX_PATH );
|
|
double ma = atof( pBuffer );
|
|
|
|
pListCtrl->GetItemText( i, 1, pBuffer, MAX_PATH );
|
|
double mr = atof( pBuffer );
|
|
|
|
pListCtrl->GetItemText( i, 2, pBuffer, MAX_PATH );
|
|
double sa = atof( pBuffer );
|
|
|
|
pListCtrl->GetItemText( i, 3, pBuffer, MAX_PATH );
|
|
double sr = atof( pBuffer );
|
|
|
|
pListCtrl->GetItemText( i, 4, pBuffer, MAX_PATH );
|
|
double cp = atof( pBuffer );
|
|
|
|
pListCtrl->GetItemText( i, 5, pBuffer, MAX_PATH );
|
|
double ct = atof( pBuffer );
|
|
|
|
pListCtrl->GetItemText( i, 6, pBuffer, MAX_PATH );
|
|
double cz = atof( pBuffer );
|
|
|
|
m_CalibrationData.AddData( ma, mr, sa, sr, cp, ct, cz );
|
|
}
|
|
|
|
pListCtrl->DeleteAllItems();
|
|
|
|
CString name;
|
|
m_CalibrationData.Execute( GetSafeHwnd(), name );
|
|
|
|
if( m_Relation.pSensor )
|
|
{
|
|
m_Relation.pSensor->GetCalibrationNameArray().Add( name );
|
|
m_Storage.SaveCalibrationName( m_Relation.pSensor );
|
|
}
|
|
|
|
m_TabCameraDlg.m_ButtonCalculate.EnableWindow( FALSE );
|
|
}
|
|
|
|
LRESULT CCalibrationDlg::OnWMCalibration(WPARAM wParam, LPARAM lParam)
|
|
{
|
|
m_TabCameraDlg.m_ButtonCalculate.EnableWindow( TRUE );
|
|
OnButtonReport();
|
|
return 0;
|
|
}
|
|
|
|
void CCalibrationDlg::OnButtonLoad()
|
|
{
|
|
CLoadDlg dlg;
|
|
dlg.SetData( &m_Storage, &m_CalibrationData, &m_Relation );
|
|
if( dlg.DoModal() == IDOK )
|
|
{
|
|
CDataList list;
|
|
m_CalibrationData.GetDataList( dlg.GetFolderName(), list );
|
|
POSITION pos = list.GetTailPosition();
|
|
while( pos )
|
|
{
|
|
DATACALC dc = list.GetPrev( pos );
|
|
TCHAR pBuffer[MAX_PATH];
|
|
CListCtrl *pListCtrl = &m_TabCameraDlg.m_ListTarget;
|
|
pListCtrl->InsertItem( 0, "" );
|
|
_stprintf( pBuffer, _T("%5.1f"), dc.ma );
|
|
pListCtrl->SetItemText( 0, 0, pBuffer );
|
|
_stprintf( pBuffer, _T("%5.1f"), dc.mr );
|
|
pListCtrl->SetItemText( 0, 1, pBuffer );
|
|
_stprintf( pBuffer, _T("%5.1f"), dc.sa );
|
|
pListCtrl->SetItemText( 0, 2, pBuffer );
|
|
_stprintf( pBuffer, _T("%5.1f"), dc.sr );
|
|
pListCtrl->SetItemText( 0, 3, pBuffer );
|
|
_stprintf( pBuffer, _T("%5.1f"), dc.cp );
|
|
pListCtrl->SetItemText( 0, 4, pBuffer );
|
|
_stprintf( pBuffer, _T("%5.1f"), dc.ct );
|
|
pListCtrl->SetItemText( 0, 5, pBuffer );
|
|
_stprintf( pBuffer, _T("%5.1f"), dc.cz );
|
|
pListCtrl->SetItemText( 0, 6, pBuffer );
|
|
}
|
|
}
|
|
}
|
|
|
|
void CCalibrationDlg::OnMove(int x, int y)
|
|
{
|
|
CDialog::OnMove(x, y);
|
|
}
|
|
|
|
void CCalibrationDlg::OnButtonReset()
|
|
{
|
|
if( m_Relation.pSensor && m_Relation.pSensor->GetType() != CVisual::LGS )
|
|
return;
|
|
|
|
if( MessageBox( _T("Are you sure that you want to reset LGS?"), NULL, MB_YESNO | MB_ICONEXCLAMATION ) != IDYES )
|
|
return;
|
|
|
|
static_cast<CSensorLGS*>(m_Relation.pSensor)->CmdReset( FALSE );
|
|
OnButtonClear();
|
|
}
|
|
|
|
void CCalibrationDlg::OnButtonClear()
|
|
{
|
|
if( m_Relation.pSensor )
|
|
m_Relation.pSensor->Reset();
|
|
m_PropertyLGSWnd.InvalidateRect( NULL );
|
|
m_PropertyLGSWnd.RedrawWindow();
|
|
|
|
m_pTarget[0].bValid = FALSE;
|
|
m_pTarget[1].bValid = FALSE;
|
|
}
|
|
|
|
void CCalibrationDlg::OnCheckFilter()
|
|
{
|
|
m_PropertyLGSWnd.UseVisibleZone( m_Filter.GetCheck() );
|
|
}
|
|
|
|
void CCalibrationDlg::OnButtonTest()
|
|
{
|
|
CVideoCameraPTZ* pCamera = (CVideoCameraPTZ*)m_Relation.pCamera;
|
|
|
|
if( m_bTestMode )
|
|
{
|
|
m_Test.SetWindowText( _T("Test...") );
|
|
m_bTestMode = FALSE;
|
|
|
|
if( pCamera /*&& pCamera->IsReady()*/ )
|
|
{
|
|
if( MessageBox( _T("Assign parameters to relation?"), NULL, MB_YESNO | MB_ICONQUESTION ) == IDYES )
|
|
{
|
|
DATARES dr[2];
|
|
if( m_CalibrationData.GetResult( m_TestFolderName, dr[0], dr[1] ) )
|
|
{
|
|
m_Storage.SaveTransform( m_Relation.pSensor );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if( pCamera /*&& pCamera->IsReady()*/ )
|
|
{
|
|
CLoadDlg dlg;
|
|
dlg.SetData( &m_Storage, &m_CalibrationData, &m_Relation );
|
|
if( dlg.DoModal() == IDOK )
|
|
{
|
|
DATARES dr[2];
|
|
if( m_CalibrationData.GetResult( m_TestFolderName = dlg.GetFolderName(), dr[0], dr[1] ) )
|
|
{
|
|
m_Relation.pSensor->GetTransform(0)->Prepare( dr[0].x, dr[0].y, dr[0].z, dr[0].psi, dr[0].theta, dr[0].phi );
|
|
m_Relation.pSensor->GetTransform(1)->Prepare( dr[1].x, dr[1].y, dr[1].z, dr[1].psi, dr[1].theta, dr[1].phi );
|
|
m_Test.SetWindowText( _T("Stop") );
|
|
m_bTestMode = TRUE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void CCalibrationDlg::OnButtonReport()
|
|
{
|
|
CReportDlg dlg;
|
|
dlg.SetCalibrationData( &m_Storage, &m_CalibrationData, &m_Relation );
|
|
dlg.DoModal();
|
|
}
|
|
|
|
void CCalibrationDlg::MakeCrossTarget()
|
|
{
|
|
if( m_pVideoWnd && m_pVideoWnd->GetSafeHwnd() )
|
|
{
|
|
CRect rect;
|
|
m_pVideoWnd->GetClientRect( &rect );
|
|
|
|
const double pX = 0.10; // 15%
|
|
const double pY = 0.25; // 30%
|
|
const int W1 = 2; // width
|
|
const int W2 = 1; // width
|
|
|
|
double x1 = ( rect.Width() * ( 1.0 - pX ) ) / 2.0;
|
|
double y1 = ( rect.Height() * ( 1.0 - pY ) ) / 2.0;
|
|
double x2 = x1 + rect.Width() * pX;
|
|
double y2 = y1 + rect.Height() * pY;
|
|
double x3 = rect.Width() / 2;
|
|
double y3 = rect.Height() / 2;
|
|
|
|
CRect frameS( (int)x1, (int)y1, (int)x2, (int)y2 );
|
|
CRect frameB( (int)x1 - W1, (int)y1 - W1, (int)x2 + W1, (int)y2 + W1 );
|
|
|
|
CRect frameU( (int)x3 - W2, frameB.top, (int)x3 + W2, frameB.top - W1 );
|
|
CRect frameD( (int)x3 - W2, frameB.bottom, (int)x3 + W2, frameB.bottom + W1 );
|
|
CRect frameL( frameB.left, (int)y3 - W2, frameB.left - W1, (int)y3 + W2 );
|
|
CRect frameR( frameB.right, (int)y3 - W2, frameB.right + W1, (int)y3 + W2 );
|
|
|
|
CRgn rgn;
|
|
rgn.CreateRectRgnIndirect( &rect );
|
|
|
|
CRgn rgnS;
|
|
rgnS.CreateRectRgnIndirect( frameS );
|
|
CRgn rgnB;
|
|
rgnB.CreateRectRgnIndirect( frameB );
|
|
|
|
CRgn rgnU;
|
|
rgnU.CreateRectRgnIndirect( frameU );
|
|
CRgn rgnD;
|
|
rgnD.CreateRectRgnIndirect( frameD );
|
|
CRgn rgnL;
|
|
rgnL.CreateRectRgnIndirect( frameL );
|
|
CRgn rgnR;
|
|
rgnR.CreateRectRgnIndirect( frameR );
|
|
|
|
rgn.CombineRgn( &rgn, &rgnB, RGN_DIFF );
|
|
rgn.CombineRgn( &rgn, &rgnU, RGN_DIFF );
|
|
rgn.CombineRgn( &rgn, &rgnD, RGN_DIFF );
|
|
rgn.CombineRgn( &rgn, &rgnL, RGN_DIFF );
|
|
rgn.CombineRgn( &rgn, &rgnR, RGN_DIFF );
|
|
|
|
rgn.CombineRgn( &rgn, &rgnS, RGN_OR );
|
|
|
|
m_pVideoWnd->SetWindowRgn( (HRGN)rgn.GetSafeHandle(), TRUE );
|
|
}
|
|
}
|
|
|
|
void CCalibrationDlg::OnSelchangeTabMode( NMHDR* pNMHDR, LRESULT* pResult )
|
|
{
|
|
BOOL bShowCamera = FALSE;
|
|
BOOL bShowLinearization = FALSE;
|
|
|
|
switch( m_TabMode.GetCurSel() )
|
|
{
|
|
case TAB_CAMERA: bShowCamera = TRUE; break;
|
|
case TAB_LINEARIZATION: bShowLinearization = TRUE; break;
|
|
}
|
|
|
|
m_TabCameraDlg.ShowWindow( bShowCamera ? SW_SHOW : SW_HIDE );
|
|
m_TabLinearizationDlg.ShowWindow( bShowLinearization ? SW_SHOW : SW_HIDE );
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
BOOL CCalibrationDlg::DownloadCalibrationTables()
|
|
{
|
|
if( !m_Relation.pSensor )
|
|
return FALSE;
|
|
|
|
m_bCtGetInProgress[0] = static_cast<CSensorLGS*>(m_Relation.pSensor)->CmdGetCalibrationTable(0);
|
|
m_bCtGetInProgress[1] = static_cast<CSensorLGS*>(m_Relation.pSensor)->CmdGetCalibrationTable(1);
|
|
return m_bCtGetInProgress[0] && m_bCtGetInProgress[1];
|
|
}
|
|
|
|
BOOL CCalibrationDlg::UploadCalibrationTables(CLgDeviceLGS::LGS_CALIBRATION_TABLE& ct1, CLgDeviceLGS::LGS_CALIBRATION_TABLE& ct2)
|
|
{
|
|
if( !m_Relation.pSensor )
|
|
return FALSE;
|
|
|
|
m_bCtSetInProgress[1] = static_cast<CSensorLGS*>(m_Relation.pSensor)->CmdSetCalibrationTable( ct2 );
|
|
m_bCtSetInProgress[0] = static_cast<CSensorLGS*>(m_Relation.pSensor)->CmdSetCalibrationTable( ct1 );
|
|
return m_bCtSetInProgress[0] && m_bCtSetInProgress[1];
|
|
}
|
|
|
|
void CCalibrationDlg::CheckCalibrationTable()
|
|
{
|
|
if( !m_Relation.pSensor || m_Relation.pSensor->GetType() != CVisual::LGS )
|
|
return;
|
|
|
|
|
|
CLgDeviceLGS::LGS_CALIBRATION_TABLE ct;
|
|
for( INT i = 0; i < 2; i++ )
|
|
{
|
|
if( m_bCtGetInProgress[i] && static_cast<CSensorLGS*>(m_Relation.pSensor)->GetGetCalibrationTable( i, ct ) )
|
|
{
|
|
m_bCtGetInProgress[i] = FALSE;
|
|
m_TabLinearizationDlg.SetCalibrationTable( FALSE, ct );
|
|
// LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CCalibrationDlg::OnTimer"), _T("Received calibration table for %s"), i ? _T("slave") : _T("master") );
|
|
}
|
|
|
|
if( m_bCtSetInProgress[i] && static_cast<CSensorLGS*>(m_Relation.pSensor)->GetSetCalibrationTable( i, ct ) )
|
|
{
|
|
m_bCtSetInProgress[i] = FALSE;
|
|
m_TabLinearizationDlg.SetCalibrationTable( TRUE, ct );
|
|
// LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CCalibrationDlg::OnTimer"), _T("Received calibration table for %s"), i ? _T("slave") : _T("master") );
|
|
}
|
|
}
|
|
}
|