Build for embedded systems

pull/10263/head
Maksim Shabunin 7 years ago
parent 9665dde678
commit 7349b8f5ce
  1. 2
      cmake/OpenCVGenConfig.cmake
  2. 12
      modules/calib3d/src/calibinit.cpp
  3. 16
      modules/core/include/opencv2/core/base.hpp
  4. 6
      modules/core/include/opencv2/core/hal/interface.h
  5. 12
      modules/core/include/opencv2/core/softfloat.hpp
  6. 24
      modules/core/src/command_line_parser.cpp
  7. 6
      modules/core/src/glob.cpp
  8. 6
      modules/core/src/lda.cpp
  9. 10
      modules/core/src/matrix.cpp
  10. 4
      modules/core/src/ocl.cpp
  11. 10
      modules/core/src/persistence.cpp
  12. 2
      modules/core/src/system.cpp
  13. 8
      modules/core/src/umatrix.cpp
  14. 4
      modules/imgcodecs/src/bitstrm.cpp
  15. 21
      modules/imgcodecs/src/exif.cpp
  16. 12
      modules/imgcodecs/src/grfmt_bmp.cpp
  17. 36
      modules/imgcodecs/src/grfmt_pam.cpp
  18. 28
      modules/imgcodecs/src/grfmt_pxm.cpp
  19. 8
      modules/imgcodecs/src/grfmt_sunras.cpp
  20. 36
      modules/imgcodecs/src/loadsave.cpp
  21. 16
      modules/imgproc/src/color.cpp
  22. 6
      modules/imgproc/src/contours.cpp
  23. 12
      modules/objdetect/src/detection_based_tracker.cpp
  24. 14
      modules/objdetect/src/hog.cpp
  25. 8
      modules/videoio/src/cap.cpp

@ -103,7 +103,7 @@ function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME)
endif()
endfunction()
if(UNIX AND NOT ANDROID)
if((CMAKE_HOST_SYSTEM_NAME MATCHES "Linux" OR UNIX) AND NOT ANDROID)
ocv_gen_config("${CMAKE_BINARY_DIR}/unix-install" "" "")
endif()

@ -431,7 +431,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
cv::Ptr<CvMemStorage> storage;
try
CV_TRY
{
int k = 0;
const int min_dilations = 0;
@ -617,11 +617,11 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 15, 0.1));
}
}
catch(...)
CV_CATCH_ALL
{
cvFree(&quads);
cvFree(&corners);
throw;
CV_RETHROW();
}
cvFree(&quads);
cvFree(&corners);
@ -2151,13 +2151,13 @@ bool cv::findCirclesGrid2( InputArray _image, Size patternSize,
void* oldCbkData;
ErrorCallback oldCbk = redirectError(quiet_error, 0, &oldCbkData);
#endif
try
CV_TRY
{
isFound = boxFinder.findHoles();
}
catch (const cv::Exception &)
CV_CATCH(Exception, e)
{
CV_UNUSED(e);
}
#if BE_QUIET
redirectError(oldCbk, oldCbkData);

@ -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; }

@ -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;
}

@ -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);
}

@ -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();
}
}

@ -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 )

@ -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;
}

@ -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
{
}
}

@ -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)

@ -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);

@ -98,7 +98,7 @@ void RBaseStream::readBlock()
{
if( m_block_pos == 0 && m_current < m_end )
return;
throw RBS_THROW_EOS;
CV_THROW (RBS_THROW_EOS);
}
fseek( m_file, m_block_pos, SEEK_SET );
@ -107,7 +107,7 @@ void RBaseStream::readBlock()
m_current = m_start;
if( readed == 0 || m_current >= m_end )
throw RBS_THROW_EOS;
CV_THROW (RBS_THROW_EOS);
}

