imagecore 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +24 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/ext/imagecore/analyze_image.cxx +58 -0
- data/ext/imagecore/analyze_image.h +6 -0
- data/ext/imagecore/extconf.rb +9 -0
- data/ext/imagecore/imagecore.cxx +34 -0
- data/ext/opencv/core/___.c +3 -0
- data/ext/opencv/core/alloc.cpp +697 -0
- data/ext/opencv/core/array.cpp +3206 -0
- data/ext/opencv/core/datastructs.cpp +4064 -0
- data/ext/opencv/core/extconf.rb +22 -0
- data/ext/opencv/core/matrix.cpp +3777 -0
- data/ext/opencv/core/precomp.hpp +216 -0
- data/ext/opencv/core/system.cpp +832 -0
- data/ext/opencv/core/tables.cpp +3512 -0
- data/ext/opencv/highgui/___.c +3 -0
- data/ext/opencv/highgui/bitstrm.cpp +582 -0
- data/ext/opencv/highgui/bitstrm.hpp +182 -0
- data/ext/opencv/highgui/extconf.rb +28 -0
- data/ext/opencv/highgui/grfmt_base.cpp +128 -0
- data/ext/opencv/highgui/grfmt_base.hpp +113 -0
- data/ext/opencv/highgui/grfmt_bmp.cpp +564 -0
- data/ext/opencv/highgui/grfmt_bmp.hpp +99 -0
- data/ext/opencv/highgui/grfmt_exr.hpp +113 -0
- data/ext/opencv/highgui/grfmt_imageio.hpp +56 -0
- data/ext/opencv/highgui/grfmt_jpeg.cpp +622 -0
- data/ext/opencv/highgui/grfmt_jpeg.hpp +90 -0
- data/ext/opencv/highgui/grfmt_jpeg2000.cpp +529 -0
- data/ext/opencv/highgui/grfmt_jpeg2000.hpp +95 -0
- data/ext/opencv/highgui/grfmt_png.cpp +406 -0
- data/ext/opencv/highgui/grfmt_png.hpp +101 -0
- data/ext/opencv/highgui/grfmt_pxm.cpp +513 -0
- data/ext/opencv/highgui/grfmt_pxm.hpp +92 -0
- data/ext/opencv/highgui/grfmt_sunras.cpp +425 -0
- data/ext/opencv/highgui/grfmt_sunras.hpp +105 -0
- data/ext/opencv/highgui/grfmt_tiff.cpp +718 -0
- data/ext/opencv/highgui/grfmt_tiff.hpp +136 -0
- data/ext/opencv/highgui/grfmts.hpp +56 -0
- data/ext/opencv/highgui/loadsave.cpp +535 -0
- data/ext/opencv/highgui/precomp.hpp +223 -0
- data/ext/opencv/highgui/utils.cpp +689 -0
- data/ext/opencv/highgui/utils.hpp +128 -0
- data/ext/opencv/imgproc/___.c +3 -0
- data/ext/opencv/imgproc/_geom.h +72 -0
- data/ext/opencv/imgproc/color.cpp +3179 -0
- data/ext/opencv/imgproc/contours.cpp +1780 -0
- data/ext/opencv/imgproc/extconf.rb +11 -0
- data/ext/opencv/imgproc/filter.cpp +3063 -0
- data/ext/opencv/imgproc/precomp.hpp +159 -0
- data/ext/opencv/imgproc/shapedescr.cpp +1306 -0
- data/ext/opencv/imgproc/smooth.cpp +1566 -0
- data/ext/opencv/imgproc/tables.cpp +214 -0
- data/ext/opencv/imgproc/thresh.cpp +636 -0
- data/ext/opencv/imgproc/utils.cpp +242 -0
- data/ext/opencv/include/opencv2/core/core.hpp +4344 -0
- data/ext/opencv/include/opencv2/core/core_c.h +1885 -0
- data/ext/opencv/include/opencv2/core/internal.hpp +710 -0
- data/ext/opencv/include/opencv2/core/mat.hpp +2557 -0
- data/ext/opencv/include/opencv2/core/operations.hpp +3623 -0
- data/ext/opencv/include/opencv2/core/types_c.h +1875 -0
- data/ext/opencv/include/opencv2/core/version.hpp +58 -0
- data/ext/opencv/include/opencv2/highgui/highgui.hpp +198 -0
- data/ext/opencv/include/opencv2/highgui/highgui_c.h +506 -0
- data/ext/opencv/include/opencv2/imgproc/imgproc.hpp +1139 -0
- data/ext/opencv/include/opencv2/imgproc/imgproc_c.h +783 -0
- data/ext/opencv/include/opencv2/imgproc/types_c.h +538 -0
- data/imagecore.gemspec +20 -0
- data/lib/imagecore.rb +16 -0
- data/lib/imagecore/version.rb +3 -0
- metadata +119 -0
@@ -0,0 +1,216 @@
|
|
1
|
+
/*M///////////////////////////////////////////////////////////////////////////////////////
|
2
|
+
//
|
3
|
+
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
4
|
+
//
|
5
|
+
// By downloading, copying, installing or using the software you agree to this license.
|
6
|
+
// If you do not agree to this license, do not download, install,
|
7
|
+
// copy or use the software.
|
8
|
+
//
|
9
|
+
//
|
10
|
+
// License Agreement
|
11
|
+
// For Open Source Computer Vision Library
|
12
|
+
//
|
13
|
+
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
14
|
+
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
15
|
+
// Third party copyrights are property of their respective owners.
|
16
|
+
//
|
17
|
+
// Redistribution and use in source and binary forms, with or without modification,
|
18
|
+
// are permitted provided that the following conditions are met:
|
19
|
+
//
|
20
|
+
// * Redistribution's of source code must retain the above copyright notice,
|
21
|
+
// this list of conditions and the following disclaimer.
|
22
|
+
//
|
23
|
+
// * Redistribution's in binary form must reproduce the above copyright notice,
|
24
|
+
// this list of conditions and the following disclaimer in the documentation
|
25
|
+
// and/or other materials provided with the distribution.
|
26
|
+
//
|
27
|
+
// * The name of the copyright holders may not be used to endorse or promote products
|
28
|
+
// derived from this software without specific prior written permission.
|
29
|
+
//
|
30
|
+
// This software is provided by the copyright holders and contributors "as is" and
|
31
|
+
// any express or implied warranties, including, but not limited to, the implied
|
32
|
+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
33
|
+
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
34
|
+
// indirect, incidental, special, exemplary, or consequential damages
|
35
|
+
// (including, but not limited to, procurement of substitute goods or services;
|
36
|
+
// loss of use, data, or profits; or business interruption) however caused
|
37
|
+
// and on any theory of liability, whether in contract, strict liability,
|
38
|
+
// or tort (including negligence or otherwise) arising in any way out of
|
39
|
+
// the use of this software, even if advised of the possibility of such damage.
|
40
|
+
//
|
41
|
+
//M*/
|
42
|
+
|
43
|
+
#ifndef __OPENCV_PRECOMP_H__
|
44
|
+
#define __OPENCV_PRECOMP_H__
|
45
|
+
|
46
|
+
#if defined _MSC_VER && _MSC_VER >= 1200
|
47
|
+
// disable warnings related to inline functions
|
48
|
+
#pragma warning( disable: 4251 4711 4710 4514 )
|
49
|
+
#endif
|
50
|
+
|
51
|
+
#ifdef HAVE_CVCONFIG_H
|
52
|
+
#include "cvconfig.h"
|
53
|
+
#endif
|
54
|
+
|
55
|
+
#include "opencv2/core/core.hpp"
|
56
|
+
#include "opencv2/core/core_c.h"
|
57
|
+
#include "opencv2/core/internal.hpp"
|
58
|
+
|
59
|
+
#include <assert.h>
|
60
|
+
#include <ctype.h>
|
61
|
+
#include <float.h>
|
62
|
+
#include <limits.h>
|
63
|
+
#include <math.h>
|
64
|
+
#include <stdio.h>
|
65
|
+
#include <stdlib.h>
|
66
|
+
#include <string.h>
|
67
|
+
|
68
|
+
#ifdef HAVE_TEGRA_OPTIMIZATION
|
69
|
+
#include "opencv2/core/core_tegra.hpp"
|
70
|
+
#endif
|
71
|
+
|
72
|
+
namespace cv
|
73
|
+
{
|
74
|
+
|
75
|
+
// -128.f ... 255.f
|
76
|
+
extern const float g_8x32fTab[];
|
77
|
+
#define CV_8TO32F(x) cv::g_8x32fTab[(x)+128]
|
78
|
+
|
79
|
+
extern const ushort g_8x16uSqrTab[];
|
80
|
+
#define CV_SQR_8U(x) cv::g_8x16uSqrTab[(x)+255]
|
81
|
+
|
82
|
+
extern const char* g_HersheyGlyphs[];
|
83
|
+
|
84
|
+
extern const uchar g_Saturate8u[];
|
85
|
+
#define CV_FAST_CAST_8U(t) (assert(-256 <= (t) && (t) <= 512), cv::g_Saturate8u[(t)+256])
|
86
|
+
#define CV_MIN_8U(a,b) ((a) - CV_FAST_CAST_8U((a) - (b)))
|
87
|
+
#define CV_MAX_8U(a,b) ((a) + CV_FAST_CAST_8U((b) - (a)))
|
88
|
+
|
89
|
+
|
90
|
+
#if defined WIN32 || defined _WIN32
|
91
|
+
void deleteThreadAllocData();
|
92
|
+
void deleteThreadRNGData();
|
93
|
+
#endif
|
94
|
+
|
95
|
+
template<typename T1, typename T2=T1, typename T3=T1> struct OpAdd
|
96
|
+
{
|
97
|
+
typedef T1 type1;
|
98
|
+
typedef T2 type2;
|
99
|
+
typedef T3 rtype;
|
100
|
+
T3 operator ()(T1 a, T2 b) const { return saturate_cast<T3>(a + b); }
|
101
|
+
};
|
102
|
+
|
103
|
+
template<typename T1, typename T2=T1, typename T3=T1> struct OpSub
|
104
|
+
{
|
105
|
+
typedef T1 type1;
|
106
|
+
typedef T2 type2;
|
107
|
+
typedef T3 rtype;
|
108
|
+
T3 operator ()(T1 a, T2 b) const { return saturate_cast<T3>(a - b); }
|
109
|
+
};
|
110
|
+
|
111
|
+
template<typename T1, typename T2=T1, typename T3=T1> struct OpRSub
|
112
|
+
{
|
113
|
+
typedef T1 type1;
|
114
|
+
typedef T2 type2;
|
115
|
+
typedef T3 rtype;
|
116
|
+
T3 operator ()(T1 a, T2 b) const { return saturate_cast<T3>(b - a); }
|
117
|
+
};
|
118
|
+
|
119
|
+
template<typename T> struct OpMin
|
120
|
+
{
|
121
|
+
typedef T type1;
|
122
|
+
typedef T type2;
|
123
|
+
typedef T rtype;
|
124
|
+
T operator ()(T a, T b) const { return std::min(a, b); }
|
125
|
+
};
|
126
|
+
|
127
|
+
template<typename T> struct OpMax
|
128
|
+
{
|
129
|
+
typedef T type1;
|
130
|
+
typedef T type2;
|
131
|
+
typedef T rtype;
|
132
|
+
T operator ()(T a, T b) const { return std::max(a, b); }
|
133
|
+
};
|
134
|
+
|
135
|
+
inline Size getContinuousSize( const Mat& m1, int widthScale=1 )
|
136
|
+
{
|
137
|
+
return m1.isContinuous() ? Size(m1.cols*m1.rows*widthScale, 1) :
|
138
|
+
Size(m1.cols*widthScale, m1.rows);
|
139
|
+
}
|
140
|
+
|
141
|
+
inline Size getContinuousSize( const Mat& m1, const Mat& m2, int widthScale=1 )
|
142
|
+
{
|
143
|
+
return (m1.flags & m2.flags & Mat::CONTINUOUS_FLAG) != 0 ?
|
144
|
+
Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
|
145
|
+
}
|
146
|
+
|
147
|
+
inline Size getContinuousSize( const Mat& m1, const Mat& m2,
|
148
|
+
const Mat& m3, int widthScale=1 )
|
149
|
+
{
|
150
|
+
return (m1.flags & m2.flags & m3.flags & Mat::CONTINUOUS_FLAG) != 0 ?
|
151
|
+
Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
|
152
|
+
}
|
153
|
+
|
154
|
+
inline Size getContinuousSize( const Mat& m1, const Mat& m2,
|
155
|
+
const Mat& m3, const Mat& m4,
|
156
|
+
int widthScale=1 )
|
157
|
+
{
|
158
|
+
return (m1.flags & m2.flags & m3.flags & m4.flags & Mat::CONTINUOUS_FLAG) != 0 ?
|
159
|
+
Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
|
160
|
+
}
|
161
|
+
|
162
|
+
inline Size getContinuousSize( const Mat& m1, const Mat& m2,
|
163
|
+
const Mat& m3, const Mat& m4,
|
164
|
+
const Mat& m5, int widthScale=1 )
|
165
|
+
{
|
166
|
+
return (m1.flags & m2.flags & m3.flags & m4.flags & m5.flags & Mat::CONTINUOUS_FLAG) != 0 ?
|
167
|
+
Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
|
168
|
+
}
|
169
|
+
|
170
|
+
struct NoVec
|
171
|
+
{
|
172
|
+
size_t operator()(const void*, const void*, void*, size_t) const { return 0; }
|
173
|
+
};
|
174
|
+
|
175
|
+
extern volatile bool USE_SSE2;
|
176
|
+
|
177
|
+
typedef void (*BinaryFunc)(const uchar* src1, size_t step1,
|
178
|
+
const uchar* src2, size_t step2,
|
179
|
+
uchar* dst, size_t step, Size sz,
|
180
|
+
void*);
|
181
|
+
|
182
|
+
BinaryFunc getConvertFunc(int sdepth, int ddepth);
|
183
|
+
BinaryFunc getConvertScaleFunc(int sdepth, int ddepth);
|
184
|
+
BinaryFunc getCopyMaskFunc(size_t esz);
|
185
|
+
|
186
|
+
enum { BLOCK_SIZE = 1024 };
|
187
|
+
|
188
|
+
#ifdef HAVE_IPP
|
189
|
+
static inline IppiSize ippiSize(int width, int height) { IppiSize sz = { width, height}; return sz; }
|
190
|
+
static inline IppiSize ippiSize(Size _sz) { IppiSize sz = { _sz.width, _sz.height}; return sz; }
|
191
|
+
#endif
|
192
|
+
|
193
|
+
#if defined HAVE_IPP && (IPP_VERSION_MAJOR >= 7)
|
194
|
+
#define ARITHM_USE_IPP 1
|
195
|
+
#define IF_IPP(then_call, else_call) then_call
|
196
|
+
#else
|
197
|
+
#define ARITHM_USE_IPP 0
|
198
|
+
#define IF_IPP(then_call, else_call) else_call
|
199
|
+
#endif
|
200
|
+
|
201
|
+
inline bool checkScalar(const Mat& sc, int atype, int sckind, int akind)
|
202
|
+
{
|
203
|
+
if( sc.dims > 2 || (sc.cols != 1 && sc.rows != 1) || !sc.isContinuous() )
|
204
|
+
return false;
|
205
|
+
int cn = CV_MAT_CN(atype);
|
206
|
+
if( akind == _InputArray::MATX && sckind != _InputArray::MATX )
|
207
|
+
return false;
|
208
|
+
return sc.size() == Size(1, 1) || sc.size() == Size(1, cn) || sc.size() == Size(cn, 1) ||
|
209
|
+
(sc.size() == Size(1, 4) && sc.type() == CV_64F && cn <= 4);
|
210
|
+
}
|
211
|
+
|
212
|
+
void convertAndUnrollScalar( const Mat& sc, int buftype, uchar* scbuf, size_t blocksize );
|
213
|
+
|
214
|
+
}
|
215
|
+
|
216
|
+
#endif /*_CXCORE_INTERNAL_H_*/
|
@@ -0,0 +1,832 @@
|
|
1
|
+
/*M///////////////////////////////////////////////////////////////////////////////////////
|
2
|
+
//
|
3
|
+
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
4
|
+
//
|
5
|
+
// By downloading, copying, installing or using the software you agree to this license.
|
6
|
+
// If you do not agree to this license, do not download, install,
|
7
|
+
// copy or use the software.
|
8
|
+
//
|
9
|
+
//
|
10
|
+
// License Agreement
|
11
|
+
// For Open Source Computer Vision Library
|
12
|
+
//
|
13
|
+
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
14
|
+
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
15
|
+
// Third party copyrights are property of their respective owners.
|
16
|
+
//
|
17
|
+
// Redistribution and use in source and binary forms, with or without modification,
|
18
|
+
// are permitted provided that the following conditions are met:
|
19
|
+
//
|
20
|
+
// * Redistribution's of source code must retain the above copyright notice,
|
21
|
+
// this list of conditions and the following disclaimer.
|
22
|
+
//
|
23
|
+
// * Redistribution's in binary form must reproduce the above copyright notice,
|
24
|
+
// this list of conditions and the following disclaimer in the documentation
|
25
|
+
// and/or other materials provided with the distribution.
|
26
|
+
//
|
27
|
+
// * The name of the copyright holders may not be used to endorse or promote products
|
28
|
+
// derived from this software without specific prior written permission.
|
29
|
+
//
|
30
|
+
// This software is provided by the copyright holders and contributors "as is" and
|
31
|
+
// any express or implied warranties, including, but not limited to, the implied
|
32
|
+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
33
|
+
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
34
|
+
// indirect, incidental, special, exemplary, or consequential damages
|
35
|
+
// (including, but not limited to, procurement of substitute goods or services;
|
36
|
+
// loss of use, data, or profits; or business interruption) however caused
|
37
|
+
// and on any theory of liability, whether in contract, strict liability,
|
38
|
+
// or tort (including negligence or otherwise) arising in any way out of
|
39
|
+
// the use of this software, even if advised of the possibility of such damage.
|
40
|
+
//
|
41
|
+
//M*/
|
42
|
+
|
43
|
+
#include "precomp.hpp"
|
44
|
+
|
45
|
+
#if defined WIN32 || defined _WIN32 || defined WINCE
|
46
|
+
#include <tchar.h>
|
47
|
+
#if defined _MSC_VER
|
48
|
+
#if _MSC_VER >= 1400
|
49
|
+
#include <intrin.h>
|
50
|
+
#elif defined _M_IX86
|
51
|
+
static void __cpuid(int* cpuid_data, int)
|
52
|
+
{
|
53
|
+
__asm
|
54
|
+
{
|
55
|
+
push ebx
|
56
|
+
push edi
|
57
|
+
mov edi, cpuid_data
|
58
|
+
mov eax, 1
|
59
|
+
cpuid
|
60
|
+
mov [edi], eax
|
61
|
+
mov [edi + 4], ebx
|
62
|
+
mov [edi + 8], ecx
|
63
|
+
mov [edi + 12], edx
|
64
|
+
pop edi
|
65
|
+
pop ebx
|
66
|
+
}
|
67
|
+
}
|
68
|
+
#endif
|
69
|
+
#endif
|
70
|
+
#else
|
71
|
+
#include <pthread.h>
|
72
|
+
#include <sys/time.h>
|
73
|
+
#include <time.h>
|
74
|
+
|
75
|
+
#if defined __MACH__ && defined __APPLE__
|
76
|
+
#include <mach/mach.h>
|
77
|
+
#include <mach/mach_time.h>
|
78
|
+
#endif
|
79
|
+
|
80
|
+
#endif
|
81
|
+
|
82
|
+
#ifdef _OPENMP
|
83
|
+
#include "omp.h"
|
84
|
+
#endif
|
85
|
+
|
86
|
+
#include <stdarg.h>
|
87
|
+
|
88
|
+
#if defined __linux__ || defined __APPLE__
|
89
|
+
#include <unistd.h>
|
90
|
+
#include <stdio.h>
|
91
|
+
#include <sys/types.h>
|
92
|
+
#if defined ANDROID
|
93
|
+
#include <sys/sysconf.h>
|
94
|
+
#else
|
95
|
+
#include <sys/sysctl.h>
|
96
|
+
#endif
|
97
|
+
#endif
|
98
|
+
|
99
|
+
namespace cv
|
100
|
+
{
|
101
|
+
|
102
|
+
Exception::Exception() { code = 0; line = 0; }
|
103
|
+
|
104
|
+
Exception::Exception(int _code, const string& _err, const string& _func, const string& _file, int _line)
|
105
|
+
: code(_code), err(_err), func(_func), file(_file), line(_line)
|
106
|
+
{
|
107
|
+
formatMessage();
|
108
|
+
}
|
109
|
+
|
110
|
+
Exception::~Exception() throw() {}
|
111
|
+
|
112
|
+
/*!
|
113
|
+
\return the error description and the context as a text string.
|
114
|
+
*/
|
115
|
+
const char* Exception::what() const throw() { return msg.c_str(); }
|
116
|
+
|
117
|
+
void Exception::formatMessage()
|
118
|
+
{
|
119
|
+
if( func.size() > 0 )
|
120
|
+
msg = format("%s:%d: error: (%d) %s in function %s\n", file.c_str(), line, code, err.c_str(), func.c_str());
|
121
|
+
else
|
122
|
+
msg = format("%s:%d: error: (%d) %s\n", file.c_str(), line, code, err.c_str());
|
123
|
+
}
|
124
|
+
|
125
|
+
struct HWFeatures
|
126
|
+
{
|
127
|
+
enum { MAX_FEATURE = CV_HARDWARE_MAX_FEATURE };
|
128
|
+
|
129
|
+
HWFeatures(void)
|
130
|
+
{
|
131
|
+
memset( have, 0, sizeof(have) );
|
132
|
+
x86_family = 0;
|
133
|
+
}
|
134
|
+
|
135
|
+
static HWFeatures initialize(void)
|
136
|
+
{
|
137
|
+
HWFeatures f;
|
138
|
+
int cpuid_data[4] = { 0, 0, 0, 0 };
|
139
|
+
|
140
|
+
#if defined _MSC_VER && (defined _M_IX86 || defined _M_X64)
|
141
|
+
__cpuid(cpuid_data, 1);
|
142
|
+
#elif defined __GNUC__ && (defined __i386__ || defined __x86_64__)
|
143
|
+
#ifdef __x86_64__
|
144
|
+
asm __volatile__
|
145
|
+
(
|
146
|
+
"movl $1, %%eax\n\t"
|
147
|
+
"cpuid\n\t"
|
148
|
+
:[eax]"=a"(cpuid_data[0]),[ebx]"=b"(cpuid_data[1]),[ecx]"=c"(cpuid_data[2]),[edx]"=d"(cpuid_data[3])
|
149
|
+
:
|
150
|
+
: "cc"
|
151
|
+
);
|
152
|
+
#else
|
153
|
+
asm volatile
|
154
|
+
(
|
155
|
+
"pushl %%ebx\n\t"
|
156
|
+
"movl $1,%%eax\n\t"
|
157
|
+
"cpuid\n\t"
|
158
|
+
"popl %%ebx\n\t"
|
159
|
+
: "=a"(cpuid_data[0]), "=c"(cpuid_data[2]), "=d"(cpuid_data[3])
|
160
|
+
:
|
161
|
+
: "cc"
|
162
|
+
);
|
163
|
+
#endif
|
164
|
+
#endif
|
165
|
+
|
166
|
+
f.x86_family = (cpuid_data[0] >> 8) & 15;
|
167
|
+
if( f.x86_family >= 6 )
|
168
|
+
{
|
169
|
+
f.have[CV_CPU_MMX] = (cpuid_data[3] & (1 << 23)) != 0;
|
170
|
+
f.have[CV_CPU_SSE] = (cpuid_data[3] & (1<<25)) != 0;
|
171
|
+
f.have[CV_CPU_SSE2] = (cpuid_data[3] & (1<<26)) != 0;
|
172
|
+
f.have[CV_CPU_SSE3] = (cpuid_data[2] & (1<<0)) != 0;
|
173
|
+
f.have[CV_CPU_SSSE3] = (cpuid_data[2] & (1<<9)) != 0;
|
174
|
+
f.have[CV_CPU_SSE4_1] = (cpuid_data[2] & (1<<19)) != 0;
|
175
|
+
f.have[CV_CPU_SSE4_2] = (cpuid_data[2] & (1<<20)) != 0;
|
176
|
+
f.have[CV_CPU_POPCNT] = (cpuid_data[2] & (1<<23)) != 0;
|
177
|
+
f.have[CV_CPU_AVX] = (cpuid_data[2] & (1<<28)) != 0;
|
178
|
+
}
|
179
|
+
|
180
|
+
return f;
|
181
|
+
}
|
182
|
+
|
183
|
+
int x86_family;
|
184
|
+
bool have[MAX_FEATURE+1];
|
185
|
+
};
|
186
|
+
|
187
|
+
static HWFeatures featuresEnabled = HWFeatures::initialize(), featuresDisabled = HWFeatures();
|
188
|
+
static HWFeatures* currentFeatures = &featuresEnabled;
|
189
|
+
|
190
|
+
bool checkHardwareSupport(int feature)
|
191
|
+
{
|
192
|
+
CV_DbgAssert( 0 <= feature && feature <= CV_HARDWARE_MAX_FEATURE );
|
193
|
+
return currentFeatures->have[feature];
|
194
|
+
}
|
195
|
+
|
196
|
+
#ifdef HAVE_IPP
|
197
|
+
volatile bool useOptimizedFlag = true;
|
198
|
+
|
199
|
+
struct IPPInitializer
|
200
|
+
{
|
201
|
+
IPPInitializer(void) { ippStaticInit(); }
|
202
|
+
};
|
203
|
+
|
204
|
+
IPPInitializer ippInitializer;
|
205
|
+
#else
|
206
|
+
volatile bool useOptimizedFlag = true;
|
207
|
+
#endif
|
208
|
+
|
209
|
+
volatile bool USE_SSE2 = false;
|
210
|
+
|
211
|
+
void setUseOptimized( bool flag )
|
212
|
+
{
|
213
|
+
useOptimizedFlag = flag;
|
214
|
+
currentFeatures = flag ? &featuresEnabled : &featuresDisabled;
|
215
|
+
USE_SSE2 = currentFeatures->have[CV_CPU_SSE2];
|
216
|
+
}
|
217
|
+
|
218
|
+
bool useOptimized(void)
|
219
|
+
{
|
220
|
+
return useOptimizedFlag;
|
221
|
+
}
|
222
|
+
|
223
|
+
int64 getTickCount(void)
|
224
|
+
{
|
225
|
+
#if defined WIN32 || defined _WIN32 || defined WINCE
|
226
|
+
LARGE_INTEGER counter;
|
227
|
+
QueryPerformanceCounter( &counter );
|
228
|
+
return (int64)counter.QuadPart;
|
229
|
+
#elif defined __linux || defined __linux__
|
230
|
+
struct timespec tp;
|
231
|
+
clock_gettime(CLOCK_MONOTONIC, &tp);
|
232
|
+
return (int64)tp.tv_sec*1000000000 + tp.tv_nsec;
|
233
|
+
#elif defined __MACH__ && defined __APPLE__
|
234
|
+
return (int64)mach_absolute_time();
|
235
|
+
#else
|
236
|
+
struct timeval tv;
|
237
|
+
struct timezone tz;
|
238
|
+
gettimeofday( &tv, &tz );
|
239
|
+
return (int64)tv.tv_sec*1000000 + tv.tv_usec;
|
240
|
+
#endif
|
241
|
+
}
|
242
|
+
|
243
|
+
double getTickFrequency(void)
|
244
|
+
{
|
245
|
+
#if defined WIN32 || defined _WIN32 || defined WINCE
|
246
|
+
LARGE_INTEGER freq;
|
247
|
+
QueryPerformanceFrequency(&freq);
|
248
|
+
return (double)freq.QuadPart;
|
249
|
+
#elif defined __linux || defined __linux__
|
250
|
+
return 1e9;
|
251
|
+
#elif defined __MACH__ && defined __APPLE__
|
252
|
+
static double freq = 0;
|
253
|
+
if( freq == 0 )
|
254
|
+
{
|
255
|
+
mach_timebase_info_data_t sTimebaseInfo;
|
256
|
+
mach_timebase_info(&sTimebaseInfo);
|
257
|
+
freq = sTimebaseInfo.denom*1e9/sTimebaseInfo.numer;
|
258
|
+
}
|
259
|
+
return freq;
|
260
|
+
#else
|
261
|
+
return 1e6;
|
262
|
+
#endif
|
263
|
+
}
|
264
|
+
|
265
|
+
#if defined __GNUC__ && (defined __i386__ || defined __x86_64__ || defined __ppc__)
|
266
|
+
#if defined(__i386__)
|
267
|
+
|
268
|
+
int64 getCPUTickCount(void)
|
269
|
+
{
|
270
|
+
int64 x;
|
271
|
+
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
|
272
|
+
return x;
|
273
|
+
}
|
274
|
+
#elif defined(__x86_64__)
|
275
|
+
|
276
|
+
int64 getCPUTickCount(void)
|
277
|
+
{
|
278
|
+
unsigned hi, lo;
|
279
|
+
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
|
280
|
+
return (int64)lo | ((int64)hi << 32);
|
281
|
+
}
|
282
|
+
|
283
|
+
#elif defined(__ppc__)
|
284
|
+
|
285
|
+
int64 getCPUTickCount(void)
|
286
|
+
{
|
287
|
+
int64 result = 0;
|
288
|
+
unsigned upper, lower, tmp;
|
289
|
+
__asm__ volatile(
|
290
|
+
"0: \n"
|
291
|
+
"\tmftbu %0 \n"
|
292
|
+
"\tmftb %1 \n"
|
293
|
+
"\tmftbu %2 \n"
|
294
|
+
"\tcmpw %2,%0 \n"
|
295
|
+
"\tbne 0b \n"
|
296
|
+
: "=r"(upper),"=r"(lower),"=r"(tmp)
|
297
|
+
);
|
298
|
+
return lower | ((int64)upper << 32);
|
299
|
+
}
|
300
|
+
|
301
|
+
#else
|
302
|
+
|
303
|
+
#error "RDTSC not defined"
|
304
|
+
|
305
|
+
#endif
|
306
|
+
|
307
|
+
#elif defined _MSC_VER && defined WIN32 && defined _M_IX86
|
308
|
+
|
309
|
+
int64 getCPUTickCount(void)
|
310
|
+
{
|
311
|
+
__asm _emit 0x0f;
|
312
|
+
__asm _emit 0x31;
|
313
|
+
}
|
314
|
+
|
315
|
+
#else
|
316
|
+
|
317
|
+
#ifdef HAVE_IPP
|
318
|
+
int64 getCPUTickCount(void)
|
319
|
+
{
|
320
|
+
return ippGetCpuClocks();
|
321
|
+
}
|
322
|
+
#else
|
323
|
+
int64 getCPUTickCount(void)
|
324
|
+
{
|
325
|
+
return getTickCount();
|
326
|
+
}
|
327
|
+
#endif
|
328
|
+
|
329
|
+
#endif
|
330
|
+
|
331
|
+
|
332
|
+
static int numThreads = 0;
|
333
|
+
static int numProcs = 0;
|
334
|
+
|
335
|
+
int getNumThreads(void)
|
336
|
+
{
|
337
|
+
if( !numProcs )
|
338
|
+
setNumThreads(0);
|
339
|
+
return numThreads;
|
340
|
+
}
|
341
|
+
|
342
|
+
void setNumThreads( int
|
343
|
+
#ifdef _OPENMP
|
344
|
+
threads
|
345
|
+
#endif
|
346
|
+
)
|
347
|
+
{
|
348
|
+
if( !numProcs )
|
349
|
+
{
|
350
|
+
#ifdef _OPENMP
|
351
|
+
numProcs = omp_get_num_procs();
|
352
|
+
#else
|
353
|
+
numProcs = 1;
|
354
|
+
#endif
|
355
|
+
}
|
356
|
+
|
357
|
+
#ifdef _OPENMP
|
358
|
+
if( threads <= 0 )
|
359
|
+
threads = numProcs;
|
360
|
+
else
|
361
|
+
threads = MIN( threads, numProcs );
|
362
|
+
|
363
|
+
numThreads = threads;
|
364
|
+
#else
|
365
|
+
numThreads = 1;
|
366
|
+
#endif
|
367
|
+
}
|
368
|
+
|
369
|
+
|
370
|
+
int getThreadNum(void)
|
371
|
+
{
|
372
|
+
#ifdef _OPENMP
|
373
|
+
return omp_get_thread_num();
|
374
|
+
#else
|
375
|
+
return 0;
|
376
|
+
#endif
|
377
|
+
}
|
378
|
+
|
379
|
+
int getNumberOfCPUs(void)
|
380
|
+
{
|
381
|
+
#if defined WIN32 || defined _WIN32
|
382
|
+
SYSTEM_INFO sysinfo;
|
383
|
+
GetSystemInfo( &sysinfo );
|
384
|
+
|
385
|
+
return (int)sysinfo.dwNumberOfProcessors;
|
386
|
+
#elif defined __linux__
|
387
|
+
return (int)sysconf( _SC_NPROCESSORS_ONLN );
|
388
|
+
#elif defined __APPLE__
|
389
|
+
int numCPU=0;
|
390
|
+
int mib[4];
|
391
|
+
size_t len = sizeof(numCPU);
|
392
|
+
|
393
|
+
/* set the mib for hw.ncpu */
|
394
|
+
mib[0] = CTL_HW;
|
395
|
+
mib[1] = HW_AVAILCPU; // alternatively, try HW_NCPU;
|
396
|
+
|
397
|
+
/* get the number of CPUs from the system */
|
398
|
+
sysctl(mib, 2, &numCPU, &len, NULL, 0);
|
399
|
+
|
400
|
+
if( numCPU < 1 )
|
401
|
+
{
|
402
|
+
mib[1] = HW_NCPU;
|
403
|
+
sysctl( mib, 2, &numCPU, &len, NULL, 0 );
|
404
|
+
|
405
|
+
if( numCPU < 1 )
|
406
|
+
numCPU = 1;
|
407
|
+
}
|
408
|
+
|
409
|
+
return (int)numCPU;
|
410
|
+
#else
|
411
|
+
return 1;
|
412
|
+
#endif
|
413
|
+
}
|
414
|
+
|
415
|
+
string format( const char* fmt, ... )
|
416
|
+
{
|
417
|
+
char buf[1 << 16];
|
418
|
+
va_list args;
|
419
|
+
va_start( args, fmt );
|
420
|
+
vsprintf( buf, fmt, args );
|
421
|
+
return string(buf);
|
422
|
+
}
|
423
|
+
|
424
|
+
string tempfile( const char* suffix )
|
425
|
+
{
|
426
|
+
char buf[L_tmpnam];
|
427
|
+
char* name = 0;
|
428
|
+
#if ANDROID
|
429
|
+
strcpy(buf, "/sdcard/__opencv_temp_XXXXXX");
|
430
|
+
name = mktemp(buf);
|
431
|
+
#else
|
432
|
+
name = tmpnam(buf);
|
433
|
+
#endif
|
434
|
+
if (*name == '\\')
|
435
|
+
++name;
|
436
|
+
string n(name);
|
437
|
+
if (suffix != 0)
|
438
|
+
n += (n[n.size()-1] == '.' && suffix[0] == '.' ? suffix + 1 : suffix);
|
439
|
+
return n;
|
440
|
+
}
|
441
|
+
|
442
|
+
static CvErrorCallback customErrorCallback = 0;
|
443
|
+
static void* customErrorCallbackData = 0;
|
444
|
+
static bool breakOnError = false;
|
445
|
+
|
446
|
+
bool setBreakOnError(bool value)
|
447
|
+
{
|
448
|
+
bool prevVal = breakOnError;
|
449
|
+
breakOnError = value;
|
450
|
+
return prevVal;
|
451
|
+
}
|
452
|
+
|
453
|
+
void error( const Exception& exc )
|
454
|
+
{
|
455
|
+
if (customErrorCallback != 0)
|
456
|
+
customErrorCallback(exc.code, exc.func.c_str(), exc.err.c_str(),
|
457
|
+
exc.file.c_str(), exc.line, customErrorCallbackData);
|
458
|
+
else
|
459
|
+
{
|
460
|
+
const char* errorStr = cvErrorStr(exc.code);
|
461
|
+
char buf[1 << 16];
|
462
|
+
|
463
|
+
sprintf( buf, "OpenCV Error: %s (%s) in %s, file %s, line %d",
|
464
|
+
errorStr, exc.err.c_str(), exc.func.size() > 0 ?
|
465
|
+
exc.func.c_str() : "unknown function", exc.file.c_str(), exc.line );
|
466
|
+
fprintf( stderr, "%s\n", buf );
|
467
|
+
fflush( stderr );
|
468
|
+
}
|
469
|
+
|
470
|
+
if(breakOnError)
|
471
|
+
{
|
472
|
+
static volatile int* p = 0;
|
473
|
+
*p = 0;
|
474
|
+
}
|
475
|
+
|
476
|
+
throw exc;
|
477
|
+
}
|
478
|
+
|
479
|
+
CvErrorCallback
|
480
|
+
redirectError( CvErrorCallback errCallback, void* userdata, void** prevUserdata)
|
481
|
+
{
|
482
|
+
if( prevUserdata )
|
483
|
+
*prevUserdata = customErrorCallbackData;
|
484
|
+
|
485
|
+
CvErrorCallback prevCallback = customErrorCallback;
|
486
|
+
|
487
|
+
customErrorCallback = errCallback;
|
488
|
+
customErrorCallbackData = userdata;
|
489
|
+
|
490
|
+
return prevCallback;
|
491
|
+
}
|
492
|
+
|
493
|
+
}
|
494
|
+
|
495
|
+
/*CV_IMPL int
|
496
|
+
cvGuiBoxReport( int code, const char *func_name, const char *err_msg,
|
497
|
+
const char *file, int line, void* )
|
498
|
+
{
|
499
|
+
#if (!defined WIN32 && !defined _WIN32) || defined WINCE
|
500
|
+
return cvStdErrReport( code, func_name, err_msg, file, line, 0 );
|
501
|
+
#else
|
502
|
+
if( code != CV_StsBackTrace && code != CV_StsAutoTrace )
|
503
|
+
{
|
504
|
+
size_t msg_len = strlen(err_msg ? err_msg : "") + 1024;
|
505
|
+
char* message = (char*)alloca(msg_len);
|
506
|
+
char title[100];
|
507
|
+
|
508
|
+
wsprintf( message, "%s (%s)\nin function %s, %s(%d)\n\n"
|
509
|
+
"Press \"Abort\" to terminate application.\n"
|
510
|
+
"Press \"Retry\" to debug (if the app is running under debugger).\n"
|
511
|
+
"Press \"Ignore\" to continue (this is not safe).\n",
|
512
|
+
cvErrorStr(code), err_msg ? err_msg : "no description",
|
513
|
+
func_name, file, line );
|
514
|
+
|
515
|
+
wsprintf( title, "OpenCV GUI Error Handler" );
|
516
|
+
|
517
|
+
int answer = MessageBox( NULL, message, title, MB_ICONERROR|MB_ABORTRETRYIGNORE|MB_SYSTEMMODAL );
|
518
|
+
|
519
|
+
if( answer == IDRETRY )
|
520
|
+
{
|
521
|
+
CV_DBG_BREAK();
|
522
|
+
}
|
523
|
+
return answer != IDIGNORE;
|
524
|
+
}
|
525
|
+
return 0;
|
526
|
+
#endif
|
527
|
+
}*/
|
528
|
+
|
529
|
+
CV_IMPL int cvCheckHardwareSupport(int feature)
|
530
|
+
{
|
531
|
+
CV_DbgAssert( 0 <= feature && feature <= CV_HARDWARE_MAX_FEATURE );
|
532
|
+
return cv::currentFeatures->have[feature];
|
533
|
+
}
|
534
|
+
|
535
|
+
CV_IMPL int cvUseOptimized( int flag )
|
536
|
+
{
|
537
|
+
int prevMode = cv::useOptimizedFlag;
|
538
|
+
cv::setUseOptimized( flag != 0 );
|
539
|
+
return prevMode;
|
540
|
+
}
|
541
|
+
|
542
|
+
CV_IMPL int64 cvGetTickCount(void)
|
543
|
+
{
|
544
|
+
return cv::getTickCount();
|
545
|
+
}
|
546
|
+
|
547
|
+
CV_IMPL double cvGetTickFrequency(void)
|
548
|
+
{
|
549
|
+
return cv::getTickFrequency()*1e-6;
|
550
|
+
}
|
551
|
+
|
552
|
+
CV_IMPL void cvSetNumThreads(int nt)
|
553
|
+
{
|
554
|
+
cv::setNumThreads(nt);
|
555
|
+
}
|
556
|
+
|
557
|
+
CV_IMPL int cvGetNumThreads()
|
558
|
+
{
|
559
|
+
return cv::getNumThreads();
|
560
|
+
}
|
561
|
+
|
562
|
+
CV_IMPL int cvGetThreadNum()
|
563
|
+
{
|
564
|
+
return cv::getThreadNum();
|
565
|
+
}
|
566
|
+
|
567
|
+
|
568
|
+
CV_IMPL CvErrorCallback
|
569
|
+
cvRedirectError( CvErrorCallback errCallback, void* userdata, void** prevUserdata)
|
570
|
+
{
|
571
|
+
return cv::redirectError(errCallback, userdata, prevUserdata);
|
572
|
+
}
|
573
|
+
|
574
|
+
CV_IMPL int cvNulDevReport( int, const char*, const char*,
|
575
|
+
const char*, int, void* )
|
576
|
+
{
|
577
|
+
return 0;
|
578
|
+
}
|
579
|
+
|
580
|
+
CV_IMPL int cvStdErrReport( int, const char*, const char*,
|
581
|
+
const char*, int, void* )
|
582
|
+
{
|
583
|
+
return 0;
|
584
|
+
}
|
585
|
+
|
586
|
+
CV_IMPL int cvGuiBoxReport( int, const char*, const char*,
|
587
|
+
const char*, int, void* )
|
588
|
+
{
|
589
|
+
return 0;
|
590
|
+
}
|
591
|
+
|
592
|
+
CV_IMPL int cvGetErrInfo( const char**, const char**, const char**, int* )
|
593
|
+
{
|
594
|
+
return 0;
|
595
|
+
}
|
596
|
+
|
597
|
+
|
598
|
+
CV_IMPL const char* cvErrorStr( int status )
|
599
|
+
{
|
600
|
+
static char buf[256];
|
601
|
+
|
602
|
+
switch (status)
|
603
|
+
{
|
604
|
+
case CV_StsOk : return "No Error";
|
605
|
+
case CV_StsBackTrace : return "Backtrace";
|
606
|
+
case CV_StsError : return "Unspecified error";
|
607
|
+
case CV_StsInternal : return "Internal error";
|
608
|
+
case CV_StsNoMem : return "Insufficient memory";
|
609
|
+
case CV_StsBadArg : return "Bad argument";
|
610
|
+
case CV_StsNoConv : return "Iterations do not converge";
|
611
|
+
case CV_StsAutoTrace : return "Autotrace call";
|
612
|
+
case CV_StsBadSize : return "Incorrect size of input array";
|
613
|
+
case CV_StsNullPtr : return "Null pointer";
|
614
|
+
case CV_StsDivByZero : return "Division by zero occured";
|
615
|
+
case CV_BadStep : return "Image step is wrong";
|
616
|
+
case CV_StsInplaceNotSupported : return "Inplace operation is not supported";
|
617
|
+
case CV_StsObjectNotFound : return "Requested object was not found";
|
618
|
+
case CV_BadDepth : return "Input image depth is not supported by function";
|
619
|
+
case CV_StsUnmatchedFormats : return "Formats of input arguments do not match";
|
620
|
+
case CV_StsUnmatchedSizes : return "Sizes of input arguments do not match";
|
621
|
+
case CV_StsOutOfRange : return "One of arguments\' values is out of range";
|
622
|
+
case CV_StsUnsupportedFormat : return "Unsupported format or combination of formats";
|
623
|
+
case CV_BadCOI : return "Input COI is not supported";
|
624
|
+
case CV_BadNumChannels : return "Bad number of channels";
|
625
|
+
case CV_StsBadFlag : return "Bad flag (parameter or structure field)";
|
626
|
+
case CV_StsBadPoint : return "Bad parameter of type CvPoint";
|
627
|
+
case CV_StsBadMask : return "Bad type of mask argument";
|
628
|
+
case CV_StsParseError : return "Parsing error";
|
629
|
+
case CV_StsNotImplemented : return "The function/feature is not implemented";
|
630
|
+
case CV_StsBadMemBlock : return "Memory block has been corrupted";
|
631
|
+
case CV_StsAssert : return "Assertion failed";
|
632
|
+
case CV_GpuNotSupported : return "No GPU support";
|
633
|
+
case CV_GpuApiCallError : return "Gpu Api call";
|
634
|
+
case CV_GpuNppCallError : return "Npp Api call";
|
635
|
+
};
|
636
|
+
|
637
|
+
sprintf(buf, "Unknown %s code %d", status >= 0 ? "status":"error", status);
|
638
|
+
return buf;
|
639
|
+
}
|
640
|
+
|
641
|
+
CV_IMPL int cvGetErrMode(void)
|
642
|
+
{
|
643
|
+
return 0;
|
644
|
+
}
|
645
|
+
|
646
|
+
CV_IMPL int cvSetErrMode(int)
|
647
|
+
{
|
648
|
+
return 0;
|
649
|
+
}
|
650
|
+
|
651
|
+
CV_IMPL int cvGetErrStatus(void)
|
652
|
+
{
|
653
|
+
return 0;
|
654
|
+
}
|
655
|
+
|
656
|
+
CV_IMPL void cvSetErrStatus(int)
|
657
|
+
{
|
658
|
+
}
|
659
|
+
|
660
|
+
|
661
|
+
CV_IMPL void cvError( int code, const char* func_name,
|
662
|
+
const char* err_msg,
|
663
|
+
const char* file_name, int line )
|
664
|
+
{
|
665
|
+
cv::error(cv::Exception(code, err_msg, func_name, file_name, line));
|
666
|
+
}
|
667
|
+
|
668
|
+
/* function, which converts int to int */
|
669
|
+
CV_IMPL int
|
670
|
+
cvErrorFromIppStatus( int status )
|
671
|
+
{
|
672
|
+
switch (status)
|
673
|
+
{
|
674
|
+
case CV_BADSIZE_ERR: return CV_StsBadSize;
|
675
|
+
case CV_BADMEMBLOCK_ERR: return CV_StsBadMemBlock;
|
676
|
+
case CV_NULLPTR_ERR: return CV_StsNullPtr;
|
677
|
+
case CV_DIV_BY_ZERO_ERR: return CV_StsDivByZero;
|
678
|
+
case CV_BADSTEP_ERR: return CV_BadStep;
|
679
|
+
case CV_OUTOFMEM_ERR: return CV_StsNoMem;
|
680
|
+
case CV_BADARG_ERR: return CV_StsBadArg;
|
681
|
+
case CV_NOTDEFINED_ERR: return CV_StsError;
|
682
|
+
case CV_INPLACE_NOT_SUPPORTED_ERR: return CV_StsInplaceNotSupported;
|
683
|
+
case CV_NOTFOUND_ERR: return CV_StsObjectNotFound;
|
684
|
+
case CV_BADCONVERGENCE_ERR: return CV_StsNoConv;
|
685
|
+
case CV_BADDEPTH_ERR: return CV_BadDepth;
|
686
|
+
case CV_UNMATCHED_FORMATS_ERR: return CV_StsUnmatchedFormats;
|
687
|
+
case CV_UNSUPPORTED_COI_ERR: return CV_BadCOI;
|
688
|
+
case CV_UNSUPPORTED_CHANNELS_ERR: return CV_BadNumChannels;
|
689
|
+
case CV_BADFLAG_ERR: return CV_StsBadFlag;
|
690
|
+
case CV_BADRANGE_ERR: return CV_StsBadArg;
|
691
|
+
case CV_BADCOEF_ERR: return CV_StsBadArg;
|
692
|
+
case CV_BADFACTOR_ERR: return CV_StsBadArg;
|
693
|
+
case CV_BADPOINT_ERR: return CV_StsBadPoint;
|
694
|
+
|
695
|
+
default:
|
696
|
+
return CV_StsError;
|
697
|
+
}
|
698
|
+
}
|
699
|
+
|
700
|
+
static CvModuleInfo cxcore_info = { 0, "cxcore", CV_VERSION, 0 };
|
701
|
+
|
702
|
+
CvModuleInfo* CvModule::first = 0, *CvModule::last = 0;
|
703
|
+
|
704
|
+
CvModule::CvModule( CvModuleInfo* _info )
|
705
|
+
{
|
706
|
+
cvRegisterModule( _info );
|
707
|
+
info = last;
|
708
|
+
}
|
709
|
+
|
710
|
+
CvModule::~CvModule(void)
|
711
|
+
{
|
712
|
+
if( info )
|
713
|
+
{
|
714
|
+
CvModuleInfo* p = first;
|
715
|
+
for( ; p != 0 && p->next != info; p = p->next )
|
716
|
+
;
|
717
|
+
|
718
|
+
if( p )
|
719
|
+
p->next = info->next;
|
720
|
+
|
721
|
+
if( first == info )
|
722
|
+
first = info->next;
|
723
|
+
|
724
|
+
if( last == info )
|
725
|
+
last = p;
|
726
|
+
|
727
|
+
free( info );
|
728
|
+
info = 0;
|
729
|
+
}
|
730
|
+
}
|
731
|
+
|
732
|
+
CV_IMPL int
|
733
|
+
cvRegisterModule( const CvModuleInfo* module )
|
734
|
+
{
|
735
|
+
CV_Assert( module != 0 && module->name != 0 && module->version != 0 );
|
736
|
+
|
737
|
+
size_t name_len = strlen(module->name);
|
738
|
+
size_t version_len = strlen(module->version);
|
739
|
+
|
740
|
+
CvModuleInfo* module_copy = (CvModuleInfo*)malloc( sizeof(*module_copy) +
|
741
|
+
name_len + 1 + version_len + 1 );
|
742
|
+
|
743
|
+
*module_copy = *module;
|
744
|
+
module_copy->name = (char*)(module_copy + 1);
|
745
|
+
module_copy->version = (char*)(module_copy + 1) + name_len + 1;
|
746
|
+
|
747
|
+
memcpy( (void*)module_copy->name, module->name, name_len + 1 );
|
748
|
+
memcpy( (void*)module_copy->version, module->version, version_len + 1 );
|
749
|
+
module_copy->next = 0;
|
750
|
+
|
751
|
+
if( CvModule::first == 0 )
|
752
|
+
CvModule::first = module_copy;
|
753
|
+
else
|
754
|
+
CvModule::last->next = module_copy;
|
755
|
+
|
756
|
+
CvModule::last = module_copy;
|
757
|
+
|
758
|
+
return 0;
|
759
|
+
}
|
760
|
+
|
761
|
+
CvModule cxcore_module( &cxcore_info );
|
762
|
+
|
763
|
+
CV_IMPL void
|
764
|
+
cvGetModuleInfo( const char* name, const char **version, const char **plugin_list )
|
765
|
+
{
|
766
|
+
static char joint_verinfo[1024] = "";
|
767
|
+
static char plugin_list_buf[1024] = "";
|
768
|
+
|
769
|
+
if( version )
|
770
|
+
*version = 0;
|
771
|
+
|
772
|
+
if( plugin_list )
|
773
|
+
*plugin_list = 0;
|
774
|
+
|
775
|
+
CvModuleInfo* module;
|
776
|
+
|
777
|
+
if( version )
|
778
|
+
{
|
779
|
+
if( name )
|
780
|
+
{
|
781
|
+
size_t i, name_len = strlen(name);
|
782
|
+
|
783
|
+
for( module = CvModule::first; module != 0; module = module->next )
|
784
|
+
{
|
785
|
+
if( strlen(module->name) == name_len )
|
786
|
+
{
|
787
|
+
for( i = 0; i < name_len; i++ )
|
788
|
+
{
|
789
|
+
int c0 = toupper(module->name[i]), c1 = toupper(name[i]);
|
790
|
+
if( c0 != c1 )
|
791
|
+
break;
|
792
|
+
}
|
793
|
+
if( i == name_len )
|
794
|
+
break;
|
795
|
+
}
|
796
|
+
}
|
797
|
+
if( !module )
|
798
|
+
CV_Error( CV_StsObjectNotFound, "The module is not found" );
|
799
|
+
|
800
|
+
*version = module->version;
|
801
|
+
}
|
802
|
+
else
|
803
|
+
{
|
804
|
+
char* ptr = joint_verinfo;
|
805
|
+
|
806
|
+
for( module = CvModule::first; module != 0; module = module->next )
|
807
|
+
{
|
808
|
+
sprintf( ptr, "%s: %s%s", module->name, module->version, module->next ? ", " : "" );
|
809
|
+
ptr += strlen(ptr);
|
810
|
+
}
|
811
|
+
|
812
|
+
*version = joint_verinfo;
|
813
|
+
}
|
814
|
+
}
|
815
|
+
|
816
|
+
if( plugin_list )
|
817
|
+
*plugin_list = plugin_list_buf;
|
818
|
+
}
|
819
|
+
|
820
|
+
#if defined BUILD_SHARED_LIBS && defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
|
821
|
+
BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID )
|
822
|
+
{
|
823
|
+
if( fdwReason == DLL_THREAD_DETACH || fdwReason == DLL_PROCESS_DETACH )
|
824
|
+
{
|
825
|
+
cv::deleteThreadAllocData();
|
826
|
+
cv::deleteThreadRNGData();
|
827
|
+
}
|
828
|
+
return TRUE;
|
829
|
+
}
|
830
|
+
#endif
|
831
|
+
|
832
|
+
/* End of file. */
|