1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Build for embedded systems

This commit is contained in:
Maksim Shabunin
2017-11-28 12:53:40 +03:00
parent 9665dde678
commit 7349b8f5ce
25 changed files with 184 additions and 135 deletions
@@ -342,7 +342,23 @@ enum BorderTypes {
#define CV_SUPPRESS_DEPRECATED_START
#define CV_SUPPRESS_DEPRECATED_END
#endif
#define CV_UNUSED(name) (void)name
#if defined __GNUC__ && !defined __EXCEPTIONS
#define CV_TRY
#define CV_CATCH(A, B) for (A B; false; )
#define CV_CATCH_ALL if (false)
#define CV_THROW(A) abort()
#define CV_RETHROW() abort()
#else
#define CV_TRY try
#define CV_CATCH(A, B) catch(const A & B)
#define CV_CATCH_ALL catch(...)
#define CV_THROW(A) throw A
#define CV_RETHROW() throw
#endif
//! @endcond
/*! @brief Signals an error and raises the exception.
@@ -32,7 +32,11 @@
#if !defined _MSC_VER && !defined __BORLANDC__
# if defined __cplusplus && __cplusplus >= 201103L && !defined __APPLE__
# include <cstdint>
typedef std::uint32_t uint;
# ifdef __NEWLIB__
typedef unsigned int uint;
# else
typedef std::uint32_t uint;
# endif
# else
# include <stdint.h>
typedef uint32_t uint;
@@ -122,6 +122,12 @@ public:
explicit softfloat( const uint64_t );
explicit softfloat( const int32_t );
explicit softfloat( const int64_t );
#ifdef CV_INT32_T_IS_LONG_INT
// for platforms with int32_t = long int
explicit softfloat( const int a ) { *this = softfloat(static_cast<int32_t>(a)); }
#endif
/** @brief Construct from float */
explicit softfloat( const float a ) { Cv32suf s; s.f = a; v = s.u; }
@@ -253,6 +259,12 @@ public:
explicit softdouble( const uint64_t );
explicit softdouble( const int32_t );
explicit softdouble( const int64_t );
#ifdef CV_INT32_T_IS_LONG_INT
// for platforms with int32_t = long int
explicit softdouble( const int a ) { *this = softdouble(static_cast<int32_t>(a)); }
#endif
/** @brief Construct from double */
explicit softdouble( const double a ) { Cv64suf s; s.f = a; v = s.u; }
+10 -14
View File
@@ -115,7 +115,7 @@ static void from_str(const String& str, int type, void* dst)
void CommandLineParser::getByName(const String& name, bool space_delete, int type, void* dst) const
{
try
CV_TRY
{
for (size_t i = 0; i < impl->data.size(); i++)
{
@@ -140,20 +140,19 @@ void CommandLineParser::getByName(const String& name, bool space_delete, int typ
}
}
}
catch (Exception& e)
CV_CATCH (Exception, e)
{
impl->error = true;
impl->error_message = impl->error_message + "Parameter '"+ name + "': " + e.err + "\n";
return;
}
CV_Error_(Error::StsBadArg, ("undeclared key '%s' requested", name.c_str()));
}
void CommandLineParser::getByIndex(int index, bool space_delete, int type, void* dst) const
{
try
CV_TRY
{
for (size_t i = 0; i < impl->data.size(); i++)
{
@@ -173,13 +172,12 @@ void CommandLineParser::getByIndex(int index, bool space_delete, int type, void*
}
}
}
catch(Exception& e)
CV_CATCH(Exception, e)
{
impl->error = true;
impl->error_message = impl->error_message + format("Parameter #%d: ", index) + e.err + "\n";
return;
}
CV_Error_(Error::StsBadArg, ("undeclared position %d requested", index));
}
@@ -454,14 +452,13 @@ std::vector<String> CommandLineParser::Impl::split_range_string(const String& _s
std::vector<String> vec;
String word = "";
bool begin = false;
while (!str.empty())
{
if (str[0] == fs)
{
if (begin == true)
{
throw cv::Exception(CV_StsParseError,
CV_THROW (cv::Exception(CV_StsParseError,
String("error in split_range_string(")
+ str
+ String(", ")
@@ -470,7 +467,7 @@ std::vector<String> CommandLineParser::Impl::split_range_string(const String& _s
+ String(1, ss)
+ String(")"),
"", __FILE__, __LINE__
);
));
}
begin = true;
word = "";
@@ -481,7 +478,7 @@ std::vector<String> CommandLineParser::Impl::split_range_string(const String& _s
{
if (begin == false)
{
throw cv::Exception(CV_StsParseError,
CV_THROW (cv::Exception(CV_StsParseError,
String("error in split_range_string(")
+ str
+ String(", ")
@@ -490,7 +487,7 @@ std::vector<String> CommandLineParser::Impl::split_range_string(const String& _s
+ String(1, ss)
+ String(")"),
"", __FILE__, __LINE__
);
));
}
begin = false;
vec.push_back(word);
@@ -505,7 +502,7 @@ std::vector<String> CommandLineParser::Impl::split_range_string(const String& _s
if (begin == true)
{
throw cv::Exception(CV_StsParseError,
CV_THROW (cv::Exception(CV_StsParseError,
String("error in split_range_string(")
+ str
+ String(", ")
@@ -514,9 +511,8 @@ std::vector<String> CommandLineParser::Impl::split_range_string(const String& _s
+ String(1, ss)
+ String(")"),
"", __FILE__, __LINE__
);
));
}
return vec;
}
+3 -3
View File
@@ -231,7 +231,7 @@ static void glob_rec(const cv::String& directory, const cv::String& wildchart, s
if ((dir = opendir (directory.c_str())) != 0)
{
/* find all the files and directories within directory */
try
CV_TRY
{
struct dirent *ent;
while ((ent = readdir (dir)) != 0)
@@ -255,10 +255,10 @@ static void glob_rec(const cv::String& directory, const cv::String& wildchart, s
result.push_back(entry);
}
}
catch (...)
CV_CATCH_ALL
{
closedir(dir);
throw;
CV_RETHROW();
}
closedir(dir);
}
+3 -3
View File
@@ -863,7 +863,7 @@ private:
d = alloc_1d<double> (n);
e = alloc_1d<double> (n);
ort = alloc_1d<double> (n);
try {
CV_TRY {
// Reduce to Hessenberg form.
orthes();
// Reduce Hessenberg to real Schur form.
@@ -881,10 +881,10 @@ private:
// Deallocate the memory by releasing all internal working data.
release();
}
catch (...)
CV_CATCH_ALL
{
release();
throw;
CV_RETHROW();
}
}
+5 -5
View File
@@ -424,12 +424,12 @@ void Mat::create(int d, const int* _sizes, int _type)
#endif
if(!a)
a = a0;
try
CV_TRY
{
u = a->allocate(dims, size, _type, 0, step.p, 0, USAGE_DEFAULT);
CV_Assert(u != 0);
}
catch(...)
CV_CATCH_ALL
{
if(a != a0)
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)
}
*this = m;
try
CV_TRY
{
if( _rowRange != Range::all() && _rowRange != Range(0,rows) )
{
@@ -505,10 +505,10 @@ Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange)
flags |= SUBMATRIX_FLAG;
}
}
catch(...)
CV_CATCH_ALL
{
release();
throw;
CV_RETHROW();
}
if( rows == 1 )
+2 -2
View File
@@ -827,11 +827,11 @@ bool useOpenCL()
CoreTLSData* data = getCoreTlsData().get();
if( data->useOpenCL < 0 )
{
try
CV_TRY
{
data->useOpenCL = (int)(haveOpenCL() && Device::getDefault().ptr() && Device::getDefault().available()) ? 1 : 0;
}
catch (...)
CV_CATCH_ALL
{
data->useOpenCL = 0;
}
+5 -5
View File
@@ -4513,7 +4513,7 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
//mode = cvGetErrMode();
//cvSetErrMode( CV_ErrModeSilent );
try
CV_TRY
{
switch (fs->fmt)
{
@@ -4523,11 +4523,11 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
default: break;
}
}
catch (...)
CV_CATCH_ALL
{
fs->is_opened = true;
cvReleaseFileStorage( &fs );
throw;
CV_RETHROW();
}
//cvSetErrMode( mode );
@@ -5986,11 +5986,11 @@ icvReadSeq( CvFileStorage* fs, CvFileNode* node )
flags |= CV_SEQ_FLAG_HOLE;
if( !strstr(flags_str, "untyped") )
{
try
CV_TRY
{
flags |= icvDecodeSimpleFormat(dt);
}
catch(...)
CV_CATCH_ALL
{
}
}
+1 -1
View File
@@ -961,7 +961,7 @@ void error( const Exception& exc )
*p = 0;
}
throw exc;
CV_THROW(exc);
}
void error(int _code, const String& _err, const char* _func, const char* _file, int _line)
+4 -4
View File
@@ -295,11 +295,11 @@ UMat Mat::getUMat(int accessFlags, UMatUsageFlags usageFlags) const
new_u = a->allocate(dims, size.p, type(), data, step.p, accessFlags, usageFlags);
}
bool allocated = false;
try
CV_TRY
{
allocated = UMat::getStdAllocator()->allocate(new_u, accessFlags, usageFlags);
}
catch (const cv::Exception& e)
CV_CATCH(cv::Exception, e)
{
fprintf(stderr, "Exception: %s\n", e.what());
}
@@ -371,12 +371,12 @@ void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlag
a = a0;
a0 = Mat::getDefaultAllocator();
}
try
CV_TRY
{
u = a->allocate(dims, size, _type, 0, step.p, 0, usageFlags);
CV_Assert(u != 0);
}
catch(...)
CV_CATCH_ALL
{
if(a != a0)
u = a0->allocate(dims, size, _type, 0, step.p, 0, usageFlags);