-
Notifications
You must be signed in to change notification settings - Fork 0
/
CvInc.h
220 lines (197 loc) · 7.04 KB
/
CvInc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/***************************************************************************************************************:')
CvInc.h
Fabrice Le Bars
Created : 2018-08-07
***************************************************************************************************************:)*/
// Prevent Visual Studio Intellisense from defining _WIN32 and _MSC_VER when we use
// Visual Studio to edit Linux or Borland C++ code.
#ifdef __linux__
# undef _WIN32
#endif // __linux__
#if defined(__GNUC__) || defined(__BORLANDC__)
# undef _MSC_VER
#endif // defined(__GNUC__) || defined(__BORLANDC__)
#ifndef CVINC_H
#define CVINC_H
#ifdef _MSC_VER
// Disable some Visual Studio warnings.
#pragma warning(disable : 4100)
#pragma warning(disable : 4458)
#pragma warning(disable : 4996)
#pragma warning(disable : 6204)
#pragma warning(disable : 6201)
#pragma warning(disable : 6294)
#pragma warning(disable : 6385)
#endif // _MSC_VER
#ifdef __BORLANDC__
// Disable some Borland C++ Builder warnings.
#pragma warn -8019
#endif // __BORLANDC__
#ifdef __GNUC__
// Disable some GCC warnings.
#if (__GNUC__ >= 9)
#pragma GCC diagnostic ignored "-Wdeprecated-copy"
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif // (__GNUC__ >= 9)
//#pragma GCC diagnostic ignored "-Wunused-parameter"
//#pragma GCC diagnostic ignored "-Wunused-variable"
//#pragma GCC diagnostic ignored "-Wunused-value"
#pragma GCC diagnostic ignored "-Wunused-function"
//#pragma GCC diagnostic ignored "-Wunused"
//#pragma GCC diagnostic ignored "-Wcomment"
//#pragma GCC diagnostic ignored "-Wuninitialized"
//#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
#pragma GCC diagnostic push
#endif // (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
#endif // __GNUC__
// OpenCV headers.
#ifndef DISABLE_OPENCV_VERSION
// This header should only contain simple C code without dependencies on other headers...
#include "opencv2/core/version.hpp"
#else
// OpenCV 1.X.X...
#include "cv.h"
#include "cvaux.h"
#include "highgui.h"
#endif // !DISABLE_OPENCV_VERSION
// Temporary workaround because many conversions from C to C++ types are disabled by default after OpenCV 4.2.0...
#ifndef DISABLE_OPENCV_C_API_CTORS
#if (CV_MAJOR_VERSION >= 4)
#if (CV_MINOR_VERSION >= 2)
#ifndef CV__ENABLE_C_API_CTORS
#define CV__ENABLE_C_API_CTORS
#endif // !CV__ENABLE_C_API_CTORS
#ifndef CV__SKIP_MESSAGE_MALFORMED_C_API_CTORS
#define CV__SKIP_MESSAGE_MALFORMED_C_API_CTORS
#endif // !CV__SKIP_MESSAGE_MALFORMED_C_API_CTORS
#endif // (CV_MINOR_VERSION >= 2)
#endif // (CV_MAJOR_VERSION >= 4)
#endif // !DISABLE_OPENCV_C_API_CTORS
#if (CV_MAJOR_VERSION >= 2)
// To try to solve cvRound() undefined problem in C mode in OpenCV 3.1.0...
// After OpenCV 3.2.0, C mode will probably not build any more due to several problems in core OpenCV headers...
// Starting with OpenCV 4.0.0, most of the C headers have been removed...
#if (CV_MAJOR_VERSION == 3)
#include "opencv2/core/fast_math.hpp"
#endif // (CV_MAJOR_VERSION == 3)
//#include "opencv/cv.h" // Sometimes cause strange errors in debug and C++ mode due to the redefinition of free()...
//#include "opencv/cvwimage.h"
//#include "opencv/cxcore.h"
//#include "opencv/highgui.h"
#include "opencv2/core/core_c.h"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/highgui/highgui_c.h"
#if (CV_MAJOR_VERSION == 3)
#include "opencv2/imgcodecs/imgcodecs_c.h"
#include "opencv2/videoio/videoio_c.h"
#endif // (CV_MAJOR_VERSION == 3)
#if (CV_MAJOR_VERSION >= 4)
#include "opencv2/imgcodecs/legacy/constants_c.h"
#include "opencv2/videoio/legacy/constants_c.h"
#include "opencv2/videoio/videoio_c.h"
#endif // (CV_MAJOR_VERSION >= 4)
// The following headers do not build in C mode.
#ifdef __cplusplus
#if ((CV_MAJOR_VERSION == 2) || (CV_MAJOR_VERSION == 3))
//#include "opencv/cvaux.h" // Not found on Ubuntu 12.04...?
//#include "opencv/cxmisc.h"
//#include "opencv/ml.h"
#endif // ((CV_MAJOR_VERSION == 2) || (CV_MAJOR_VERSION == 3))
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#if (CV_MAJOR_VERSION >= 3)
#include "opencv2/imgcodecs/imgcodecs.hpp"
#include "opencv2/videoio/videoio.hpp"
#endif // (CV_MAJOR_VERSION >= 3)
//#include "opencv2/contrib/contrib.hpp"
#endif // __cplusplus
#endif // (CV_MAJOR_VERSION >= 2)
// min and max may be undefined so we need to redefine them here...
#if (CV_MAJOR_VERSION >= 2)
#ifdef _MSC_VER
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif // !max
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif // !min
#endif // _MSC_VER
#endif // (CV_MAJOR_VERSION >= 2)
// Some macros might be missing depending on OpenCV versions...
#ifndef DISABLE_OPENCV_COMPAT_MACROS
#define DISABLE_OPENCV_COMPAT_MACROS // Needed to avoid redefinition errors...
#ifdef __cplusplus
#if (CV_MAJOR_VERSION < 3)
namespace cv
{
enum
{
CAP_PROP_FRAME_WIDTH = CV_CAP_PROP_FRAME_WIDTH,
CAP_PROP_FRAME_HEIGHT = CV_CAP_PROP_FRAME_HEIGHT
};
// Don't know how to define cv::VideoWriter::fourcc...
}
#endif // (CV_MAJOR_VERSION < 3)
#endif // __cplusplus
#endif // !DISABLE_OPENCV_COMPAT_MACROS
// The ENTER key code seems to vary depending on OpenCV versions...
#ifndef CV_KEY_CODE_ENTER
#ifdef _WIN32
#define CV_KEY_CODE_ENTER 13
#else
#if (CV_MAJOR_VERSION >= 4)
#define CV_KEY_CODE_ENTER 13
#else
#ifdef __APPLE__
#define CV_KEY_CODE_ENTER 13
#else
#define CV_KEY_CODE_ENTER 10
#endif // __APPLE__
#endif // (CV_MAJOR_VERSION >= 4)
#endif // _WIN32
#endif // !CV_KEY_CODE_ENTER
// CV_RGB does not always work with CvScalar after OpenCV 4.2.0...
#ifndef CV_RGB_CvScalar
#define CV_RGB_CvScalar(r, g, b) cvScalar((b), (g), (r), 0)
#endif // !CV_RGB_CvScalar
#if (CV_MAJOR_VERSION >= 4)
#ifndef USE_OPENCV_HIGHGUI_CPP_API
#define USE_OPENCV_HIGHGUI_CPP_API
#endif // !USE_OPENCV_HIGHGUI_CPP_API
#endif // (CV_MAJOR_VERSION >= 4)
#ifdef __GNUC__
// Restore the GCC warnings previously disabled.
#if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
#pragma GCC diagnostic pop
#else
//#pragma GCC diagnostic warning "-Wunknown-pragmas"
//#pragma GCC diagnostic warning "-Wuninitialized"
//#pragma GCC diagnostic warning "-Wcomment"
//#pragma GCC diagnostic warning "-Wunused"
#pragma GCC diagnostic warning "-Wunused-function"
//#pragma GCC diagnostic warning "-Wunused-value"
//#pragma GCC diagnostic warning "-Wunused-variable"
//#pragma GCC diagnostic warning "-Wunused-parameter"
//#if (__GNUC__ >= 9)
//#pragma GCC diagnostic warning "-Wclass-memaccess"
//#pragma GCC diagnostic warning "-Wdeprecated-copy"
//#endif // (__GNUC__ >= 9)
#endif // (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
#endif // __GNUC__
#ifdef __BORLANDC__
// Restore the Borland C++ Builder warnings previously disabled.
#pragma warn .8019
#endif // __BORLANDC__
#ifdef _MSC_VER
// Restore the Visual Studio warnings previously disabled.
#pragma warning(default : 6385)
#pragma warning(default : 6294)
#pragma warning(default : 6201)
#pragma warning(default : 6204)
#pragma warning(default : 4996)
#pragma warning(default : 4458)
#pragma warning(default : 4100)
#endif // _MSC_VER
#endif // !CVINC_H