Move the sources to trunk
[opencv] / filters / ProxyTrans / HowToUse.txt
1 ProxyTrans transform filter would call your function as a callback
2 on every frame instead of processing the image itself. If you
3 create a filter graph with your application, insert the proxy
4 filter before renderer (or at any other place you like) and set a
5 callback function defined in the application; the proxy implements
6 the special interface for such case -- IProxyTrans. Then start the
7 DS and every frame will be processed with your function. You can
8 find the binary of ProxyTrans in Bin folder of your OpenCV
9 installation. Here is the example of using ProxyTrans. Also refer
10 to Apps\Hawk\MainFrm.cpp and Apps\Hawk\AviSource.cpp.
11
12 #include <iProxyTrans.h>
13 #include <ProxyTransuids.h>
14
15 void callback(void*);
16
17 int Initialize()
18 {
19 /* Initialize the source filter, filter graph.
20 Find the samples of those in Apps\Hawk\MainFrm.cpp, functions
21 CMainFrame::CreateCamera and CMainFrame::CreateFilterGraph */
22
23     IProxyTransform* pProxyTrans = NULL;
24     // Create a proxy transform filter
25     if(FAILED(CoCreateInstance(CLSID_ProxyTransform, NULL,
26 CLSCTX_INPROC_SERVER,
27                 IID_IProxyTransform, (void**)&pProxyTrans))
28 || !pProxyTrans)
29     {
30         return -1;
31     }
32     IBaseFilter* pProxyFilter = NULL;
33     pProxyTrans->QueryInterface(IID_IBaseFilter, (void**)&pProxyFilter);
34
35     // Set the proxy callback
36     pProxyTrans->set_transform((void(*)(void*))callback, 0);
37
38     /* Connect the filters together and run DS, see the samples mentioned above */
39 }
40
41 void callback(void* _image)
42 {
43     IplImage* image = (IplImage*)_image;
44     /* process the frame as usual IplImage.
45     No image data is copied by ProxyTrans, it just creates an
46     IplImage structure that points to the data. Right now the data
47     format is restricted to 24 bits bmp which is a common case. */
48 }