Skip to content

Commit 9fa5050

Browse files
committed
Merge pull request opencv#10263 from mshabunin:embedded-build
2 parents 61c2f09 + 7349b8f commit 9fa5050

25 files changed

+184
-135
lines changed

cmake/OpenCVGenConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME)
103103
endif()
104104
endfunction()
105105

106-
if(UNIX AND NOT ANDROID)
106+
if((CMAKE_HOST_SYSTEM_NAME MATCHES "Linux" OR UNIX) AND NOT ANDROID)
107107
ocv_gen_config("${CMAKE_BINARY_DIR}/unix-install" "" "")
108108
endif()
109109

modules/calib3d/src/calibinit.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
431431

432432
cv::Ptr<CvMemStorage> storage;
433433

434-
try
434+
CV_TRY
435435
{
436436
int k = 0;
437437
const int min_dilations = 0;
@@ -617,11 +617,11 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
617617
cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 15, 0.1));
618618
}
619619
}
620-
catch(...)
620+
CV_CATCH_ALL
621621
{
622622
cvFree(&quads);
623623
cvFree(&corners);
624-
throw;
624+
CV_RETHROW();
625625
}
626626
cvFree(&quads);
627627
cvFree(&corners);
@@ -2151,13 +2151,13 @@ bool cv::findCirclesGrid2( InputArray _image, Size patternSize,
21512151
void* oldCbkData;
21522152
ErrorCallback oldCbk = redirectError(quiet_error, 0, &oldCbkData);
21532153
#endif
2154-
try
2154+
CV_TRY
21552155
{
21562156
isFound = boxFinder.findHoles();
21572157
}
2158-
catch (const cv::Exception &)
2158+
CV_CATCH(Exception, e)
21592159
{
2160-
2160+
CV_UNUSED(e);
21612161
}
21622162
#if BE_QUIET
21632163
redirectError(oldCbk, oldCbkData);

modules/core/include/opencv2/core/base.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,23 @@ enum BorderTypes {
342342
#define CV_SUPPRESS_DEPRECATED_START
343343
#define CV_SUPPRESS_DEPRECATED_END
344344
#endif
345+
345346
#define CV_UNUSED(name) (void)name
347+
348+
#if defined __GNUC__ && !defined __EXCEPTIONS
349+
#define CV_TRY
350+
#define CV_CATCH(A, B) for (A B; false; )
351+
#define CV_CATCH_ALL if (false)
352+
#define CV_THROW(A) abort()
353+
#define CV_RETHROW() abort()
354+
#else
355+
#define CV_TRY try
356+
#define CV_CATCH(A, B) catch(const A & B)
357+
#define CV_CATCH_ALL catch(...)
358+
#define CV_THROW(A) throw A
359+
#define CV_RETHROW() throw
360+
#endif
361+
346362
//! @endcond
347363

348364
/*! @brief Signals an error and raises the exception.

modules/core/include/opencv2/core/hal/interface.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232
#if !defined _MSC_VER && !defined __BORLANDC__
3333
# if defined __cplusplus && __cplusplus >= 201103L && !defined __APPLE__
3434
# include <cstdint>
35-
typedef std::uint32_t uint;
35+
# ifdef __NEWLIB__
36+
typedef unsigned int uint;
37+
# else
38+
typedef std::uint32_t uint;
39+
# endif
3640
# else
3741
# include <stdint.h>
3842
typedef uint32_t uint;

modules/core/include/opencv2/core/softfloat.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ struct CV_EXPORTS softfloat
122122
explicit softfloat( const uint64_t );
123123
explicit softfloat( const int32_t );
124124
explicit softfloat( const int64_t );
125+
126+
#ifdef CV_INT32_T_IS_LONG_INT
127+
// for platforms with int32_t = long int
128+
explicit softfloat( const int a ) { *this = softfloat(static_cast<int32_t>(a)); }
129+
#endif
130+
125131
/** @brief Construct from float */
126132
explicit softfloat( const float a ) { Cv32suf s; s.f = a; v = s.u; }
127133

@@ -253,6 +259,12 @@ struct CV_EXPORTS softdouble
253259
explicit softdouble( const uint64_t );
254260
explicit softdouble( const int32_t );
255261
explicit softdouble( const int64_t );
262+
263+
#ifdef CV_INT32_T_IS_LONG_INT
264+
// for platforms with int32_t = long int
265+
explicit softdouble( const int a ) { *this = softdouble(static_cast<int32_t>(a)); }
266+
#endif
267+
256268
/** @brief Construct from double */
257269
explicit softdouble( const double a ) { Cv64suf s; s.f = a; v = s.u; }
258270

modules/core/src/command_line_parser.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static void from_str(const String& str, int type, void* dst)
115115

116116
void CommandLineParser::getByName(const String& name, bool space_delete, int type, void* dst) const
117117
{
118-
try
118+
CV_TRY
119119
{
120120
for (size_t i = 0; i < impl->data.size(); i++)
121121
{
@@ -140,20 +140,19 @@ void CommandLineParser::getByName(const String& name, bool space_delete, int typ
140140
}
141141
}
142142
}
143-
catch (Exception& e)
143+
CV_CATCH (Exception, e)
144144
{
145145
impl->error = true;
146146
impl->error_message = impl->error_message + "Parameter '"+ name + "': " + e.err + "\n";
147147
return;
148148
}
149-
150149
CV_Error_(Error::StsBadArg, ("undeclared key '%s' requested", name.c_str()));
151150
}
152151

153152

154153
void CommandLineParser::getByIndex(int index, bool space_delete, int type, void* dst) const
155154
{
156-
try
155+
CV_TRY
157156
{
158157
for (size_t i = 0; i < impl->data.size(); i++)
159158
{
@@ -173,13 +172,12 @@ void CommandLineParser::getByIndex(int index, bool space_delete, int type, void*
173172
}
174173
}
175174
}
176-
catch(Exception& e)
175+
CV_CATCH(Exception, e)
177176
{
178177
impl->error = true;
179178
impl->error_message = impl->error_message + format("Parameter #%d: ", index) + e.err + "\n";
180179
return;
181180
}
182-
183181
CV_Error_(Error::StsBadArg, ("undeclared position %d requested", index));
184182
}
185183

@@ -454,14 +452,13 @@ std::vector<String> CommandLineParser::Impl::split_range_string(const String& _s
454452
std::vector<String> vec;
455453
String word = "";
456454
bool begin = false;
457-
458455
while (!str.empty())
459456
{
460457
if (str[0] == fs)
461458
{
462459
if (begin == true)
463460
{
464-
throw cv::Exception(CV_StsParseError,
461+
CV_THROW (cv::Exception(CV_StsParseError,
465462
String("error in split_range_string(")
466463
+ str
467464
+ String(", ")
@@ -470,7 +467,7 @@ std::vector<String> CommandLineParser::Impl::split_range_string(const String& _s
470467
+ String(1, ss)
471468
+ String(")"),
472469
"", __FILE__, __LINE__
473-
);
470+
));
474471
}
475472
begin = true;
476473
word = "";
@@ -481,7 +478,7 @@ std::vector<String> CommandLineParser::Impl::split_range_string(const String& _s
481478
{
482479
if (begin == false)
483480
{
484-
throw cv::Exception(CV_StsParseError,
481+
CV_THROW (cv::Exception(CV_StsParseError,
485482
String("error in split_range_string(")
486483
+ str
487484
+ String(", ")
@@ -490,7 +487,7 @@ std::vector<String> CommandLineParser::Impl::split_range_string(const String& _s
490487
+ String(1, ss)
491488
+ String(")"),
492489
"", __FILE__, __LINE__
493-
);
490+
));
494491
}
495492
begin = false;
496493
vec.push_back(word);
@@ -505,7 +502,7 @@ std::vector<String> CommandLineParser::Impl::split_range_string(const String& _s
505502

506503
if (begin == true)
507504
{
508-
throw cv::Exception(CV_StsParseError,
505+
CV_THROW (cv::Exception(CV_StsParseError,
509506
String("error in split_range_string(")
510507
+ str
511508
+ String(", ")
@@ -514,9 +511,8 @@ std::vector<String> CommandLineParser::Impl::split_range_string(const String& _s
514511
+ String(1, ss)
515512
+ String(")"),
516513
"", __FILE__, __LINE__
517-
);
514+
));
518515
}
519-
520516
return vec;
521517
}
522518

modules/core/src/glob.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static void glob_rec(const cv::String& directory, const cv::String& wildchart, s
231231
if ((dir = opendir (directory.c_str())) != 0)
232232
{
233233
/* find all the files and directories within directory */
234-
try
234+
CV_TRY
235235
{
236236
struct dirent *ent;
237237
while ((ent = readdir (dir)) != 0)
@@ -255,10 +255,10 @@ static void glob_rec(const cv::String& directory, const cv::String& wildchart, s
255255
result.push_back(entry);
256256
}
257257
}
258-
catch (...)
258+
CV_CATCH_ALL
259259
{
260260
closedir(dir);
261-
throw;
261+
CV_RETHROW();
262262
}
263263
closedir(dir);
264264
}

modules/core/src/lda.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ class EigenvalueDecomposition {
863863
d = alloc_1d<double> (n);
864864
e = alloc_1d<double> (n);
865865
ort = alloc_1d<double> (n);
866-
try {
866+
CV_TRY {
867867
// Reduce to Hessenberg form.
868868
orthes();
869869
// Reduce Hessenberg to real Schur form.
@@ -881,10 +881,10 @@ class EigenvalueDecomposition {
881881
// Deallocate the memory by releasing all internal working data.
882882
release();
883883
}
884-
catch (...)
884+
CV_CATCH_ALL
885885
{
886886
release();
887-
throw;
887+
CV_RETHROW();
888888
}
889889
}
890890

modules/core/src/matrix.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,12 @@ void Mat::create(int d, const int* _sizes, int _type)
424424
#endif
425425
if(!a)
426426
a = a0;
427-
try
427+
CV_TRY
428428
{
429429
u = a->allocate(dims, size, _type, 0, step.p, 0, USAGE_DEFAULT);
430430
CV_Assert(u != 0);
431431
}
432-
catch(...)
432+
CV_CATCH_ALL
433433
{
434434
if(a != a0)
435435
u = a0->allocate(dims, size, _type, 0, step.p, 0, USAGE_DEFAULT);
@@ -484,7 +484,7 @@ Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange)
484484
}
485485

486486
*this = m;
487-
try
487+
CV_TRY
488488
{
489489
if( _rowRange != Range::all() && _rowRange != Range(0,rows) )
490490
{
@@ -505,10 +505,10 @@ Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange)
505505
flags |= SUBMATRIX_FLAG;
506506
}
507507
}
508-
catch(...)
508+
CV_CATCH_ALL
509509
{
510510
release();
511-
throw;
511+
CV_RETHROW();
512512
}
513513

514514
if( rows == 1 )

modules/core/src/ocl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,11 +867,11 @@ bool useOpenCL()
867867
CoreTLSData* data = getCoreTlsData().get();
868868
if( data->useOpenCL < 0 )
869869
{
870-
try
870+
CV_TRY
871871
{
872872
data->useOpenCL = (int)(haveOpenCL() && Device::getDefault().ptr() && Device::getDefault().available()) ? 1 : 0;
873873
}
874-
catch (...)
874+
CV_CATCH_ALL
875875
{
876876
data->useOpenCL = 0;
877877
}

0 commit comments

Comments
 (0)