@ -41,6 +41,8 @@
//M*/
#include "exif.hpp"
#include "opencv2/core/cvdef.h"
#include "opencv2/core/base.hpp"
namespace {
@ -79,14 +81,15 @@ ExifReader::~ExifReader()
*/
bool ExifReader::parse()
{
try {
CV_TRY {
m_exif = getExif();
if( !m_exif.empty() )
{
return true;
}
return false;
} catch (ExifParsingError&) {
} CV_CATCH (ExifParsingError, e) {
CV_UNUSED(e);
return false;
}
}
@ -150,11 +153,11 @@ std::map<int, ExifEntry_t > ExifReader::getExif()
case COM:
bytesToSkip = getFieldSize();
if (bytesToSkip < markerSize) {
throw ExifParsingError();
CV_THROW (ExifParsingError());
}
m_stream.seekg( static_cast<long>( bytesToSkip - markerSize ), m_stream.cur );
if ( m_stream.fail() ) {
throw ExifParsingError();
CV_THROW (ExifParsingError());
}
break;
@ -165,12 +168,12 @@ std::map<int, ExifEntry_t > ExifReader::getExif()
case APP1: //actual Exif Marker
exifSize = getFieldSize();
if (exifSize <= offsetToTiffHeader) {
throw ExifParsingError();
CV_THROW (ExifParsingError());
}
m_data.resize( exifSize - offsetToTiffHeader );
m_stream.seekg( static_cast<long>( offsetToTiffHeader ), m_stream.cur );
if ( m_stream.fail() ) {
throw ExifParsingError();
CV_THROW (ExifParsingError());
}
m_stream.read( reinterpret_cast<char*>(&m_data[0]), exifSize - offsetToTiffHeader );
count = m_stream.gcount();
@ -415,7 +418,7 @@ std::string ExifReader::getString(const size_t offset) const
dataOffset = getU32( offset + 8 );
}
if (dataOffset > m_data.size() || dataOffset + size > m_data.size()) {
throw ExifParsingError();
CV_THROW (ExifParsingError());
}
std::vector<uint8_t>::const_iterator it = m_data.begin() + dataOffset;
std::string result( it, it + size ); //copy vector content into result
@ -432,7 +435,7 @@ std::string ExifReader::getString(const size_t offset) const
uint16_t ExifReader::getU16(const size_t offset) const
{
if (offset + 1 >= m_data.size())
throw ExifParsingError();
CV_THROW (ExifParsingError());
if( m_format == INTEL )
{
@ -450,7 +453,7 @@ uint16_t ExifReader::getU16(const size_t offset) const
uint32_t ExifReader::getU32(const size_t offset) const
{
if (offset + 3 >= m_data.size())
throw ExifParsingError();
CV_THROW (ExifParsingError());
if( m_format == INTEL )
{

@ -89,7 +89,7 @@ bool BmpDecoder::readHeader()
else if( !m_strm.open( m_filename ))
return false;
try
CV_TRY
{
m_strm.skip( 10 );
m_offset = m_strm.getDWord();
@ -172,9 +172,9 @@ bool BmpDecoder::readHeader()
}
}
}
catch(...)
CV_CATCH_ALL
{
throw;
CV_RETHROW();
}
// in 32 bit case alpha channel is used - so require CV_8UC4 type
m_type = iscolor ? (m_bpp == 32 ? CV_8UC4 : CV_8UC3 ) : CV_8UC1;
@ -224,7 +224,7 @@ bool BmpDecoder::readData( Mat& img )
}
uchar *src = _src, *bgr = _bgr;
try
CV_TRY
{
m_strm.setPos( m_offset );
@ -492,9 +492,9 @@ decode_rle8_bad: ;
CV_ErrorNoReturn(cv::Error::StsError, "Invalid/unsupported mode");
}
}
catch(...)
CV_CATCH_ALL
{
throw;
CV_RETHROW();
}
return result;

@ -374,25 +374,25 @@ bool PAMDecoder::readHeader()
}
else if( !m_strm.open( m_filename ))
return false;
try
CV_TRY
{
byte = m_strm.getByte();
if( byte != 'P' )
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
byte = m_strm.getByte();
if (byte != '7')
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
byte = m_strm.getByte();
if (byte != '\n' && byte != '\r')
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
uint i;
memset (&flds, 0x00, sizeof (struct parsed_fields));
do {
if (!ReadPAMHeaderLine(m_strm, fieldtype, value))
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
switch (fieldtype) {
case PAM_HEADER_NONE:
case PAM_HEADER_COMMENT:
@ -402,32 +402,32 @@ bool PAMDecoder::readHeader()
break;
case PAM_HEADER_HEIGHT:
if (flds.height)
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
if (!ParseNumber (value, &m_height))
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
flds.height = true;
break;
case PAM_HEADER_WIDTH:
if (flds.width)
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
if (!ParseNumber (value, &m_width))
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
flds.width = true;
break;
case PAM_HEADER_DEPTH:
if (flds.depth)
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
if (!ParseNumber (value, &m_channels))
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
flds.depth = true;
break;
case PAM_HEADER_MAXVAL:
if (flds.maxval)
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
if (!ParseNumber (value, &m_maxval))
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
if ( m_maxval > 65535 )
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
if ( m_maxval > 255 ) {
m_sampledepth = CV_16U;
}
@ -446,7 +446,7 @@ bool PAMDecoder::readHeader()
}
break;
default:
throw RBS_BAD_HEADER;
CV_THROW( RBS_BAD_HEADER );
}
} while (fieldtype != PAM_HEADER_ENDHDR);
@ -464,7 +464,7 @@ bool PAMDecoder::readHeader()
return true;
}
} catch(...)
} CV_CATCH_ALL
{
}
@ -511,7 +511,7 @@ bool PAMDecoder::readData( Mat& img )
layout.graychan = 0;
}
try
CV_TRY
{
m_strm.setPos( m_offset );
@ -612,7 +612,7 @@ bool PAMDecoder::readData( Mat& img )
}
res = true;
} catch(...)
} CV_CATCH_ALL
{
}

