356e3e965697bb4482c4420b26efdf1893b4e361
[opencv] / filters / Tracker3dFilter / include / ITracker3dFilter.h
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
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.
8 //
9 //
10 //                        Intel License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2002, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 //   * Redistributions of source code must retain the above copyright notice,
20 //     this list of conditions and the following disclaimer.
21 //
22 //   * Redistributions 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.
25 //
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.
28 //
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.
39 //
40 //M*/
41
42 #pragma once
43 #pragma warning(disable:4786)
44
45 #include <objbase.h>
46 #include <vector>
47 #include <string>
48 #include "ITracker.h"
49
50 // {7CD9FE5C-AEDB-4d66-A22F-EA1A48256D5F}
51 DEFINE_GUID(IID_ITracker3dFilter, 0x7cd9fe5c, 0xaedb, 0x4d66, 0xa2, 0x2f, 0xea, 0x1a, 0x48, 0x25, 0x6d, 0x5f);
52
53 // {C4A7F22C-DD1A-4ad8-81CA-773C10BEA6D2}
54 DEFINE_GUID(IID_ITracker3dCallback, 0xc4a7f22c, 0xdd1a, 0x4ad8, 0x81, 0xca, 0x77, 0x3c, 0x10, 0xbe, 0xa6, 0xd2);
55
56 // {0CFDE75C-F623-4320-A46F-2F751EA8712A}
57 DEFINE_GUID(IID_ITracker3dInternal, 0xcfde75c, 0xf623, 0x4320, 0xa4, 0x6f, 0x2f, 0x75, 0x1e, 0xa8, 0x71, 0x2a);
58
59 // {E08D9471-8C14-4547-9B61-0D8A89E7C42B}
60 DEFINE_GUID(CLSID_Tracker3dFilter, 0xe08d9471, 0x8c14, 0x4547, 0x9b, 0x61, 0xd, 0x8a, 0x89, 0xe7, 0xc4, 0x2b);
61
62
63 // The application and/or property page registers for callbacks from the filter by
64 // implementing this interface and passing it to ITracker3dFilter::AddCallback.
65 interface ITracker3dCallback : IUnknown
66 {
67     // Callback is called by the filter after processing each set of frames.
68     // The image argument is the raw image data, with no header.
69     // If the image is needed past the time the callback returns,
70     // this function should AddRef the IUnknown pointer and release it when
71     // it is done with the image.
72     // If tracked_objects is needed past the time the callback returns,
73     // it must be copied.
74     STDMETHOD(Callback)(const std::vector<Cv3dTrackerTrackedObject> &tracked_objects, const unsigned char *image, IUnknown *unk) = 0;
75 };
76
77 interface ITracker3dFilter : IUnknown
78 {
79     STDMETHOD(GetNumberOfCameras)(int &num_cameras) = 0;
80
81     // Load/SaveCameraConfiguration allows the camera position and
82     // orientation information to be saved in a file. This allows
83     // tracking to begin without having to recalibrate the camera.
84     // The filter also saves the camera configuration in the registry
85     // and will load it from there if LoadCameraConfiguration is not
86     // called.
87     STDMETHOD(LoadCameraConfiguration)(const char *filename) = 0;
88     STDMETHOD(SaveCameraConfiguration)(const char *filename) = 0;
89
90     // The default tracker is used when SetTrackers is called with the
91     // second argument set to NULL. The default tracker is saved when
92     // the filter graph is saved.
93     STDMETHOD(GetDefaultTracker)(GUID &filename) = 0;
94     STDMETHOD(SetDefaultTracker)(const GUID &filename) = 0;
95
96     // SetTrackers is used to change the number of streams (cameras)
97     // as well as to specify which trackers to use. If the trackers
98     // argument is NULL, an instance of the default tracker is created
99     // for each stream. If the trackers argument is non-NULL, it is
100     // an array of num_streams pointers to trackers. If any of the
101     // pointers is NULL, no tracker is assigned to that stream; the
102     // stream is effectively ignored.
103     // SetTrackers should not be called if the filter's pins are connected,
104     // unless num_streams is unchanged and the new trackers are guaranteed
105     // to accept the same image format as the current trackers.
106     STDMETHOD(SetTrackers)(int num_streams, ITracker * const *trackers) = 0;
107     STDMETHOD(GetTrackers)(std::vector<ITracker *> &trackers) = 0;
108
109     // CalibrateCameras begins camera calibration. Calibration continues
110     // until all cameras are calibrated simultaneously. The array of camera
111     // intrinsics filenames has an entry for each camera. The camera
112     // intrinsics files are text files in the format created by CalibFilter.
113     // For testing purposes, if continuous is set to true, calibration
114     // continues even after calibration succeeds, until this method is called
115     // again with continuous set to false.
116     STDMETHOD(CalibrateCameras)(int checkerboard_width, int checkerboard_height,
117                                 const char *camera_intrinsics_filenames[],
118                                 float square_size = 1.0f,
119                                 bool continuous = false) = 0;
120
121     // GetTrackedObjects returns the last set of objects found. This is the
122     // same as the informotion passed to the callback function.
123     STDMETHOD(GetTrackedObjects)(std::vector<Cv3dTrackerTrackedObject> &tracked_objects) = 0;
124
125     // Only one image is passed to the callback function. ViewingStream
126     // controls which camera's image that is.
127     STDMETHOD(SetViewingStream)(int stream) = 0;
128     STDMETHOD(GetViewingStream)(int &stream) = 0;
129
130     // GetCameraName returns a unique ASCII identifier for the specified
131     // camera (not intended to be human readable).
132     STDMETHOD(GetCameraName)(int camera, std::string &name) = 0;
133
134     // PreferredInputSize specifies what image size should be accepted.
135     // To be effective, this must be set before the input pins are connected.
136     enum InputSize { SIZE_Any, SIZE_320x240, SIZE_640x480 };
137     STDMETHOD(SetPreferredInputSize)(InputSize size) = 0;
138     STDMETHOD(GetPreferredInputSize)(InputSize &size) = 0;
139
140     // AddCallback is used to register a callback which will be called
141     // after each frame is processed.
142     STDMETHOD(AddCallback)(ITracker3dCallback *) = 0;
143     STDMETHOD(RemoveCallback)(ITracker3dCallback *) = 0;
144
145     // IsConnected reports whether any or all of the filter's pins are
146     // connected. If any pins are connected, some methods should not be
147     // called.
148     STDMETHOD(IsConnected)(bool &any_connected, bool &all_connected) = 0;
149 };
150
151 interface ITracker3dInternal : IUnknown
152 {
153     // GetCameraInfo returns the current calibration information for the cameras.
154     STDMETHOD(GetCameraInfo)(std::vector<Cv3dTrackerCameraInfo> &info) = 0;
155 };