camellia 2.7.0-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/CamelliaLib-2.7.0.tar.gz +0 -0
- data/README +59 -0
- data/doc/README +58 -0
- data/doc/camellia.dox +205 -0
- data/doc/html/annotated.html +52 -0
- data/doc/html/camellia_8h-source.html +1618 -0
- data/doc/html/camellia_8h.html +4583 -0
- data/doc/html/doxygen.css +358 -0
- data/doc/html/doxygen.png +0 -0
- data/doc/html/files.html +29 -0
- data/doc/html/ftv2blank.png +0 -0
- data/doc/html/ftv2doc.png +0 -0
- data/doc/html/ftv2folderclosed.png +0 -0
- data/doc/html/ftv2folderopen.png +0 -0
- data/doc/html/ftv2lastnode.png +0 -0
- data/doc/html/ftv2link.png +0 -0
- data/doc/html/ftv2mlastnode.png +0 -0
- data/doc/html/ftv2mnode.png +0 -0
- data/doc/html/ftv2node.png +0 -0
- data/doc/html/ftv2plastnode.png +0 -0
- data/doc/html/ftv2pnode.png +0 -0
- data/doc/html/ftv2vertline.png +0 -0
- data/doc/html/functions.html +108 -0
- data/doc/html/functions_0x62.html +78 -0
- data/doc/html/functions_0x63.html +112 -0
- data/doc/html/functions_0x64.html +113 -0
- data/doc/html/functions_0x65.html +102 -0
- data/doc/html/functions_0x66.html +82 -0
- data/doc/html/functions_0x67.html +76 -0
- data/doc/html/functions_0x68.html +88 -0
- data/doc/html/functions_0x69.html +90 -0
- data/doc/html/functions_0x6b.html +70 -0
- data/doc/html/functions_0x6c.html +88 -0
- data/doc/html/functions_0x6d.html +93 -0
- data/doc/html/functions_0x6e.html +79 -0
- data/doc/html/functions_0x6f.html +74 -0
- data/doc/html/functions_0x70.html +72 -0
- data/doc/html/functions_0x72.html +73 -0
- data/doc/html/functions_0x73.html +130 -0
- data/doc/html/functions_0x74.html +82 -0
- data/doc/html/functions_0x76.html +74 -0
- data/doc/html/functions_0x77.html +75 -0
- data/doc/html/functions_0x78.html +72 -0
- data/doc/html/functions_0x79.html +77 -0
- data/doc/html/functions_0x7e.html +76 -0
- data/doc/html/functions_func.html +93 -0
- data/doc/html/functions_func_0x62.html +64 -0
- data/doc/html/functions_func_0x63.html +83 -0
- data/doc/html/functions_func_0x64.html +99 -0
- data/doc/html/functions_func_0x65.html +95 -0
- data/doc/html/functions_func_0x66.html +74 -0
- data/doc/html/functions_func_0x67.html +72 -0
- data/doc/html/functions_func_0x68.html +76 -0
- data/doc/html/functions_func_0x69.html +70 -0
- data/doc/html/functions_func_0x6c.html +76 -0
- data/doc/html/functions_func_0x6d.html +78 -0
- data/doc/html/functions_func_0x6f.html +65 -0
- data/doc/html/functions_func_0x70.html +64 -0
- data/doc/html/functions_func_0x72.html +65 -0
- data/doc/html/functions_func_0x73.html +113 -0
- data/doc/html/functions_func_0x74.html +74 -0
- data/doc/html/functions_func_0x76.html +64 -0
- data/doc/html/functions_func_0x77.html +64 -0
- data/doc/html/functions_func_0x7e.html +72 -0
- data/doc/html/functions_vars.html +290 -0
- data/doc/html/globals.html +368 -0
- data/doc/html/globals_defs.html +41 -0
- data/doc/html/globals_func.html +364 -0
- data/doc/html/index.html +11 -0
- data/doc/html/main.html +22 -0
- data/doc/html/pages.html +24 -0
- data/doc/html/structCamAffineTransform.html +37 -0
- data/doc/html/structCamArithmParams.html +60 -0
- data/doc/html/structCamBasin.html +62 -0
- data/doc/html/structCamBitmapFont.html +37 -0
- data/doc/html/structCamBlobInfo.html +90 -0
- data/doc/html/structCamBlobs.html +51 -0
- data/doc/html/structCamImage.html +853 -0
- data/doc/html/structCamKeypoint.html +79 -0
- data/doc/html/structCamKeypoints.html +99 -0
- data/doc/html/structCamKeypointsKdTree.html +42 -0
- data/doc/html/structCamKeypointsMatches.html +54 -0
- data/doc/html/structCamLabelingResults.html +46 -0
- data/doc/html/structCamLinearFilterKernel.html +63 -0
- data/doc/html/structCamMeasuresResults.html +54 -0
- data/doc/html/structCamMorphoMathsKernel.html +81 -0
- data/doc/html/structCamPoint.html +46 -0
- data/doc/html/structCamRLEImage.html +183 -0
- data/doc/html/structCamROI.html +80 -0
- data/doc/html/structCamRun.html +56 -0
- data/doc/html/structCamSepFilterKernel.html +67 -0
- data/doc/html/structCamTable.html +46 -0
- data/doc/html/structCamTableOfBasins.html +37 -0
- data/doc/html/structCamVolbergFwdParams.html +46 -0
- data/doc/html/structCamWarpingParams.html +70 -0
- data/doc/html/tab_b.gif +0 -0
- data/doc/html/tab_l.gif +0 -0
- data/doc/html/tab_r.gif +0 -0
- data/doc/html/tabs.css +102 -0
- data/doc/html/todo.html +29 -0
- data/doc/html/tree.html +106 -0
- data/doc/rtf/refman.rtf +7866 -0
- data/ext/Makefile +149 -0
- data/ext/README +12 -0
- data/ext/camellia_ruby.i +493 -0
- data/ext/camellia_ruby_wrap.cxx +21103 -0
- data/ext/extconf.rb +12 -0
- data/ext/install.rb +11 -0
- data/ext/swig_ruby.dsp +159 -0
- data/ext/swig_ruby.vcproj +290 -0
- data/ext/test.rb +31 -0
- data/inc/SHLWAPI.H +661 -0
- data/inc/cam_capture.h +202 -0
- data/inc/camellia.h +2651 -0
- data/inc/camellia_internals.h +205 -0
- data/inc/config.h +62 -0
- data/inc/config.h.in +61 -0
- data/inc/stamp-h1 +1 -0
- data/lib/camellia-fox.rb +39 -0
- data/test/test_arithm.rb +13 -0
- data/test/test_capture.rb +15 -0
- data/test/test_color_labeling.rb +45 -0
- data/test/test_copy.rb +13 -0
- data/test/test_draw.rb +15 -0
- data/test/test_fixed_filters.rb +23 -0
- data/test/test_fox.rb +106 -0
- data/test/test_fox2.rb +108 -0
- data/test/test_histogram.rb +18 -0
- data/test/test_hough.rb +29 -0
- data/test/test_keypoints.rb +106 -0
- data/test/test_labeling.rb +30 -0
- data/test/test_mask.rb +34 -0
- data/test/test_warping.rb +46 -0
- data/test/test_watershed.rb +35 -0
- data/test/ts_camellia.rb +12 -0
- metadata +204 -0
data/inc/cam_capture.h
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
#ifndef __CAM_CAPTURE_H
|
2
|
+
#define __CAM_CAPTURE_H
|
3
|
+
|
4
|
+
#include <atlbase.h>
|
5
|
+
#include <qedit.h>
|
6
|
+
#include <stdio.h>
|
7
|
+
|
8
|
+
#include "camellia.h"
|
9
|
+
|
10
|
+
#define SafeRelease(p) { if( (p) != 0 ) { (p)->Release(); (p)= NULL; } }
|
11
|
+
|
12
|
+
#include <dshow.h>
|
13
|
+
|
14
|
+
class CamCaptureGraph
|
15
|
+
{
|
16
|
+
public:
|
17
|
+
void showPropPage();
|
18
|
+
bool createFilterGraph(IMoniker * videoDeive);
|
19
|
+
CamCaptureGraph();
|
20
|
+
virtual ~CamCaptureGraph();
|
21
|
+
|
22
|
+
void setDesiredVideoFormat(int w, int h, int fps);
|
23
|
+
// Set the window to display the video
|
24
|
+
void SetRenderWindow(HWND hWnd, bool isScaling = false) { m_pRenderCWnd = hWnd; m_fIsScaling = isScaling; }
|
25
|
+
|
26
|
+
// Render a video file
|
27
|
+
void RenderFile(char * vname = NULL);
|
28
|
+
// Automatically find a capturing device to capture video
|
29
|
+
// If fSetup = true, a dialog is popped first to ask for video format
|
30
|
+
bool CaptureLive(bool fSetup = false);
|
31
|
+
|
32
|
+
// Init the given video device, but does NOT start the capture;
|
33
|
+
bool initCaptureLive (IMoniker * videoDeive, bool fSetup = false);
|
34
|
+
|
35
|
+
// Destroy the whole Graph
|
36
|
+
void Destroy() { destroyFilterGraph(); };
|
37
|
+
|
38
|
+
// Pause the video
|
39
|
+
void Pause() { m_pMediaControl->Pause(); }
|
40
|
+
// Continue play the video
|
41
|
+
void Play();
|
42
|
+
// Stop the video
|
43
|
+
void Stop() { m_pMediaControl->Stop(); }
|
44
|
+
LONGLONG Seek( int offset );
|
45
|
+
// Seek in the video if the media type allows
|
46
|
+
|
47
|
+
// this is only useful before the video graph is built
|
48
|
+
// if you don't want to show the video,
|
49
|
+
// call it first thing after the object is constructed.
|
50
|
+
void setVideoFlag(bool flag);
|
51
|
+
|
52
|
+
protected:
|
53
|
+
// Create the filter graph to render the video (capture or playback)
|
54
|
+
virtual bool createFilterGraph();
|
55
|
+
// Release the filter graph
|
56
|
+
virtual void destroyFilterGraph();
|
57
|
+
// Start the playing
|
58
|
+
void startGraph();
|
59
|
+
// Stop playing
|
60
|
+
void stopGraph();
|
61
|
+
// automaticly find a usable capturing device
|
62
|
+
HRESULT findCaptureDevice(IBaseFilter ** ppSrcFilter);
|
63
|
+
|
64
|
+
///////////////////////////////////////////////////////////////////
|
65
|
+
// Build the capture graph
|
66
|
+
virtual bool buildCaptureGraph(IBaseFilter * filter = 0);
|
67
|
+
virtual bool buildRenderFileGraph();
|
68
|
+
|
69
|
+
///////////////////////////////////////////////////////////////////
|
70
|
+
// The following 3 functions are for derivation if you need extra
|
71
|
+
// filters in the graph, implement the 3 functions to do it
|
72
|
+
///////////////////////////////////////////////////////////////////
|
73
|
+
// create and add extra filters, called in createFilterGraph() to
|
74
|
+
// create extra filters into the graph
|
75
|
+
virtual void addExtraFilters() {}
|
76
|
+
// release the resource related to the extra filters
|
77
|
+
virtual void releaseExtraFilters() {}
|
78
|
+
// initialization the extra filters after the graph is finished
|
79
|
+
virtual bool initExtraFilters() {return false;}
|
80
|
+
|
81
|
+
// Get the input or output pin to connect filters
|
82
|
+
IPin* get_pin( IBaseFilter* pFilter, PIN_DIRECTION dir );
|
83
|
+
|
84
|
+
// DirectShow interface pointers
|
85
|
+
IGraphBuilder *m_pGraphBuilder; // build render graph
|
86
|
+
ICaptureGraphBuilder2 * m_pCaptureGraphBuilder2; // for capture
|
87
|
+
IMediaControl *m_pMediaControl; // MediaControl
|
88
|
+
IVideoWindow *m_pVideoWindow; // window to play video
|
89
|
+
IFilterGraph *m_pFilterGraph; // Filter Graph
|
90
|
+
IMediaSeeking *m_pMediaSeeking; // Seeking interface
|
91
|
+
|
92
|
+
HWND m_pRenderCWnd; // The CWnd to display the video in
|
93
|
+
WCHAR m_aVName[100]; // The video file name to render
|
94
|
+
bool m_fIsCapturing; // What kind of graph we are building
|
95
|
+
bool m_fIsScaling; // scale the video to the display window
|
96
|
+
bool m_fShowCaptureProperties; // Setup dialog before capture
|
97
|
+
bool m_fstartGraph; // has the video graph started;
|
98
|
+
bool m_showVideoFlag; // default = false;
|
99
|
+
// Do we want the filtergraph to be viewable by GraphEdit
|
100
|
+
|
101
|
+
bool m_fRegisterFilterGraph;
|
102
|
+
DWORD m_dwGraphRegister;
|
103
|
+
void removeGraphFromRot(DWORD pdwRegister);
|
104
|
+
HRESULT addGraphToRot(IUnknown *pUnkGraph, DWORD *pdwRegister);
|
105
|
+
|
106
|
+
int m_desiredWidth, m_desiredHeight;
|
107
|
+
int m_desiredFrameRate;
|
108
|
+
|
109
|
+
HRESULT selectVideoFormat();
|
110
|
+
|
111
|
+
public:
|
112
|
+
IBaseFilter * m_pSrcFilter;
|
113
|
+
};
|
114
|
+
|
115
|
+
class CamCaptureGrabberCB: public ISampleGrabberCB
|
116
|
+
{
|
117
|
+
public: // The interface to control the tracker with the SampleGrabberFilter
|
118
|
+
CamCaptureGrabberCB();
|
119
|
+
~CamCaptureGrabberCB();
|
120
|
+
|
121
|
+
void SetGrabMediaType( AM_MEDIA_TYPE mt ) {m_mediaType = mt;}
|
122
|
+
|
123
|
+
// The function that called when every frame is being processed
|
124
|
+
// So we implement our tracking algorithm here now. It is like
|
125
|
+
// the Transform() in Transform filter.
|
126
|
+
STDMETHODIMP SampleCB(double SampleTime, IMediaSample *pSample);
|
127
|
+
|
128
|
+
STDMETHODIMP BufferCB(double SampleTime, BYTE *pBuffer, long BufferLen) {return E_NOTIMPL;}
|
129
|
+
|
130
|
+
// Control the tracking parameters
|
131
|
+
void SetParams(int *params);
|
132
|
+
void GetParams(int *params);
|
133
|
+
|
134
|
+
public: // The interface needed by ISampleGrabber Filter
|
135
|
+
void unlockImage();
|
136
|
+
CamImage * lockImage();
|
137
|
+
// fake out any COM ref counting
|
138
|
+
STDMETHODIMP_(ULONG) AddRef() { return 2; }
|
139
|
+
STDMETHODIMP_(ULONG) Release() { return 1; }
|
140
|
+
// fake out any COM QI'ing
|
141
|
+
STDMETHODIMP QueryInterface(REFIID riid, void ** ppv) {
|
142
|
+
if( riid == IID_ISampleGrabberCB || riid == IID_IUnknown ) {
|
143
|
+
*ppv = (void *) static_cast<ISampleGrabberCB*> ( this );
|
144
|
+
return NOERROR;
|
145
|
+
}
|
146
|
+
return E_NOINTERFACE;
|
147
|
+
}
|
148
|
+
|
149
|
+
protected:
|
150
|
+
|
151
|
+
// The image dimension. We need them for change the coordinate of windows
|
152
|
+
// (left_top is (0, 0) to that of the image (left_bottom is (0,0))
|
153
|
+
int m_imgWidth, m_imgHeight;
|
154
|
+
|
155
|
+
// For calculating the Frame rate
|
156
|
+
double m_dFrameRate, m_dPrevTime;
|
157
|
+
|
158
|
+
// The media type we are processing
|
159
|
+
AM_MEDIA_TYPE m_mediaType;
|
160
|
+
CRITICAL_SECTION m_cs;
|
161
|
+
|
162
|
+
public:
|
163
|
+
CamImage *m_image;
|
164
|
+
HANDLE m_imageReady;
|
165
|
+
};
|
166
|
+
|
167
|
+
///////////////////////////////////////////////////////////////////////
|
168
|
+
// This class build a graph with a grabbing filter to get each image
|
169
|
+
// frame and process it with CamCaptureGrabberCB::SampleCB() callback
|
170
|
+
// function.
|
171
|
+
class CamCaptureDirectShow : public CamCaptureGraph
|
172
|
+
{
|
173
|
+
public:
|
174
|
+
CamCaptureDirectShow();
|
175
|
+
virtual ~CamCaptureDirectShow();
|
176
|
+
|
177
|
+
protected:
|
178
|
+
|
179
|
+
virtual bool buildCaptureGraph(IBaseFilter *filter = 0);
|
180
|
+
|
181
|
+
virtual void addExtraFilters();
|
182
|
+
virtual void releaseExtraFilters();
|
183
|
+
virtual bool initExtraFilters();
|
184
|
+
|
185
|
+
// ColorConverter is needed to convert other color to RGB24
|
186
|
+
IBaseFilter *m_pColorConv;
|
187
|
+
// Grab filter which get image data for each frame
|
188
|
+
IBaseFilter *m_pGrabFilter;
|
189
|
+
// The interface to set callback function
|
190
|
+
ISampleGrabber *m_pSampleGrabber;
|
191
|
+
|
192
|
+
public:
|
193
|
+
void unlockImage();
|
194
|
+
CamImage *lockImage();
|
195
|
+
void setImage(CamImage &image);
|
196
|
+
|
197
|
+
// The callback interface to track object through the frames
|
198
|
+
CamCaptureGrabberCB *m_pTrackingCB;
|
199
|
+
CamImage * waitForImage(int timeout);
|
200
|
+
};
|
201
|
+
|
202
|
+
#endif // __CAM_CAPTURE_H
|
data/inc/camellia.h
ADDED
@@ -0,0 +1,2651 @@
|
|
1
|
+
/** \file camellia.h
|
2
|
+
* \brief Camellia Image Processing Library header file
|
3
|
+
* \author Bruno STEUX (Mines Paris / ParisTech)
|
4
|
+
*
|
5
|
+
* Camellia Image Processing Library
|
6
|
+
*
|
7
|
+
|
8
|
+
The Camellia Image Processing Library is an open source low-level image processing library.
|
9
|
+
As it uses the IplImage structure to describe images, it is a good replacement to the IPL (Intel) library
|
10
|
+
and a good complement to the OpenCV library. It includes a lot of functions for image processing
|
11
|
+
(filtering, morphological mathematics, labeling, warping, loading/saving images, etc.),
|
12
|
+
some of them being highly optimized; It is also cross-platform and robust. It is doxygen-documented
|
13
|
+
and examples of use are provided.
|
14
|
+
|
15
|
+
This software library is an outcome of the Camellia european project (IST-2001-34410).
|
16
|
+
It was developped by the Ecole des Mines de Paris (ENSMP), in coordination with
|
17
|
+
the other partners of the project.
|
18
|
+
|
19
|
+
==========================================================================
|
20
|
+
|
21
|
+
Copyright (c) 2002-2007, Ecole des Mines de Paris - Centre de Robotique
|
22
|
+
All rights reserved.
|
23
|
+
|
24
|
+
Redistribution and use in source and binary forms, with or without
|
25
|
+
modification, are permitted provided that the following conditions are met:
|
26
|
+
|
27
|
+
* Redistributions of source code must retain the above copyright
|
28
|
+
notice, this list of conditions and the following disclaimer.
|
29
|
+
* Redistributions in binary form must reproduce the above copyright
|
30
|
+
notice, this list of conditions and the following disclaimer
|
31
|
+
in the documentation and/or other materials provided with the distribution.
|
32
|
+
* Neither the name of the Ecole des Mines de Paris nor the names of
|
33
|
+
its contributors may be used to endorse or promote products
|
34
|
+
derived from this software without specific prior written permission.
|
35
|
+
|
36
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
37
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
38
|
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
39
|
+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
40
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
41
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
42
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
43
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
44
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
45
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
46
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
47
|
+
|
48
|
+
==========================================================================
|
49
|
+
*/
|
50
|
+
|
51
|
+
#ifndef _CAMELLIA_H_
|
52
|
+
#define _CAMELLIA_H_
|
53
|
+
|
54
|
+
#define CAM_VERSION "2.7.0 : Bastille ($Rev: 270 $)"
|
55
|
+
|
56
|
+
#include <stdlib.h>
|
57
|
+
|
58
|
+
/*******************************************
|
59
|
+
* Compilation options : *
|
60
|
+
*/
|
61
|
+
// Pixel definition
|
62
|
+
#define CAM_PIXEL unsigned char
|
63
|
+
#define CAM_SIGNED_PIXEL signed char
|
64
|
+
|
65
|
+
// Max image size
|
66
|
+
#define CAM_MAX_SCANLINE 1280
|
67
|
+
#define CAM_MAX_FRAME_HEIGHT 1024
|
68
|
+
|
69
|
+
// 64-bit processor or memory bandwidth?
|
70
|
+
#define CAM_64BITS
|
71
|
+
|
72
|
+
// Pentium4 optimizations?
|
73
|
+
#define CAM_OPT_P4
|
74
|
+
|
75
|
+
// Big endian architecture?
|
76
|
+
//#define CAM_BIG_ENDIAN
|
77
|
+
|
78
|
+
// Generate 8 AND 16 bits pixel size code
|
79
|
+
#define CAM_GENERATE_FULL_CODE
|
80
|
+
|
81
|
+
/* *
|
82
|
+
*******************************************/
|
83
|
+
#ifdef _WIN32
|
84
|
+
#define CAM_INT64 __int64
|
85
|
+
#define CAM_UINT64 unsigned __int64
|
86
|
+
#else
|
87
|
+
#define CAM_INT64 long long
|
88
|
+
#define CAM_UINT64 unsigned long long
|
89
|
+
#endif
|
90
|
+
|
91
|
+
#ifdef __INTEL_COMPILER
|
92
|
+
#define CAM_ALIGN16 __declspec(align(16))
|
93
|
+
#else
|
94
|
+
#define CAM_ALIGN16
|
95
|
+
#endif
|
96
|
+
|
97
|
+
#define CAM_FIXED_POINT signed long
|
98
|
+
#define CAM_FLOAT2FIXED(x,dot_pos) ((CAM_FIXED_POINT)((x)*(1<<dot_pos)))
|
99
|
+
|
100
|
+
#define CAM_DEPTH_SIGN 0x80000000
|
101
|
+
#define CAM_DEPTH_MASK 0x7FFFFFFF
|
102
|
+
|
103
|
+
#define CAM_DEPTH_1U 1
|
104
|
+
#define CAM_DEPTH_8U 8
|
105
|
+
#define CAM_DEPTH_10U 10
|
106
|
+
#define CAM_DEPTH_12U 12
|
107
|
+
#define CAM_DEPTH_16U 16
|
108
|
+
#define CAM_DEPTH_32U 32
|
109
|
+
|
110
|
+
#define CAM_DEPTH_8S (CAM_DEPTH_SIGN| 8)
|
111
|
+
#define CAM_DEPTH_10S (CAM_DEPTH_SIGN|10)
|
112
|
+
#define CAM_DEPTH_12S (CAM_DEPTH_SIGN|12)
|
113
|
+
#define CAM_DEPTH_16S (CAM_DEPTH_SIGN|16)
|
114
|
+
#define CAM_DEPTH_32S (CAM_DEPTH_SIGN|32)
|
115
|
+
|
116
|
+
#define CAM_DATA_ORDER_PIXEL 0
|
117
|
+
#define CAM_DATA_ORDER_PLANE 1
|
118
|
+
|
119
|
+
#define CAM_ORIGIN_TL 0
|
120
|
+
|
121
|
+
#define CAM_ALIGN_4BYTES 4
|
122
|
+
#define CAM_ALIGN_8BYTES 8
|
123
|
+
#define CAM_ALIGN_16BYTES 16
|
124
|
+
#define CAM_ALIGN_32BYTES 32
|
125
|
+
|
126
|
+
#define CAM_ALIGN_DWORD CAM_ALIGN_4BYTES
|
127
|
+
#define CAM_ALIGN_QWORD CAM_ALIGN_8BYTES
|
128
|
+
|
129
|
+
#define CAM_BORDER_CONSTANT 0
|
130
|
+
#define CAM_BORDER_REPLICATE 1
|
131
|
+
|
132
|
+
/*--- Indexes to access IplImage.BorderMode[],IplImage.BorderConst[] ----*/
|
133
|
+
#define CAM_SIDE_TOP_INDEX 0
|
134
|
+
#define CAM_SIDE_BOTTOM_INDEX 1
|
135
|
+
#define CAM_SIDE_LEFT_INDEX 2
|
136
|
+
#define CAM_SIDE_RIGHT_INDEX 3
|
137
|
+
|
138
|
+
/*---------- values of argument of iplSetBorderMode(,,border,) ----------*/
|
139
|
+
#define CAM_SIDE_TOP (1<<CAM_SIDE_TOP_INDEX)
|
140
|
+
#define CAM_SIDE_BOTTOM (1<<CAM_SIDE_BOTTOM_INDEX)
|
141
|
+
#define CAM_SIDE_LEFT (1<<CAM_SIDE_LEFT_INDEX)
|
142
|
+
#define CAM_SIDE_RIGHT (1<<CAM_SIDE_RIGHT_INDEX)
|
143
|
+
#define CAM_SIDE_ALL (CAM_SIDE_RIGHT | CAM_SIDE_TOP | CAM_SIDE_LEFT | CAM_SIDE_BOTTOM)
|
144
|
+
|
145
|
+
#ifdef CAM_BIG_ENDIAN
|
146
|
+
#define CAM_FC( ch0, ch1, ch2, ch3 ) \
|
147
|
+
((int)(ch3)|((int)(ch2)<<8)|((int)(ch1)<<16)|((int)(ch0)<<24))
|
148
|
+
#else
|
149
|
+
#define CAM_FC( ch0, ch1, ch2, ch3 ) \
|
150
|
+
((int)(ch0)|((int)(ch1)<<8)|((int)(ch2)<<16)|((int)(ch3)<<24))
|
151
|
+
#endif
|
152
|
+
|
153
|
+
#ifndef SWIG
|
154
|
+
#define CAM_COLORMODEL_RGB CAM_FC('R','G','B',000)
|
155
|
+
#define CAM_COLORMODEL_RGBA CAM_FC('R','G','B','A')
|
156
|
+
#define CAM_COLORMODEL_YUV CAM_FC('Y','U','V',000)
|
157
|
+
#define CAM_COLORMODEL_GREY CAM_FC('G',000,000,000)
|
158
|
+
#define CAM_CHANNELSEQ_RGB CAM_FC('R','G','B',000)
|
159
|
+
#define CAM_CHANNELSEQ_RGBA CAM_FC('R','G','B','A')
|
160
|
+
#define CAM_CHANNELSEQ_YUV CAM_FC('Y','U','V',000)
|
161
|
+
#define CAM_CHANNELSEQ_GREY CAM_FC('G',000,000,000)
|
162
|
+
#define CAM_CHANNELSEQ_BGR CAM_FC('B','G','R',000)
|
163
|
+
#define CAM_CHANNELSEQ_BGRA CAM_FC('B','G','R','A')
|
164
|
+
#endif // SWIG
|
165
|
+
|
166
|
+
#define CAM_HEADER_ONLY (1<<29)
|
167
|
+
|
168
|
+
#ifdef __cplusplus
|
169
|
+
struct CamImage;
|
170
|
+
struct CamTableOfBasins;
|
171
|
+
struct CamBitmapFont;
|
172
|
+
struct CamKeypoints;
|
173
|
+
struct CamKeypoint;
|
174
|
+
|
175
|
+
/// The IPL Region Of Interest structure
|
176
|
+
struct CamROI {
|
177
|
+
#else
|
178
|
+
/// The IPL Region Of Interest structure
|
179
|
+
typedef struct {
|
180
|
+
#endif
|
181
|
+
/// The channel of interest number
|
182
|
+
/** This parameter indicates which channel in the original image will
|
183
|
+
* be affected by processing taking place in the region of interest;
|
184
|
+
* coi equal to 0 indicates that all channel will be affected
|
185
|
+
*/
|
186
|
+
int coi;
|
187
|
+
int xOffset; ///< The offset from the origin of the rectangular ROI.
|
188
|
+
int yOffset; ///< The offset from the origin of the rectangular ROI.
|
189
|
+
int width; ///< The size of the rectangular ROI
|
190
|
+
int height; ///< The size of the rectangular ROI
|
191
|
+
|
192
|
+
// C++ Wrapping
|
193
|
+
#ifdef __cplusplus
|
194
|
+
CamROI() {coi=0; xOffset=0; yOffset=0; width=0; height=0;}
|
195
|
+
CamROI(int _coi, int _xOffset, int _yOffset, int _width, int _height) {
|
196
|
+
coi=_coi; xOffset=_xOffset; yOffset=_yOffset; width=_width; height=_height;
|
197
|
+
}
|
198
|
+
CamROI(const CamImage &image, int _coi=0);
|
199
|
+
~CamROI() {};
|
200
|
+
CamROI intersect(const CamROI &roi) const; ///< C++ wrapping for function camROIIntersect()
|
201
|
+
bool clip(CamImage &image);
|
202
|
+
bool reduce(int i);
|
203
|
+
bool enlarge(int i);
|
204
|
+
};
|
205
|
+
|
206
|
+
struct CamLinearFilterKernel;
|
207
|
+
struct CamMorphoMathsKernel;
|
208
|
+
struct CamRLEImage;
|
209
|
+
struct CamTable;
|
210
|
+
struct CamMeasuresResults;
|
211
|
+
struct CamSepFilterKernel;
|
212
|
+
struct CamAffineTransform;
|
213
|
+
|
214
|
+
/// The structure used to identify a point in 2D
|
215
|
+
struct CamPoint {
|
216
|
+
int x; ///< x coordinate
|
217
|
+
int y; ///< y coordinate
|
218
|
+
|
219
|
+
CamPoint apply_affine_transform(const CamAffineTransform &t) const;
|
220
|
+
CamPoint(int xp, int yp) {x = xp; y = yp;}
|
221
|
+
CamPoint() {x = 0; y = 0;}
|
222
|
+
};
|
223
|
+
#else
|
224
|
+
} CamROI;
|
225
|
+
|
226
|
+
/// The structure used to identify a point in 2D
|
227
|
+
typedef struct {
|
228
|
+
int x; ///< x coordinate
|
229
|
+
int y; ///< y coordinate
|
230
|
+
} CamPoint;
|
231
|
+
#endif
|
232
|
+
|
233
|
+
#define CAM_POINT 1
|
234
|
+
#define CAM_CROSS 2
|
235
|
+
#define CAM_CIRCLE 4
|
236
|
+
|
237
|
+
/// The famous IplImage/CamImage structure, today's standard structure for image processing.
|
238
|
+
/** This structure originally comes from IPL (Image Processing Library) by Intel.
|
239
|
+
* This standard structure is also used in OpenCV (Open Source Computer Vision Libary).
|
240
|
+
* The IplImage structure is the preferred structure for image processing with RT-Maps
|
241
|
+
* (Real-Time "des Mines" Automotive Prototyping System).
|
242
|
+
*/
|
243
|
+
#ifdef __cplusplus
|
244
|
+
struct CamImage {
|
245
|
+
#else
|
246
|
+
typedef struct {
|
247
|
+
#endif
|
248
|
+
#ifdef SWIG
|
249
|
+
%immutable;
|
250
|
+
#endif
|
251
|
+
int nSize; ///< Size of CamImage struct
|
252
|
+
int id; ///< Frame Id (user dependant)
|
253
|
+
int nChannels; ///< Number of channels in the image (generally 1,3 or 4)
|
254
|
+
int alphaChannel; ///< Alpha channel number (0 if there is no alpha channel in the image)
|
255
|
+
|
256
|
+
/// Bit depth of pixels.
|
257
|
+
/** Can be one of CAM_DEPTH_1U, CAM_DEPTH_8U, CAM_DEPTH_8S, CAM_DEPTH_10U, CAM_DEPTH_10S, CAM_DEPTH_12U, CAM_DEPTH_12S, CAM_DEPTH_16U, CAM_DEPTH_16S, CAM_DEPTH_32U, CAM_DEPTH_32S
|
258
|
+
*/
|
259
|
+
int depth;
|
260
|
+
char colorModel[4]; ///< A four-character string describing the color model: "RGB", "GRAY", "HLS", etc.
|
261
|
+
|
262
|
+
/// The sequence of color channels
|
263
|
+
/** Can be one of the following: "G", "GREY", "BGR", "BGRA", "RGB", "RGBA", "HLS", "YUV"
|
264
|
+
*/
|
265
|
+
char channelSeq[4];
|
266
|
+
int dataOrder; ///< CAM_DATA_ORDER_PIXEL or CAM_DATA_ORDER_PLANE
|
267
|
+
int origin; ///< The origin of the image. Can only be CAM_ORIGIN_TL (top left).
|
268
|
+
int align; ///< Alignment of image data : 4 (CAM_ALIGN_DWORD) or 8 (CAM_ALIGN_QWORD) byte align
|
269
|
+
int width; ///< Width of the image in pixels
|
270
|
+
int height; ///< Height of the image in pixels
|
271
|
+
|
272
|
+
#ifdef SWIG
|
273
|
+
%mutable;
|
274
|
+
#endif
|
275
|
+
/// Pointer to a ROI (Region of interest) structure.
|
276
|
+
/** This argument can be NULL, which implies that a region of interest
|
277
|
+
* comprises all channels and the entire image area.
|
278
|
+
*/
|
279
|
+
CamROI *roi;
|
280
|
+
#ifdef SWIG
|
281
|
+
%immutable;
|
282
|
+
#endif
|
283
|
+
|
284
|
+
/// Pointer to the header of another image that specifies the mask ROI.
|
285
|
+
/** This argument can be NULL, which indicates that no mask ROI is used.
|
286
|
+
* A pixel is processed if the corresponding mask pixel is not 0, and is not
|
287
|
+
* processed if the mask pixel is 0. At the moment, only RLE encoded masks
|
288
|
+
* are supported (CamRLEImage structure)
|
289
|
+
**/
|
290
|
+
void *mask; ///< Pointer to mask image
|
291
|
+
|
292
|
+
/// The image ID
|
293
|
+
/** Field reserved for the use of the application to identify the image.
|
294
|
+
*/
|
295
|
+
void *imageId; ///< Free for user application
|
296
|
+
|
297
|
+
void *misc; ///< Free for user application (information on tiling in IplImage structure)
|
298
|
+
int imageSize; ///< Useful size in bytes
|
299
|
+
unsigned char *imageData; ///< Pointer to aligned image
|
300
|
+
int widthStep; ///< The size of aligned line in bytes
|
301
|
+
int borderMode[4]; ///< The top, bottom, left and right border mode
|
302
|
+
int borderConst[4]; ///< Constants for the top, bottom, left and right border
|
303
|
+
unsigned char *imageDataOrigin; ///< Pointer to full, nonaligned image. A NULL value indicates that the image is not owned by the structure
|
304
|
+
|
305
|
+
// C++ Wrapping
|
306
|
+
|
307
|
+
#ifdef __cplusplus
|
308
|
+
CamImage() {nSize=sizeof(CamImage); imageData=NULL; roi=NULL; imageSize=0; mask=NULL; imageDataOrigin=NULL; depth=CAM_DEPTH_8U; nChannels=1; } ///< Default non-allocating constructor
|
309
|
+
CamImage(int width, int height, int depth=CAM_DEPTH_8U, int channelseq=0); ///< Allocating constructor (1 to 16 bits, signed/unsigned, G/RGB/RGBA/YUV)
|
310
|
+
CamImage(const CamImage& image); ///< Copy constructor
|
311
|
+
~CamImage(); ///< Default destructor. Free any allocated memory.
|
312
|
+
|
313
|
+
#ifndef SWIG
|
314
|
+
CamImage& operator=(const CamImage &image); ///< Operator= redefinition
|
315
|
+
#endif
|
316
|
+
CamImage* clone() const; ///< Clone image (using camClone() function)
|
317
|
+
CamImage* copy() const; ///< Copy (not clone). Takes into account ROI and masks. C++ wrapping for camCopy() function
|
318
|
+
bool copy(CamImage &dest) const; ///< Copy (not clone). Takes into account ROI and masks. C++ wrapping for camCopy() function
|
319
|
+
bool allocated() const {return (imageData)?true:false;} ///< Check whether the image is allocated or not
|
320
|
+
bool alloc(int width, int height, int depth=CAM_DEPTH_8U, int channelseq=0); ///< Image allocation (1 to 16 bits, signed/unsigned, G/RGB/RGBA/YUV/HLS)
|
321
|
+
bool fill_header(int width, int height, int depth=CAM_DEPTH_8U, int channelseq=0); ///< Image header filling (1 to 16 bits, signed/unsigned, G/RGB/RGBA/YUV/HLS)
|
322
|
+
bool deallocate(); ///< Deallocate image (C++ wrapping for camDeallocateImage() function)
|
323
|
+
bool free() {return deallocate();}
|
324
|
+
bool alloc_rgb(int width, int height); ///< RGB image allocation (8 bits, pixel oriented)
|
325
|
+
bool alloc_rgba(int width, int height); ///< RGBA image allocation (8 bits, pixel oriented, alpha channel)
|
326
|
+
bool alloc_bgr(int width, int height); ///< BGR image allocation (8 bits, pixel oriented)
|
327
|
+
bool alloc_bgra(int width, int height); ///< BGRA image allocation (8 bits, pixel oriented, alpha channel)
|
328
|
+
bool alloc_yuv(int width, int height); ///< YUV image allocation (8 bits, planar oriented)
|
329
|
+
bool alloc_hls(int width, int height); ///< HLS image allocation (16 bits, planar oriented)
|
330
|
+
bool load_pgm(const char *filename); ///< C++ wrapping for camLoadPGM() function
|
331
|
+
bool save_pgm(const char *filename) const; ///< C++ wrapping for camSavePGM() function
|
332
|
+
bool save_raw_pgm(const char *filename) const; ///< C++ wrapping for camSaveRawPGM() function
|
333
|
+
bool load_bmp(const char *filename); ///< C++ wrapping for camLoadPGM() function
|
334
|
+
bool save_bmp(const char *filename) const; ///< C++ wrapping for camSavePGM() function
|
335
|
+
bool set_roi(const CamROI &roi); ///< C++ wrapping for camSetROI() function
|
336
|
+
void get_pixels(char **result, int *len) const; ///< Fills an char array allocated with C++ operator new. len is filled with the length of the array. Used for mapping Ruby to_s member.
|
337
|
+
bool set_pixels(const char *pixels, int sz); ///< Set pixels of the picture, from a byte array
|
338
|
+
void inspect(char **result, int *len) const; ///< Returns some textual information about the image
|
339
|
+
bool view() const; ///< View the picture
|
340
|
+
bool set(int color); ///< C++ wrapping for camSet() function
|
341
|
+
bool alpha_composite(const CamImage& source2, CamImage& dest) const; ///< C++ wrapping for camAlphaComposite() function
|
342
|
+
|
343
|
+
int erode_square3(); ///< C++ wrapping for camErodeSquare3() function
|
344
|
+
int erode_square3(CamImage &dest) const; ///< C++ wrapping for camErodeSquare3() function
|
345
|
+
int erode_circle5(); ///< C++ wrapping for camErodeCircle5() function
|
346
|
+
int erode_circle5(CamImage &dest) const; ///< C++ wrapping for camErodeCircle5() function
|
347
|
+
int erode_circle7(); ///< C++ wrapping for camErodeCircle7() function
|
348
|
+
int erode_circle7(CamImage &dest) const; ///< C++ wrapping for camErodeCircle7() function
|
349
|
+
int dilate_square3(); ///< C++ wrapping for camDilateSquare3() function
|
350
|
+
int dilate_square3(CamImage &dest) const; ///< C++ wrapping for camDilateSquare3() function
|
351
|
+
int dilate_circle5(); ///< C++ wrapping for camDilateCircle5() function
|
352
|
+
int dilate_circle5(CamImage &dest) const; ///< C++ wrapping for camDilateCircle5() function
|
353
|
+
int dilate_circle7(); ///< C++ wrapping for camDilateCircle7() function
|
354
|
+
int dilate_circle7(CamImage &dest) const; ///< C++ wrapping for camDilateCircle7() function
|
355
|
+
int morpho_gradient_square3(); ///< C++ wrapping for camMorphoGradientSquare3() function
|
356
|
+
int morpho_gradient_square3(CamImage &dest) const; ///< C++ wrapping for camMorphoGradientSquare3() function
|
357
|
+
int morpho_gradient_circle5(); ///< C++ wrapping for camMorphoGradientCircle5() function
|
358
|
+
int morpho_gradient_circle5(CamImage &dest) const; ///< C++ wrapping for camMorphoGradientCircle5() function
|
359
|
+
int morpho_gradient_circle7(); ///< C++ wrapping for camMorphoGradientCircle7() function
|
360
|
+
int morpho_gradient_circle7(CamImage &dest) const; ///< C++ wrapping for camMorphoGradientCircle7() function
|
361
|
+
|
362
|
+
int morpho_maths(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camMorphoMaths() function
|
363
|
+
int morpho_maths(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camMorphoMaths() function
|
364
|
+
int erode_3x3(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camErode3x3() function
|
365
|
+
int erode_3x3(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camErode3x3() function
|
366
|
+
int dilate_3x3(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camDilate3x3() function
|
367
|
+
int dilate_3x3(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camDilate3x3() function
|
368
|
+
int erode_5x5(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camErode5x5() function
|
369
|
+
int erode_5x5(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camErode5x5() function
|
370
|
+
int dilate_5x5(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camDilate5x5() function
|
371
|
+
int dilate_5x5(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camDilate5x5() function
|
372
|
+
int erode_7x7(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camErode7x7() function
|
373
|
+
int erode_7x7(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camErode7x7() function
|
374
|
+
int dilate_7x7(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camDilate7x7() function
|
375
|
+
int dilate_7x7(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camDilate7x7() function
|
376
|
+
|
377
|
+
int linear_filter_3x3(const CamLinearFilterKernel &ker); ///< C++ wrapping for camLinearFilter3x3() function
|
378
|
+
int linear_filter_3x3(CamImage &dest, const CamLinearFilterKernel &k) const; ///< C++ wrapping for camLinearFilter3x3() function
|
379
|
+
int linear_filter_5x5(const CamLinearFilterKernel &ker); ///< C++ wrapping for camLinearFilter5x5() function
|
380
|
+
int linear_filter_5x5(CamImage &dest, const CamLinearFilterKernel &k) const; ///< C++ wrapping for camLinearFilter5x5() function
|
381
|
+
int linear_filter_abs_3x3(const CamLinearFilterKernel &ker); ///< C++ wrapping for camLinearFilterAbs3x3() function
|
382
|
+
int linear_filter_abs_3x3(CamImage &dest, const CamLinearFilterKernel &k) const; ///< C++ wrapping for camLinearFilterAbs3x3() function
|
383
|
+
int linear_filter_abs_5x5(const CamLinearFilterKernel &ker); ///< C++ wrapping for camLinearFilterAbs5x5() function
|
384
|
+
int linear_filter_abs_5x5(CamImage &dest, const CamLinearFilterKernel &k) const; ///< C++ wrapping for camLinearFilterAbs5x5() function
|
385
|
+
bool sobel_v(); ///< C++ wrapping for camSobelV() function
|
386
|
+
bool sobel_h(); ///< C++ wrapping for camSobelH() function
|
387
|
+
bool sobel_v_abs(); ///< C++ wrapping for camSobelVAbs() function
|
388
|
+
bool sobel_h_abs(); ///< C++ wrapping for camSobelHAbs() function
|
389
|
+
bool sobel_v(CamImage &dest) const; ///< C++ wrapping for camSobelV() function
|
390
|
+
bool sobel_h(CamImage &dest) const; ///< C++ wrapping for camSobelH() function
|
391
|
+
bool sobel_v_abs(CamImage &dest) const; ///< C++ wrapping for camSobelVAbs() function
|
392
|
+
bool sobel_h_abs(CamImage &dest) const; ///< C++ wrapping for camSobelHAbs() function
|
393
|
+
int sep_filter_3x3(const CamSepFilterKernel &ker); ///< C++ wrapping for camSepFilter3x3() function
|
394
|
+
int sep_filter_3x3(CamImage &dest, const CamSepFilterKernel &k) const; ///< C++ wrapping for camSepFilter3x3() function
|
395
|
+
int sep_filter_5x5(const CamSepFilterKernel &ker); ///< C++ wrapping for camSepFilter5x5() function
|
396
|
+
int sep_filter_5x5(CamImage &dest, const CamSepFilterKernel &k) const; ///< C++ wrapping for camSepFilter5x5() function
|
397
|
+
int sep_filter_7x7(const CamSepFilterKernel &ker); ///< C++ wrapping for camSepFilter7x7() function
|
398
|
+
int sep_filter_7x7(CamImage &dest, const CamSepFilterKernel &k) const; ///< C++ wrapping for camSepFilter7x7() function
|
399
|
+
int sep_filter_abs_3x3(const CamSepFilterKernel &ker); ///< C++ wrapping for camSepFilterAbs3x3() function
|
400
|
+
int sep_filter_abs_3x3(CamImage &dest, const CamSepFilterKernel &k) const; ///< C++ wrapping for camSepFilterAbs3x3() function
|
401
|
+
int sep_filter_abs_5x5(const CamSepFilterKernel &ker); ///< C++ wrapping for camSepFilterAbs5x5() function
|
402
|
+
int sep_filter_abs_5x5(CamImage &dest, const CamSepFilterKernel &k) const; ///< C++ wrapping for camSepFilterAbs5x5() function
|
403
|
+
int sep_filter_abs_7x7(const CamSepFilterKernel &ker); ///< C++ wrapping for camSepFilterAbs7x7() function
|
404
|
+
int sep_filter_abs_7x7(CamImage &dest, const CamSepFilterKernel &k) const; ///< C++ wrapping for camSepFilterAbs7x7() function
|
405
|
+
bool fixed_filter(CamImage &dest, int filter) const; ///< C++ wrapping for camFixedFilter() function
|
406
|
+
bool fixed_filter(int filter); ///< C++ wrapping for camFixedFilter() function
|
407
|
+
|
408
|
+
bool draw_line(int x1, int y1, int x2, int y2, int color); ///< C++ wrapping for camDrawLine() function
|
409
|
+
bool accumulate_line(int x1, int y1, int x2, int y2, int acc); ///< C++ wrapping for camAccumulateLine() function
|
410
|
+
bool draw_rectangle(int x1, int y1, int x2, int y2, int color); ///< C++ wrapping for camDrawRectangle() function
|
411
|
+
bool draw_text_16s(const char *text, int x, int y, int cwidth, int cheight, int orientation, int color); ///< C++ wrapping for camDrawText16s() function
|
412
|
+
bool draw_text_bitmap(const char *text, int x, int y, const CamBitmapFont &font); ///< C++ wrapping for camDrawTextBitmap() function
|
413
|
+
bool draw_circle(int x, int y, int r, int color); ///< C++ wrapping for camDrawCircle() function
|
414
|
+
bool draw_ellipse(int x, int y, int rx, int ry, int color); ///< C++ wrapping for camDrawEllipse() function
|
415
|
+
bool plot(int x, int y, int color, int kind=CAM_POINT); ///< C++ wrapping for camPlot() function
|
416
|
+
int fill_color(int x, int y, int fillcolor, int tolerance=-1); ///< C++ wrapping for camFillColor() function
|
417
|
+
|
418
|
+
bool warping(CamImage &dest, int interpolation_method, bool perspective, const CamPoint &ul, const CamPoint &ur, const CamPoint &lr, const CamPoint &ll) const; ///< C++ wrapping for camWarping() function
|
419
|
+
bool scale(CamImage &dest) const; ///< C++ wrapping for camScale() function
|
420
|
+
bool set_mask(const CamRLEImage &mask); ///< C++ wrapping for camSetRLEMask() function
|
421
|
+
bool set_mask(const CamImage &mask); ///< C++ wrapping for camSetMask() function
|
422
|
+
bool apply_lut(const CamTable &lut); ///< C++ wrapping for camApplyLUT() function
|
423
|
+
bool apply_lut(CamImage &dest, const CamTable &lut) const; ///< C++ wrapping for camApplyLUT() function
|
424
|
+
|
425
|
+
CamImage *to_yuv() const; ///< C++ wrapping for camRGB2YUV() function
|
426
|
+
bool to_yuv(CamImage &dest) const; ///< C++ wrapping for camRGB2YUV() function
|
427
|
+
CamImage *to_y() const; ///< C++ wrapping for camRGB2Y() function
|
428
|
+
bool to_y(CamImage &dest) const; ///< C++ wrapping for camRGB2Y() function
|
429
|
+
CamImage *to_rgb() const; ///< C++ wrapping for camYUV2RGB() function
|
430
|
+
bool to_rgb(CamImage &dest) const; ///< C++ wrapping for camYUV2RGB() function
|
431
|
+
CamImage *to_hls() const; ///< C++ wrapping for camRGB2HLS() function
|
432
|
+
bool to_hls(CamImage &dest) const; ///< C++ wrapping for camRGB2HLS() function
|
433
|
+
|
434
|
+
CamRLEImage* encode() const; ///< C++ wrapping for camRLEEncode() function
|
435
|
+
CamRLEImage* encode_lut(const CamTable &LUT) const; ///< C++ wrapping for camRLEEncodeLUT() function
|
436
|
+
CamRLEImage* encode_threshold(int threshold) const; ///< C++ wrapping for camRLEEncodeThreshold() function
|
437
|
+
CamRLEImage* encode_threshold_inv(int threshold) const; ///< C++ wrapping for camRLEEncodeThresholdInv() function
|
438
|
+
CamRLEImage* encode_color(const CamTable &clusters) const; ///< C++ wrapping for camRLEEncodeColor() function
|
439
|
+
bool encode(CamRLEImage& dest) const; ///< C++ wrapping for camRLEEncode() function
|
440
|
+
bool encode_lut(CamRLEImage& dest, const CamTable &LUT) const; ///< C++ wrapping for camRLEEncodeLUT() function
|
441
|
+
bool encode_threshold(CamRLEImage& dest, int threshold) const; ///< C++ wrapping for camRLEEncodeThreshold() function
|
442
|
+
bool encode_threshold_inv(CamRLEImage& dest, int threshold) const; ///< C++ wrapping for camRLEEncodeThresholdInv() function
|
443
|
+
|
444
|
+
int threshold(CamImage &dest,int threshold) const; ///< C++ wrapping for camThreshold() function
|
445
|
+
int threshold_inv(CamImage &dest,int threshold) const; ///< C++ wrapping for camThresholdInv() function
|
446
|
+
int abs(CamImage &dest) const; ///< C++ wrapping for camAbs() function
|
447
|
+
int threshold(int threshold); ///< C++ wrapping for camThreshold() function
|
448
|
+
int threshold_inv(int threshold); ///< C++ wrapping for camThresholdInv() function
|
449
|
+
int abs(); ///< C++ wrapping for camAbs() function
|
450
|
+
|
451
|
+
int arithm(int operation, int c1=0, int c2=0, int c3=0); ///< C++ wrapping for camMonadicArithm() function
|
452
|
+
int arithm(CamImage& dest, int operation, int c1=0, int c2=0, int c3=0) const; ///< C++ wrapping for camMonadicArithm() function
|
453
|
+
int arithm(const CamImage& source2, CamImage& dest, int operation, int c1=0, int c2=0, int c3=0, int c4=0) const; ///< C++ wrapping for camDyadicArithm() function
|
454
|
+
|
455
|
+
CamMeasuresResults measures() const; ///< C++ wrapping for camMeasures() function
|
456
|
+
float average_deviation(int average=0) const; ///< C++ wrapping for camMeasureAverageDeviation() function
|
457
|
+
|
458
|
+
bool sum_hv(CamTable& hsum, CamTable &vsum) const; ///< C++ wrapping for camSumHV() function
|
459
|
+
bool sum_h(CamTable& sum) const; ///< C++ wrapping for camSumH() function
|
460
|
+
bool sum_v(CamTable& sum) const; ///< C++ wrapping for camSumV() function
|
461
|
+
|
462
|
+
int histogram(CamTable& histo) const; ///< C++ wrapping for camHistogram() function
|
463
|
+
bool histogram_equalization(CamImage &dest, const CamTable &src_histo, int option=0, CamImage *work=NULL); /// C++ wrapping for camHistogramEqualizatio() function
|
464
|
+
bool histogram_2_channels(int ch1, int ch2, CamImage &result, int size=1) const; ///< C++ wrapping for camHistogram2Channels() function
|
465
|
+
int find_threshold(int percent) const; ///< C++ wrapping for camFindThreshold() function
|
466
|
+
|
467
|
+
int hough_circle(int percent, int rmin, int rmax, int &xc, int &yc, int &rc) const; ///< C++ wrapping for camHoughCircle() function
|
468
|
+
|
469
|
+
int hierarchical_watershed(CamImage &watershed, CamTableOfBasins &tob) const; ///< C++ wrapping for camHierarchicalWatershed() function
|
470
|
+
int hierarchical_watershed_contours(CamImage &ws, CamTableOfBasins &tob) const; ///< C++ wrapping for camHierarchicalWatershedContours() function
|
471
|
+
int hierarchical_watershed_regions(const CamTableOfBasins &tob); ///< C++ wrapping for camHierarchicalWatershedRegions() function
|
472
|
+
|
473
|
+
bool draw_keypoints(const CamKeypoints &points, int color = 255); ///< C++ wrapping for camDrawKeypoints() function
|
474
|
+
bool draw_keypoint(const CamKeypoint &point, int color = 255); ///< C++ wrapping for camDrawKeypoint() function
|
475
|
+
bool harris(CamKeypoints &points, int k = 41) const; ///< C++ wrapping for camHarris() function
|
476
|
+
bool integral_image(CamImage &dest) const; ///< C++ wrapping for camIntegralImage() function
|
477
|
+
CamImage *integral_image() const; ///< C++ wrapping for camIntegralImage() function
|
478
|
+
bool fast_hessian_detector(CamKeypoints &points, int threshold, int options = 0) const; /// C++ wrapping for camFastHessianDetector() function
|
479
|
+
};
|
480
|
+
|
481
|
+
inline CamROI::CamROI(const CamImage &image, int _coi) { coi=_coi; xOffset=0; yOffset=0; width=image.width; height=image.height; }
|
482
|
+
|
483
|
+
#else
|
484
|
+
} CamImage;
|
485
|
+
#endif
|
486
|
+
|
487
|
+
/* Camellia C functions headers
|
488
|
+
*/
|
489
|
+
|
490
|
+
#ifndef SWIG
|
491
|
+
|
492
|
+
#define CAM_PIXEL_ACCESS(ptr,y,x) \
|
493
|
+
((CAM_PIXEL*)((char*)ptr+y*ptr##widthstep)+x)
|
494
|
+
|
495
|
+
#define CAM_MAX(a,b) (((a)>(b))?(a):(b))
|
496
|
+
#define CAM_MIN(a,b) (((a)<(b))?(a):(b))
|
497
|
+
|
498
|
+
/*! \def CAM_RGBA
|
499
|
+
* \brief 32 bits integer color representation, including an alpha channel.
|
500
|
+
*/
|
501
|
+
#define CAM_RGBA(r,g,b,a) ((r)|((g)<<8)|((b)<<16)|((a)<<24))
|
502
|
+
|
503
|
+
/*! \def CAM_RGB
|
504
|
+
* \brief 24 bits integer color representation. Stricly equivalent to the Windows RGB macro.
|
505
|
+
* Please use this one in place of RGB for better portability of the code.
|
506
|
+
*/
|
507
|
+
#define CAM_RGB(r,g,b) ((r)|((g)<<8)|((b)<<16))
|
508
|
+
|
509
|
+
#endif // SWIG
|
510
|
+
|
511
|
+
/* General purpose structures
|
512
|
+
*/
|
513
|
+
|
514
|
+
/* Monadic and Dyadic Arithmetic Operators kernel
|
515
|
+
*/
|
516
|
+
|
517
|
+
#define CAM_ARITHM_ABS 0
|
518
|
+
#define CAM_ARITHM_INVERSE 1
|
519
|
+
#define CAM_ARITHM_SELECT 2
|
520
|
+
#define CAM_ARITHM_THRESHOLD 3
|
521
|
+
#define CAM_ARITHM_DOUBLE_THRESHOLD 4
|
522
|
+
|
523
|
+
#define CAM_ARITHM_ADD 0
|
524
|
+
#define CAM_ARITHM_SUM 0
|
525
|
+
#define CAM_ARITHM_SUB 1
|
526
|
+
#define CAM_ARITHM_MUL 2
|
527
|
+
#define CAM_ARITHM_ABSDIFF 3
|
528
|
+
#define CAM_ARITHM_WEIGHTED_SUM 4
|
529
|
+
#define CAM_ARITHM_INF 5
|
530
|
+
#define CAM_ARITHM_SUP 6
|
531
|
+
#define CAM_ARITHM_COMP_INF 7
|
532
|
+
#define CAM_ARITHM_COMP_EQUAL 8
|
533
|
+
#define CAM_ARITHM_COMP_SUP 9
|
534
|
+
#define CAM_ARITHM_AND 10
|
535
|
+
#define CAM_ARITHM_OR 11
|
536
|
+
|
537
|
+
// Shorter constants
|
538
|
+
#define CAM_ABS 0
|
539
|
+
#define CAM_INVERSE 1
|
540
|
+
#define CAM_SELECT 2
|
541
|
+
#define CAM_THRESHOLD 3
|
542
|
+
#define CAM_DOUBLE_THRESHOLD 4
|
543
|
+
|
544
|
+
#define CAM_ADD 0
|
545
|
+
#define CAM_SUM 0
|
546
|
+
#define CAM_SUB 1
|
547
|
+
#define CAM_ABSDIFF 2
|
548
|
+
#define CAM_WEIGHTED_SUM 3
|
549
|
+
#define CAM_INF 4
|
550
|
+
#define CAM_SUP 5
|
551
|
+
#define CAM_COMP_INF 6
|
552
|
+
#define CAM_COMP_EQUAL 7
|
553
|
+
#define CAM_COMP_SUP 8
|
554
|
+
#define CAM_AND 9
|
555
|
+
#define CAM_OR 10
|
556
|
+
|
557
|
+
#ifndef SWIG
|
558
|
+
|
559
|
+
/// This is the parameter structure for the arithmetic computation kernel
|
560
|
+
/** Basically, it includes the code of the operation to execute, and
|
561
|
+
* the different parameters for this operation.
|
562
|
+
*/
|
563
|
+
typedef struct {
|
564
|
+
int operation; ///< Operation to apply to the sources
|
565
|
+
int c1; ///< Additional parameter (see camMonadicArithm() and camDyadicArithm() for details)
|
566
|
+
int c2; ///< Additional parameter (see camMonadicArithm() and camDyadicArithm() for details)
|
567
|
+
int c3; ///< Additional parameter (see camMonadicArithm() and camDyadicArithm() for details)
|
568
|
+
int c4; ///< Additional parameter (see camMonadicArithm() and camDyadicArithm() for details)
|
569
|
+
} CamArithmParams;
|
570
|
+
|
571
|
+
#endif // SWIG
|
572
|
+
|
573
|
+
#ifdef __cplusplus
|
574
|
+
extern "C" {
|
575
|
+
#endif
|
576
|
+
|
577
|
+
#ifndef SWIG
|
578
|
+
|
579
|
+
/// This is the function that implements all the monadic arithmetic operators (i.e. operators with only one operand)
|
580
|
+
/** This function can be used to compute the absolute value of an image (<DFN>CAM_ARITHM_ABS</DFN>),
|
581
|
+
* to invert an image (<DFN>CAM_ARITHM_INVERSE</DFN>), to select all pixels with a given value in an image (<DFN>CAM_ARITHM_SELECT</DFN>),
|
582
|
+
* to threshold an image either with one threshold value (<DFN>CAM_ARITHM_THRESHOLD</DFN>), or two threshold values (<DFN>CAM_ARITHM_DOUBLE_THRESHOLD</DFN>)
|
583
|
+
*
|
584
|
+
* \param source The source ::CamImage to process. The source must be a grey-level image,
|
585
|
+
* except when the operation is an image inversion (<DFN>CAM_ARITHM_INVERSE</DFN>).
|
586
|
+
* \param dest The destination ::CamImage. The destination image can be either a grey-level
|
587
|
+
* image or a binary image. In the latter case, <DFN>CAM_ARITHM_ABS</DFN> is not a valid
|
588
|
+
* operation
|
589
|
+
* \param params A pointer to a ::CamArithmParams structure, defining all the parameters
|
590
|
+
* of the function to apply to the source image.
|
591
|
+
*
|
592
|
+
* Here are the details on the operations and parameters to set in the ::CamArithmParams structure :
|
593
|
+
* - <DFN>CAM_ARITHM_ABS</DFN> : Absolute value computation. <I>pdest=abs(psource)</I>.
|
594
|
+
* - <DFN>CAM_ARITHM_INVERSE</DFN> : Inverse. <I>pdest=not(psource)</I>.
|
595
|
+
* - <DFN>CAM_ARITHM_SELECT</DFN> : Selection of a part of an image. <I>if (psource=c1) then pdest=c2 else pdest=c3</I>.
|
596
|
+
* - <DFN>CAM_ARITHM_THRESHOLD</DFN> : Comparison with a scalar (also called thresholding). <I>if (psource<c1) then pdest=c2 else pdest=c3</I>.
|
597
|
+
* - <DFN>CAM_ARITHM_DOUBLE_THRESHOLD</DFN> : Double thresholding. <I>if (psource>c1 and psource<c2) then pdest=c3 else pdest=c4</I>.
|
598
|
+
*
|
599
|
+
* \return 0 (false) if an error occurs. An accumulator of all results pixel values otherwise.
|
600
|
+
*
|
601
|
+
* Note that this kernel supports in-place processing (i.e. dest can be the same as source param).
|
602
|
+
*
|
603
|
+
*/
|
604
|
+
int camMonadicArithm(CamImage *source, CamImage *dest, CamArithmParams *params);
|
605
|
+
|
606
|
+
/// This is the function that implements all the dyadic arithmetic operators (i.e. operators with two operands)
|
607
|
+
/** This function can be used to compute the sum of two images (<DFN>CAM_ARITHM_ADD</DFN>),
|
608
|
+
* to substract two images (<DFN>CAM_ARITHM_SUB</DFN>), to compute the absolute difference
|
609
|
+
* between two images (<DFN>CAM_ARITHM_ABSDIFF</DFN>), to compute the weighted sum of two images (<DFN>CAM_ARITHM_WEIGHTED_SUM</DFN>),
|
610
|
+
* etc. (see below)
|
611
|
+
*
|
612
|
+
* \param source1 The first source ::CamImage to process. Any source image can be either grey-level or
|
613
|
+
* binary, depending on the operation to apply.
|
614
|
+
*
|
615
|
+
* \param source2 The second source ::CamImage to process. Any source image can be either grey-level or
|
616
|
+
* binary, depending on the operation to apply.
|
617
|
+
*
|
618
|
+
* \param dest The destination ::CamImage. The destination image can be either a grey-level
|
619
|
+
* image or a binary image, but source1, source2 and dest must be of the same kind.
|
620
|
+
*
|
621
|
+
* \param params A pointer to a ::CamArithmParams structure, defining all the parameters
|
622
|
+
* of the function to apply to the source images.
|
623
|
+
*
|
624
|
+
* Here are the details on the operations and parameters to set in the ::CamArithmParams structure :
|
625
|
+
* - <DFN>CAM_ARITHM_ADD</DFN> : Addition of images, with saturation. <I>pdest=psource1+psource2; if (pdest<0) then pdest=0; if (pdest>valmax) then pdest=valmax</I>.
|
626
|
+
* - <DFN>CAM_ARITHM_SUB</DFN> : Substraction of images, with saturation. <I>pdest=psource1-psource2; if (pdest<valmin) then pdest=valmin; if (pdest>valmax) then pdest=valmax</I>.
|
627
|
+
* - <DFN>CAM_ARITHM_MUL</DFN> : Multiplication of images, with saturation. <I>pdest=(psource1*psource2)>>c1; if (pdest<valmin) then pdest=valmin; if (pdest>valmax) then pdest=valmax</I>.
|
628
|
+
* - <DFN>CAM_ARITHM_ABSDIFF</DFN> : Absolute difference, with saturation. <I>pdest=abs(psource1-psource2)</I>.
|
629
|
+
* - <DFN>CAM_ARITHM_WEIGHTED_SUM</DFN> : Weighted sum. <I>pdest=(c1*psource1+c2*psource2)>>c3</I>.
|
630
|
+
* - <DFN>CAM_ARITHM_INF</DFN> : Inf. <I>pdest=inf(psource1,psource2)</I>.
|
631
|
+
* - <DFN>CAM_ARITHM_SUP</DFN> : Sup. <I>pdest=sup(psource1,psource2)</I>.
|
632
|
+
* - <DFN>CAM_ARITHM_COMP_INF</DFN> : Comparison. <I>if (psource1<psource2) pdest=c1 else pdest=c2</I>.
|
633
|
+
* - <DFN>CAM_ARITHM_COMP_EQUAL</DFN> : Equality test. <I>if (psource1=psource2) pdest=c1 else pdest=c2</I>.
|
634
|
+
* - <DFN>CAM_ARITHM_COMP_SUP</DFN> : Comparison. <I>if (psource1>psource2) pdest=c1 else pdest=c2</I>.
|
635
|
+
* - <DFN>CAM_ARITHM_AND</DFN> : <I>pdest=psource1 & psource2</I> (arithmetic boolean "and" operator)
|
636
|
+
* - <DFN>CAM_ARITHM_OR</DFN> : <I>pdest=psource1 | psource2</I> (arithmetic boolean "or" operator)
|
637
|
+
*
|
638
|
+
* \return 0 (false) if an error occurs. An accumulator of all results pixel values otherwise.
|
639
|
+
*
|
640
|
+
* Note that this kernel supports in-place processing (i.e. dest can be the same as one of the sources).
|
641
|
+
*
|
642
|
+
* Note also that this kernel supports signed images, and thus can produce signed results
|
643
|
+
* (see the member depth in ::CamImage structure).
|
644
|
+
*
|
645
|
+
*/
|
646
|
+
int camDyadicArithm(CamImage *source1, CamImage *source2, CamImage *dest, CamArithmParams *params);
|
647
|
+
|
648
|
+
/// Image addition
|
649
|
+
/** Simple wrapper for camDyadicArithm() */
|
650
|
+
int camAdd(CamImage *source1, CamImage *source2, CamImage *dest);
|
651
|
+
|
652
|
+
/// Image multiplication
|
653
|
+
/** Simple wrapper for camDyadicArithm() */
|
654
|
+
int camMul(CamImage *source1, CamImage *source2, CamImage *dest);
|
655
|
+
|
656
|
+
/// Image subtraction
|
657
|
+
/** Simple wrapper for camDyadicArithm() */
|
658
|
+
int camSub(CamImage *source1, CamImage *source2, CamImage *dest);
|
659
|
+
|
660
|
+
/// Simple threshold function (wrapper for camMonadicArithm() function)
|
661
|
+
/** Turn all pixels below (<) the threshold value to 0, and all pixels above (>=) to 255
|
662
|
+
*/
|
663
|
+
int camThreshold(CamImage *source, CamImage *dest, int threshold);
|
664
|
+
|
665
|
+
/// Simple threshold function (wrapper for camMonadicArithm() function)
|
666
|
+
/** Turn all pixels below (<) the threshold value to 255, and all pixels above (>=) to 0
|
667
|
+
*/
|
668
|
+
int camThresholdInv(CamImage *source, CamImage *dest, int threshold);
|
669
|
+
|
670
|
+
/// Compute absolute value of image (for signed images) (wrapper for camMonadicArithm() function)
|
671
|
+
int camAbs(CamImage *source, CamImage *dest);
|
672
|
+
|
673
|
+
/* Apply-a-LUT-on-image Kernel
|
674
|
+
*/
|
675
|
+
|
676
|
+
// 12 bits maximum LUT management
|
677
|
+
#define CAM_TABLE_SIZE 4096
|
678
|
+
|
679
|
+
#define CamLUT CamTable
|
680
|
+
#define CamHisto CamTable
|
681
|
+
|
682
|
+
#ifdef __cplusplus
|
683
|
+
/// Pixel table (LUT (Look-Up Table) and histogram) structure
|
684
|
+
struct CamTable {
|
685
|
+
#else
|
686
|
+
/// LUT (Look-Up Table) structure
|
687
|
+
typedef struct {
|
688
|
+
#endif
|
689
|
+
int t[CAM_TABLE_SIZE]; ///< Table containing the resulting pixel value for each input
|
690
|
+
int size; ///< Number of valid entries
|
691
|
+
#ifdef __cplusplus
|
692
|
+
CamTable(int s=0) {size=s;}
|
693
|
+
int &operator[](int n);
|
694
|
+
bool set(const int* const array, int sz) { if (sz<CAM_TABLE_SIZE) { size=sz; for (int i=0;i<sz;i++) t[i]=array[i]; return true;} return false;}
|
695
|
+
};
|
696
|
+
#else
|
697
|
+
} CamTable;
|
698
|
+
#endif
|
699
|
+
|
700
|
+
/// Apply a Look-Up-Table on image function
|
701
|
+
int camApplyLUT(CamImage *source, CamImage *dest, CamTable *LUT);
|
702
|
+
|
703
|
+
#endif // SWIG
|
704
|
+
|
705
|
+
/* Fundamental Morphological Mathematics Algorithms' kernel
|
706
|
+
*/
|
707
|
+
#define CAM_MM_NEIGHB 7
|
708
|
+
|
709
|
+
#define CAM_MM_DILATED 0
|
710
|
+
#define CAM_MM_ERODED 1
|
711
|
+
#define CAM_MM_ORIGINAL 2
|
712
|
+
|
713
|
+
#define CAM_MM_SUBSTRACTION 0
|
714
|
+
#define CAM_MM_MULTIPLEX 1
|
715
|
+
#define CAM_MM_THINNING 2
|
716
|
+
#define CAM_MM_THICKENING 3
|
717
|
+
|
718
|
+
/// This is the parameter structure for the morpho maths kernel
|
719
|
+
/** Basically, it includes the structural elements for dilation and erosion
|
720
|
+
* as well as options for the full kernel.
|
721
|
+
*/
|
722
|
+
#ifdef __cplusplus
|
723
|
+
struct CamMorphoMathsKernel {
|
724
|
+
#else
|
725
|
+
typedef struct {
|
726
|
+
#endif
|
727
|
+
// Structural elements
|
728
|
+
#ifndef SWIG
|
729
|
+
int dilationStructElt[CAM_MM_NEIGHB][CAM_MM_NEIGHB]; ///< The structural element used for all dilation operations
|
730
|
+
int erosionStructElt[CAM_MM_NEIGHB][CAM_MM_NEIGHB]; ///< The structural element used for all erosion operations
|
731
|
+
#endif
|
732
|
+
int source1; ///< CAM_MM_DILATED | CAM_MM_ERODED | CAM_MM_ORIGINAL
|
733
|
+
int source2; ///< CAM_MM_DILATED | CAM_MM_ERODED | CAM_MM_ORIGINAL
|
734
|
+
int operation; ///< CAM_MM_SUBSTRACTION | CAM_MM_MULTIPLEX | CAM_MM_THINNING | CAM_MM_THICKENING
|
735
|
+
#ifdef __cplusplus
|
736
|
+
/// Default constructor
|
737
|
+
CamMorphoMathsKernel() {
|
738
|
+
for (int i=0;i<CAM_MM_NEIGHB;i++) {
|
739
|
+
for (int j=0;j<CAM_MM_NEIGHB;j++) {
|
740
|
+
dilationStructElt[i][j]=0;
|
741
|
+
erosionStructElt[i][j]=0;
|
742
|
+
}
|
743
|
+
}
|
744
|
+
source1=CAM_MM_ORIGINAL;
|
745
|
+
source2=CAM_MM_ORIGINAL;
|
746
|
+
operation=CAM_MM_MULTIPLEX;
|
747
|
+
}
|
748
|
+
/// Set an element of the dilation kernel
|
749
|
+
bool set_dilate(int x, int y, int val) {
|
750
|
+
if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
|
751
|
+
dilationStructElt[x][y]=val; return true;
|
752
|
+
} else return false;
|
753
|
+
}
|
754
|
+
/// Get an element from the dilation kernel
|
755
|
+
int get_dilate(int x,int y) {
|
756
|
+
if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
|
757
|
+
return dilationStructElt[x][y];
|
758
|
+
} else return 0;
|
759
|
+
}
|
760
|
+
/// Set an element of the erosion kernel
|
761
|
+
bool set_erode(int x, int y, int val) {
|
762
|
+
if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
|
763
|
+
erosionStructElt[x][y]=val; return true;
|
764
|
+
} else return false;
|
765
|
+
}
|
766
|
+
/// Get an element from the erosion kernel
|
767
|
+
int get_erode(int x,int y) {
|
768
|
+
if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
|
769
|
+
return erosionStructElt[x][y];
|
770
|
+
} else return 0;
|
771
|
+
}
|
772
|
+
};
|
773
|
+
#else
|
774
|
+
} CamMorphoMathsKernel;
|
775
|
+
#endif
|
776
|
+
|
777
|
+
#ifndef SWIG
|
778
|
+
|
779
|
+
/** @name Morphomaths LLAs
|
780
|
+
* These functions share the same morpho maths kernel
|
781
|
+
*/
|
782
|
+
//@{
|
783
|
+
|
784
|
+
/// This is the function that can compute erosion AND dilation in one scan (with 5x5 neighborhood).
|
785
|
+
/** It can be used to compute thinning, thickening, or morphological gradient in one scan.
|
786
|
+
* If only erosion or dilation is needed, it's more simple (and a bit faster) to use the
|
787
|
+
* dedicated functions.
|
788
|
+
*
|
789
|
+
* \param source The source ::CamImage to process
|
790
|
+
* \param dest The destination ::CamImage
|
791
|
+
* \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
|
792
|
+
* elements, as well as the behaviour of the kernel.
|
793
|
+
* \return Sum (Accumulator) of all computed pixels
|
794
|
+
*
|
795
|
+
* Note that this kernel supports in-place processing (i.e. dest can be the same as source param)
|
796
|
+
*/
|
797
|
+
int camMorphoMaths(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel);
|
798
|
+
|
799
|
+
// These are specific functions able to compute only erosion or dilation, on 3x3, 5x5 or 7x7 neighbourhood
|
800
|
+
|
801
|
+
/** \param source The source ::CamImage to process
|
802
|
+
* \param dest The destination ::CamImage
|
803
|
+
* \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
|
804
|
+
* element to use. Only the ErosionStructElt member is used by this function.
|
805
|
+
* \return Sum (Accumulator) of all computed pixels
|
806
|
+
*
|
807
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
808
|
+
*/
|
809
|
+
int camErode3x3(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); ///< 3x3 neighborhood erosion
|
810
|
+
|
811
|
+
/** \param source The source ::CamImage to process
|
812
|
+
* \param dest The destination ::CamImage
|
813
|
+
* \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
|
814
|
+
* element to use. Only the ErosionStructElt member is used by this function.
|
815
|
+
* \return Sum (Accumulator) of all computed pixels
|
816
|
+
*
|
817
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
818
|
+
*/
|
819
|
+
int camErode5x5(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); ///< 5x5 neighborhood erosion
|
820
|
+
|
821
|
+
/** \param source The source ::CamImage to process
|
822
|
+
* \param dest The destination ::CamImage
|
823
|
+
* \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
|
824
|
+
* element to use. Only the ErosionStructElt member is used by this function.
|
825
|
+
* \return Sum (Accumulator) of all computed pixels
|
826
|
+
*
|
827
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
828
|
+
*/
|
829
|
+
int camErode7x7(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); ///< 7x7 neighborhood erosion
|
830
|
+
|
831
|
+
/** \param source The source ::CamImage to process
|
832
|
+
* \param dest The destination ::CamImage
|
833
|
+
* \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
|
834
|
+
* element to use. Only the DilationStructElt member is used by this function.
|
835
|
+
* \return Sum (Accumulator) of all computed pixels
|
836
|
+
*
|
837
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
838
|
+
*/
|
839
|
+
int camDilate3x3(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); ///< 3x3 neighborhood dilation
|
840
|
+
|
841
|
+
/** \param source The source ::CamImage to process
|
842
|
+
* \param dest The destination ::CamImage
|
843
|
+
* \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
|
844
|
+
* element to use. Only the DilationStructElt member is used by this function.
|
845
|
+
* \return Sum (Accumulator) of all computed pixels
|
846
|
+
*
|
847
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
848
|
+
*/
|
849
|
+
int camDilate5x5(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); ///< 5x5 neighborhood dilation
|
850
|
+
|
851
|
+
/** \param source The source ::CamImage to process
|
852
|
+
* \param dest The destination ::CamImage
|
853
|
+
* \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
|
854
|
+
* element to use. Only the DilationStructElt member is used by this function.
|
855
|
+
* \return Sum (Accumulator) of all computed pixels
|
856
|
+
*
|
857
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
858
|
+
*/
|
859
|
+
int camDilate7x7(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); ///< 7x7 neighborhood dilation
|
860
|
+
|
861
|
+
/** Computes the morphological gradient of an image.
|
862
|
+
*
|
863
|
+
* Uses a circular structural element of diameter 5.
|
864
|
+
* It is twice faster than the original morpho maths kernel.
|
865
|
+
*
|
866
|
+
* \param source The source ::CamImage to process. Must be a grey-level image.
|
867
|
+
* \param dest The destination ::CamImage. Must be a grey-level image.
|
868
|
+
* \return Sum (Accumulator) of all computed pixels
|
869
|
+
*
|
870
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
871
|
+
*/
|
872
|
+
int camMorphoGradientCircle5(CamImage *source, CamImage *dest); ///< Morphological gradient computation (Diameter-5 circle structural element)
|
873
|
+
|
874
|
+
/** Computes the eroded image of a source image, using a circular structural
|
875
|
+
* element of diameter 5. Highly optimized code.
|
876
|
+
*
|
877
|
+
* \param source The source ::CamImage to process. Must be a grey-level image.
|
878
|
+
* \param dest The destination ::CamImage. Must be a grey-level image.
|
879
|
+
* \return Sum (Accumulator) of all computed pixels
|
880
|
+
*
|
881
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
882
|
+
*/
|
883
|
+
int camErodeCircle5(CamImage *source, CamImage *dest); ///< Erosion (Optimized for diameter-5 circle structural element)
|
884
|
+
|
885
|
+
/** Computes the dilated image of a source image, using a circular structural
|
886
|
+
* element of diameter 5. Highly optimized code.
|
887
|
+
*
|
888
|
+
* \param source The source ::CamImage to process. Must be a grey-level image.
|
889
|
+
* \param dest The destination ::CamImage. Must be a grey-level image.
|
890
|
+
* \return Sum (Accumulator) of all computed pixels
|
891
|
+
*
|
892
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
893
|
+
*/
|
894
|
+
int camDilateCircle5(CamImage *source, CamImage *dest); ///< Dilation (Optimized for diameter-5 circle structural element)
|
895
|
+
|
896
|
+
/** Computes the morphological gradient of an image.
|
897
|
+
*
|
898
|
+
* Uses a circular structural element of diameter 7.
|
899
|
+
* It is twice faster than the original morpho maths kernel.
|
900
|
+
*
|
901
|
+
* \param source The source ::CamImage to process. Must be a grey-level image.
|
902
|
+
* \param dest The destination ::CamImage. Must be a grey-level image.
|
903
|
+
* \return Sum (Accumulator) of all computed pixels
|
904
|
+
*
|
905
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
906
|
+
*/
|
907
|
+
int camMorphoGradientCircle7(CamImage *source, CamImage *dest); ///< Morphological gradient computation (Diameter-7 circle structural element)
|
908
|
+
|
909
|
+
/** Computes the eroded image of a source image, using a circular structural
|
910
|
+
* element of diameter 7. Highly optimized code.
|
911
|
+
*
|
912
|
+
* \param source The source ::CamImage to process. Must be a grey-level image.
|
913
|
+
* \param dest The destination ::CamImage. Must be a grey-level image.
|
914
|
+
* \return Sum (Accumulator) of all computed pixels
|
915
|
+
*
|
916
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
917
|
+
*/
|
918
|
+
int camErodeCircle7(CamImage *source, CamImage *dest); ///< Erosion (Optimized for diameter-7 circle structural element)
|
919
|
+
|
920
|
+
/** Computes the dilated image of a source image, using a circular structural
|
921
|
+
* element of diameter 7. Highly optimized code.
|
922
|
+
*
|
923
|
+
* \param source The source ::CamImage to process. Must be a grey-level image.
|
924
|
+
* \param dest The destination ::CamImage. Must be a grey-level image.
|
925
|
+
* \return Sum (Accumulator) of all computed pixels
|
926
|
+
*
|
927
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
928
|
+
*/
|
929
|
+
int camDilateCircle7(CamImage *source, CamImage *dest); ///< Dilation (Optimized for diameter-7 circle structural element)
|
930
|
+
|
931
|
+
/** Computes the morphological gradient of an image.
|
932
|
+
*
|
933
|
+
* Uses a 3x3 square structural element (very classical).
|
934
|
+
* Highly optimized code.
|
935
|
+
*
|
936
|
+
* \param source The source ::CamImage to process. Must be a grey-level image.
|
937
|
+
* \param dest The destination ::CamImage. Must be a grey-level image.
|
938
|
+
* \return Sum (Accumulator) of all computed pixels
|
939
|
+
*
|
940
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
941
|
+
*/
|
942
|
+
int camMorphoGradientSquare3(CamImage *source, CamImage *dest); ///< Morphological gradient computation (3x3 square structural element)
|
943
|
+
|
944
|
+
/** Computes the eroded image of a source image, using a classical 3x3 square structural
|
945
|
+
* element. Highly optimized code.
|
946
|
+
*
|
947
|
+
* \param source The source ::CamImage to process. Must be a grey-level image.
|
948
|
+
* \param dest The destination ::CamImage. Must be a grey-level image.
|
949
|
+
* \return Sum (Accumulator) of all computed pixels
|
950
|
+
*
|
951
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
952
|
+
*/
|
953
|
+
int camErodeSquare3(CamImage *source, CamImage *dest); ///< Erosion (3x3 square structural element)
|
954
|
+
|
955
|
+
/** Computes the dilated image of a source image, using a classical 3x3 square structural
|
956
|
+
* element. Highly optimized code.
|
957
|
+
*
|
958
|
+
* \param source The source ::CamImage to process. Must be a grey-level image.
|
959
|
+
* \param dest The destination ::CamImage. Must be a grey-level image.
|
960
|
+
* \return Sum (Accumulator) of all computed pixels
|
961
|
+
*
|
962
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
963
|
+
*/
|
964
|
+
int camDilateSquare3(CamImage *source, CamImage *dest); ///< Dilation (3x3 square structural element)
|
965
|
+
//@}
|
966
|
+
|
967
|
+
/* Labeling kernel
|
968
|
+
*/
|
969
|
+
#define CamLabellingResults CamLabelingResults
|
970
|
+
#define camLabelling camLabeling
|
971
|
+
#define camLabelling2ndScan camLabeling2ndScan
|
972
|
+
#define camRLELabelling camRLELabeling
|
973
|
+
|
974
|
+
#define CAM_LABEL_MAX_BLOBS 1024
|
975
|
+
#define CAM_LABEL_PIXEL unsigned short
|
976
|
+
|
977
|
+
#define CAM_LABEL_PIXEL_ACCESS(ptr,y,x) \
|
978
|
+
((CAM_LABEL_PIXEL*)((char*)ptr+y*ptr##widthstep)+x)
|
979
|
+
|
980
|
+
/// Data structure containing the result of pixel-based labeling.
|
981
|
+
typedef struct {
|
982
|
+
int nbLabels; ///< Number of labels found in the frame
|
983
|
+
int equiv[CAM_LABEL_MAX_BLOBS]; ///< Labels equivalence table (see D3.1 for details)
|
984
|
+
} CamLabelingResults;
|
985
|
+
|
986
|
+
/// 4-connectedness labeling function
|
987
|
+
/** Computes the labeled image of a source image,
|
988
|
+
* i.e. finds the connected pixels (using 4-connectedness)
|
989
|
+
*
|
990
|
+
* \param source The source ::CamImage to process. Must be a grey-level image.
|
991
|
+
* \param dest The destination ::CamImage..Must be 16-bits deep (its the label result image)
|
992
|
+
* \param results The ::CamLabelingResults containing the label equivalence table, to provide to a blob analysis function.
|
993
|
+
* \return 0 (false) if an error occurs
|
994
|
+
*
|
995
|
+
* Note that this function is rather obsolete. This pixel-based labeling algorithm is
|
996
|
+
* outdated compared to RLE-based labeling.
|
997
|
+
*
|
998
|
+
* \sa camRLELabeling
|
999
|
+
*/
|
1000
|
+
int camLabeling(CamImage *source, CamImage *dest, CamLabelingResults *results);
|
1001
|
+
|
1002
|
+
/** This algorithm is useless. Presented here for better understanding purpose only.
|
1003
|
+
* Indeed, Blob analysis first scan (camBlobAnalysis1stScan()) integrates this second scan.
|
1004
|
+
* In-place processing only.
|
1005
|
+
*/
|
1006
|
+
int camLabeling2ndScan(CamImage *image, CamLabelingResults *results); ///< Second scan for pixel-based labeling. Obsolete.
|
1007
|
+
|
1008
|
+
/* Blob analysis Kernel
|
1009
|
+
* C code */
|
1010
|
+
|
1011
|
+
#endif // SWIG
|
1012
|
+
|
1013
|
+
#define CAM_RLE_INT_TYPE unsigned short
|
1014
|
+
|
1015
|
+
/// The CamRun structure, basic element of a Run-Length Encoding (RLE) of an image.
|
1016
|
+
/** sizeof(CamRun) is 8 (64 bits)
|
1017
|
+
*/
|
1018
|
+
typedef struct {
|
1019
|
+
CAM_RLE_INT_TYPE value; ///< Which color(s) this run represents
|
1020
|
+
CAM_RLE_INT_TYPE length; ///< The length of the run (in pixels)
|
1021
|
+
CAM_RLE_INT_TYPE blob; ///< Run's parent in the connected components tree, which becomes the blob number after labeling
|
1022
|
+
CAM_RLE_INT_TYPE line; ///< The line to which the run belongs
|
1023
|
+
} CamRun;
|
1024
|
+
|
1025
|
+
#ifndef SWIG
|
1026
|
+
|
1027
|
+
/// The Blob (block of bits) Information Structure. This is the most important result of Labeling + Blob analysis.
|
1028
|
+
typedef struct {
|
1029
|
+
int id;
|
1030
|
+
int left; ///< Leftmost coordinate of the blob
|
1031
|
+
int top; ///< Topmost coordinate of the blob
|
1032
|
+
int width; ///< Width of the blob
|
1033
|
+
int height; ///< Height of the blob
|
1034
|
+
int surface; ///< Number of pixels covered by this blob
|
1035
|
+
int cx; ///< Center of gravity (x)
|
1036
|
+
int cy; ///< Center of gravity (y)
|
1037
|
+
int value; ///< Blob value, or average pixel value in the original image
|
1038
|
+
int min; ///< Minimum pixel value in the original image
|
1039
|
+
int max; ///< Maximum pixel value in the original image
|
1040
|
+
CamRun *first; ///< First run of the blob (only for RLE labeling)
|
1041
|
+
CamRun *last; ///< Last run of the blob (only for RLE labeling)
|
1042
|
+
void *misc; ///< Additional user-dependant blob information
|
1043
|
+
} CamBlobInfo;
|
1044
|
+
|
1045
|
+
#define CamBlobAnalysisResults CamBlobs // For compatibility with previous versions
|
1046
|
+
|
1047
|
+
#ifdef __cplusplus
|
1048
|
+
/// The result of any blob analysis. Essentially an array of ::CamBlobInfo
|
1049
|
+
struct CamBlobs {
|
1050
|
+
int nbBlobs; ///< Number of valid blobs
|
1051
|
+
CamBlobInfo blobInfo[CAM_LABEL_MAX_BLOBS]; ///< Array of information on the blobs
|
1052
|
+
CamBlobs() {nbBlobs=0;} ///< Default constructor
|
1053
|
+
CamBlobInfo& operator[](int index);
|
1054
|
+
};
|
1055
|
+
#else
|
1056
|
+
/// The result of any blob analysis. Essentially an array of ::CamBlobInfo
|
1057
|
+
typedef struct {
|
1058
|
+
int nbBlobs; ///< Number of valid blobs
|
1059
|
+
CamBlobInfo blobInfo[CAM_LABEL_MAX_BLOBS]; ///< Array of information on the blobs
|
1060
|
+
} CamBlobs;
|
1061
|
+
#endif
|
1062
|
+
|
1063
|
+
/** Computes the most important blob information :
|
1064
|
+
* <DFN>top</DFN>, <DFN>left</DFN>, <DFN>width</DFN>, <DFN>height</DFN>, <DFN>cx</DFN>, <DFN>cy</DFN>,
|
1065
|
+
* and <DFN>surface</DFN>. <DFN>average</DFN>, <DFN>min</DFN> and <DFN>max</DFN>
|
1066
|
+
* are computed only if a pointer on the original image is provided (slower).
|
1067
|
+
*
|
1068
|
+
* \param blobImage The result of a previous labeling operation.
|
1069
|
+
* \param original The original ::CamImage that was labelled previously. Can bet set to NULL.
|
1070
|
+
* \param info The ::CamLabelingResults structure provided by the former call to camLabeling().(in data)
|
1071
|
+
* \param results The ::CamBlobs structure that is filled with the collected blob information.
|
1072
|
+
*
|
1073
|
+
* \return 0 (false) if an error occurs, especially if the number of blobs is too high.(more than the <DFN>CAM_LABEL_MAX_BLOBS</DFN> constant)
|
1074
|
+
*
|
1075
|
+
* In-place processing (<DFN>blobImage</DFN> will be affected).
|
1076
|
+
*/
|
1077
|
+
int camBlobAnalysis1stScan(CamImage *blobImage, CamImage *original, CamLabelingResults *info, CamBlobs *results); ///< Blob analysis function.
|
1078
|
+
|
1079
|
+
/// Second pass, to get some more information if needed.
|
1080
|
+
/** Computes the <DFN>average</DFN>, <DFN>min</DFN> and <DFN>max</DFN> blob information, if it was
|
1081
|
+
* not computed before.
|
1082
|
+
*
|
1083
|
+
* \param blobImage The result of a previous labeling operation.
|
1084
|
+
* \param original The original ::CamImage.that was labelled previously.
|
1085
|
+
* \param results The ::CamBlobs structure that is filled with the collected blob information.
|
1086
|
+
*
|
1087
|
+
* \return 0 (false) if an error occurs.
|
1088
|
+
*/
|
1089
|
+
int camBlobAnalysisRefinement(CamImage *blobImage, CamImage *original, CamBlobs *results);
|
1090
|
+
|
1091
|
+
/* RLE Labeling kernel
|
1092
|
+
* New : v1.4 of LLAs
|
1093
|
+
* Updated v1.6 and v1.9, v2.0 of LLAs
|
1094
|
+
*/
|
1095
|
+
|
1096
|
+
/** @name RLE images processing functions and data structures
|
1097
|
+
*/
|
1098
|
+
//@{
|
1099
|
+
|
1100
|
+
#ifdef __cplusplus
|
1101
|
+
/// The CamRLEImage structure : the RLE (Run Length Encoded) image structure.
|
1102
|
+
struct CamRLEImage {
|
1103
|
+
#else
|
1104
|
+
/// The CamRLEImage structure : the RLE (Run Length Encoded) image structure.
|
1105
|
+
typedef struct {
|
1106
|
+
#endif
|
1107
|
+
int nSize; ///< Size of CamImage struct
|
1108
|
+
int id; ///< Frame id (user dependent)
|
1109
|
+
int height; ///< Image height
|
1110
|
+
int width; ///< Image width
|
1111
|
+
int nbRuns; ///< The number of runs
|
1112
|
+
int allocated; ///< Number of runs allocated
|
1113
|
+
CamRun *runs; ///< A pointer to the array of runs
|
1114
|
+
|
1115
|
+
#ifdef __cplusplus
|
1116
|
+
CamRLEImage() {nSize=sizeof(CamRLEImage); allocated=0; runs=NULL; nbRuns=0;} ///< Default constructor
|
1117
|
+
CamRLEImage(int nbruns); ///< Constructor with max number of runs parameter
|
1118
|
+
CamRLEImage(const CamRLEImage &image); ///< Copy constructor
|
1119
|
+
~CamRLEImage(); ///< Default destructor
|
1120
|
+
|
1121
|
+
CamRLEImage& operator=(const CamRLEImage &image); ///< Operator= redefinition
|
1122
|
+
CamRLEImage* clone() const; ///< Clone RLE image (using camRLEClone() function)
|
1123
|
+
bool alloc(int nbruns); ///< Allocator (C++ wrapping of camRLEAllocate() function)
|
1124
|
+
bool realloc(int nbruns); ///< Reallocator (C++ wrapping of camRLEReallocate() function)
|
1125
|
+
|
1126
|
+
bool encode(const CamImage &image); ///< C++ wrapping for camRLEEncode() function
|
1127
|
+
bool encode_lut(const CamImage &image, const CamTable &LUT); ///< C++ wrapping for camRLEEncodeLUT() function
|
1128
|
+
bool encode_threshold(const CamImage &image, int threshold); ///< C++ wrapping for camRLEEncodeThreshold() function
|
1129
|
+
bool encode_threshold_inv(const CamImage &image, int threshold);///< C++ wrapping for camRLEEncodeThresholdInv() function
|
1130
|
+
bool encode_color(const CamImage &image, const CamTable &clusters); ///< C++ wrapping for camRLEEncodeColor() function
|
1131
|
+
CamBlobs* labeling(); ///< C++ wrapping for camRLELabeling() function
|
1132
|
+
bool labeling(CamBlobs &results); ///< C++ wrapping for camRLELabeling() function
|
1133
|
+
bool blob_analysis(CamBlobs &results) const; ///< C++ wrapping for camRLEBlobAnalysis() function
|
1134
|
+
bool apply_lut(const CamTable &LUT); ///< C++ wrapping for camRLEApplyLUT() function
|
1135
|
+
bool apply_lut(CamRLEImage &dest, const CamTable &LUT) const; ///< C++ wrapping for camRLEApplyLUT() function
|
1136
|
+
bool decode(CamImage &dest) const; ///< C++ wrapping for camRLEDecode() function
|
1137
|
+
bool decode(CamImage &dest, const CamTable &LUT) const; ///< C++ wrapping for camRLEDecode() function
|
1138
|
+
bool decode_blobs(CamImage &dest) const; ///< C++ wrapping for camRLEDecodeBlobs() function
|
1139
|
+
bool decode_blobs(CamImage &dest, const CamTable &LUT) const; ///< C++ wrapping for camRLEDecodeBlos() function
|
1140
|
+
bool inverse(); ///< C++ wrapping for camRLEInverse() function
|
1141
|
+
bool erode_cross(CamRLEImage &dest) const; ///< C++ wrapping for camRLEErodeCross() function
|
1142
|
+
CamRLEImage *erode_cross() const; ///< C++ wrapping for camRLEErodeCross() function
|
1143
|
+
bool erode_3x3(CamRLEImage &dest) const; ///< C++ wrapping for camRLEErode3x3() function
|
1144
|
+
CamRLEImage *erode_3x3() const; ///< C++ wrapping for camRLEErode3x3() function
|
1145
|
+
bool erode_3x2(CamRLEImage &dest) const; ///< C++ wrapping for camRLEErode3x2() function
|
1146
|
+
CamRLEImage *erode_3x2() const; ///< C++ wrapping for camRLEErode3x2() function
|
1147
|
+
};
|
1148
|
+
#else
|
1149
|
+
} CamRLEImage;
|
1150
|
+
#endif
|
1151
|
+
|
1152
|
+
/// RLE Image allocation.
|
1153
|
+
/** Allocates a RLE image.
|
1154
|
+
*
|
1155
|
+
* \param rle The ::CamRLEImage to allocate. The number of runs should be chosen
|
1156
|
+
* so that it is enough to encode the image to process. A typical value
|
1157
|
+
* used for this parameter is <DFN>source.width*source.height/16</DFN>, assuming
|
1158
|
+
* a typical run will of length 16. Note that this is very realistic when
|
1159
|
+
* the original image was thresholded and filtered.
|
1160
|
+
* \param max_runs The number of runs to allocate.
|
1161
|
+
* \return 0 (false) if an error occurs.
|
1162
|
+
*
|
1163
|
+
* Note that this function uses the standard C <DFN>malloc()</DFN> function.
|
1164
|
+
*
|
1165
|
+
* Note also that the amount of memory allocated is <DFN>8*max_runs</DFN> bytes. Thus, using
|
1166
|
+
* the typical <DFN>max_runs</DFN> value exposed above, a grey-level image will be compressed
|
1167
|
+
* by a factor of 2, and a binary image expanded by a factor of 4 using RLE encoding.
|
1168
|
+
*
|
1169
|
+
* The RLE image should be deallocated using the camRLEDeallocate() function,
|
1170
|
+
* or by calling the standard C function <DFN>free()</DFN> on the
|
1171
|
+
* <DFN>runs</DFN> member of the ::CamRLEImage structure.
|
1172
|
+
*
|
1173
|
+
*/
|
1174
|
+
int camRLEAllocate(CamRLEImage *rle, int max_runs);
|
1175
|
+
|
1176
|
+
/// RLE image deallocation.
|
1177
|
+
/** Release a RLE image memory. Should be matched with a call to camRLEAllocate()
|
1178
|
+
*
|
1179
|
+
* \param rle The ::CamRLEImage to deallocate.
|
1180
|
+
* \return 0 (false) if an error occurs.
|
1181
|
+
*
|
1182
|
+
* Note that this function uses the standard C <DFN>free()</DFN> function.
|
1183
|
+
*
|
1184
|
+
*/
|
1185
|
+
int camRLEDeallocate(CamRLEImage *rle);
|
1186
|
+
|
1187
|
+
/// Alias for camRLEDeallocate() function
|
1188
|
+
int camRLEFree(CamRLEImage *rle);
|
1189
|
+
|
1190
|
+
/// RLE image reallocation
|
1191
|
+
/** Reallocates a RLE image.
|
1192
|
+
*
|
1193
|
+
* \param rle The ::CamRLEImage to reallocate.
|
1194
|
+
* \param new_max_runs The new number of allocated runs
|
1195
|
+
* \return 0 (false) if an error occurs.
|
1196
|
+
*
|
1197
|
+
* Note that this function uses the standard C <DFN>realloc()</DFN> function.
|
1198
|
+
*
|
1199
|
+
*/
|
1200
|
+
int camRLEReallocate(CamRLEImage *rle, int new_max_runs);
|
1201
|
+
|
1202
|
+
/// RLE image cloning
|
1203
|
+
/** Clone a RLE image.
|
1204
|
+
*
|
1205
|
+
* \param source The ::CamRLEImage to clone.
|
1206
|
+
* \param dest The ::CamRLEImage to allocate (shouldn't be allocated)
|
1207
|
+
* \return 0 (false) if an error occurs.
|
1208
|
+
*
|
1209
|
+
* Note that this function uses the standard C <DFN>malloc()</DFN> function.
|
1210
|
+
*/
|
1211
|
+
int camRLEClone(CamRLEImage *source, CamRLEImage *dest);
|
1212
|
+
|
1213
|
+
/// Run-Length encoding
|
1214
|
+
/**
|
1215
|
+
* \param src The source ::CamImage to encode. This should be either a thresholded
|
1216
|
+
* image or a binary image. Note that this source image should be filtered
|
1217
|
+
* (using camErode3x3() for instance) before encoding,
|
1218
|
+
* in order to avoid a too high number of runs.
|
1219
|
+
* \param dest The ::CamRLEImage resulting of the encoding.
|
1220
|
+
* \return 0 (false) if an error occurs.
|
1221
|
+
*
|
1222
|
+
* Note that binary images encoding was optimized.
|
1223
|
+
*/
|
1224
|
+
int camRLEEncode(CamImage *src, CamRLEImage *dest);
|
1225
|
+
|
1226
|
+
/// Run-Length encoding, with integrated LUT operations.
|
1227
|
+
/** Introduced v1.9.
|
1228
|
+
*
|
1229
|
+
* \param src The source ::CamImage to encode. This must be a grey-level image.
|
1230
|
+
* Note that this source image should be filtered
|
1231
|
+
* (using camErode3x3() for instance) before encoding,
|
1232
|
+
* in order to avoid a too high number of runs.
|
1233
|
+
* \param dest The ::CamRLEImage resulting of the encoding.
|
1234
|
+
* \param LUT An array of integer used to classify the source image pixels.
|
1235
|
+
* \return 0 (false) if an error occurs.
|
1236
|
+
*/
|
1237
|
+
int camRLEEncodeLUT(CamImage *src, CamRLEImage *dest, CamTable *LUT);
|
1238
|
+
|
1239
|
+
/// Run-Length encoding, with integrated thresholding.
|
1240
|
+
/** \param src The source ::CamImage to encode. This must be a grey-level image.
|
1241
|
+
* Note that this source image should be filtered
|
1242
|
+
* (using camErodeSquare3() for instance) before encoding,
|
1243
|
+
* in order to avoid a too high number of runs.
|
1244
|
+
* \param dest The ::CamRLEImage resulting of the encoding.
|
1245
|
+
* \param threshold The threshold used. All pixels with value higher (>=) than threshold will be labelled..
|
1246
|
+
* \return 0 (false) if an error occurs.
|
1247
|
+
*/
|
1248
|
+
int camRLEEncodeThreshold(CamImage *src, CamRLEImage *dest, int threshold);
|
1249
|
+
|
1250
|
+
/// Run-Length encoding, with integrated thresholding.
|
1251
|
+
/** \param src The source ::CamImage to encode. This must be a grey-level image.
|
1252
|
+
* Note that this source image should be filtered
|
1253
|
+
* (using camErodeSquare3() for instance) before encoding,
|
1254
|
+
* in order to avoid a too high number of runs.
|
1255
|
+
* \param dest The ::CamRLEImage resulting of the encoding.
|
1256
|
+
* \param threshold The threshold used. All pixels with value lower (>=) than threshold will be labelled..
|
1257
|
+
* \return 0 (false) if an error occurs.
|
1258
|
+
*/
|
1259
|
+
int camRLEEncodeThresholdInv(CamImage *src, CamRLEImage *dest, int threshold);
|
1260
|
+
|
1261
|
+
int camRLEEncodeColor(CamImage *source, CamRLEImage *dest, CamTable *clusters);
|
1262
|
+
|
1263
|
+
/// RLE image labeling + blob analysis. 4-connectedness labeling.
|
1264
|
+
/** Very fast labeling algorithm originally introduced by the Carneggie Mellon University (see below).
|
1265
|
+
* This function also performs a basic blob analysis
|
1266
|
+
*
|
1267
|
+
* \param src The source ::CamRLEImage to label. Note that the content of <DFN>src</DFN> is altered,
|
1268
|
+
* for RLE labeling is performed in-place. This is what makes it especially fast,
|
1269
|
+
* since it doesn't require neither an additional label image nor an equivalence
|
1270
|
+
* table, everything being stored in the ::CamRLEImage structure.
|
1271
|
+
* \param results The ::CamBlobs containing the results of the blob analysis.
|
1272
|
+
* \return 0 (false) if an error occurs. Generally when the number
|
1273
|
+
* of blobs exceeds the <DFN>CAM_LABEL_MAX_BLOBS</DFN> constant.
|
1274
|
+
*
|
1275
|
+
* This code is based on the ideas developped in the CMVision library by CMU.
|
1276
|
+
*
|
1277
|
+
* \verbatim
|
1278
|
+
|
1279
|
+
-------------------------------------------------------------------------
|
1280
|
+
Copyright 1999, 2000 #### ### ### ## ## ## #### ## ### ## ##
|
1281
|
+
James R. Bruce ## ####### ## ## ## ## ## ## ## ######
|
1282
|
+
School of Computer Science ## ## # ## ## ## ## ### ## ## ## ## ###
|
1283
|
+
Carnegie Mellon University #### ## ## ### ## #### ## ### ## ##
|
1284
|
+
-------------------------------------------------------------------------
|
1285
|
+
|
1286
|
+
* \endverbatim
|
1287
|
+
*/
|
1288
|
+
int camRLELabeling(CamRLEImage *src, CamBlobs *results);
|
1289
|
+
|
1290
|
+
/// The RLE Blob Analysis function
|
1291
|
+
/** Automatically called by camRLELabeling().
|
1292
|
+
*
|
1293
|
+
* \param src The source ::CamRLEImage, already labelled.
|
1294
|
+
* \param results The ::CamBlobs containing the results of the blob analysis.
|
1295
|
+
* \return 0 (false) if an error occurs. Generally when the number
|
1296
|
+
* of blobs exceeds the <DFN>CAM_LABEL_MAX_BLOBS</DFN> constant.
|
1297
|
+
*/
|
1298
|
+
int camRLEBlobAnalysis(CamRLEImage *src, CamBlobs *results);
|
1299
|
+
|
1300
|
+
/// The RLE "Apply a LUT" function
|
1301
|
+
/** Very useful to post-process a RLE image. This function join runs when needed.
|
1302
|
+
*
|
1303
|
+
* Applying a LUT (i.e. for instance thresholding) can be useful
|
1304
|
+
* for many purposes (like "several thresholds at once" processing). For experts only.
|
1305
|
+
*
|
1306
|
+
* \param src The source ::CamRLEImage.
|
1307
|
+
* \param dest The destination ::CamRLEImage.
|
1308
|
+
* \param LUT Look-up-table applied to the <DFN>value</DFN> member of each run.
|
1309
|
+
* \return 0 (false) if an error occurs.
|
1310
|
+
*/
|
1311
|
+
int camRLEApplyLUT(CamRLEImage *src, CamRLEImage *dest, CamTable *LUT);
|
1312
|
+
|
1313
|
+
/// The RLE decoding function
|
1314
|
+
/** Reconstructs an ::CamImage from runs.
|
1315
|
+
*
|
1316
|
+
* \param src The source ::CamRLEImage.
|
1317
|
+
* \param dest The destination ::CamImage. Must be grey-level image
|
1318
|
+
* (binary image RLE decoding not yet implemented).
|
1319
|
+
* \param LUT Look-up-table applied to the <DFN>value</DFN> member of each run, to produce
|
1320
|
+
* the pixel value in the <DFN>dest</DFN> image.
|
1321
|
+
* \return 0 (false) if an error occurs.
|
1322
|
+
*
|
1323
|
+
* \todo Implement binary image RLE decoding
|
1324
|
+
*/
|
1325
|
+
int camRLEDecode(CamRLEImage *src, CamImage *dest, CamTable *LUT);
|
1326
|
+
|
1327
|
+
/// Another RLE decoding function, used to retrieve some specific blobs.
|
1328
|
+
/** Reconstructs an ::CamImage from a labelled RLE image. Very useful to see the result of labeling.
|
1329
|
+
*
|
1330
|
+
* \param src The source ::CamRLEImage.
|
1331
|
+
* \param dest The destination ::CamImage. Must be grey-level image
|
1332
|
+
* (binary image RLE decoding not yet implemented).
|
1333
|
+
* \param LUT Look-up-table applied to the <DFN>blob</DFN> member of each run, to produce
|
1334
|
+
* the pixel value in the <DFN>dest</DFN> image.
|
1335
|
+
* \return 0 (false) if an error occurs.
|
1336
|
+
*
|
1337
|
+
* \todo Implement binary image RLE decoding
|
1338
|
+
*/
|
1339
|
+
int camRLEDecodeBlobs(CamRLEImage *src, CamImage *dest, CamTable *LUT);
|
1340
|
+
|
1341
|
+
/// RLE image inversion
|
1342
|
+
/** Very useful function, for finding holes in blobs.
|
1343
|
+
* \param image The source and destination ::CamRLEImage. In-place processing only.
|
1344
|
+
* \return 0 (false) if an error occurs.
|
1345
|
+
*/
|
1346
|
+
int camRLEInverse(CamRLEImage *image);
|
1347
|
+
|
1348
|
+
/// RLE blob sides reconstruction
|
1349
|
+
int camRLEBlobSides(CamBlobInfo *blob, int *left, int *top, int *right, int *bottom);
|
1350
|
+
|
1351
|
+
/// RLE blob intersection with a ROI
|
1352
|
+
int camRLEBlobROIIntersect(CamBlobInfo *blob, CamROI *roi);
|
1353
|
+
|
1354
|
+
/// Retrieves the average, min and max values
|
1355
|
+
int camRLEBlobMeasures(CamBlobInfo *blob, CamImage *original);
|
1356
|
+
|
1357
|
+
/// RLE image erosion (cross structural element)
|
1358
|
+
/**
|
1359
|
+
* \param image The source ::CamRLEImage.
|
1360
|
+
* \param result The destination ::CamRLEImage
|
1361
|
+
* \return 0 (false) if an error occurs.
|
1362
|
+
*/
|
1363
|
+
int camRLEErodeCross(CamRLEImage *image, CamRLEImage *result);
|
1364
|
+
|
1365
|
+
/// RLE image erosion (3x3 square structural element)
|
1366
|
+
/**
|
1367
|
+
* \param image The source ::CamRLEImage.
|
1368
|
+
* \param result The destination ::CamRLEImage
|
1369
|
+
* \return 0 (false) if an error occurs.
|
1370
|
+
*/
|
1371
|
+
int camRLEErode3x3(CamRLEImage *image, CamRLEImage *result);
|
1372
|
+
|
1373
|
+
/// RLE image erosion (3x2 square structural element)
|
1374
|
+
/**
|
1375
|
+
* \param image The source ::CamRLEImage.
|
1376
|
+
* \param result The destination ::CamRLEImage
|
1377
|
+
* \return 0 (false) if an error occurs.
|
1378
|
+
*/
|
1379
|
+
int camRLEErode3x2(CamRLEImage *image, CamRLEImage *result);
|
1380
|
+
|
1381
|
+
//@}
|
1382
|
+
|
1383
|
+
/** @name Histogram computation
|
1384
|
+
*/
|
1385
|
+
//@{
|
1386
|
+
|
1387
|
+
/// The classical image histogramming
|
1388
|
+
/** Counts the number of occurence of each pixel value, on one channel only
|
1389
|
+
* (grey-level image), for images up to 12-bits deep. It supports signed images
|
1390
|
+
* by centering the histogram around the 0 value.
|
1391
|
+
*
|
1392
|
+
* \param image The ::CamImage to analyze. One channel only.
|
1393
|
+
* \param histo A pointer to a CamTable (array of integers) that will contain the results of histogramming.
|
1394
|
+
* \return 0 (false) if an error occurs. Accumulated values of scanned pixels otherwise.
|
1395
|
+
*
|
1396
|
+
* camHistogram supports masking and ROIs.
|
1397
|
+
*/
|
1398
|
+
int camHistogram(CamImage *image, CamTable *histo);
|
1399
|
+
|
1400
|
+
#define CAM_EQUAL_PERFECT 0
|
1401
|
+
#define CAM_EQUAL_FAST 1
|
1402
|
+
|
1403
|
+
/// Histogram Equalization
|
1404
|
+
/** Performs a histogram equalization, with no holes.
|
1405
|
+
*
|
1406
|
+
* \param src The ::CamImage to equalize. One channel only.
|
1407
|
+
* \param dest The resulting equalized image.
|
1408
|
+
* \param src_histo The histogram of the source image, obtained by a previous call to camHistogram().
|
1409
|
+
* \param option <DFN>CAM_EQUAL_FAST</DFN> or <DFN>CAM_EQUAL_PERFECT</DFN> (default)
|
1410
|
+
* \param work A ::CamImage used for internal computation. If set to NULL, allocation and deallocation will be done internally.
|
1411
|
+
* \return 0 (false) if an error occurs.
|
1412
|
+
*
|
1413
|
+
* camHistogramEqualization supports in-place operation, masking and ROIs.
|
1414
|
+
*/
|
1415
|
+
int camHistogramEqualization(CamImage *src, CamImage *dest, CamTable *src_histo, int option, CamImage *work);
|
1416
|
+
|
1417
|
+
/// Two channels histogram computation
|
1418
|
+
/** The result of this operation is 2D, and thus is stored in an image.
|
1419
|
+
*
|
1420
|
+
* \param image The ::CamImage for which to compute the histogram
|
1421
|
+
* \param ch1 The first channel number
|
1422
|
+
* \param ch2 The second channel number
|
1423
|
+
* \param result The ::CamImage containing the results of histogramming.
|
1424
|
+
* \param size Subsampling factor. size=1 results in a 256x256 picture, size=2 results in a 128x128 picture, etc.
|
1425
|
+
* \return 0 (false) if an error occurs.
|
1426
|
+
*/
|
1427
|
+
int camHistogram2Channels(CamImage *image, int ch1, int ch2, CamImage *result, int size);
|
1428
|
+
|
1429
|
+
/// Compute the threshold for a given percentage of pixels
|
1430
|
+
int camFindThreshold(CamTable *histo, int percent);
|
1431
|
+
//@}
|
1432
|
+
|
1433
|
+
/* Horizontal and vertical summing
|
1434
|
+
*/
|
1435
|
+
|
1436
|
+
/// Horizontal and vertical summing function
|
1437
|
+
/** Very useful to detect features in images, generally after applying
|
1438
|
+
* a filter like sobel or morphological gradient.
|
1439
|
+
*
|
1440
|
+
* \param image The ::CamImage to process (or its ROI)
|
1441
|
+
* \param hsum The ::CamTable array of integers containing the horizontal sum.
|
1442
|
+
* \param vsum The ::CamTable array of integers containing the vertical sum.
|
1443
|
+
* \return 0 (false) if an error occurs.
|
1444
|
+
*/
|
1445
|
+
int camSumHV(CamImage *image, CamTable *hsum, CamTable *vsum);
|
1446
|
+
|
1447
|
+
/// Vertical summing function
|
1448
|
+
/** Very useful to detect features in images, generally after applying
|
1449
|
+
* a filter like sobel or morphological gradient.
|
1450
|
+
*
|
1451
|
+
* \param image The ::CamImage to process (or its ROI)
|
1452
|
+
* \param results The ::CamTable array of integers filled with results.
|
1453
|
+
* \return 0 (false) if an error occurs.
|
1454
|
+
*/
|
1455
|
+
int camSumV(CamImage *image, CamTable *results);
|
1456
|
+
|
1457
|
+
/// Horizontal summing function
|
1458
|
+
/** Very useful to detect features in images, generally after applying
|
1459
|
+
* a filter like sobel or morphological gradient.
|
1460
|
+
*
|
1461
|
+
* \param image The ::CamImage to process (or its ROI)
|
1462
|
+
* \param results The ::CamTable array of integers filled with results.
|
1463
|
+
* \return 0 (false) if an error occurs.
|
1464
|
+
*/
|
1465
|
+
int camSumH(CamImage *image, CamTable *results);
|
1466
|
+
|
1467
|
+
#endif // SWIG
|
1468
|
+
|
1469
|
+
/* Measures in an image : min, max, average computation
|
1470
|
+
*/
|
1471
|
+
#ifdef __cplusplus
|
1472
|
+
/// The structure containing the result of measuring
|
1473
|
+
struct CamMeasuresResults {
|
1474
|
+
#else
|
1475
|
+
/// The structure containing the result of measuring
|
1476
|
+
typedef struct {
|
1477
|
+
#endif
|
1478
|
+
int min, xmin, ymin; ///< Minimum pixel value
|
1479
|
+
int max, xmax, ymax; ///< Maximum pixel value
|
1480
|
+
int average; ///< Average pixel value
|
1481
|
+
int sum; ///< Sum of all the pixels
|
1482
|
+
#ifdef __cplusplus
|
1483
|
+
CamMeasuresResults() {min=0;xmin=0;ymin=0;max=0;xmax=0;ymax=0;average=0;sum=0;}
|
1484
|
+
};
|
1485
|
+
#else
|
1486
|
+
} CamMeasuresResults;
|
1487
|
+
#endif
|
1488
|
+
|
1489
|
+
#ifndef SWIG
|
1490
|
+
|
1491
|
+
/// Sum of pixels in an image
|
1492
|
+
int camSumOfPixels(CamImage *image);
|
1493
|
+
|
1494
|
+
/// Measures in an image : min, max, average and sum
|
1495
|
+
/** Average deviation is not measured. See camMeasureAverageDeviation().
|
1496
|
+
*
|
1497
|
+
* \param image The ::CamImage to process (or its ROI)
|
1498
|
+
* \param results The ::CamMeasuresResults structure to be filled.
|
1499
|
+
* \return 0 (false) if an error occurs.
|
1500
|
+
*/
|
1501
|
+
int camMeasures(CamImage *image, CamMeasuresResults *results);
|
1502
|
+
|
1503
|
+
/// Average deviation computation
|
1504
|
+
/** This makes the second scan required for average deviation estimation.
|
1505
|
+
* Uses the average field in ::CamMeasuresResults structure, so camMeasures()
|
1506
|
+
* must have been called prior to this function (to do the 1st scan).
|
1507
|
+
*
|
1508
|
+
* \param image The ::CamImage to process (or its ROI)
|
1509
|
+
* \param average A former measure of average. If 0 or a negative number is provided, the average will be computed
|
1510
|
+
* \return 0 (false) if an error occurs.
|
1511
|
+
*/
|
1512
|
+
float camMeasureAverageDeviation(CamImage *image, int average);
|
1513
|
+
|
1514
|
+
/** @name Warping functions
|
1515
|
+
*/
|
1516
|
+
//@{
|
1517
|
+
|
1518
|
+
/// Warping using Volberg's algorithm
|
1519
|
+
/** This is a forward separable mapping algorithm, i.e. the user
|
1520
|
+
* must provide two functions that compute the destination points
|
1521
|
+
* of any source point.
|
1522
|
+
*
|
1523
|
+
* This function is the core function, making a single scanline mapping.
|
1524
|
+
* It must be called twice to have a full mapping. Use camVolbergFwd()
|
1525
|
+
* to do this.
|
1526
|
+
*/
|
1527
|
+
#ifdef CAM_VOLBERG_ORIGINAL
|
1528
|
+
void volbergfvd(double f[], int in[] , int out[] , int inlen, int outlen);
|
1529
|
+
#else
|
1530
|
+
void camVolbergFwdScanline(CAM_PIXEL *in, int inlen, CAM_PIXEL *out, int outlen, double f[]);
|
1531
|
+
#endif
|
1532
|
+
|
1533
|
+
/// The structure to provide to the Volberg's algorithm : two functions
|
1534
|
+
typedef struct {
|
1535
|
+
void (*hfwd)(int x, int y, double *xp); ///< First scan, horizontal resampling
|
1536
|
+
void (*vfwd)(int x, int y, double *yp); ///< Second scan, vertical resampling
|
1537
|
+
} CamVolbergFwdParams;
|
1538
|
+
|
1539
|
+
/// Helper function for using Volberg's warping algorithm
|
1540
|
+
/**
|
1541
|
+
* \param source The ::CamImage to warp
|
1542
|
+
* \param dest The warped image
|
1543
|
+
* \param params The ::camVolbergFwdParams structure providing the mapping functions
|
1544
|
+
*/
|
1545
|
+
void camVolbergFwd(CamImage *source, CamImage *dest, CamVolbergFwdParams *params);
|
1546
|
+
|
1547
|
+
/* Backward warping
|
1548
|
+
*/
|
1549
|
+
|
1550
|
+
#endif // SWIG
|
1551
|
+
|
1552
|
+
#define CAM_NN_INTERPOLATION 0
|
1553
|
+
#define CAM_BILINEAR_INTERPOLATION 1
|
1554
|
+
|
1555
|
+
#ifndef SWIG
|
1556
|
+
|
1557
|
+
/// The parameters structure used by camWarping()
|
1558
|
+
typedef struct {
|
1559
|
+
int interpolation; ///< Interpolation method (either <DFN>CAM_NN_INTERPOLATION</DFN> or <DFN>CAM_BILINEAR_INTERPOLATION</DFN>.
|
1560
|
+
int perspective; ///< 2D (0) or 3D (parallel to the ground)
|
1561
|
+
|
1562
|
+
/// The points in the source image.
|
1563
|
+
/** Beware : These are 16-bits fixed-points (1 is (1<<16)).
|
1564
|
+
*
|
1565
|
+
* Indexes :
|
1566
|
+
* - 0 : top-left source point
|
1567
|
+
* - 1 : top-right source point
|
1568
|
+
* - 2 : bottom-right source point
|
1569
|
+
* - 3 : bottom-left source point
|
1570
|
+
*/
|
1571
|
+
CamPoint p[4];
|
1572
|
+
} CamWarpingParams;
|
1573
|
+
|
1574
|
+
/// Backward warping function
|
1575
|
+
/** This function operates a backward mapping from the source image to a destination image.
|
1576
|
+
* All the params refer to locations in the source image, whereas the ROI scanned
|
1577
|
+
* by this warping function is set by the <DFN>roi</DFN> member of the dest image
|
1578
|
+
*
|
1579
|
+
* \param source The ::CamImage to warp
|
1580
|
+
* \param dest The warped image
|
1581
|
+
* \param params The ::CamWarpingParams structure providing the ROI in the source image (not rectangular)
|
1582
|
+
*
|
1583
|
+
*/
|
1584
|
+
int camWarping(CamImage *source, CamImage *dest, CamWarpingParams *params);
|
1585
|
+
|
1586
|
+
/// Scaling function
|
1587
|
+
/** This function operates a scaling from the source image to the destination image.
|
1588
|
+
* It can upscale or downscale pictures, and uses bilinear interpolation technique.
|
1589
|
+
*
|
1590
|
+
* \param source The ::CamImage to warp
|
1591
|
+
* \param dest The warped image
|
1592
|
+
*/
|
1593
|
+
int camScale(CamImage *source, CamImage *dest);
|
1594
|
+
|
1595
|
+
int camWarpingSuperSampling(CamImage *source, CamImage *dest, CamWarpingParams *params);
|
1596
|
+
|
1597
|
+
/// Simple helper function, used by camWarping()
|
1598
|
+
/**
|
1599
|
+
* \param p An array defining the segments to intersect (AB and CD). These points
|
1600
|
+
* must be provided in 16-bits fixed-point arithmetic form (1 is (1<<16)).
|
1601
|
+
* \param res The intersection point.
|
1602
|
+
* \return 0 if the segments are parallel. 1 otherwise
|
1603
|
+
*/
|
1604
|
+
int camIntersectionSegments(CamPoint p[4], CamPoint *res);
|
1605
|
+
//@}
|
1606
|
+
|
1607
|
+
/** @name Linear filtering kernel
|
1608
|
+
*/
|
1609
|
+
//@{
|
1610
|
+
|
1611
|
+
// For compatibility with older versions
|
1612
|
+
#define CamSobel3x3 camSobel
|
1613
|
+
#define CamSobelAbs3x3 camSobelAbs
|
1614
|
+
|
1615
|
+
#define CAM_LINEAR_FILTER_KERNEL_MAX_SIZE 7
|
1616
|
+
|
1617
|
+
#endif //SWIG
|
1618
|
+
|
1619
|
+
#ifdef __cplusplus
|
1620
|
+
/// The parameters structure for linear filtering
|
1621
|
+
struct CamLinearFilterKernel {
|
1622
|
+
#else
|
1623
|
+
/// The parameters structure for linear filtering
|
1624
|
+
typedef struct {
|
1625
|
+
#endif
|
1626
|
+
#ifndef SWIG
|
1627
|
+
int kernel[CAM_LINEAR_FILTER_KERNEL_MAX_SIZE][CAM_LINEAR_FILTER_KERNEL_MAX_SIZE]; ///< The NxN coefficients matrix (aka the kernel)
|
1628
|
+
#endif
|
1629
|
+
int coeff1; ///< Multiplicative coefficient
|
1630
|
+
int coeff2; ///< Final value is (result*coeff1)>>coeff2. This is to simulate division.
|
1631
|
+
#ifdef __cplusplus
|
1632
|
+
/// Default constructor
|
1633
|
+
CamLinearFilterKernel() {
|
1634
|
+
for (int i=0;i<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE;i++) {
|
1635
|
+
for (int j=0;j<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE;j++) {
|
1636
|
+
kernel[i][j]=0;
|
1637
|
+
}
|
1638
|
+
}
|
1639
|
+
coeff1=1;
|
1640
|
+
coeff2=0;
|
1641
|
+
}
|
1642
|
+
/// Set an element of the linear filter kernel
|
1643
|
+
bool set(int x, int y, int val) {
|
1644
|
+
if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)&&(y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
|
1645
|
+
kernel[x][y]=val; return true;
|
1646
|
+
} else return false;
|
1647
|
+
}
|
1648
|
+
/// Get an element from the linear filter kernel
|
1649
|
+
int get(int x,int y) {
|
1650
|
+
if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)&&(y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
|
1651
|
+
return kernel[x][y];
|
1652
|
+
} else return 0;
|
1653
|
+
}
|
1654
|
+
};
|
1655
|
+
#else
|
1656
|
+
} CamLinearFilterKernel;
|
1657
|
+
#endif
|
1658
|
+
|
1659
|
+
#ifndef SWIG
|
1660
|
+
|
1661
|
+
/// 3x3 Linear Filtering function
|
1662
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1663
|
+
* \param dest The destination ::CamImage
|
1664
|
+
* \param params A pointer to a ::CamLinearFilterKernel structure, providing
|
1665
|
+
* the linear kernel to use.
|
1666
|
+
* \return Sum (Accumulator) of all computed pixels
|
1667
|
+
*
|
1668
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1669
|
+
*
|
1670
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1671
|
+
* so that results of filtering are unbiased.
|
1672
|
+
*/
|
1673
|
+
int camLinearFilter3x3(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
|
1674
|
+
|
1675
|
+
/// 5x5 Linear Filtering function
|
1676
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1677
|
+
* \param dest The destination ::CamImage
|
1678
|
+
* \param params A pointer to a ::CamLinearFilterKernel structure, providing
|
1679
|
+
* the linear kernel to use.
|
1680
|
+
* \return Sum (Accumulator) of all computed pixels
|
1681
|
+
*
|
1682
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1683
|
+
*
|
1684
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1685
|
+
* so that results of filtering are unbiased.
|
1686
|
+
*/
|
1687
|
+
int camLinearFilter5x5(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
|
1688
|
+
|
1689
|
+
/// 3x3 Linear Filtering function (absolute)
|
1690
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1691
|
+
* \param dest The destination ::CamImage
|
1692
|
+
* \param params A pointer to a ::CamLinearFilterKernel structure, providing
|
1693
|
+
* the linear kernel to use.
|
1694
|
+
* \return Sum (Accumulator) of all computed pixels
|
1695
|
+
*
|
1696
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1697
|
+
*
|
1698
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1699
|
+
* so that results of filtering are unbiased.
|
1700
|
+
*/
|
1701
|
+
int camLinearFilterAbs3x3(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
|
1702
|
+
|
1703
|
+
/// 5x5 Linear Filtering function (absolute)
|
1704
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1705
|
+
* \param dest The destination ::CamImage
|
1706
|
+
* \param params A pointer to a ::CamLinearFilterKernel structure, providing
|
1707
|
+
* the linear kernel to use.
|
1708
|
+
* \return Sum (Accumulator) of all computed pixels
|
1709
|
+
*
|
1710
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1711
|
+
*
|
1712
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1713
|
+
* so that results of filtering are unbiased.
|
1714
|
+
*/
|
1715
|
+
int camLinearFilterAbs5x5(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
|
1716
|
+
|
1717
|
+
/* Obsolete
|
1718
|
+
* int camSobel(CamImage *source, CamImage *dest, int vert_edges);
|
1719
|
+
* int camSobelAbs(CamImage *source, CamImage *dest, int vert_edges);
|
1720
|
+
*/
|
1721
|
+
|
1722
|
+
#endif //SWIG
|
1723
|
+
|
1724
|
+
#ifdef __cplusplus
|
1725
|
+
/// The parameters structure for linear filtering
|
1726
|
+
struct CamSepFilterKernel {
|
1727
|
+
#else
|
1728
|
+
/// The parameters structure for linear filtering
|
1729
|
+
typedef struct {
|
1730
|
+
#endif
|
1731
|
+
#ifndef SWIG
|
1732
|
+
int x[CAM_LINEAR_FILTER_KERNEL_MAX_SIZE]; ///< The horizontal array of coefficients
|
1733
|
+
int y[CAM_LINEAR_FILTER_KERNEL_MAX_SIZE]; ///< The vertical array of coefficients
|
1734
|
+
#endif
|
1735
|
+
int coeff1; ///< Multiplicative coefficient
|
1736
|
+
int coeff2; ///< Final value is (result*coeff1)>>coeff2. This is to simulate division.
|
1737
|
+
#ifdef __cplusplus
|
1738
|
+
/// Default constructor
|
1739
|
+
CamSepFilterKernel() {
|
1740
|
+
for (int i=0;i<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE;i++) {
|
1741
|
+
x[i]=0; y[i]=0;
|
1742
|
+
}
|
1743
|
+
coeff1=1;
|
1744
|
+
coeff2=0;
|
1745
|
+
}
|
1746
|
+
/// Set an element of the linear separable filter kernel
|
1747
|
+
bool set_x(int y, int val) {
|
1748
|
+
if ((y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
|
1749
|
+
x[y]=val; return true;
|
1750
|
+
} else return false;
|
1751
|
+
}
|
1752
|
+
bool set_y(int x, int val) {
|
1753
|
+
if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
|
1754
|
+
y[x]=val; return true;
|
1755
|
+
} else return false;
|
1756
|
+
}
|
1757
|
+
/// Get an element from the linear separable filter kernel
|
1758
|
+
int get_x(int y) {
|
1759
|
+
if ((y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
|
1760
|
+
return x[y];
|
1761
|
+
} else return 0;
|
1762
|
+
}
|
1763
|
+
int get_y(int x) {
|
1764
|
+
if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
|
1765
|
+
return y[x];
|
1766
|
+
} else return 0;
|
1767
|
+
}
|
1768
|
+
};
|
1769
|
+
#else
|
1770
|
+
} CamSepFilterKernel;
|
1771
|
+
#endif
|
1772
|
+
|
1773
|
+
#define CAM_SOBEL_H 1
|
1774
|
+
#define CAM_SOBEL_V 2
|
1775
|
+
#define CAM_GAUSSIAN_3x3 3
|
1776
|
+
#define CAM_GAUSSIAN_5x5 4
|
1777
|
+
#define CAM_GAUSSIAN_7x7 5
|
1778
|
+
#define CAM_SCHARR_H 6
|
1779
|
+
#define CAM_SCHARR_V 7
|
1780
|
+
|
1781
|
+
#ifndef SWIG
|
1782
|
+
|
1783
|
+
/// 3x3 Linear Filtering function with a separable kernel
|
1784
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1785
|
+
* \param dest The destination ::CamImage
|
1786
|
+
* \param kernel A pointer to a ::CamSepFilterKernel structure, specifying the separable linear kernel to use.
|
1787
|
+
* \return Sum (Accumulator) of all computed pixels
|
1788
|
+
*
|
1789
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1790
|
+
*
|
1791
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1792
|
+
* so that results of filtering are unbiased.
|
1793
|
+
*/
|
1794
|
+
int camSepFilter3x3(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
|
1795
|
+
|
1796
|
+
/// 3x3 Linear Filtering function with a separable kernel (absolute value)
|
1797
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1798
|
+
* \param dest The destination ::CamImage
|
1799
|
+
* \param kernel A pointer to a ::CamSepFilterKernel structure, specifying the separable linear kernel to use.
|
1800
|
+
* \return Sum (Accumulator) of all computed pixels
|
1801
|
+
*
|
1802
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1803
|
+
*
|
1804
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1805
|
+
* so that results of filtering are unbiased.
|
1806
|
+
*/
|
1807
|
+
int camSepFilterAbs3x3(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
|
1808
|
+
|
1809
|
+
/// 5x5 Linear Filtering function with a separable kernel
|
1810
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1811
|
+
* \param dest The destination ::CamImage
|
1812
|
+
* \param kernel A pointer to a ::CamSepFilterKernel structure, specifying the separable linear kernel to use.
|
1813
|
+
* \return Sum (Accumulator) of all computed pixels
|
1814
|
+
*
|
1815
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1816
|
+
*
|
1817
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1818
|
+
* so that results of filtering are unbiased.
|
1819
|
+
*/
|
1820
|
+
int camSepFilter5x5(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
|
1821
|
+
|
1822
|
+
/// 5x5 Linear Filtering function with a separable kernel (absolute value)
|
1823
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1824
|
+
* \param dest The destination ::CamImage
|
1825
|
+
* \param kernel A pointer to a ::CamSepFilterKernel structure, specifying the separable linear kernel to use.
|
1826
|
+
* \return Sum (Accumulator) of all computed pixels
|
1827
|
+
*
|
1828
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1829
|
+
*
|
1830
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1831
|
+
* so that results of filtering are unbiased.
|
1832
|
+
*/
|
1833
|
+
int camSepFilterAbs5x5(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
|
1834
|
+
|
1835
|
+
/// 7x7 Linear Filtering function with a separable kernel
|
1836
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1837
|
+
* \param dest The destination ::CamImage
|
1838
|
+
* \param kernel A pointer to a ::CamSepFilterKernel structure, specifying the separable linear kernel to use.
|
1839
|
+
* \return Sum (Accumulator) of all computed pixels
|
1840
|
+
*
|
1841
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1842
|
+
*
|
1843
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1844
|
+
* so that results of filtering are unbiased.
|
1845
|
+
*/
|
1846
|
+
int camSepFilter7x7(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
|
1847
|
+
|
1848
|
+
/// 7x7 Linear Filtering function with a separable kernel (absolute value)
|
1849
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1850
|
+
* \param dest The destination ::CamImage
|
1851
|
+
* \param kernel A pointer to a ::CamSepFilterKernel structure, specifying the separable linear kernel to use.
|
1852
|
+
* \return Sum (Accumulator) of all computed pixels
|
1853
|
+
*
|
1854
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1855
|
+
*
|
1856
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1857
|
+
* so that results of filtering are unbiased.
|
1858
|
+
*/
|
1859
|
+
int camSepFilterAbs7x7(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
|
1860
|
+
|
1861
|
+
/// 3x3 Horizontal Sobel Filter. Detects horizontal edges.
|
1862
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1863
|
+
* \param dest The destination ::CamImage
|
1864
|
+
* \return 1 if the function succeeds. 0 otherwise.
|
1865
|
+
*
|
1866
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1867
|
+
*
|
1868
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1869
|
+
* so that results of filtering are unbiased.
|
1870
|
+
*/
|
1871
|
+
int camSobelH(CamImage *source, CamImage *dest);
|
1872
|
+
|
1873
|
+
/// 3x3 Horizontal Sobel Filter (absolute). Detects horizontal edges.
|
1874
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1875
|
+
* \param dest The destination ::CamImage
|
1876
|
+
* \return 1 if the function succeeds. 0 otherwise.
|
1877
|
+
*
|
1878
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1879
|
+
*
|
1880
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1881
|
+
* so that results of filtering are unbiased.
|
1882
|
+
*/
|
1883
|
+
int camSobelHAbs(CamImage *source, CamImage *dest);
|
1884
|
+
|
1885
|
+
/// 3x3 Vertical Sobel Filter. Detects Vertical edges.
|
1886
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1887
|
+
* \param dest The destination ::CamImage
|
1888
|
+
* \return 1 if the function succeeds. 0 otherwise.
|
1889
|
+
*
|
1890
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1891
|
+
*
|
1892
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1893
|
+
* so that results of filtering are unbiased.
|
1894
|
+
*/
|
1895
|
+
int camSobelV(CamImage *source, CamImage *dest);
|
1896
|
+
|
1897
|
+
/// 3x3 Vertical Sobel Filter (absolute). Detects Vertical edges.
|
1898
|
+
/** \param source The source ::CamImage to process. Grey scale only.
|
1899
|
+
* \param dest The destination ::CamImage
|
1900
|
+
* \return 1 if the function succeeds. 0 otherwise.
|
1901
|
+
*
|
1902
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1903
|
+
*
|
1904
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1905
|
+
* so that results of filtering are unbiased.
|
1906
|
+
*/
|
1907
|
+
int camSobelVAbs(CamImage *source, CamImage *dest);
|
1908
|
+
|
1909
|
+
/// Linear convolution with a predefined kernel
|
1910
|
+
/** The function camFixedFilter() is used to convolve the input image with a predefined filter kernel
|
1911
|
+
* specified in argument.
|
1912
|
+
*
|
1913
|
+
* \param source The source ::CamImage to process. Grey scale only.
|
1914
|
+
* \param dest The destination ::CamImage
|
1915
|
+
* \param filter Constant defining the kernel to be used. The filter kernel can be one of the following :
|
1916
|
+
* - <DFN>CAM_SOBEL_H</DFN> performs a horizontal edges detection (3x3 sobel)
|
1917
|
+
* - <DFN>CAM_SOBEL_V</DFN> performs a vertical edges detection (3x3 sobel)
|
1918
|
+
* - <DFN>CAM_GAUSSIAN_3x3</DFN> performs a gaussian filtering
|
1919
|
+
* - <DFN>CAM_GAUSSIAN_5x5</DFN> performs a gaussian filtering
|
1920
|
+
* - <DFN>CAM_GAUSSIAN_7x7</DFN> performs a gaussian filtering
|
1921
|
+
* - <DFN>CAM_SCHARR_H</DFN> performs a horizontal edges detection (3x3 scharr filter. Better preserves gradient direction)
|
1922
|
+
* - <DFN>CAM_SCHARR_V</DFN> performs a vertical edges detection (3x3 scharr filter. Better preserves gradient direction)
|
1923
|
+
*
|
1924
|
+
* \return 1 if the function succeeds. 0 otherwise.
|
1925
|
+
*
|
1926
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1927
|
+
*
|
1928
|
+
* Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
|
1929
|
+
* so that results of filtering are unbiased.
|
1930
|
+
*/
|
1931
|
+
int camFixedFilter(CamImage *source, CamImage *dest, int filter);
|
1932
|
+
|
1933
|
+
int camScharrH(CamImage *source, CamImage *dest);
|
1934
|
+
int camScharrV(CamImage *source, CamImage *dest);
|
1935
|
+
int camScharrHAbs(CamImage *source, CamImage *dest);
|
1936
|
+
int camScharrVAbs(CamImage *source, CamImage *dest);
|
1937
|
+
|
1938
|
+
//@}
|
1939
|
+
|
1940
|
+
/** @name Median filtering kernel
|
1941
|
+
*/
|
1942
|
+
//@{
|
1943
|
+
|
1944
|
+
#define camMedianFiltering3x3 camMedianFilter3x3
|
1945
|
+
#define camMedianFiltering5x5 camMedianFilter5x5
|
1946
|
+
|
1947
|
+
/// 3x3 Median Filtering function
|
1948
|
+
/** For each 3x3 set of pixels, keep the median value. Considered as being a
|
1949
|
+
* good filter, less sensitive to noise.than linear filtering.
|
1950
|
+
*
|
1951
|
+
* \param source The source ::CamImage to process. Grey scale only.
|
1952
|
+
* \param dest The destination ::CamImage
|
1953
|
+
* \return 0 (false) if an error occurs
|
1954
|
+
*
|
1955
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1956
|
+
*/
|
1957
|
+
int camMedianFilter3x3(CamImage *source, CamImage *dest);
|
1958
|
+
|
1959
|
+
/// 5x5 Median Filtering function
|
1960
|
+
/** For each 5x5 set of pixels, keep the median value. Considered as being a
|
1961
|
+
* good filter, less sensitive to noise.than linear filtering.
|
1962
|
+
*
|
1963
|
+
* \param source The source ::CamImage to process. Grey scale only.
|
1964
|
+
* \param dest The destination ::CamImage
|
1965
|
+
* \return 0 (false) if an error occurs
|
1966
|
+
*
|
1967
|
+
* Note that this function supports in-place processing (i.e. dest can be the same as source param)
|
1968
|
+
*/
|
1969
|
+
int camMedianFilter5x5(CamImage *source, CamImage *dest);
|
1970
|
+
//@}
|
1971
|
+
|
1972
|
+
/** @name Watersheding kernel
|
1973
|
+
*/
|
1974
|
+
//@{
|
1975
|
+
|
1976
|
+
/// 1D watershed computation
|
1977
|
+
/** Retrieves all the watershed points, along with their depth (i.e. the minimum depth of
|
1978
|
+
* the 2 catchment bassins contributing to the watershed point).
|
1979
|
+
*
|
1980
|
+
* 1D watersheding operation is a very smart way to analyze the results of an histogram
|
1981
|
+
* (generally before thresholding), yielding better results than a simple n% threshold.
|
1982
|
+
*
|
1983
|
+
* \param input The 1D integer data for which to compute the watershed
|
1984
|
+
* \param size The size of the 1D integer array (<DFN>t</DFN>). Generally 256 when <DFN>t</DFN> is the
|
1985
|
+
* results of an histogramming operation.
|
1986
|
+
* \param results The 1D integer array contaning the results of the watershed computation.
|
1987
|
+
* A value different from 0 indicates a watershed point, the value indicating the depth
|
1988
|
+
* (and thus the importance) associated to this watershed point.
|
1989
|
+
* The memory for this array is not allocated by this function, and thus an array
|
1990
|
+
* of appropriate size must be allocated before calling this function.
|
1991
|
+
*
|
1992
|
+
* \return 0 (false) if an error occurs
|
1993
|
+
*/
|
1994
|
+
int camWatershed1D(int *input, int size, int *results);
|
1995
|
+
#else
|
1996
|
+
%immutable;
|
1997
|
+
#endif // SWIG
|
1998
|
+
|
1999
|
+
/// The structure defining a basin
|
2000
|
+
typedef struct
|
2001
|
+
{
|
2002
|
+
int dynamics; ///< Its dynamics (importance)
|
2003
|
+
int minimum; ///< Minimum of the basin
|
2004
|
+
int flooded; ///< The catchment basin which has flooded it
|
2005
|
+
int surface; ///< Surface of the region
|
2006
|
+
int accsurface; ///< Accumulated surface of all children
|
2007
|
+
unsigned short x,y; ///< Position of the minimum
|
2008
|
+
} CamBasin;
|
2009
|
+
|
2010
|
+
#define CAM_NOT_COMPUTED 65536
|
2011
|
+
|
2012
|
+
#ifndef SWIG
|
2013
|
+
#ifdef __cplusplus
|
2014
|
+
/// The table of basins structure. Simply a dynamic size array of <DFN>CamBasin</DFN>.
|
2015
|
+
struct CamTableOfBasins {
|
2016
|
+
int sizeMax;
|
2017
|
+
int nbBasins;
|
2018
|
+
CamBasin *tab;
|
2019
|
+
CamBasin& operator[](int index) {return tab[index];}
|
2020
|
+
void get_rid_of(CamBasin &basin) {basin.surface=0;}
|
2021
|
+
CamTableOfBasins() {tab=NULL;sizeMax=0;nbBasins=0;}
|
2022
|
+
~CamTableOfBasins();
|
2023
|
+
};
|
2024
|
+
#else
|
2025
|
+
typedef struct
|
2026
|
+
{
|
2027
|
+
int sizeMax;
|
2028
|
+
int nbBasins;
|
2029
|
+
CamBasin *tab;
|
2030
|
+
} CamTableOfBasins;
|
2031
|
+
#endif
|
2032
|
+
|
2033
|
+
/// Free a table of basins after use.
|
2034
|
+
void camFreeTableOfBasins(CamTableOfBasins *t);
|
2035
|
+
|
2036
|
+
/// 2D Hierarchical watershed computation
|
2037
|
+
/** Retrieves all the basins (regional segmentation)
|
2038
|
+
*
|
2039
|
+
* Watersheding computes a hierarchichal segmentation of an image.
|
2040
|
+
* Watersheding operation is a very smart way to analyze the results of a gradient image.
|
2041
|
+
*
|
2042
|
+
* \param source The ::CamImage for which to compute the watershed
|
2043
|
+
* \param dest A 16-bits deep ::CamImage where the results of the watersheding operation are stored.
|
2044
|
+
* The index of the basin is given by the pixel value minus 1 (so starting at 1).
|
2045
|
+
* Border pixels are set to -32768.
|
2046
|
+
* <DFN>dest</DFN> must be allocated by the caller, and must have the same size as
|
2047
|
+
* the <DFN>source</DFN> image. It must also be a signed 16 bits deep image (<dfn>CAM_DEPTH_16S</dfn>).
|
2048
|
+
* \param tob The table of basins, containing their dynamics, their surface and their minimum value.
|
2049
|
+
* This table is allocated by the function.
|
2050
|
+
*
|
2051
|
+
* \return 0 (false) if an error occurs
|
2052
|
+
*/
|
2053
|
+
int camHierarchicalWatershed(CamImage *source, CamImage *dest, CamTableOfBasins *tob);
|
2054
|
+
|
2055
|
+
/// 2D Hierarchical watershed computation (with watershed/contours markers)
|
2056
|
+
/** Retrieves all the watershed points, along with all the basins (regional segmentation)
|
2057
|
+
*
|
2058
|
+
* Watersheding computes a hierarchichal segmentation of an image.
|
2059
|
+
* Watersheding operation is a very smart way to analyze the results of a gradient image.
|
2060
|
+
*
|
2061
|
+
* \param source The ::CamImage for which to compute the watershed
|
2062
|
+
* \param dest A 16-bits deep ::CamImage where the results of the watersheding operation are stored.
|
2063
|
+
* A negative pixel value indicates a watershed point.
|
2064
|
+
* A positive indicates that this pixel belongs to a basin.
|
2065
|
+
* The index of the basin is given by the pixel value minus 1. Border pixels are set to -32768.
|
2066
|
+
* <DFN>dest</DFN> must be allocated by the caller, and must have the same size as
|
2067
|
+
* the <DFN>source</DFN> image. It must also be a signed 16 bits deep image (<dfn>CAM_DEPTH_16S</dfn>).
|
2068
|
+
* \param tob The table of basins, containing their dynamics, their surface and their minimum value.
|
2069
|
+
* This table is allocated by the function.
|
2070
|
+
*
|
2071
|
+
* \return 0 (false) if an error occurs
|
2072
|
+
*/
|
2073
|
+
int camHierarchicalWatershedContours(CamImage *source, CamImage *dest, CamTableOfBasins *tob);
|
2074
|
+
|
2075
|
+
/// Retrieves regions from a watershed image
|
2076
|
+
/** Retrieves all the regions of basins with surface different from 0. The user can set the surface of a basin in
|
2077
|
+
* the table of basins to deselect it. Thus, the user can remove from the watershed image all the basins with
|
2078
|
+
* low dynamics, and the pixels of this basin will be affected to a flooding basin.
|
2079
|
+
*
|
2080
|
+
* \return 0 (false) if an error occurs
|
2081
|
+
*/
|
2082
|
+
int camHierarchicalWatershedRegions(CamImage *watershed, CamTableOfBasins *tob);
|
2083
|
+
//@}
|
2084
|
+
|
2085
|
+
/** @name Hough functions
|
2086
|
+
*/
|
2087
|
+
//@{
|
2088
|
+
|
2089
|
+
/// Circle Hough. Find a circle in a picture.
|
2090
|
+
/** Find a circle in the input picture. Returns the circle with the bigger hough accumulation.
|
2091
|
+
*
|
2092
|
+
* \param image The ::CamImage to process
|
2093
|
+
* \param percent The percentage of pixels to consider (from the gradient image). Directly proportionnal to the speed of exection. Typically 10.
|
2094
|
+
* \param rmin The minimum radius to look for
|
2095
|
+
* \param rmax The maximum radius to look for. This determines the size of the (x,y,r) Hough cube
|
2096
|
+
* \param xc A pointer to the circle center (return value)
|
2097
|
+
* \param yc A pointer to the circle center (return value)
|
2098
|
+
* \param rc A pointer to the circle radius (return value)
|
2099
|
+
*
|
2100
|
+
* \return The confidence in the circle found (hough accumulator)
|
2101
|
+
*/
|
2102
|
+
int camHoughCircle(CamImage *image, int percent, int rmin, int rmax, int *xc, int *yc, int *rc);
|
2103
|
+
|
2104
|
+
struct _CamKeypoints;
|
2105
|
+
|
2106
|
+
#endif // SWIG
|
2107
|
+
|
2108
|
+
/** @name Keypoints and Local descriptors
|
2109
|
+
*/
|
2110
|
+
//@{
|
2111
|
+
|
2112
|
+
#ifdef __cplusplus
|
2113
|
+
#ifdef SWIG
|
2114
|
+
%mutable;
|
2115
|
+
#endif
|
2116
|
+
|
2117
|
+
/// The Keypoint structure
|
2118
|
+
struct CamKeypoint {
|
2119
|
+
#else
|
2120
|
+
typedef struct {
|
2121
|
+
#endif // __cplusplus
|
2122
|
+
int descriptor[128]; ///< The descriptor table itself
|
2123
|
+
int x; ///< x coordinate of keypoints in image
|
2124
|
+
int y; ///< y coordinate of keypoints in image
|
2125
|
+
int scale; ///< Scale in pixels
|
2126
|
+
int angle; ///< Angle in degrees
|
2127
|
+
int value; ///< Hessian value
|
2128
|
+
#ifdef SWIG
|
2129
|
+
%immutable;
|
2130
|
+
#endif
|
2131
|
+
int size; ///< Size of descriptor
|
2132
|
+
void *internal; ///< Internal use only
|
2133
|
+
#ifdef __cplusplus
|
2134
|
+
CamKeypoints *set;
|
2135
|
+
bool draw(CamImage &image, int color = 255) const; ///< C++ wrapping for camDrawKeypoint function
|
2136
|
+
bool set_descriptor(const int* const array, int sz); ///< Set the descriptor
|
2137
|
+
CamKeypoint() { x = 0; y = 0; scale = 0; angle = 0; value = 0; size = 0; internal = NULL; set = NULL; }
|
2138
|
+
};
|
2139
|
+
#else
|
2140
|
+
struct _CamKeypoints *set;
|
2141
|
+
} CamKeypoint;
|
2142
|
+
#endif
|
2143
|
+
|
2144
|
+
typedef struct {
|
2145
|
+
CamKeypoint *p1;
|
2146
|
+
CamKeypoint *p2;
|
2147
|
+
int mark;
|
2148
|
+
int error;
|
2149
|
+
} CamKeypointsMatch;
|
2150
|
+
|
2151
|
+
#define CAM_MAX_NB_MATCHES 2048
|
2152
|
+
|
2153
|
+
#ifdef __cplusplus
|
2154
|
+
/// Affine Transform parameters
|
2155
|
+
struct CamAffineTransform {
|
2156
|
+
double m[6];
|
2157
|
+
};
|
2158
|
+
|
2159
|
+
/// A match between 2 CamKeypoints
|
2160
|
+
struct CamKeypointsMatches {
|
2161
|
+
#else
|
2162
|
+
|
2163
|
+
typedef struct {
|
2164
|
+
double m[6];
|
2165
|
+
} CamAffineTransform;
|
2166
|
+
|
2167
|
+
typedef struct {
|
2168
|
+
#endif //__cplusplus
|
2169
|
+
int nbMatches;
|
2170
|
+
int nbOutliers;
|
2171
|
+
int allocated;
|
2172
|
+
CamKeypointsMatch *pairs;
|
2173
|
+
#ifdef __cplusplus
|
2174
|
+
CamKeypointsMatches(int size = CAM_MAX_NB_MATCHES); ///< Default constructor
|
2175
|
+
~CamKeypointsMatches(); ///< Default destructor
|
2176
|
+
CamAffineTransform find_affine_transform(int *error) const; ///< C++ wrapping for camFindAffindTransform function
|
2177
|
+
CamAffineTransform find_affine_transform2(int *error) const; ///< C++ wrapping for camFindAffindTransform function
|
2178
|
+
};
|
2179
|
+
#else
|
2180
|
+
} CamKeypointsMatches;
|
2181
|
+
#endif
|
2182
|
+
|
2183
|
+
#ifdef __cplusplus
|
2184
|
+
struct CamKeypointsKdTree;
|
2185
|
+
|
2186
|
+
#ifdef SWIG
|
2187
|
+
%mutable;
|
2188
|
+
#endif
|
2189
|
+
/// The CamKeypoints structure
|
2190
|
+
struct CamKeypoints {
|
2191
|
+
#else
|
2192
|
+
/// The CamKeypoints structure
|
2193
|
+
typedef struct _CamKeypoints {
|
2194
|
+
#endif
|
2195
|
+
int width, height; ///< Original size of object (or picture of object)
|
2196
|
+
int cx, cy; ///< Reference coordinate of object (center)
|
2197
|
+
int id; ///< Id of reference object
|
2198
|
+
#ifdef SWIG
|
2199
|
+
%immutable;
|
2200
|
+
#endif
|
2201
|
+
int allocated;
|
2202
|
+
int nbPoints; ///< Number of valid points
|
2203
|
+
CamKeypoint **keypoint; ///< Array of keypoints
|
2204
|
+
CamKeypoint *bag; ///< Bag of keypoints
|
2205
|
+
#ifdef __cplusplus
|
2206
|
+
CamKeypoints() {allocated = 0; nbPoints = 0; keypoint = NULL; bag = NULL; cx = 0; cy = 0;} ///< Default constructor
|
2207
|
+
CamKeypoints(int nbPoints); ///< Constructor with max number of points
|
2208
|
+
#ifndef SWIG
|
2209
|
+
CamKeypoint& operator[](int index);
|
2210
|
+
#endif
|
2211
|
+
~CamKeypoints(); ///< Default destructor
|
2212
|
+
|
2213
|
+
bool add(CamKeypoint &p);
|
2214
|
+
CamKeypoints& operator<<(CamKeypoint &p) { add(p); return *this; }
|
2215
|
+
bool draw(CamImage &image, int color = 255) const; ///< C++ wrapping for camDrawKeypoints function
|
2216
|
+
int matching(const CamKeypoints **models, int nbModels, CamKeypointsMatches &matches) const; ///< C++ wrapping for camKeypointsMatching() function
|
2217
|
+
int matching2(const CamKeypoints &points, CamKeypointsMatches &matches) const; ///< C++ wrapping for camKeypointsMatching2() function
|
2218
|
+
int matchingKdTree(const CamKeypointsKdTree &kdTree, CamKeypointsMatches &matches, int explore = 100) const; ///< C++ wrapping for camKeypointsMatchingKdTree() function
|
2219
|
+
|
2220
|
+
bool alloc(int nbPoints); ///< Allocator (C++ wrapping of camKeypointsAllocate() function)
|
2221
|
+
bool realloc(int nbPoints); ///< Reallocator (C++ wrapping of camKeypointsReallocate() function)
|
2222
|
+
};
|
2223
|
+
#else
|
2224
|
+
} CamKeypoints;
|
2225
|
+
#endif
|
2226
|
+
|
2227
|
+
#define CAM_UPRIGHT 1
|
2228
|
+
|
2229
|
+
int camKeypointsSetParameters(int patchSize, int sigma, int threshGradient);
|
2230
|
+
|
2231
|
+
#ifndef SWIG
|
2232
|
+
|
2233
|
+
/// Keypoints allocation
|
2234
|
+
int camAllocateKeypoints(CamKeypoints *fpoints, int nbPoints);
|
2235
|
+
|
2236
|
+
/// Keypoints reallocation
|
2237
|
+
int camReallocateKeypoints(CamKeypoints *fpoints, int nbPoints);
|
2238
|
+
|
2239
|
+
/// Keypoints release
|
2240
|
+
int camFreeKeypoints(CamKeypoints *fpoints);
|
2241
|
+
|
2242
|
+
/// Draw kepoints on screen
|
2243
|
+
int camDrawKeypoints(CamKeypoints *points, CamImage *dest, int color);
|
2244
|
+
|
2245
|
+
/// Draw one keypoint on screen
|
2246
|
+
int camDrawKeypoint(CamKeypoint *point, CamImage *dest, int color);
|
2247
|
+
|
2248
|
+
/// Harris corner detector.
|
2249
|
+
/** \param k Harris' corner detection parameter (default value is 41, matching k=0.04 in Harris' article)
|
2250
|
+
*/
|
2251
|
+
int camHarris(CamImage *source, CamKeypoints *points, int k);
|
2252
|
+
|
2253
|
+
/// Local maxima finder (Circle7 neighborhood)
|
2254
|
+
int camFindLocalMaximaCircle7(CamImage *source, CamKeypoints *points, int threshold);
|
2255
|
+
|
2256
|
+
/// Local maxima finder (Circle5 neighborhood)
|
2257
|
+
int camFindLocalMaximaCircle5(CamImage *source, CamKeypoints *points, int threshold);
|
2258
|
+
|
2259
|
+
/// Local maxima finder (Square3 neighborhood)
|
2260
|
+
int camFindLocalMaximaCircle3(CamImage *source, CamKeypoints *points, int threshold);
|
2261
|
+
|
2262
|
+
/// Integral image computation
|
2263
|
+
int camIntegralImage(CamImage *src, CamImage *dest);
|
2264
|
+
|
2265
|
+
/// Fast Hessian Detection (for one scale only)
|
2266
|
+
int camFastHessianDetectorFixedScale(CamImage *integral, CamImage *dest, int scale);
|
2267
|
+
|
2268
|
+
/// Fast Hessian Detection (for all scales)
|
2269
|
+
int camFastHessianDetector(CamImage *source, CamKeypoints *points, int threshold, int options);
|
2270
|
+
|
2271
|
+
/// Find a keypoint in a set of keypoints
|
2272
|
+
CamKeypoint* camFindKeypoint(CamKeypoint *point, CamKeypoints *points, int *dist1, int *dist2);
|
2273
|
+
|
2274
|
+
/// Allocate keypoints matches
|
2275
|
+
int camAllocateKeypointsMatches(CamKeypointsMatches *matches, int nbpairs);
|
2276
|
+
|
2277
|
+
/// Free keypoints matches
|
2278
|
+
void camFreeKeypointsMatches(CamKeypointsMatches *matches);
|
2279
|
+
|
2280
|
+
/// Find an object in a database (brute force matching)
|
2281
|
+
int camKeypointsMatching(CamKeypoints *target, CamKeypoints **models, int nbModels, CamKeypointsMatches *matches);
|
2282
|
+
int camKeypointsMatching2(CamKeypoints *points1, CamKeypoints *points2, CamKeypointsMatches *matches);
|
2283
|
+
|
2284
|
+
/// Find the affine transform from one object to the next
|
2285
|
+
int camFindAffineTransform(CamKeypointsMatches *matches, CamAffineTransform *t, int *error);
|
2286
|
+
int camFindAffineTransform2(CamKeypointsMatches *matches, CamAffineTransform *t, int *error);
|
2287
|
+
|
2288
|
+
/// Apply an affine transform on a point (xy) to find the target point (uv)
|
2289
|
+
void camApplyAffineTransform(CamPoint *xy, CamPoint *uv, CamAffineTransform *t);
|
2290
|
+
|
2291
|
+
typedef struct _CamFPKdTreeNode {
|
2292
|
+
int i;
|
2293
|
+
int m;
|
2294
|
+
struct _CamFPKdTreeNode *right;
|
2295
|
+
} CamFPKdTreeNode;
|
2296
|
+
|
2297
|
+
int camKeypointsMatchingKdTree(CamKeypoints *target, CamFPKdTreeNode *kdTreeRoot, CamKeypointsMatches *matches, int explore);
|
2298
|
+
|
2299
|
+
CamFPKdTreeNode *camKeypointsCompileKdTree(CamKeypoints **models, int nbModels);
|
2300
|
+
|
2301
|
+
CamKeypoint *camFindKeypointKdTree(CamKeypoint *point, CamFPKdTreeNode *kdTreeRoot, int explore, int *dist1, int *dist2);
|
2302
|
+
|
2303
|
+
#endif // SWIG
|
2304
|
+
|
2305
|
+
#ifdef __cplusplus
|
2306
|
+
/// The CamKeypointsKdTree class
|
2307
|
+
struct CamKeypointsKdTree {
|
2308
|
+
CamFPKdTreeNode *root;
|
2309
|
+
|
2310
|
+
void compile(const CamKeypoints **models, int nbModels) {root = camKeypointsCompileKdTree((CamKeypoints**)models, nbModels);}
|
2311
|
+
CamKeypoint *find(const CamKeypoint *point, int explore = 100, int *dist1 = NULL, int *dist2 = NULL) const; // C++ Wrapper for camFindKeypointKdTree function
|
2312
|
+
|
2313
|
+
CamKeypointsKdTree(const CamKeypoints **models = NULL, int nbModels = 0) { if (nbModels != 0) compile(models, nbModels); else root = NULL;};
|
2314
|
+
~CamKeypointsKdTree() {if (root) free(root);} ///< Default destructor
|
2315
|
+
};
|
2316
|
+
#endif // __cplusplus
|
2317
|
+
|
2318
|
+
//@}
|
2319
|
+
|
2320
|
+
/** @name Utility functions
|
2321
|
+
*/
|
2322
|
+
//@{
|
2323
|
+
|
2324
|
+
/* Image allocation utility routines
|
2325
|
+
*/
|
2326
|
+
|
2327
|
+
#ifndef SWIG
|
2328
|
+
|
2329
|
+
/// Grey scale image allocation
|
2330
|
+
int camAllocateImage(CamImage *image, int width, int height, int depth);
|
2331
|
+
/// Any kind of image allocation
|
2332
|
+
int camAllocateImageEx(CamImage *image, int width, int height, int depth, int color_seq);
|
2333
|
+
/// Fill image header (no memory initialization)
|
2334
|
+
int camFillImageHeader(CamImage *image, int width, int height, int depth, int channelseq);
|
2335
|
+
/// YUV image allocation
|
2336
|
+
int camAllocateYUVImage(CamImage *image, int width, int height);
|
2337
|
+
/// HLS image allocation
|
2338
|
+
int camAllocateHLSImage(CamImage *image, int width, int height);
|
2339
|
+
/// RGB image allocation
|
2340
|
+
int camAllocateRGBImage(CamImage *image, int width, int height);
|
2341
|
+
/// RGB image allocation with alpha channel
|
2342
|
+
int camAllocateRGBAImage(CamImage *image, int width, int height);
|
2343
|
+
/// BGR image allocation
|
2344
|
+
int camAllocateBGRImage(CamImage *image, int width, int height);
|
2345
|
+
/// BGR image allocation with alpha channel
|
2346
|
+
int camAllocateBGRAImage(CamImage *image, int width, int height);
|
2347
|
+
/// Image memory release
|
2348
|
+
int camDeallocateImage(CamImage *image);
|
2349
|
+
/// Image memory release
|
2350
|
+
int camFreeImage(CamImage *image);
|
2351
|
+
|
2352
|
+
/* Other useful functions
|
2353
|
+
*/
|
2354
|
+
/// Set the ROI utility function
|
2355
|
+
int camSetROI(CamROI *roi, int coi, int xOffset, int yOffset, int width, int height);
|
2356
|
+
/// Set the ROI to the maximum size of the image
|
2357
|
+
int camSetMaxROI(CamROI *roi, CamImage *image);
|
2358
|
+
/// Reduce the roi by a given number of pixels on each side
|
2359
|
+
int camReduceROI(CamROI *roi, int pixels);
|
2360
|
+
/// Enlarge the roi by a given number of pixels on each side
|
2361
|
+
int camEnlargeROI(CamROI *roi, int pixels);
|
2362
|
+
/// Simple 2x Zoom functin (by pixels replication)
|
2363
|
+
int camZoom2x(CamImage *src, CamImage *dst);
|
2364
|
+
/// Simple nearest-neighbour decimation
|
2365
|
+
int camDecimateNN(CamImage *src, CamImage *dest, int factor);
|
2366
|
+
/// Set the image mask (Run-Length encoded mask)
|
2367
|
+
int camSetRLEMask(CamImage *image, CamRLEImage *mask);
|
2368
|
+
/// Set the image mask (::CamImage mask)
|
2369
|
+
int camSetMask(CamImage *image, CamImage *mask);
|
2370
|
+
|
2371
|
+
#define camDownScaling2x2 camDownscaling2x2
|
2372
|
+
/// 2x2 linear interpolation downscaling
|
2373
|
+
int camDownScaling2x2(CamImage *src, CamImage *dest);
|
2374
|
+
/// Copy function, without any color space conversion, but able to deal with planar/pixel oriented conversion, ROIs and even masking
|
2375
|
+
/** Supports grey scale to color conversion, as well as RGB to RGBA, and RGBA to RGB copying (adding and removing alpha channel)
|
2376
|
+
*
|
2377
|
+
* \return 0 (false) if an error occurs
|
2378
|
+
*/
|
2379
|
+
int camCopy(CamImage *source, CamImage *dest);
|
2380
|
+
/// Simple cloning function
|
2381
|
+
/** This function allocates the memory for the dest image. dest actual content is not considered by this function.
|
2382
|
+
* Beware not to have allocated an image in dest before, otherwise this will result in a memory leak.
|
2383
|
+
*/
|
2384
|
+
int camClone(CamImage *source, CamImage *dest);
|
2385
|
+
/// Reference copy
|
2386
|
+
/** This function doesn't copy the pixels, only the structure. Destination image will reference the same pixels as the source image.
|
2387
|
+
* The image will be freed when source will be deallocated through camDeallocateImage() function.
|
2388
|
+
*/
|
2389
|
+
int camRefCopy(CamImage *source, CamImage *dest);
|
2390
|
+
/// Set all the pixel values to <DFN>fillValue</DFN>
|
2391
|
+
int camSet(CamImage *image, int fillValue);
|
2392
|
+
/// Alpha channel compositing
|
2393
|
+
/** \param source1 must be a RGB image
|
2394
|
+
* \param source2 must be a RGBA image (with an alpha channel)
|
2395
|
+
* \param dest destination image
|
2396
|
+
*/
|
2397
|
+
int camAlphaComposite(CamImage *source1, CamImage *source2, CamImage *dest);
|
2398
|
+
|
2399
|
+
/// Set the border value of an image
|
2400
|
+
int camSetBorder(CamImage *image, int borderValue);
|
2401
|
+
/// Clip the roi of an image
|
2402
|
+
int camClipROI(CamImage *image);
|
2403
|
+
/// Clip a ROI with respect to an image
|
2404
|
+
int camClip(CamROI *roi, CamImage *image);
|
2405
|
+
/// Compute intersection between ROIs
|
2406
|
+
int camROIIntersect(CamROI *roi1, CamROI *roi2, CamROI *dest);
|
2407
|
+
|
2408
|
+
#endif //SWIG
|
2409
|
+
int camSetImageViewer(char *s);
|
2410
|
+
#ifndef SWIG
|
2411
|
+
|
2412
|
+
/// View an image
|
2413
|
+
int camView(CamImage *image);
|
2414
|
+
/// Returns the version of the library
|
2415
|
+
const char *camVersion();
|
2416
|
+
|
2417
|
+
/* Drawing functions
|
2418
|
+
*/
|
2419
|
+
/// Draw a line
|
2420
|
+
int camDrawLine(CamImage *image, int x1, int y1, int x2, int y2, int color);
|
2421
|
+
/// Accumulate a line in a frame (very useful for Hough transforms)
|
2422
|
+
int camAccumulateLine(CamImage *image, int x1, int y1, int x2, int y2, int acc);
|
2423
|
+
/// Draw a rectangle
|
2424
|
+
int camDrawRectangle(CamImage *image, int x1, int y1, int x2, int y2, int color);
|
2425
|
+
/// Draw some text using 16 segments font (looks like an alarm clock...)
|
2426
|
+
int camDrawText16s(CamImage *image, char *text, int x, int y, int cwidth, int cheight, int orientation, int color);
|
2427
|
+
/// Draw a circle
|
2428
|
+
int camDrawCircle(CamImage *image, int x, int y, int r, int color);
|
2429
|
+
/// Draw an ellipse
|
2430
|
+
int camDrawEllipse(CamImage *image, int x, int y, int rx, int ry, int color);
|
2431
|
+
/// Plot
|
2432
|
+
/** Plots a point (\ref CAM_POINT), a cross (\ref CAM_CROSS), a circle (\ref CAM_CIRCLE) or a combination of them (<DFN>CAM_CROSS|CAM_CIRCLE</DFN> for instance)
|
2433
|
+
*/
|
2434
|
+
int camPlot(CamImage *image, int x, int y, int color, int kind);
|
2435
|
+
/// Fill a region with a color
|
2436
|
+
/** Try to fill the image with pixels as much possible pixels with the same color as the original pixel color in (x,y)
|
2437
|
+
*
|
2438
|
+
* \param x horizontal coordinate where to start the filling
|
2439
|
+
* \param y vertical coordinate where to start the filling
|
2440
|
+
* \param fillcolor filling color (use CAM_RGB or CAM_RGBA macros to set this color)
|
2441
|
+
* \param tolerance this sets where the filling should stop. The reference is the color of the original pixel color in (x,y), and all the pixels nearby that are within the
|
2442
|
+
* tolerance parameters get filled. If tolerance is set to -1, the filling stops with pixels having the same color as the filling color
|
2443
|
+
* (this mode is very useful for filling circles, rectangles, etc.)
|
2444
|
+
*
|
2445
|
+
* \return The number of colored pixels (at least 1 is function succeeds)
|
2446
|
+
*/
|
2447
|
+
int camFillColor(CamImage *image, int x, int y, int fillcolor, int tolerance);
|
2448
|
+
|
2449
|
+
#endif // SWIG
|
2450
|
+
|
2451
|
+
#ifdef __cplusplus
|
2452
|
+
/// The bitmap font structure
|
2453
|
+
struct CamBitmapFont {
|
2454
|
+
#else
|
2455
|
+
typedef struct {
|
2456
|
+
#endif
|
2457
|
+
int first_char;
|
2458
|
+
int nb_chars;
|
2459
|
+
int height;
|
2460
|
+
CamRLEImage *masks;
|
2461
|
+
CamImage *letters;
|
2462
|
+
#ifdef __cplusplus
|
2463
|
+
CamBitmapFont() {first_char=33; nb_chars=0; masks=NULL; letters=NULL;}
|
2464
|
+
CamBitmapFont(const char *filename);
|
2465
|
+
~CamBitmapFont();
|
2466
|
+
bool load(const char *filename);
|
2467
|
+
};
|
2468
|
+
#else
|
2469
|
+
} CamBitmapFont;
|
2470
|
+
#endif
|
2471
|
+
|
2472
|
+
#ifndef SWIG
|
2473
|
+
/// Load a bitmap font
|
2474
|
+
int camLoadBitmapFont(CamBitmapFont *font, char *filename);
|
2475
|
+
/// Deallocate a bitmap font
|
2476
|
+
int camFreeBitmapFont(CamBitmapFont *font);
|
2477
|
+
/// Draw some text using a bitmap font
|
2478
|
+
int camDrawTextBitmap(CamImage *image, char *text, int x, int y, CamBitmapFont *font);
|
2479
|
+
#endif // SWIG
|
2480
|
+
|
2481
|
+
/// 24 bits integer color representation. Stricly equivalent to the Windows RGB macro.
|
2482
|
+
/** Please use this one in place of RGB for better portability of the code.
|
2483
|
+
*/
|
2484
|
+
int camRGB(int r, int g, int b);
|
2485
|
+
|
2486
|
+
/// 32 bits integer color representation, including an alpha channel
|
2487
|
+
int camRGBA(int r, int g, int b, int a);
|
2488
|
+
|
2489
|
+
#ifndef SWIG
|
2490
|
+
|
2491
|
+
/* Load and save PGM images
|
2492
|
+
*/
|
2493
|
+
/// Load a PGM image
|
2494
|
+
int camLoadPGM(CamImage *image, char *fn);
|
2495
|
+
/// Save a PGM image
|
2496
|
+
int camSavePGM(CamImage *image, char *filename);
|
2497
|
+
/// Save a raw PGM image (8-bits only)
|
2498
|
+
int camSaveRawPGM(CamImage *image, char *filename);
|
2499
|
+
|
2500
|
+
/* Load and save BMP images
|
2501
|
+
*/
|
2502
|
+
/// Load a BMP image
|
2503
|
+
int camLoadBMP(CamImage *image, char *fn);
|
2504
|
+
/// Save a BMP image
|
2505
|
+
int camSaveBMP(CamImage *image, char *filename);
|
2506
|
+
|
2507
|
+
/* Load config files
|
2508
|
+
*/
|
2509
|
+
#define CAM_CONFIG_MAX_ENTRIES 256
|
2510
|
+
typedef struct {
|
2511
|
+
int nbEntries;
|
2512
|
+
char parameter[CAM_CONFIG_MAX_ENTRIES][128];
|
2513
|
+
char value[CAM_CONFIG_MAX_ENTRIES][128];
|
2514
|
+
} CamConfig;
|
2515
|
+
|
2516
|
+
int camLoadConfig(const char *filename, CamConfig *config);
|
2517
|
+
int camConfigInt(const CamConfig *config, const char *entry);
|
2518
|
+
float camConfigFloat(const CamConfig *config, const char *entry);
|
2519
|
+
const char *camConfigString(const CamConfig *config, const char *entry);
|
2520
|
+
|
2521
|
+
/* Image capture functions
|
2522
|
+
*/
|
2523
|
+
void* camCaptureInit(int options);
|
2524
|
+
int camCapture(void *handle, CamImage *image);
|
2525
|
+
int camCaptureOver(void *handle);
|
2526
|
+
|
2527
|
+
#endif
|
2528
|
+
|
2529
|
+
#define CAM_CAPTURE_AUTO_SOURCE 1
|
2530
|
+
#define CAM_CAPTURE_DISPLAY 2
|
2531
|
+
#define CAM_CAPTURE_USE_READ 4
|
2532
|
+
|
2533
|
+
#ifdef __cplusplus
|
2534
|
+
class CamCapture {
|
2535
|
+
void *handle;
|
2536
|
+
public:
|
2537
|
+
bool capture(CamImage &capture);
|
2538
|
+
bool ready() {return (handle)?true:false;}
|
2539
|
+
CamCapture(int options=0);
|
2540
|
+
~CamCapture();
|
2541
|
+
};
|
2542
|
+
#endif
|
2543
|
+
|
2544
|
+
#ifndef SWIG
|
2545
|
+
|
2546
|
+
/// Error management function
|
2547
|
+
void camError(char *module, char *error);
|
2548
|
+
typedef void (*camErrorFunct)(char *,char*);
|
2549
|
+
void camSetErrorFunct(camErrorFunct funct);
|
2550
|
+
//@}
|
2551
|
+
|
2552
|
+
/** @name Color conversion functions
|
2553
|
+
*/
|
2554
|
+
//@{
|
2555
|
+
int camYUV2RGB(CamImage* source, CamImage *dest); ///< Converts a YUV image to a RGB image
|
2556
|
+
int camRGB2YUV(CamImage* source, CamImage *dest); ///< Converts a RGB image to a YUV image
|
2557
|
+
int camRGB2Y(CamImage *source, CamImage *dest); ///< Converts a RGB image to a gray scale image
|
2558
|
+
int camRGB2HLS(CamImage* source, CamImage *dest); ///< Converts a RGB image to a HLS image
|
2559
|
+
//@}
|
2560
|
+
|
2561
|
+
/** @name Motion estimation functions
|
2562
|
+
*/
|
2563
|
+
//@{
|
2564
|
+
/*
|
2565
|
+
* Computes the Sum of Absolute Values between two 8x8 blocks
|
2566
|
+
*
|
2567
|
+
* This function takes into account the blocks lying partially outside the image.
|
2568
|
+
* MMX optimized if <DFN>CAM_OPT_MMX</DFN> compilation option is set (requires Intel C++ compiler).
|
2569
|
+
*
|
2570
|
+
*
|
2571
|
+
* \param image1 Current image
|
2572
|
+
* \param image2 Previous image
|
2573
|
+
* \param bleft The x coordinate of the current block
|
2574
|
+
* \param btop The y coordinate of the current block
|
2575
|
+
* \param dx The x offset to reach the candidate block
|
2576
|
+
* \param dy The y offset to reach the candidate block
|
2577
|
+
*
|
2578
|
+
* \return The SAD value between the given two blocks
|
2579
|
+
*/
|
2580
|
+
int camSAD8x8(CamImage *image1, CamImage *image2, int bleft, int btop, int dx, int dy);
|
2581
|
+
|
2582
|
+
/*
|
2583
|
+
* Computes the Sum of Absolute Values between two 16x16 blocks
|
2584
|
+
*
|
2585
|
+
* This function takes into account the blocks lying partially outside the image.
|
2586
|
+
* MMX optimized if <DFN>CAM_OPT_MMX</DFN> compilation option is set (requires Intel C++ compiler).
|
2587
|
+
*
|
2588
|
+
*
|
2589
|
+
* \param image1 Current image
|
2590
|
+
* \param image2 Previous image
|
2591
|
+
* \param bleft The x coordinate of the current block
|
2592
|
+
* \param btop The y coordinate of the current block
|
2593
|
+
* \param dx The x offset to reach the candidate block
|
2594
|
+
* \param dy The y offset to reach the candidate block
|
2595
|
+
*
|
2596
|
+
* \return The SAD value between the given two blocks
|
2597
|
+
*/
|
2598
|
+
int camSAD16x16(CamImage *image1, CamImage *image2, int bleft, int btop, int dx, int dy);
|
2599
|
+
|
2600
|
+
typedef struct {
|
2601
|
+
int niter; ///< Number of iterations (should be set to 0)
|
2602
|
+
int seed; ///< Seed for randomization
|
2603
|
+
int lsearch; ///< Number of pixels for searching around the blocks (small search)
|
2604
|
+
int rsearch; ///< Full random search parameter
|
2605
|
+
int blockSize; ///< Block size (8 or 16)
|
2606
|
+
int scans; ///< Number of scans
|
2607
|
+
int candidates; ///< Number of candidates (per scan)
|
2608
|
+
int test0; ///< Systematically test (0,0) motion vector
|
2609
|
+
} CamMotionEstimation3DRSParams;
|
2610
|
+
|
2611
|
+
typedef struct {
|
2612
|
+
int vx[CAM_MAX_SCANLINE/8][CAM_MAX_FRAME_HEIGHT/8]; ///< Horizontal motion vectors
|
2613
|
+
int vy[CAM_MAX_SCANLINE/8][CAM_MAX_FRAME_HEIGHT/8]; ///< Vertical motion vectors
|
2614
|
+
int SAD[CAM_MAX_SCANLINE/8][CAM_MAX_FRAME_HEIGHT/8]; ///< SAD results
|
2615
|
+
} CamMotionEstimation3DRSResults;
|
2616
|
+
|
2617
|
+
int camMotionEstimation3DRSInit(CamMotionEstimation3DRSParams *params, int seed, int lsearch, int rsearch, int bs, int scans, int candidates, int test0);
|
2618
|
+
int camMotionEstimation3DRS(CamImage *current, CamImage *previous, CamMotionEstimation3DRSParams *params, CamMotionEstimation3DRSResults *results);
|
2619
|
+
//@}
|
2620
|
+
|
2621
|
+
/** @name 3D Projection/Retroprojection functions
|
2622
|
+
*/
|
2623
|
+
//@{
|
2624
|
+
|
2625
|
+
void camProject(const double extr[4][4], const double fc[2], const double cc[2], double x, double y, double z, int *xp, int *yp);
|
2626
|
+
|
2627
|
+
void camBackproject(const double extr[4][4], const double fc[2], const double cc[2], int xp, int yp, double z, double *x, double *y);
|
2628
|
+
|
2629
|
+
int camUndistort(CamImage *source, CamImage *dest,
|
2630
|
+
const float* intrinsic_matrix,
|
2631
|
+
const float* dist_coeffs);
|
2632
|
+
int camUndistortFixed(CamImage *source, CamImage *dest,
|
2633
|
+
const CAM_FIXED_POINT* intrinsic_matrix,
|
2634
|
+
const CAM_FIXED_POINT* dist_coeffs);
|
2635
|
+
int camUndistortBuildLUT(CamImage *source,
|
2636
|
+
const float* intrinsic_matrix,
|
2637
|
+
const float* dist_coeffs,
|
2638
|
+
CamImage *LUTX, CamImage *LUTY);
|
2639
|
+
int camUndistortLUT(CamImage *source, CamImage *dest,
|
2640
|
+
CamImage *LUTX, CamImage *LUTY);
|
2641
|
+
|
2642
|
+
//@}
|
2643
|
+
|
2644
|
+
#endif // SWIG
|
2645
|
+
|
2646
|
+
#ifdef __cplusplus
|
2647
|
+
}
|
2648
|
+
#endif
|
2649
|
+
|
2650
|
+
#endif
|
2651
|
+
|