@ -148,11 +148,11 @@ bool PxMDecoder::readHeader()
else if( !m_strm.open( m_filename ))
return false;
try
CV_TRY
{
int code = m_strm.getByte();
if( code != 'P' )
throw RBS_BAD_HEADER;
CV_THROW (RBS_BAD_HEADER);
code = m_strm.getByte();
switch( code )
@ -160,7 +160,7 @@ bool PxMDecoder::readHeader()
case '1': case '4': m_bpp = 1; break;
case '2': case '5': m_bpp = 8; break;
case '3': case '6': m_bpp = 24; break;
default: throw RBS_BAD_HEADER;
default: CV_THROW (RBS_BAD_HEADER);
}
m_binary = code >= '4';
@ -171,7 +171,7 @@ bool PxMDecoder::readHeader()
m_maxval = m_bpp == 1 ? 1 : ReadNumber(m_strm);
if( m_maxval > 65535 )
throw RBS_BAD_HEADER;
CV_THROW (RBS_BAD_HEADER);
//if( m_maxval > 255 ) m_binary = false; nonsense
if( m_maxval > 255 )
@ -183,14 +183,15 @@ bool PxMDecoder::readHeader()
result = true;
}
}
catch (const cv::Exception&)
CV_CATCH (cv::Exception, e)
{
throw;
CV_UNUSED(e);
CV_RETHROW();
}
catch (...)
CV_CATCH_ALL
{
std::cerr << "PXM::readHeader(): unknown C++ exception" << std::endl << std::flush;
throw;
CV_RETHROW();
}
if( !result )
@ -230,7 +231,7 @@ bool PxMDecoder::readData( Mat& img )
FillGrayPalette( palette, m_bpp==1 ? 1 : 8 , m_bpp == 1 );
}
try
CV_TRY
{
m_strm.setPos( m_offset );
@ -356,14 +357,15 @@ bool PxMDecoder::readData( Mat& img )
CV_ErrorNoReturn(Error::StsError, "m_bpp is not supported");
}
}
catch (const cv::Exception&)
CV_CATCH (cv::Exception, e)
{
throw;
CV_UNUSED(e);
CV_RETHROW();
}
catch (...)
CV_CATCH_ALL
{
std::cerr << "PXM::readData(): unknown exception" << std::endl << std::flush;
throw;
CV_RETHROW();
}
return result;

