init: 64 bits version of the webcam
This commit is contained in:
@ -41,25 +41,21 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_CVSTD_HPP__
|
||||
#define __OPENCV_CORE_CVSTD_HPP__
|
||||
#ifndef OPENCV_CORE_CVSTD_HPP
|
||||
#define OPENCV_CORE_CVSTD_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error cvstd.hpp header must be compiled as C++
|
||||
#endif
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <cctype>
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
# include <string>
|
||||
#endif
|
||||
#include <string>
|
||||
|
||||
// import useful primitives from stl
|
||||
#ifndef OPENCV_NOSTL_TRANSITIONAL
|
||||
# include <algorithm>
|
||||
# include <utility>
|
||||
# include <cstdlib> //for abs(int)
|
||||
@ -67,6 +63,11 @@
|
||||
|
||||
namespace cv
|
||||
{
|
||||
static inline uchar abs(uchar a) { return a; }
|
||||
static inline ushort abs(ushort a) { return a; }
|
||||
static inline unsigned abs(unsigned a) { return a; }
|
||||
static inline uint64 abs(uint64 a) { return a; }
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
using std::abs;
|
||||
@ -77,29 +78,6 @@ namespace cv
|
||||
using std::log;
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
static inline uchar abs(uchar a) { return a; }
|
||||
static inline ushort abs(ushort a) { return a; }
|
||||
static inline unsigned abs(unsigned a) { return a; }
|
||||
static inline uint64 abs(uint64 a) { return a; }
|
||||
}
|
||||
|
||||
#else
|
||||
namespace cv
|
||||
{
|
||||
template<typename T> static inline T min(T a, T b) { return a < b ? a : b; }
|
||||
template<typename T> static inline T max(T a, T b) { return a > b ? a : b; }
|
||||
template<typename T> static inline T abs(T a) { return a < 0 ? -a : a; }
|
||||
template<typename T> static inline void swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
|
||||
|
||||
template<> inline uchar abs(uchar a) { return a; }
|
||||
template<> inline ushort abs(ushort a) { return a; }
|
||||
template<> inline unsigned abs(unsigned a) { return a; }
|
||||
template<> inline uint64 abs(uint64 a) { return a; }
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace cv {
|
||||
|
||||
//! @addtogroup core_utils
|
||||
@ -411,6 +389,11 @@ struct Ptr
|
||||
template<typename Y>
|
||||
Ptr<Y> dynamicCast() const;
|
||||
|
||||
#ifdef CV_CXX_MOVE_SEMANTICS
|
||||
Ptr(Ptr&& o);
|
||||
Ptr& operator = (Ptr&& o);
|
||||
#endif
|
||||
|
||||
private:
|
||||
detail::PtrOwner* owner;
|
||||
T* stored;
|
||||
@ -487,7 +470,7 @@ public:
|
||||
|
||||
static const size_t npos = size_t(-1);
|
||||
|
||||
explicit String();
|
||||
String();
|
||||
String(const String& str);
|
||||
String(const String& str, size_t pos, size_t len = npos);
|
||||
String(const char* s);
|
||||
@ -554,7 +537,6 @@ public:
|
||||
|
||||
String toLowerCase() const;
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
String(const std::string& str);
|
||||
String(const std::string& str, size_t pos, size_t len = npos);
|
||||
String& operator=(const std::string& str);
|
||||
@ -563,7 +545,6 @@ public:
|
||||
|
||||
friend String operator+ (const String& lhs, const std::string& rhs);
|
||||
friend String operator+ (const std::string& lhs, const String& rhs);
|
||||
#endif
|
||||
|
||||
private:
|
||||
char* cstr_;
|
||||
@ -571,6 +552,8 @@ private:
|
||||
|
||||
char* allocate(size_t len); // len without trailing 0
|
||||
void deallocate();
|
||||
|
||||
String(int); // disabled and invalid. Catch invalid usages like, commandLineParser.has(0) problem
|
||||
};
|
||||
|
||||
//! @} core_basic
|
||||
@ -615,6 +598,7 @@ String::String(const char* s)
|
||||
{
|
||||
if (!s) return;
|
||||
size_t len = strlen(s);
|
||||
if (!len) return;
|
||||
memcpy(allocate(len), s, len);
|
||||
}
|
||||
|
||||
@ -623,6 +607,7 @@ String::String(const char* s, size_t n)
|
||||
: cstr_(0), len_(0)
|
||||
{
|
||||
if (!n) return;
|
||||
if (!s) return;
|
||||
memcpy(allocate(n), s, n);
|
||||
}
|
||||
|
||||
@ -630,6 +615,7 @@ inline
|
||||
String::String(size_t n, char c)
|
||||
: cstr_(0), len_(0)
|
||||
{
|
||||
if (!n) return;
|
||||
memset(allocate(n), c, n);
|
||||
}
|
||||
|
||||
@ -638,6 +624,7 @@ String::String(const char* first, const char* last)
|
||||
: cstr_(0), len_(0)
|
||||
{
|
||||
size_t len = (size_t)(last - first);
|
||||
if (!len) return;
|
||||
memcpy(allocate(len), first, len);
|
||||
}
|
||||
|
||||
@ -646,6 +633,7 @@ String::String(Iterator first, Iterator last)
|
||||
: cstr_(0), len_(0)
|
||||
{
|
||||
size_t len = (size_t)(last - first);
|
||||
if (!len) return;
|
||||
char* str = allocate(len);
|
||||
while (first != last)
|
||||
{
|
||||
@ -678,7 +666,7 @@ String& String::operator=(const char* s)
|
||||
deallocate();
|
||||
if (!s) return *this;
|
||||
size_t len = strlen(s);
|
||||
memcpy(allocate(len), s, len);
|
||||
if (len) memcpy(allocate(len), s, len);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -744,7 +732,7 @@ const char* String::begin() const
|
||||
inline
|
||||
const char* String::end() const
|
||||
{
|
||||
return len_ ? cstr_ + 1 : 0;
|
||||
return len_ ? cstr_ + len_ : NULL;
|
||||
}
|
||||
|
||||
inline
|
||||
@ -896,6 +884,7 @@ size_t String::find_first_of(const String& str, size_t pos) const
|
||||
inline
|
||||
size_t String::find_first_of(const char* s, size_t pos) const
|
||||
{
|
||||
if (len_ == 0) return npos;
|
||||
if (pos >= len_ || !s[0]) return npos;
|
||||
const char* lmax = cstr_ + len_;
|
||||
for (const char* i = cstr_ + pos; i < lmax; ++i)
|
||||
@ -910,6 +899,7 @@ size_t String::find_first_of(const char* s, size_t pos) const
|
||||
inline
|
||||
size_t String::find_last_of(const char* s, size_t pos, size_t n) const
|
||||
{
|
||||
if (len_ == 0) return npos;
|
||||
if (pos >= len_) pos = len_ - 1;
|
||||
for (const char* i = cstr_ + pos; i >= cstr_; --i)
|
||||
{
|
||||
@ -935,6 +925,7 @@ size_t String::find_last_of(const String& str, size_t pos) const
|
||||
inline
|
||||
size_t String::find_last_of(const char* s, size_t pos) const
|
||||
{
|
||||
if (len_ == 0) return npos;
|
||||
if (pos >= len_) pos = len_ - 1;
|
||||
for (const char* i = cstr_ + pos; i >= cstr_; --i)
|
||||
{
|
||||
@ -948,8 +939,9 @@ size_t String::find_last_of(const char* s, size_t pos) const
|
||||
inline
|
||||
String String::toLowerCase() const
|
||||
{
|
||||
if (!cstr_)
|
||||
return String();
|
||||
String res(cstr_, len_);
|
||||
|
||||
for (size_t i = 0; i < len_; ++i)
|
||||
res.cstr_[i] = (char) ::tolower(cstr_[i]);
|
||||
|
||||
@ -968,8 +960,8 @@ String operator + (const String& lhs, const String& rhs)
|
||||
{
|
||||
String s;
|
||||
s.allocate(lhs.len_ + rhs.len_);
|
||||
memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
memcpy(s.cstr_ + lhs.len_, rhs.cstr_, rhs.len_);
|
||||
if (lhs.len_) memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
if (rhs.len_) memcpy(s.cstr_ + lhs.len_, rhs.cstr_, rhs.len_);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -979,8 +971,8 @@ String operator + (const String& lhs, const char* rhs)
|
||||
String s;
|
||||
size_t rhslen = strlen(rhs);
|
||||
s.allocate(lhs.len_ + rhslen);
|
||||
memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
memcpy(s.cstr_ + lhs.len_, rhs, rhslen);
|
||||
if (lhs.len_) memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
if (rhslen) memcpy(s.cstr_ + lhs.len_, rhs, rhslen);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -990,8 +982,8 @@ String operator + (const char* lhs, const String& rhs)
|
||||
String s;
|
||||
size_t lhslen = strlen(lhs);
|
||||
s.allocate(lhslen + rhs.len_);
|
||||
memcpy(s.cstr_, lhs, lhslen);
|
||||
memcpy(s.cstr_ + lhslen, rhs.cstr_, rhs.len_);
|
||||
if (lhslen) memcpy(s.cstr_, lhs, lhslen);
|
||||
if (rhs.len_) memcpy(s.cstr_ + lhslen, rhs.cstr_, rhs.len_);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -1000,7 +992,7 @@ String operator + (const String& lhs, char rhs)
|
||||
{
|
||||
String s;
|
||||
s.allocate(lhs.len_ + 1);
|
||||
memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
if (lhs.len_) memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
s.cstr_[lhs.len_] = rhs;
|
||||
return s;
|
||||
}
|
||||
@ -1011,7 +1003,7 @@ String operator + (char lhs, const String& rhs)
|
||||
String s;
|
||||
s.allocate(rhs.len_ + 1);
|
||||
s.cstr_[0] = lhs;
|
||||
memcpy(s.cstr_ + 1, rhs.cstr_, rhs.len_);
|
||||
if (rhs.len_) memcpy(s.cstr_ + 1, rhs.cstr_, rhs.len_);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -1038,22 +1030,11 @@ static inline bool operator>= (const String& lhs, const char* rhs) { return lh
|
||||
|
||||
} // cv
|
||||
|
||||
#ifndef OPENCV_NOSTL_TRANSITIONAL
|
||||
namespace std
|
||||
{
|
||||
static inline void swap(cv::String& a, cv::String& b) { a.swap(b); }
|
||||
}
|
||||
#else
|
||||
namespace cv
|
||||
{
|
||||
template<> inline
|
||||
void swap<cv::String>(cv::String& a, cv::String& b)
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "opencv2/core/ptr.inl.hpp"
|
||||
|
||||
#endif //__OPENCV_CORE_CVSTD_HPP__
|
||||
#endif //OPENCV_CORE_CVSTD_HPP
|
||||
|
||||
Reference in New Issue
Block a user