EstervQrCode 1.1.1
Library for qr code manipulation
utility.hpp
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 // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
16 // Copyright (C) 2015, Itseez Inc., all rights reserved.
17 // Third party copyrights are property of their respective owners.
18 //
19 // Redistribution and use in source and binary forms, with or without modification,
20 // are permitted provided that the following conditions are met:
21 //
22 // * Redistribution's of source code must retain the above copyright notice,
23 // this list of conditions and the following disclaimer.
24 //
25 // * Redistribution's in binary form must reproduce the above copyright notice,
26 // this list of conditions and the following disclaimer in the documentation
27 // and/or other materials provided with the distribution.
28 //
29 // * The name of the copyright holders may not be used to endorse or promote products
30 // derived from this software without specific prior written permission.
31 //
32 // This software is provided by the copyright holders and contributors "as is" and
33 // any express or implied warranties, including, but not limited to, the implied
34 // warranties of merchantability and fitness for a particular purpose are disclaimed.
35 // In no event shall the Intel Corporation or contributors be liable for any direct,
36 // indirect, incidental, special, exemplary, or consequential damages
37 // (including, but not limited to, procurement of substitute goods or services;
38 // loss of use, data, or profits; or business interruption) however caused
39 // and on any theory of liability, whether in contract, strict liability,
40 // or tort (including negligence or otherwise) arising in any way out of
41 // the use of this software, even if advised of the possibility of such damage.
42 //
43 //M*/
44 
45 #ifndef OPENCV_CORE_UTILITY_H
46 #define OPENCV_CORE_UTILITY_H
47 
48 #ifndef __cplusplus
49 # error utility.hpp header must be compiled as C++
50 #endif
51 
52 #if defined(check)
53 # warning Detected Apple 'check' macro definition, it can cause build conflicts. Please, include this header before any Apple headers.
54 #endif
55 
56 #include "opencv2/core.hpp"
57 #include <ostream>
58 
59 #include <functional>
60 
61 #if !defined(_M_CEE)
62 #include <mutex> // std::mutex, std::lock_guard
63 #endif
64 
65 namespace cv
66 {
67 
70 
97 #ifdef OPENCV_ENABLE_MEMORY_SANITIZER
98 template<typename _Tp, size_t fixed_size = 0> class AutoBuffer
99 #else
100 template<typename _Tp, size_t fixed_size = 1024/sizeof(_Tp)+8> class AutoBuffer
101 #endif
102 {
103 public:
104  typedef _Tp value_type;
105 
109  explicit AutoBuffer(size_t _size);
110 
115 
118 
120  void allocate(size_t _size);
122  void deallocate();
124  void resize(size_t _size);
126  size_t size() const;
128  inline _Tp* data() { return ptr; }
130  inline const _Tp* data() const { return ptr; }
131 
132 #if !defined(OPENCV_DISABLE_DEPRECATED_COMPATIBILITY) // use to .data() calls instead
134  operator _Tp* () { return ptr; }
136  operator const _Tp* () const { return ptr; }
137 #else
139  inline _Tp& operator[] (size_t i) { CV_DbgCheckLT(i, sz, "out of range"); return ptr[i]; }
141  inline const _Tp& operator[] (size_t i) const { CV_DbgCheckLT(i, sz, "out of range"); return ptr[i]; }
142 #endif
143 
144 protected:
146  _Tp* ptr;
148  size_t sz;
150  _Tp buf[(fixed_size > 0) ? fixed_size : 1];
151 };
152 
160 CV_EXPORTS bool setBreakOnError(bool flag);
161 
162 extern "C" typedef int (*ErrorCallback)( int status, const char* func_name,
163  const char* err_msg, const char* file_name,
164  int line, void* userdata );
165 
166 
177 CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback, void* userdata=0, void** prevUserdata=0);
178 
179 CV_EXPORTS String tempfile( const char* suffix = 0);
180 CV_EXPORTS void glob(String pattern, std::vector<String>& result, bool recursive = false);
181 
200 CV_EXPORTS_W void setNumThreads(int nthreads);
201 
219 
235 
243 
251 
254 
257 
260 
269 
282 
295 {
296 public:
299  {
300  reset();
301  }
302 
304  CV_WRAP void start()
305  {
306  startTime = cv::getTickCount();
307  }
308 
310  CV_WRAP void stop()
311  {
312  int64 time = cv::getTickCount();
313  if (startTime == 0)
314  return;
315  ++counter;
316  sumTime += (time - startTime);
317  startTime = 0;
318  }
319 
322  {
323  return sumTime;
324  }
325 
327  CV_WRAP double getTimeMicro() const
328  {
329  return getTimeMilli()*1e3;
330  }
331 
333  CV_WRAP double getTimeMilli() const
334  {
335  return getTimeSec()*1e3;
336  }
337 
339  CV_WRAP double getTimeSec() const
340  {
341  return (double)getTimeTicks() / getTickFrequency();
342  }
343 
346  {
347  return counter;
348  }
349 
351  CV_WRAP double getFPS() const
352  {
353  const double sec = getTimeSec();
354  if (sec < DBL_EPSILON)
355  return 0.;
356  return counter / sec;
357  }
358 
360  CV_WRAP double getAvgTimeSec() const
361  {
362  if (counter <= 0)
363  return 0.;
364  return getTimeSec() / counter;
365  }
366 
368  CV_WRAP double getAvgTimeMilli() const
369  {
370  return getAvgTimeSec() * 1e3;
371  }
372 
374  CV_WRAP void reset()
375  {
376  startTime = 0;
377  sumTime = 0;
378  counter = 0;
379  }
380 
381 private:
382  int64 counter;
383  int64 sumTime;
384  int64 startTime;
385 };
386 
397 static inline
399 {
400  return out << tm.getTimeSec() << "sec";
401 }
402 
416 
426 
432 
444 
448 
449 
457 template<typename _Tp> static inline _Tp* alignPtr(_Tp* ptr, int n=(int)sizeof(_Tp))
458 {
459  CV_DbgAssert((n & (n - 1)) == 0); // n is a power of 2
460  return (_Tp*)(((size_t)ptr + n-1) & -n);
461 }
462 
470 static inline size_t alignSize(size_t sz, int n)
471 {
472  CV_DbgAssert((n & (n - 1)) == 0); // n is a power of 2
473  return (sz + n-1) & -n;
474 }
475 
482 static inline int divUp(int a, unsigned int b)
483 {
484  CV_DbgAssert(a >= 0);
485  return (a + b - 1) / b;
486 }
488 static inline size_t divUp(size_t a, unsigned int b)
489 {
490  return (a + b - 1) / b;
491 }
492 
499 static inline int roundUp(int a, unsigned int b)
500 {
501  CV_DbgAssert(a >= 0);
502  return a + b - 1 - (a + b -1) % b;
503 }
505 static inline size_t roundUp(size_t a, unsigned int b)
506 {
507  return a + b - 1 - (a + b - 1) % b;
508 }
509 
516 template<int N, typename T> static inline
517 bool isAligned(const T& data)
518 {
519  CV_StaticAssert((N & (N - 1)) == 0, ""); // power of 2
520  return (((size_t)data) & (N - 1)) == 0;
521 }
523 template<int N> static inline
524 bool isAligned(const void* p1)
525 {
526  return isAligned<N>((size_t)p1);
527 }
529 template<int N> static inline
530 bool isAligned(const void* p1, const void* p2)
531 {
532  return isAligned<N>(((size_t)p1)|((size_t)p2));
533 }
535 template<int N> static inline
536 bool isAligned(const void* p1, const void* p2, const void* p3)
537 {
538  return isAligned<N>(((size_t)p1)|((size_t)p2)|((size_t)p3));
539 }
541 template<int N> static inline
542 bool isAligned(const void* p1, const void* p2, const void* p3, const void* p4)
543 {
544  return isAligned<N>(((size_t)p1)|((size_t)p2)|((size_t)p3)|((size_t)p4));
545 }
546 
560 CV_EXPORTS_W void setUseOptimized(bool onoff);
561 
567 
568 static inline size_t getElemSize(int type) { return (size_t)CV_ELEM_SIZE(type); }
569 
571 
577 {
578 public:
579  virtual ~ParallelLoopBody();
580  virtual void operator() (const Range& range) const = 0;
581 };
582 
587 CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.);
588 
591 {
592 private:
593  std::function<void(const Range&)> m_functor;
594 public:
595  inline
597  : m_functor(functor)
598  {
599  // nothing
600  }
601 
602  virtual void operator() (const cv::Range& range) const CV_OVERRIDE
603  {
604  m_functor(range);
605  }
606 };
607 
609 static inline
610 void parallel_for_(const Range& range, std::function<void(const Range&)> functor, double nstripes=-1.)
611 {
613 }
614 
615 
617 template<typename _Tp, typename Functor> inline
618 void Mat::forEach_impl(const Functor& operation) {
619  if (false) {
620  operation(*reinterpret_cast<_Tp*>(0), reinterpret_cast<int*>(0));
621  // If your compiler fails in this line.
622  // Please check that your functor signature is
623  // (_Tp&, const int*) <- multi-dimensional
624  // or (_Tp&, void*) <- in case you don't need current idx.
625  }
626 
627  CV_Assert(!empty());
628  CV_Assert(this->total() / this->size[this->dims - 1] <= INT_MAX);
629  const int LINES = static_cast<int>(this->total() / this->size[this->dims - 1]);
630 
631  class PixelOperationWrapper :public ParallelLoopBody
632  {
633  public:
634  PixelOperationWrapper(Mat_<_Tp>* const frame, const Functor& _operation)
635  : mat(frame), op(_operation) {}
636  virtual ~PixelOperationWrapper(){}
637  // ! Overloaded virtual operator
638  // convert range call to row call.
639  virtual void operator()(const Range &range) const CV_OVERRIDE
640  {
641  const int DIMS = mat->dims;
642  const int COLS = mat->size[DIMS - 1];
643  if (DIMS <= 2) {
644  for (int row = range.start; row < range.end; ++row) {
645  this->rowCall2(row, COLS);
646  }
647  } else {
648  std::vector<int> idx(DIMS);
649  idx[DIMS - 2] = range.start - 1;
650 
651  for (int line_num = range.start; line_num < range.end; ++line_num) {
652  idx[DIMS - 2]++;
653  for (int i = DIMS - 2; i >= 0; --i) {
654  if (idx[i] >= mat->size[i]) {
655  idx[i - 1] += idx[i] / mat->size[i];
656  idx[i] %= mat->size[i];
657  continue; // carry-over;
658  }
659  else {
660  break;
661  }
662  }
663  this->rowCall(&idx[0], COLS, DIMS);
664  }
665  }
666  }
667  private:
668  Mat_<_Tp>* const mat;
669  const Functor op;
670  // ! Call operator for each elements in this row.
671  inline void rowCall(int* const idx, const int COLS, const int DIMS) const {
672  int &col = idx[DIMS - 1];
673  col = 0;
674  _Tp* pixel = &(mat->template at<_Tp>(idx));
675 
676  while (col < COLS) {
677  op(*pixel, const_cast<const int*>(idx));
678  pixel++; col++;
679  }
680  col = 0;
681  }
682  // ! Call operator for each elements in this row. 2d mat special version.
683  inline void rowCall2(const int row, const int COLS) const {
684  union Index{
685  int body[2];
686  operator const int*() const {
687  return reinterpret_cast<const int*>(this);
688  }
689  int& operator[](const int i) {
690  return body[i];
691  }
692  } idx = {{row, 0}};
693  // Special union is needed to avoid
694  // "error: array subscript is above array bounds [-Werror=array-bounds]"
695  // when call the functor `op` such that access idx[3].
696 
697  _Tp* pixel = &(mat->template at<_Tp>(idx));
698  const _Tp* const pixel_end = pixel + COLS;
699  while(pixel < pixel_end) {
700  op(*pixel++, static_cast<const int*>(idx));
701  idx[1]++;
702  }
703  }
704  PixelOperationWrapper& operator=(const PixelOperationWrapper &) {
705  CV_Assert(false);
706  // We can not remove this implementation because Visual Studio warning C4822.
707  return *this;
708  }
709  };
710 
711  parallel_for_(cv::Range(0, LINES), PixelOperationWrapper(reinterpret_cast<Mat_<_Tp>*>(this), operation));
712 }
713 
715 
716 #if !defined(_M_CEE)
717 #ifndef OPENCV_DISABLE_THREAD_SUPPORT
720 #else // OPENCV_DISABLE_THREAD_SUPPORT
721 // Custom (failing) implementation of `std::recursive_mutex`.
722 struct Mutex {
723  void lock(){
725  "cv::Mutex is disabled by OPENCV_DISABLE_THREAD_SUPPORT=ON");
726  }
727  void unlock(){
729  "cv::Mutex is disabled by OPENCV_DISABLE_THREAD_SUPPORT=ON");
730  }
731 };
732 // Stub for cv::AutoLock when threads are disabled.
733 struct AutoLock {
734  AutoLock(Mutex &) { }
735 };
736 #endif // OPENCV_DISABLE_THREAD_SUPPORT
737 #endif // !defined(_M_CEE)
738 
739 
820 {
821 public:
822 
831  CommandLineParser(int argc, const char* const argv[], const String& keys);
832 
835 
837  CommandLineParser& operator = (const CommandLineParser& parser);
838 
841 
853 
885  template <typename T>
886  T get(const String& name, bool space_delete = true) const
887  {
888  T val = T();
889  getByName(name, space_delete, ParamType<T>::type, (void*)&val);
890  return val;
891  }
892 
917  template <typename T>
918  T get(int index, bool space_delete = true) const
919  {
920  T val = T();
921  getByIndex(index, space_delete, ParamType<T>::type, (void*)&val);
922  return val;
923  }
924 
929  bool has(const String& name) const;
930 
936  bool check() const;
937 
942  void about(const String& message);
943 
950  void printMessage() const;
951 
956  void printErrors() const;
957 
958 protected:
959  void getByName(const String& name, bool space_delete, Param type, void* dst) const;
960  void getByIndex(int index, bool space_delete, Param type, void* dst) const;
961 
962  struct Impl;
963  Impl* impl;
964 };
965 
967 
969 
971 
972 template<typename _Tp, size_t fixed_size> inline
974 {
975  ptr = buf;
976  sz = fixed_size;
977 }
978 
979 template<typename _Tp, size_t fixed_size> inline
981 {
982  ptr = buf;
983  sz = fixed_size;
984  allocate(_size);
985 }
986 
987 template<typename _Tp, size_t fixed_size> inline
988 AutoBuffer<_Tp, fixed_size>::AutoBuffer(const AutoBuffer<_Tp, fixed_size>& abuf )
989 {
990  ptr = buf;
991  sz = fixed_size;
992  allocate(abuf.size());
993  for( size_t i = 0; i < sz; i++ )
994  ptr[i] = abuf.ptr[i];
995 }
996 
997 template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>&
998 AutoBuffer<_Tp, fixed_size>::operator = (const AutoBuffer<_Tp, fixed_size>& abuf)
999 {
1000  if( this != &abuf )
1001  {
1002  deallocate();
1003  allocate(abuf.size());
1004  for( size_t i = 0; i < sz; i++ )
1005  ptr[i] = abuf.ptr[i];
1006  }
1007  return *this;
1008 }
1009 
1010 template<typename _Tp, size_t fixed_size> inline
1012 { deallocate(); }
1013 
1014 template<typename _Tp, size_t fixed_size> inline void
1016 {
1017  if(_size <= sz)
1018  {
1019  sz = _size;
1020  return;
1021  }
1022  deallocate();
1023  sz = _size;
1024  if(_size > fixed_size)
1025  {
1026  ptr = new _Tp[_size];
1027  }
1028 }
1029 
1030 template<typename _Tp, size_t fixed_size> inline void
1032 {
1033  if( ptr != buf )
1034  {
1035  delete[] ptr;
1036  ptr = buf;
1037  sz = fixed_size;
1038  }
1039 }
1040 
1041 template<typename _Tp, size_t fixed_size> inline void
1043 {
1044  if(_size <= sz)
1045  {
1046  sz = _size;
1047  return;
1048  }
1049  size_t i, prevsize = sz, minsize = MIN(prevsize, _size);
1050  _Tp* prevptr = ptr;
1051 
1052  ptr = _size > fixed_size ? new _Tp[_size] : buf;
1053  sz = _size;
1054 
1055  if( ptr != prevptr )
1056  for( i = 0; i < minsize; i++ )
1057  ptr[i] = prevptr[i];
1058  for( i = prevsize; i < _size; i++ )
1059  ptr[i] = _Tp();
1060 
1061  if( prevptr != buf )
1062  delete[] prevptr;
1063 }
1064 
1065 template<typename _Tp, size_t fixed_size> inline size_t
1067 { return sz; }
1068 
1070 
1071 
1072 // Basic Node class for tree building
1073 template<class OBJECT>
1075 {
1076 public:
1078  {
1079  m_pParent = 0;
1080  }
1081  Node(OBJECT& payload) : m_payload(payload)
1082  {
1083  m_pParent = 0;
1084  }
1086  {
1087  removeChilds();
1088  if (m_pParent)
1089  {
1090  int idx = m_pParent->findChild(this);
1091  if (idx >= 0)
1092  m_pParent->m_childs.erase(m_pParent->m_childs.begin() + idx);
1093  }
1094  }
1095 
1096  Node<OBJECT>* findChild(OBJECT& payload) const
1097  {
1098  for(size_t i = 0; i < this->m_childs.size(); i++)
1099  {
1100  if(this->m_childs[i]->m_payload == payload)
1101  return this->m_childs[i];
1102  }
1103  return NULL;
1104  }
1105 
1106  int findChild(Node<OBJECT> *pNode) const
1107  {
1108  for (size_t i = 0; i < this->m_childs.size(); i++)
1109  {
1110  if(this->m_childs[i] == pNode)
1111  return (int)i;
1112  }
1113  return -1;
1114  }
1115 
1116  void addChild(Node<OBJECT> *pNode)
1117  {
1118  if(!pNode)
1119  return;
1120 
1121  CV_Assert(pNode->m_pParent == 0);
1122  pNode->m_pParent = this;
1123  this->m_childs.push_back(pNode);
1124  }
1125 
1127  {
1128  for(size_t i = 0; i < m_childs.size(); i++)
1129  {
1130  m_childs[i]->m_pParent = 0; // avoid excessive parent vector trimming
1131  delete m_childs[i];
1132  }
1133  m_childs.clear();
1134  }
1135 
1136  int getDepth()
1137  {
1138  int count = 0;
1139  Node *pParent = m_pParent;
1140  while(pParent) count++, pParent = pParent->m_pParent;
1141  return count;
1142  }
1143 
1144 public:
1145  OBJECT m_payload;
1148 };
1149 
1150 
1151 namespace samples {
1152 
1154 // This section describes utility functions for OpenCV samples.
1155 //
1156 // @note Implementation of these utilities is not thread-safe.
1157 //
1159 
1183 CV_EXPORTS_W cv::String findFile(const cv::String& relative_path, bool required = true, bool silentMode = false);
1184 
1185 CV_EXPORTS_W cv::String findFileOrKeep(const cv::String& relative_path, bool silentMode = false);
1186 
1187 inline cv::String findFileOrKeep(const cv::String& relative_path, bool silentMode)
1188 {
1189  cv::String res = findFile(relative_path, false, silentMode);
1190  if (res.empty())
1191  return relative_path;
1192  return res;
1193 }
1194 
1203 
1212 
1214 } // namespace samples
1215 
1216 namespace utils {
1217 
1219 
1220 } // namespace
1221 
1222 } //namespace cv
1223 
1224 #ifdef CV_COLLECT_IMPL_DATA
1225 #include "opencv2/core/utils/instrumentation.hpp"
1226 #else
1228 #define CV_IMPL_ADD(impl)
1229 #endif
1230 
1231 #endif //OPENCV_CORE_UTILITY_H
Automatically Allocated Buffer Class.
Definition: utility.hpp:102
_Tp * ptr
pointer to the real buffer, can point to buf if the buffer is small enough
Definition: utility.hpp:146
void allocate(size_t _size)
allocates the new buffer of size _size. if the _size is small enough, stack-allocated buffer is used
const _Tp * data() const
returns read-only pointer to the real buffer, stack-allocated or heap-allocated
Definition: utility.hpp:130
~AutoBuffer()
destructor. calls deallocate()
AutoBuffer(const AutoBuffer< _Tp, fixed_size > &buf)
the copy constructor
size_t size() const
returns the current buffer size
_Tp * data()
returns pointer to the real buffer, stack-allocated or heap-allocated
Definition: utility.hpp:128
size_t sz
size of the real buffer
Definition: utility.hpp:148
void resize(size_t _size)
resizes the buffer and preserves the content
AutoBuffer()
the default constructor
void deallocate()
deallocates the buffer if it was dynamically allocated
AutoBuffer(size_t _size)
constructor taking the real buffer size
AutoBuffer< _Tp, fixed_size > & operator=(const AutoBuffer< _Tp, fixed_size > &buf)
the assignment operator
_Tp value_type
Definition: utility.hpp:104
Designed for command line parsing.
Definition: utility.hpp:820
T get(const String &name, bool space_delete=true) const
Access arguments by name.
Definition: utility.hpp:886
String getPathToApplication() const
Returns application path.
void about(const String &message)
Set the about message.
Impl * impl
Definition: utility.hpp:962
void getByIndex(int index, bool space_delete, Param type, void *dst) const
T get(int index, bool space_delete=true) const
Access positional arguments by index.
Definition: utility.hpp:918
CommandLineParser(const CommandLineParser &parser)
Copy constructor.
void printErrors() const
Print list of errors occurred.
void printMessage() const
Print help message.
bool has(const String &name) const
Check if field was provided in the command line.
~CommandLineParser()
Destructor.
void getByName(const String &name, bool space_delete, Param type, void *dst) const
CommandLineParser(int argc, const char *const argv[], const String &keys)
Constructor.
bool check() const
Check for parsing errors.
Template matrix class derived from Mat.
Definition: mat.hpp:2230
MatSize size
Definition: mat.hpp:2160
Mat col(int x) const
Creates a matrix header for the specified matrix column.
int dims
the matrix dimensionality, >= 2
Definition: mat.hpp:2136
Mat row(int y) const
Creates a matrix header for the specified matrix row.
size_t total() const
Returns the total number of array elements.
bool empty() const
Returns true if the array has no elements.
Mat operator()(Range rowRange, Range colRange) const
Extracts a rectangular submatrix.
Mat & operator=(const Mat &m)
assignment operators
Definition: utility.hpp:1075
Node< OBJECT > * findChild(OBJECT &payload) const
Definition: utility.hpp:1096
Node(OBJECT &payload)
Definition: utility.hpp:1081
int findChild(Node< OBJECT > *pNode) const
Definition: utility.hpp:1106
~Node()
Definition: utility.hpp:1085
int getDepth()
Definition: utility.hpp:1136
std::vector< Node< OBJECT > * > m_childs
Definition: utility.hpp:1147
Node< OBJECT > * m_pParent
Definition: utility.hpp:1146
Node()
Definition: utility.hpp:1077
void addChild(Node< OBJECT > *pNode)
Definition: utility.hpp:1116
OBJECT m_payload
Definition: utility.hpp:1145
void removeChilds()
Definition: utility.hpp:1126
Definition: utility.hpp:591
virtual void operator()(const cv::Range &range) const CV_OVERRIDE
Definition: utility.hpp:602
ParallelLoopBodyLambdaWrapper(std::function< void(const Range &)> functor)
Definition: utility.hpp:596
Base class for parallel data processors.
Definition: utility.hpp:577
virtual ~ParallelLoopBody()
Template class specifying a continuous subsequence (slice) of a sequence.
Definition: types.hpp:623
a Class to measure passing time.
Definition: utility.hpp:295
CV_WRAP void stop()
stops counting ticks.
Definition: utility.hpp:310
CV_WRAP void reset()
resets internal values.
Definition: utility.hpp:374
CV_WRAP double getFPS() const
returns average FPS (frames per second) value.
Definition: utility.hpp:351
CV_WRAP double getTimeSec() const
returns passed time in seconds.
Definition: utility.hpp:339
CV_WRAP TickMeter()
the default constructor
Definition: utility.hpp:298
CV_WRAP void start()
starts counting ticks.
Definition: utility.hpp:304
CV_WRAP double getTimeMilli() const
returns passed time in milliseconds.
Definition: utility.hpp:333
CV_WRAP double getAvgTimeMilli() const
returns average time in milliseconds
Definition: utility.hpp:368
CV_WRAP double getTimeMicro() const
returns passed time in microseconds.
Definition: utility.hpp:327
CV_WRAP int64 getCounter() const
returns internal counter value.
Definition: utility.hpp:345
CV_WRAP int64 getTimeTicks() const
returns counted ticks.
Definition: utility.hpp:321
CV_WRAP double getAvgTimeSec() const
returns average time in seconds
Definition: utility.hpp:360
T empty(T... args)
InputArrayOfArrays InputArrayOfArrays InputOutputArray InputOutputArray InputOutputArray InputOutputArray Size InputOutputArray InputOutputArray T
Definition: calib3d.hpp:1867
Param
Definition: core.hpp:3299
void void * frame
Definition: core_c.h:1913
Cv_iplAllocateImageData Cv_iplDeallocate deallocate
Definition: core_c.h:1964
const int * idx
Definition: core_c.h:668
CvArr const CvMat * mat
Definition: core_c.h:1308
int index
Definition: core_c.h:634
int int type
Definition: core_c.h:221
int count
Definition: core_c.h:1413
CvMemStorage CvSeq CvCmpFunc void * userdata
Definition: core_c.h:1724
const char const char * err_msg
Definition: core_c.h:2623
void * data
Definition: core_c.h:427
const CvArr const CvArr CvArr * result
Definition: core_c.h:1423
const char * func_name
Definition: core_c.h:2622
const char const char const char * file_name
Definition: core_c.h:2623
int64_t int64
Definition: interface.h:61
@ LINES
Definition: opengl.hpp:480
CV_EXPORTS void parallel_for_(const Range &range, const ParallelLoopBody &body, double nstripes=-1.)
Parallel data processor.
CV_EXPORTS_W void addSamplesDataSearchPath(const cv::String &path)
Override search data path by adding new search location.
CV_EXPORTS_W cv::String findFileOrKeep(const cv::String &relative_path, bool silentMode=false)
Definition: utility.hpp:1187
CV_EXPORTS_W void addSamplesDataSearchSubDirectory(const cv::String &subdir)
Append samples search data sub directory.
CV_EXPORTS_W cv::String findFile(const cv::String &relative_path, bool required=true, bool silentMode=false)
Try to find requested data file.
CV_EXPORTS_W String getHardwareFeatureName(int feature)
Returns feature name by ID.
static _Tp * alignPtr(_Tp *ptr, int n=(int) sizeof(_Tp))
Aligns a pointer to the specified number of bytes.
Definition: utility.hpp:457
#define CV_EXPORTS
Definition: cvdef.h:435
static int roundUp(int a, unsigned int b)
Round first value up to the nearest multiple of second value.
Definition: utility.hpp:499
#define MIN(a, b)
Definition: cvdef.h:513
CV_EXPORTS_W void setNumThreads(int nthreads)
OpenCV will try to set the number of threads for subsequent parallel regions.
CV_EXPORTS_W std::string getCPUFeaturesLine()
Returns list of CPU features enabled during compilation.
#define CV_OVERRIDE
Definition: cvdef.h:792
static int divUp(int a, unsigned int b)
Integer division with result round up.
Definition: utility.hpp:482
CV_EXPORTS ErrorCallback redirectError(ErrorCallback errCallback, void *userdata=0, void **prevUserdata=0)
Sets the new error handler and the optional user data.
#define CV_Error(code, msg)
Call the error handler.
Definition: base.hpp:320
CV_EXPORTS_W int getVersionMinor()
Returns minor library version.
CV_EXPORTS_W bool checkHardwareSupport(int feature)
Returns true if the specified feature is supported by the host hardware.
#define CV_EXPORTS_W
Definition: cvdef.h:472
CV_EXPORTS_W double getTickFrequency()
Returns the number of ticks per second.
CV_EXPORTS_W int getThreadNum()
Returns the index of the currently executed thread within the current parallel region....
CV_EXPORTS String tempfile(const char *suffix=0)
void forEach_impl(const Functor &operation)
Definition: utility.hpp:618
std::lock_guard< cv::Mutex > AutoLock
Definition: utility.hpp:719
CV_EXPORTS_W void setUseOptimized(bool onoff)
Enables or disables the optimized code.
CV_EXPORTS_W int getVersionRevision()
Returns revision field of the library version.
CV_EXPORTS bool setBreakOnError(bool flag)
Sets/resets the break-on-error mode.
CV_EXPORTS_W String getVersionString()
Returns library version string.
CV_EXPORTS_W int64 getTickCount()
Returns the number of ticks.
CV_EXPORTS_W bool useOptimized()
Returns the status of optimized code usage.
static size_t getElemSize(int type)
Definition: utility.hpp:568
CV_EXPORTS_W int getNumThreads()
Returns the number of threads used by OpenCV for parallel regions.
CV_EXPORTS void glob(String pattern, std::vector< String > &result, bool recursive=false)
CV_EXPORTS_W int getVersionMajor()
Returns major library version.
CV_EXPORTS_W int getNumberOfCPUs()
Returns the number of logical CPUs available for the process.
static bool isAligned(const T &data)
Alignment check of passed values.
Definition: utility.hpp:517
#define CV_WRAP
Definition: cvdef.h:481
int(* ErrorCallback)(int status, const char *func_name, const char *err_msg, const char *file_name, int line, void *userdata)
Definition: utility.hpp:162
CV_EXPORTS_W const String & getBuildInformation()
Returns full configuration time cmake output.
CV_EXPORTS_W int64 getCPUTickCount()
Returns the number of CPU ticks.
std::recursive_mutex Mutex
Definition: utility.hpp:718
static size_t alignSize(size_t sz, int n)
Aligns a buffer size to the specified number of bytes.
Definition: utility.hpp:470
#define CV_Assert(expr)
Checks a condition at runtime and throws exception if it fails.
Definition: base.hpp:342
#define CV_DbgAssert(expr)
Definition: base.hpp:375
#define CV_ELEM_SIZE(type)
Definition: cvdef.h:510
std::ostream & operator<<(std::ostream &, const DualQuat< _Tp > &)
CvArr CvSize range
Definition: imgproc_c.h:781
CvArr CvArr IplConvKernel int operation
Definition: imgproc_c.h:330
CV_EXPORTS_W void line(InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a line segment connecting two points.
OutputArray dst
Definition: imgproc.hpp:3564
@ StsNotImplemented
the requested function/feature is not implemented
Definition: base.hpp:113
CV_EXPORTS int getThreadID()
"black box" representation of the file storage associated with a file on disk.
Definition: calib3d.hpp:441
Definition: core.hpp:3182
T unlock(T... args)