@ -82,7 +82,7 @@ bool SunRasterDecoder::readHeader()
if( !m_strm.open( m_filename )) return false;
try
CV_TRY
{
m_strm.skip( 4 );
m_width = m_strm.getDWord();
@ -142,7 +142,7 @@ bool SunRasterDecoder::readHeader()
}
}
}
catch(...)
CV_CATCH_ALL
{
}
@ -179,7 +179,7 @@ bool SunRasterDecoder::readData( Mat& img )
if( !color && m_maptype == RMT_EQUAL_RGB )
CvtPaletteToGray( m_palette, gray_palette, 1 << m_bpp );
try
CV_TRY
{
m_strm.setPos( m_offset );
@ -374,7 +374,7 @@ bad_decoding_end:
assert(0);
}
}
catch( ... )
CV_CATCH_ALL
{
}

@ -426,18 +426,18 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 )
/// set the filename in the driver
decoder->setSource( filename );
try
CV_TRY
{
// read the header to make sure it succeeds
if( !decoder->readHeader() )
return 0;
}
catch (const cv::Exception& e)
CV_CATCH (cv::Exception, e)
{
std::cerr << "imread_('" << filename << "'): can't read header: " << e.what() << std::endl << std::flush;
return 0;
}
catch (...)
CV_CATCH_ALL
{
std::cerr << "imread_('" << filename << "'): can't read header: unknown exception" << std::endl << std::flush;
return 0;
@ -482,16 +482,16 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 )
// read the image data
bool success = false;
try
CV_TRY
{
if (decoder->readData(*data))
success = true;
}
catch (const cv::Exception& e)
CV_CATCH (cv::Exception, e)
{
std::cerr << "imread_('" << filename << "'): can't read data: " << e.what() << std::endl << std::flush;
}
catch (...)
CV_CATCH_ALL
{
std::cerr << "imread_('" << filename << "'): can't read data: unknown exception" << std::endl << std::flush;
}
@ -548,18 +548,18 @@ imreadmulti_(const String& filename, int flags, std::vector<Mat>& mats)
decoder->setSource(filename);
// read the header to make sure it succeeds
try
CV_TRY
{
// read the header to make sure it succeeds
if( !decoder->readHeader() )
return 0;
}
catch (const cv::Exception& e)
CV_CATCH (cv::Exception, e)
{
std::cerr << "imreadmulti_('" << filename << "'): can't read header: " << e.what() << std::endl << std::flush;
return 0;
}
catch (...)
CV_CATCH_ALL
{
std::cerr << "imreadmulti_('" << filename << "'): can't read header: unknown exception" << std::endl << std::flush;
return 0;
@ -587,16 +587,16 @@ imreadmulti_(const String& filename, int flags, std::vector<Mat>& mats)
// read the image data
Mat mat(size.height, size.width, type);
bool success = false;
try
CV_TRY
{
if (decoder->readData(mat))
success = true;
}
catch (const cv::Exception& e)
CV_CATCH (cv::Exception, e)
{
std::cerr << "imreadmulti_('" << filename << "'): can't read data: " << e.what() << std::endl << std::flush;
}
catch (...)
CV_CATCH_ALL
{
std::cerr << "imreadmulti_('" << filename << "'): can't read data: unknown exception" << std::endl << std::flush;
}
@ -738,16 +738,16 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
}
bool success = false;
try
CV_TRY
{
if (decoder->readHeader())
success = true;
}
catch (const cv::Exception& e)
CV_CATCH (cv::Exception, e)
{
std::cerr << "imdecode_('" << filename << "'): can't read header: " << e.what() << std::endl << std::flush;
}
catch (...)
CV_CATCH_ALL
{
std::cerr << "imdecode_('" << filename << "'): can't read header: unknown exception" << std::endl << std::flush;
}
@ -800,16 +800,16 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
}
success = false;
try
CV_TRY
{
if (decoder->readData(*data))
success = true;
}
catch (const cv::Exception& e)
CV_CATCH (cv::Exception, e)
{
std::cerr << "imdecode_('" << filename << "'): can't read data: " << e.what() << std::endl << std::flush;
}
catch (...)
CV_CATCH_ALL
{
std::cerr << "imdecode_('" << filename << "'): can't read data: unknown exception" << std::endl << std::flush;
}

