1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
26 // * The name of Intel Corporation may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
42 // This class implements the property page for the CKalmTrack filter
44 #include <cvstreams.h>
52 #include "Kalmanprop.h"
53 #include "Kalmanuids.h"
58 // This goes in the factory template table to create new filter instances
60 CUnknown * WINAPI CKalmTrackProperties::CreateInstance(LPUNKNOWN lpunk, HRESULT *phr)
62 CUnknown *punk = new CKalmTrackProperties(lpunk, phr);
71 void CKalmTrackProperties::InitSlider( int id, int lower, int upper, int tic_freq )
73 HWND slider = GetDlgItem( m_hWnd, id );
76 SendMessage( slider, TBM_SETRANGE, TRUE, MAKELONG(lower, upper) );
80 SendMessage( slider, TBM_SETTICFREQ, tic_freq, 0 );
86 void CKalmTrackProperties::SetSliderPos( int id, int pos )
88 HWND slider = GetDlgItem( m_hWnd, id );
91 SendMessage( slider, TBM_SETPOS, TRUE, pos );
96 int CKalmTrackProperties::GetSliderPos( int id )
98 HWND slider = GetDlgItem( m_hWnd, id );
103 pos = SendMessage( slider, TBM_GETPOS, 0, 0 );
110 void CKalmTrackProperties::ReadParamsFromControls()
112 m_params.x = ((float)GetSliderPos( IDC_WIN_LEFT ))/SLIDER_MAX;
113 m_params.y = ((float)GetSliderPos( IDC_WIN_TOP ))/SLIDER_MAX;
114 m_params.width = ((float)GetSliderPos( IDC_WIN_WIDTH ))/SLIDER_MAX;
115 m_params.height = ((float)GetSliderPos( IDC_WIN_HEIGHT ))/SLIDER_MAX;
117 m_params.Smin = GetSliderPos( IDC_S_MIN );
118 m_params.Vmin = GetSliderPos( IDC_V_MIN );
119 m_params.view = IsDlgButtonChecked( m_hWnd, IDC_BACKPR );
123 void CKalmTrackProperties::WriteParamsToControls()
125 SetSliderPos( IDC_WIN_LEFT, cvRound( m_params.x * SLIDER_MAX ));
126 SetSliderPos( IDC_WIN_TOP, cvRound( m_params.y * SLIDER_MAX ));
127 SetSliderPos( IDC_WIN_WIDTH, cvRound( m_params.width * SLIDER_MAX ));
128 SetSliderPos( IDC_WIN_HEIGHT, cvRound( m_params.height * SLIDER_MAX ));
130 SetSliderPos( IDC_S_MIN, m_params.Smin );
131 SetSliderPos( IDC_V_MIN, m_params.Vmin );
132 CheckRadioButton( m_hWnd, IDC_NORMAL, IDC_BACKPR, m_params.view + IDC_NORMAL );
138 CKalmTrackProperties::CKalmTrackProperties(LPUNKNOWN pUnk, HRESULT *phr) :
139 CBasePropertyPage(NAME("Kalman Property Page"),pUnk,
151 // Sets m_bDirty and notifies the property page site of the change
153 void CKalmTrackProperties::SetDirty()
157 m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
166 // Virtual method called by base class with Window messages
168 BOOL CKalmTrackProperties::OnReceiveMessage(HWND hwnd,
178 InitSlider( IDC_WIN_LEFT, 0, 1000, 0 );
179 InitSlider( IDC_WIN_TOP, 0, 1000, 0 );
180 InitSlider( IDC_WIN_WIDTH, 0, 1000, 0 );
181 InitSlider( IDC_WIN_HEIGHT, 0, 1000, 0 );
183 InitSlider( IDC_S_MIN, 0, 255, 5 );
184 InitSlider( IDC_V_MIN, 0, 255, 5 );
186 WriteParamsToControls();
196 if(LOWORD(wParam) == IDC_START)
198 m_pCKalmTrack->StartTracking();
200 else if (LOWORD(wParam) == IDC_STOP)
202 m_pCKalmTrack->StopTracking();
206 return CBasePropertyPage::OnReceiveMessage(hwnd,uMsg,wParam,lParam);
208 } // OnReceiveMessage
214 // Called when the property page connects to a filter
216 HRESULT CKalmTrackProperties::OnConnect(IUnknown *pUnknown)
218 ASSERT(m_pCKalmTrack == NULL);
220 HRESULT hr = pUnknown->QueryInterface(IID_ICKalmTrack, (void **) &m_pCKalmTrack);
222 return E_NOINTERFACE;
225 ASSERT(m_pCKalmTrack);
226 m_pCKalmTrack->GetParams(&m_params);
236 // Called when we're disconnected from a filter
238 HRESULT CKalmTrackProperties::OnDisconnect()
240 // Release of Interface after setting the appropriate contrast value
242 if (m_pCKalmTrack == NULL) {
246 m_pCKalmTrack->Release();
247 m_pCKalmTrack = NULL;
256 // We are being deactivated
258 HRESULT CKalmTrackProperties::OnDeactivate(void)
268 // Changes made should be kept. Change the variable
270 HRESULT CKalmTrackProperties::OnApplyChanges()
272 ReadParamsFromControls();
273 m_pCKalmTrack->SetParams(&m_params);