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.
45 #include "Calib3DWindow.h"
47 class CCalibFilter : public CTransInPlaceFilter,
49 public ISpecifyPropertyPages,
56 CCalibFilter( TCHAR *tszName, LPUNKNOWN punk, HRESULT *phr);
61 static CUnknown * WINAPI CreateInstance(LPUNKNOWN punk, HRESULT *phr);
63 // Reveals CCalibFilter & ISpecifyPropertyPages
64 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv);
68 HRESULT Transform(IMediaSample *pSample);
69 HRESULT CheckInputType(const CMediaType *mtIn);
70 HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);
71 HRESULT DecideBufferSize(IMemAllocator *pAlloc,ALLOCATOR_PROPERTIES *pProperties);
72 HRESULT CheckTransform(const CMediaType *mtIn,const CMediaType *mtOut);
74 // ICCalibFilter methods
75 STDMETHODIMP get_EtalonParams(
76 CalibEtalonType* etalon_type,
78 long* etalon_param_count);
80 STDMETHODIMP set_EtalonParams(
81 CalibEtalonType etalon_type,
83 long etalon_param_count);
85 STDMETHODIMP get_FrameInterval(
88 STDMETHODIMP set_FrameInterval(
91 STDMETHODIMP get_FramesToCollect(
94 STDMETHODIMP set_FramesToCollect(
97 STDMETHODIMP StartCalibrate();
99 ////////////////////////////////
101 STDMETHODIMP get_EnableFilter(
104 STDMETHODIMP set_EnableFilter(
107 STDMETHODIMP get_EnableUndistortion(
110 STDMETHODIMP set_EnableUndistortion(
113 STDMETHODIMP get_Show3DWindow(
116 STDMETHODIMP set_Show3DWindow(
119 STDMETHODIMP get_TrackEtalon(
122 STDMETHODIMP set_TrackEtalon(
125 STDMETHODIMP Update3DWindow();
127 STDMETHODIMP SaveCameraParams();
129 STDMETHODIMP LoadCameraParams();
131 ////////////////////////////////
133 STDMETHODIMP GetCameraParams( CvCameraParams* camera );
135 STDMETHODIMP GetState(
136 CalibState* calib_state,
137 long* frames_collected,
139 double* last_frame_time);
141 // ISpecifyPropertyPages method
142 STDMETHODIMP GetPages(CAUUID *pPages);
144 // IPersistStream implementation
145 STDMETHODIMP GetClassID( CLSID *pClsID );
147 DWORD GetSoftwareVersion();
148 //STDMETHODIMP Save(LPSTREAM pStm, BOOL fClearDirty);
150 HRESULT ReadFromStream( IStream* stream );
151 HRESULT WriteToStream( IStream* stream );
155 void CheckReallocBuffers( IplImage* rgb_img );
156 void ProcessFrame( IplImage* rgb_img, double frame_time );
157 void CalculateCameraParams( CvSize img_size );
158 double GetFrameTime( IMediaSample* sample );
159 void DrawEtalon( IplImage* rgb_img, CvPoint2D32f* corners,
160 int corner_count, CvSize etalon_size,
162 void FillEtalonObjPoints( CvPoint3D32f* obj_points,
166 CvSize GetEtalonSize();
168 // Non interface locking critical section
169 CCritSec m_CCalibFilterLock;
170 CalibFilterParams m_params, m_initial_params;
172 /* temporary images, used in processing */
173 IplImage* m_gray_img;
174 IplImage* m_thresh_img;
175 IplImage* m_undist_img;
177 /* processed frame */
180 /* calibration buffers */
182 CvPoint2D32f* m_imagePoints;
183 CvPoint3D32f* m_objectPoints;
184 CvPoint3D32f* m_transVects;
189 /* camera parameters */
190 CvCameraParams m_camera;
192 /* 3D OpenGL window */
193 CCalib3DWindow* m_window3D;
195 /* undistortion data */
196 CvCameraParams m_undistort_params;
197 IplImage* m_undistort_data;
199 }; /* CCalibFilter */