@ -6251,6 +6251,7 @@ static inline void trilinearInterpolate(int cx, int cy, int cz, const int16_t* L
c = CV_DESCALE(c, trilinear_shift*3);
}
#if CV_SIMD128
// 8 inValues are in [0; LAB_BASE]
static inline void trilinearPackedInterpolate(const v_uint16x8& inX, const v_uint16x8& inY, const v_uint16x8& inZ,
@ -6339,6 +6340,8 @@ static inline void trilinearPackedInterpolate(const v_uint16x8& inX, const v_uin
#undef DOT_SHIFT_PACK
}
#endif // CV_SIMD128
struct RGB2Lab_b
{
@ -6465,6 +6468,8 @@ struct RGB2Lab_f
i = 0;
if(useInterpolation)
{
#if CV_SIMD128
if(enablePackedLab)
{
static const int nPixels = 4*2;
@ -6548,6 +6553,7 @@ struct RGB2Lab_f
v_store_interleave(dst + i + 3*4, l_vec1, a_vec1, b_vec1);
}
}
#endif // CV_SIMD128
for(; i < n; i += 3, src += scn)
{
@ -7036,6 +7042,8 @@ struct Lab2RGBinteger
float alpha = ColorChannel<float>::max();
int i = 0;
#if CV_SIMD128
if(enablePackedLab)
{
v_float32x4 vldiv = v_setall_f32(256.f/100.0f);
@ -7122,6 +7130,7 @@ struct Lab2RGBinteger
}
}
}
#endif
for(; i < n*3; i += 3, dst += dcn)
{
@ -7142,6 +7151,7 @@ struct Lab2RGBinteger
uchar alpha = ColorChannel<uchar>::max();
i = 0;
#if CV_SIMD128
if(enablePackedLab)
{
static const int nPixels = 8*2;
@ -7213,6 +7223,7 @@ struct Lab2RGBinteger
}
}
}
#endif
for (; i < n*3; i += 3, dst += dcn)
{
@ -8097,6 +8108,8 @@ struct RGB2Luvinterpolate
int i, scn = srccn, bIdx = blueIdx;
i = 0; n *= 3;
#if CV_SIMD128
if(enablePackedRGB2Luv)
{
static const int nPixels = 8*2;
@ -8154,6 +8167,7 @@ struct RGB2Luvinterpolate
v_store_interleave(dst + i, l16, u16, v16);
}
}
#endif // CV_SIMD128
for(; i < n; i += 3, src += scn)
{
@ -8514,6 +8528,7 @@ struct Luv2RGBinteger
uchar alpha = ColorChannel<uchar>::max();
i = 0;
#if CV_SIMD128
if(enablePackedLuv2RGB)
{
static const int nPixels = 16;
@ -8586,6 +8601,7 @@ struct Luv2RGBinteger
}
}
}
#endif
for (; i < n*3; i += 3, dst += dcn)
{

@ -1828,7 +1828,7 @@ cvFindContours_Impl( void* img, CvMemStorage* storage,
}
else
{
try
CV_TRY
{
scanner = cvStartFindContours_Impl( img, storage, cntHeaderSize, mode, method, offset,
needFillBorder);
@ -1840,11 +1840,11 @@ cvFindContours_Impl( void* img, CvMemStorage* storage,
}
while( contour != 0 );
}
catch(...)
CV_CATCH_ALL
{
if( scanner )
cvEndFindContours(&scanner);
throw;
CV_RETHROW();
}
*firstContour = cvEndFindContours( &scanner );

@ -284,23 +284,23 @@ bool cv::DetectionBasedTracker::SeparateDetectionWork::run()
}
#define CATCH_ALL_AND_LOG(_block) \
try { \
CV_TRY { \
_block; \
} \
catch(cv::Exception& e) { \
CV_CATCH(cv::Exception, e) { \
LOGE0("\n %s: ERROR: OpenCV Exception caught: \n'%s'\n\n", CV_Func, e.what()); \
} catch(std::exception& e) { \
} CV_CATCH(std::exception, e) { \
LOGE0("\n %s: ERROR: Exception caught: \n'%s'\n\n", CV_Func, e.what()); \
} catch(...) { \
} CV_CATCH_ALL { \
LOGE0("\n %s: ERROR: UNKNOWN Exception caught\n\n", CV_Func); \
}
void* cv::workcycleObjectDetectorFunction(void* p)
{
CATCH_ALL_AND_LOG({ ((cv::DetectionBasedTracker::SeparateDetectionWork*)p)->workcycleObjectDetector(); });
try{
CV_TRY{
((cv::DetectionBasedTracker::SeparateDetectionWork*)p)->init();
} catch(...) {
} CV_CATCH_ALL {
LOGE0("DetectionBasedTracker: workcycleObjectDetectorFunction: ERROR concerning pointer, received as the function parameter");
}
return NULL;

@ -3686,7 +3686,7 @@ void HOGDescriptor::readALTModel(String modelfile)
String eerr("file not exist");
String efile(__FILE__);
String efunc(__FUNCTION__);
throw Exception(Error::StsError, eerr, efile, efunc, __LINE__);
CV_THROW (Exception(Error::StsError, eerr, efile, efunc, __LINE__));
}
char version_buffer[10];
if (!fread (&version_buffer,sizeof(char),10,modelfl))
@ -3696,7 +3696,7 @@ void HOGDescriptor::readALTModel(String modelfile)
String efunc(__FUNCTION__);
fclose(modelfl);
throw Exception(Error::StsError, eerr, efile, efunc, __LINE__);
CV_THROW (Exception(Error::StsError, eerr, efile, efunc, __LINE__));
}
if(strcmp(version_buffer,"V6.01")) {
String eerr("version doesnot match");
@ -3704,14 +3704,14 @@ void HOGDescriptor::readALTModel(String modelfile)
String efunc(__FUNCTION__);
fclose(modelfl);
throw Exception(Error::StsError, eerr, efile, efunc, __LINE__);
CV_THROW (Exception(Error::StsError, eerr, efile, efunc, __LINE__));
}
/* read version number */
int version = 0;
if (!fread (&version,sizeof(int),1,modelfl))
{
fclose(modelfl);
throw Exception();
CV_THROW (Exception());
}
if (version < 200)
{
@ -3719,7 +3719,7 @@ void HOGDescriptor::readALTModel(String modelfile)
String efile(__FILE__);
String efunc(__FUNCTION__);
fclose(modelfl);
throw Exception();
CV_THROW (Exception());
}
int kernel_type;
size_t nread;
@ -3765,7 +3765,7 @@ void HOGDescriptor::readALTModel(String modelfile)
if(nread != static_cast<size_t>(length) + 1) {
delete [] linearwt;
fclose(modelfl);
throw Exception();
CV_THROW (Exception());
}
for(int i = 0; i < length; i++)
@ -3776,7 +3776,7 @@ void HOGDescriptor::readALTModel(String modelfile)
delete [] linearwt;
} else {
fclose(modelfl);
throw Exception();
CV_THROW (Exception());
}
fclose(modelfl);
}

@ -141,15 +141,15 @@ static bool get_capture_debug_flag()
#define TRY_OPEN(capture, backend_func) \
{ \
if (!capture) \
try { \
CV_TRY { \
if (get_capture_debug_flag()) fprintf(stderr, "VIDEOIO(%s): trying ...\n", #backend_func); \
capture = backend_func; \
if (get_capture_debug_flag()) fprintf(stderr, "VIDEOIO(%s): result=%p ...\n", #backend_func, capture); \
} catch (const cv::Exception& e) { \
} CV_CATCH (cv::Exception, e) { \
fprintf(stderr, "VIDEOIO(%s): raised OpenCV exception:\n\n%s\n", #backend_func, e.what()); \
} catch (const std::exception& e) { \
} CV_CATCH (std::exception, e) { \
fprintf(stderr, "VIDEOIO(%s): raised C++ exception:\n\n%s\n", #backend_func, e.what()); \
} catch (...) { \
} CV_CATCH_ALL { \
fprintf(stderr, "VIDEOIO(%s): raised unknown C++ exception!\n\n", #backend_func); \
} \
}

Loading…
Cancel
Save