OpenCV 4.5.3(日本語機械翻訳)
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);
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
179CV_EXPORTS String tempfile( const char* suffix = 0);
180CV_EXPORTS void glob(String pattern, std::vector<String>& result, bool recursive = false);
181
200 CV_EXPORTS_W void setNumThreads(int nthreads);
201
218 CV_EXPORTS_W int getNumThreads();
219
234 CV_EXPORTS_W int getThreadNum();
235
242 CV_EXPORTS_W const String& getBuildInformation();
243
250 CV_EXPORTS_W String getVersionString();
251
253 CV_EXPORTS_W int getVersionMajor();
254
256 CV_EXPORTS_W int getVersionMinor();
257
259 CV_EXPORTS_W int getVersionRevision();
260
268 CV_EXPORTS_W int64 getTickCount();
269
281 CV_EXPORTS_W double getTickFrequency();
282
294 class CV_EXPORTS_W TickMeter
295{
296 public:
298 CV_WRAP TickMeter()
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
321 CV_WRAP int64 getTimeTicks() const
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
345 CV_WRAP int64 getCounter() const
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
398 std::ostream& operator << (std::ostream& out, const TickMeter& tm)
399{
400 return out << tm.getTimeSec() << "sec";
401}
402
415 CV_EXPORTS_W int64 getCPUTickCount();
416
425 CV_EXPORTS_W bool checkHardwareSupport(int feature);
426
431 CV_EXPORTS_W String getHardwareFeatureName(int feature);
432
443 CV_EXPORTS_W std::string getCPUFeaturesLine();
444
447 CV_EXPORTS_W int getNumberOfCPUs();
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
566 CV_EXPORTS_W bool useOptimized();
567
568 static inline size_t getElemSize(int type) { return (size_t)CV_ELEM_SIZE(type); }
569
571
576 class CV_EXPORTS ParallelLoopBody
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
596 ParallelLoopBodyLambdaWrapper(std::function<void(const Range&)> functor)
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{
612 parallel_for_(range, ParallelLoopBodyLambdaWrapper(functor), nstripes);
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 typedef std::recursive_mutex Mutex;
718 typedef std::lock_guard<cv::Mutex> AutoLock;
719 #endif
720
721
799 class CV_EXPORTS CommandLineParser
800{
801 public:
802
811 CommandLineParser(int argc, const char* const argv[], const String& keys);
812
815
817 CommandLineParser& operator = (const CommandLineParser& parser);
818
821
832 String getPathToApplication() const;
833
865 template <typename T>
866 T get(const String& name, bool space_delete = true) const
867 {
868 T val = T();
869 getByName(name, space_delete, ParamType<T>::type, (void*)&val);
870 return val;
871 }
872
897 template <typename T>
898 T get(int index, bool space_delete = true) const
899 {
900 T val = T();
901 getByIndex(index, space_delete, ParamType<T>::type, (void*)&val);
902 return val;
903 }
904
909 bool has(const String& name) const;
910
916 bool check() const;
917
922 void about(const String& message);
923
930 void printMessage() const;
931
936 void printErrors() const;
937
938 protected:
939 void getByName(const String& name, bool space_delete, Param type, void* dst) const;
940 void getByIndex(int index, bool space_delete, Param type, void* dst) const;
941
942 struct Impl;
943 Impl* impl;
944};
945
947
949
951
952 template<typename _Tp, size_t fixed_size> inline
954{
955 ptr = buf;
956 sz = fixed_size;
957}
958
959 template<typename _Tp, size_t fixed_size> inline
961{
962 ptr = buf;
963 sz = fixed_size;
964 allocate(_size);
965}
966
967 template<typename _Tp, size_t fixed_size> inline
968 AutoBuffer<_Tp, fixed_size>::AutoBuffer(const AutoBuffer<_Tp, fixed_size>& abuf )
969{
970 ptr = buf;
971 sz = fixed_size;
972 allocate(abuf.size());
973 for( size_t i = 0; i < sz; i++ )
974 ptr[i] = abuf.ptr[i];
975}
976
977 template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>&
978 AutoBuffer<_Tp, fixed_size>::operator = (const AutoBuffer<_Tp, fixed_size>& abuf)
979{
980 if( this != &abuf )
981 {
982 deallocate();
983 allocate(abuf.size());
984 for( size_t i = 0; i < sz; i++ )
985 ptr[i] = abuf.ptr[i];
986 }
987 return *this;
988}
989
990 template<typename _Tp, size_t fixed_size> inline
992{ deallocate(); }
993
994 template<typename _Tp, size_t fixed_size> inline void
996{
997 if(_size <= sz)
998 {
999 sz = _size;
1000 return;
1001 }
1002 deallocate();
1003 sz = _size;
1004 if(_size > fixed_size)
1005 {
1006 ptr = new _Tp[_size];
1007 }
1008}
1009
1010 template<typename _Tp, size_t fixed_size> inline void
1012{
1013 if( ptr != buf )
1014 {
1015 delete[] ptr;
1016 ptr = buf;
1017 sz = fixed_size;
1018 }
1019}
1020
1021 template<typename _Tp, size_t fixed_size> inline void
1023{
1024 if(_size <= sz)
1025 {
1026 sz = _size;
1027 return;
1028 }
1029 size_t i, prevsize = sz, minsize = MIN(prevsize, _size);
1030 _Tp* prevptr = ptr;
1031
1032 ptr = _size > fixed_size ? new _Tp[_size] : buf;
1033 sz = _size;
1034
1035 if( ptr != prevptr )
1036 for( i = 0; i < minsize; i++ )
1037 ptr[i] = prevptr[i];
1038 for( i = prevsize; i < _size; i++ )
1039 ptr[i] = _Tp();
1040
1041 if( prevptr != buf )
1042 delete[] prevptr;
1043}
1044
1045 template<typename _Tp, size_t fixed_size> inline size_t
1047 { return sz; }
1048
1050
1051
1052 // Basic Node class for tree building
1053 template<class OBJECT>
1054 class CV_EXPORTS Node
1055{
1056 public:
1057 Node()
1058 {
1059 m_pParent = 0;
1060 }
1061 Node(OBJECT& payload) : m_payload(payload)
1062 {
1063 m_pParent = 0;
1064 }
1065 ~Node()
1066 {
1067 removeChilds();
1068 if (m_pParent)
1069 {
1070 int idx = m_pParent->findChild(this);
1071 if (idx >= 0)
1072 m_pParent->m_childs.erase(m_pParent->m_childs.begin() + idx);
1073 }
1074 }
1075
1076 Node<OBJECT>* findChild(OBJECT& payload) const
1077 {
1078 for(size_t i = 0; i < this->m_childs.size(); i++)
1079 {
1080 if(this->m_childs[i]->m_payload == payload)
1081 return this->m_childs[i];
1082 }
1083 return NULL;
1084 }
1085
1086 int findChild(Node<OBJECT> *pNode) const
1087 {
1088 for (size_t i = 0; i < this->m_childs.size(); i++)
1089 {
1090 if(this->m_childs[i] == pNode)
1091 return (int)i;
1092 }
1093 return -1;
1094 }
1095
1096 void addChild(Node<OBJECT> *pNode)
1097 {
1098 if(!pNode)
1099 return;
1100
1101 CV_Assert(pNode->m_pParent == 0);
1102 pNode->m_pParent = this;
1103 this->m_childs.push_back(pNode);
1104 }
1105
1106 void removeChilds()
1107 {
1108 for(size_t i = 0; i < m_childs.size(); i++)
1109 {
1110 m_childs[i]->m_pParent = 0; // avoid excessive parent vector trimming
1111 delete m_childs[i];
1112 }
1113 m_childs.clear();
1114 }
1115
1116 int getDepth()
1117 {
1118 int count = 0;
1119 Node *pParent = m_pParent;
1120 while(pParent) count++, pParent = pParent->m_pParent;
1121 return count;
1122 }
1123
1124 public:
1125 OBJECT m_payload;
1126 Node<OBJECT>* m_pParent;
1127 std::vector<Node<OBJECT>*> m_childs;
1128};
1129
1130
1131 namespace samples {
1132
1134 // This section describes utility functions for OpenCV samples.
1135 //
1136 // @note Implementation of these utilities is not thread-safe.
1137 //
1139
1163 CV_EXPORTS_W cv::String findFile(const cv::String& relative_path, bool required = true, bool silentMode = false);
1164
1165CV_EXPORTS_W cv::String findFileOrKeep(const cv::String& relative_path, bool silentMode = false);
1166
1167 inline cv::String findFileOrKeep(const cv::String& relative_path, bool silentMode)
1168{
1169 cv::String res = findFile(relative_path, false, silentMode);
1170 if (res.empty())
1171 return relative_path;
1172 return res;
1173}
1174
1182 CV_EXPORTS_W void addSamplesDataSearchPath(const cv::String& path);
1183
1191 CV_EXPORTS_W void addSamplesDataSearchSubDirectory(const cv::String& subdir);
1192
1194} // namespace samples
1195
1196 namespace utils {
1197
1198CV_EXPORTS int getThreadID();
1199
1200} // namespace
1201
1202} //namespace cv
1203
1204 #ifdef CV_COLLECT_IMPL_DATA
1205 #include "opencv2/core/utils/instrumentation.hpp"
1206 #else
1208 #define CV_IMPL_ADD(impl)
1209 #endif
1210
1211 #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
~AutoBuffer()
destructor. calls deallocate()
AutoBuffer(const AutoBuffer< _Tp, fixed_size > &buf)
the copy constructor
_Tp * data()
returns pointer to the real buffer, stack-allocated or heap-allocated
Definition: utility.hpp:128
size_t size() const
returns the current buffer size
AutoBuffer< _Tp, fixed_size > & operator=(const AutoBuffer< _Tp, fixed_size > &buf)
the assignment operator
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
const _Tp * data() const
returns read-only pointer to the real buffer, stack-allocated or heap-allocated
Definition: utility.hpp:130
Designed for command line parsing
Definition: utility.hpp:800
T get(const String &name, bool space_delete=true) const
Access arguments by name
Definition: utility.hpp:866
String getPathToApplication() const
Returns application path
void about(const String &message)
Set the about message
T get(int index, bool space_delete=true) const
Access positional arguments by index
Definition: utility.hpp:898
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
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:2199
Mat col(int x) const
Creates a matrix header for the specified matrix column.
int dims
the matrix dimensionality, >= 2
Definition: mat.hpp:2105
Mat row(int y) const
Creates a matrix header for the specified matrix row.
Mat & operator=(const Mat &m)
assignment operators
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.
Definition: utility.hpp:1055
Base class for parallel data processors
Definition: utility.hpp:577
Definition: utility.hpp:591
Template class specifying a continuous subsequence (slice) of a sequence.
Definition: core/types.hpp:590
a Class to measure passing time.
Definition: utility.hpp:295
CV_WRAP double getTimeSec() const
returns passed time in seconds.
Definition: utility.hpp:339
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 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 int roundUp(int a, unsigned int b)
Round first value up to the nearest multiple of second value.
Definition: utility.hpp:499
CV_EXPORTS_W void setNumThreads(int nthreads)
OpenCV will try to set the number of threads for the next parallel region.
CV_EXPORTS_W std::string getCPUFeaturesLine()
Returns list of CPU features enabled during compilation.
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.
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.
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_W const String & getBuildInformation()
Returns full configuration time cmake output.
static _Tp * alignPtr(_Tp *ptr, int n=(int) sizeof(_Tp))
Aligns a pointer to the specified number of bytes.
Definition: utility.hpp:457
void forEach_impl(const Functor &operation)
Definition: utility.hpp:618
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.
CV_EXPORTS_W int getNumThreads()
Returns the number of threads used by OpenCV for parallel regions.
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
CV_EXPORTS_W int64 getCPUTickCount()
Returns the number of CPU ticks.
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
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.
cv
"black box" representation of the file storage associated with a file on disk.
Definition: aruco.hpp:75
Definition: core.hpp:3076