Templates -- Meow  204.13.18
A C++ template contains kinds of interesting classes and functions
meow Namespace Reference

Classes

class  Color3_Space
 Base class of color space with 3 channels. More...
 
class  HSLf_Space
 以浮點數Y(亮度), U(色度), V(濃度) 三個值所組成的色彩空間 More...
 
class  HSVf_Space
 以浮點數Y(亮度), U(色度), V(濃度) 三個值所組成的色彩空間 More...
 
class  RGBi_Space
 以整數 Red, Green, Blue 三個值所組成的色彩空間 More...
 
class  RGBf_Space
 以浮點數Red, Green, Blue 三個值所組成的色彩空間 More...
 
class  YUVf_Space
 以浮點數Y(亮度), U(色度), V(濃度) 三個值所組成的色彩空間 More...
 
class  BinaryIndexTree
 極度簡化的 SegmentTree 已無區間更新的操作 More...
 
class  DisjointSet
 用來維護一堆互斥集的資訊 More...
 
class  HashTableList
 一個當key相撞時會用list解決的hash_table More...
 
class  KD_Tree
 k-dimension tree More...
 
class  MergeableHeap
 一個用 左偏樹 實作的 Maximum-Heap , 除了原本heap有的功能外, 還支援 merge 功能 More...
 
class  SegmentTree
 中文名 線段樹 More...
 
class  SplayTree
 是一種神乎其技的資料結構, 維護一堆 Key->Value . 並且支援 一些 std::map 難以快速實踐的操作, 如 split , merge , keyOffset More...
 
class  SplayTree_Range
 基本上跟SplayTree一樣, 不過這邊結合線段樹, 多了區間操作 (線段樹相關operator定義請見 SegmentTree ) More...
 
class  VP_Tree
 跟KD_Tree很像歐 More...
 
class  Vector2D
 2D's vector More...
 
class  Vector3D
 3D's vector More...
 
class  Bitmap
 二維點陣資料 More...
 
struct  SceneInfo
 
class  BundleAdjustment
 
class  BundleAdjustment_LM
 
class  Camera
 Camera. More...
 
class  Eye
 一個 Camera 加上一個offset transformation More...
 
class  FeaturePoint
 特徵點 More...
 
class  FeaturePointsDetector
 
class  FeaturePointsDetector_Harris
 Harris corner detect. More...
 
class  FeaturePointsMatch
 
class  FeaturePointsMatch_K_Match
 
class  IdentityPoints
 把一個 std::map<ID,Vector<Scalar> > 包起來 More...
 
class  Photo
 底片 More...
 
class  ViewPort
 未完待續 More...
 
class  WatchBall
 多個camera, 一個offset, 一個rotation More...
 
class  LinearTransformation
 A base class for implementing kinds of linear transformations. More...
 
class  Rotation3D
 Rotation a point/vector alone an axis with given angle in 3D world. More...
 
class  Matrix
 matrix More...
 
class  Transformation
 A base class for implementing kinds of transformations. More...
 
class  BallProjection
 A ball projection is to project the given vector to a hyper-sphere. More...
 
class  PhotoProjection
 A photo projection is a kind of transformation that project point/vector to a flat photo. More...
 
class  Vector
 vector More...
 
class  ObjArray
 純粹把 std::vector 包起來, 變成繼承自 ObjBase More...
 
class  ObjBase
 一切物件的Base, 並要求每個物件都要有read, write, create, ... 等功能 More...
 
class  ObjDictionary
 純粹把 std::map 包起來, 變成繼承自 ObjBase More...
 
class  ObjProperties
 目前擺爛中 More...
 
class  ObjSelector
 利用register的概念, 達到runtime用string選擇要new的class More...
 
class  ObjType
 純粹把給定的 Type 包起來, 變成繼承自 ObjBase More...
 
class  ReaderWriter_int
 
class  ReaderWriter_size_t
 
class  ReaderWriter_double
 
class  ReaderWriter_string
 
class  Self
 A little class use for packing the data part of another class. With this technique, it can achieve Copy-On-Write(COR) mechanism at background and have a reference mechanism which much more flexible then the one C++ has. More...
 
class  Usage
 管理參數設置, 自訂usage document, 分析argc, argv More...
 
struct  PairToPair
 A structur with memember .from.first , .from.second , .to.first , .to.second. More...
 

Typedefs

typedef PairToPair< size_t,
size_t, size_t, size_t > 
FeaturePointIndexPair
 
typedef std::vector
< FeaturePointIndexPair
FeaturePointIndexPairs
 
typedef ObjType< int,
ReaderWriter_int
ObjInt
 
typedef ObjType< size_t,
ReaderWriter_size_t
ObjSizeT
 
typedef ObjType< double,
ReaderWriter_double
ObjDouble
 
typedef ObjType< std::string,
ReaderWriter_string
ObjString
 

Enumerations

enum  SceneInfoFlags { CAN_OFFSET = 0x01, CAN_ROTATE = 0x02, CAN_ZOOM = 0x04 }
 

Functions

void colorTransformate (RGBf_Space const &rgb, HSLf_Space *hsl)
 RGBf_Space to HSLf_Space More...
 
void colorTransformate (YUVf_Space const &yuv, HSLf_Space *hsl)
 YUVf_Space to HSLf_Space More...
 
void colorTransformate (HSLf_Space const &hsl, RGBf_Space *rgb)
 HSLf_Space to RGBf_Space More...
 
void colorTransformate (HSLf_Space const &hsl, YUVf_Space *yuv)
 HSLf_Space to YUVf_Space More...
 
void colorTransformate (HSLf_Space const &hsl, RGBi_Space *rgb)
 HSLf_Space to RGBi_Space More...
 
void colorTransformate (RGBi_Space const &rgb, HSLf_Space *hsl)
 RGBi_Space to HSLf_Space More...
 
void colorTransformate (RGBf_Space const &rgb, HSVf_Space *hsv)
 RGBf_Space to HSVf_Space More...
 
void colorTransformate (YUVf_Space const &yuv, HSVf_Space *hsv)
 YUVf_Space to HSVf_Space More...
 
void colorTransformate (HSLf_Space const &hsl, HSVf_Space *hsv)
 HSLf_Space to HSVf_Space More...
 
void colorTransformate (HSVf_Space const &hsv, RGBf_Space *rgb)
 HSVf_Space to RGBf_Space More...
 
void colorTransformate (HSVf_Space const &hsv, YUVf_Space *yuv)
 HSVf_Space to YUVf_Space More...
 
void colorTransformate (HSVf_Space const &hsv, HSLf_Space *hsl)
 HSVf_Space to HSLf_Space More...
 
void colorTransformate (HSVf_Space const &hsv, RGBi_Space *rgb)
 HSVf_Space to RGBi_Space More...
 
void colorTransformate (RGBi_Space const &rgb, HSVf_Space *hsv)
 RGBi_Space to HSVf_Space More...
 
void colorTransformate (RGBi_Space const &a, RGBf_Space *b)
 RGBi_Space to RGBf_Space More...
 
void colorTransformate (RGBf_Space const &a, RGBi_Space *b)
 RGBf_Space to RGBi_Space More...
 
void colorTransformate (RGBf_Space const &rgb, YUVf_Space *yuv)
 RGBf_Space to YUVf_Space More...
 
void colorTransformate (YUVf_Space const &yuv, RGBf_Space *rgb)
 YUVf_Space to RGBf_Space More...
 
void colorTransformate (RGBi_Space const &rgb, YUVf_Space *yuv)
 RGBi_Space to YUVf_Space More...
 
void colorTransformate (YUVf_Space const &yuv, RGBi_Space *rgb)
 YUVf_Space to RGBi_Space More...
 
template<class Data , class WeightingClass >
std::vector< Data > ransac (std::vector< Data > const &data, WeightingClass const &w, size_t N, double p0, double P)
 Run the RANSAC method to approach the best solution. More...
 
template<class Scalar , class Function >
Vector< Scalar > levenbergMarquardt (Function const &f, Vector< Scalar > const &init, int counter=-1)
 
template<class Scalar , class Function >
Vector< Scalar > levenbergMarquardtTraining (Function &f, Vector< Scalar > const &init, Scalar const &init_mu, Scalar const &mu_pow, Scalar const &er_max, int retry_number, int counter)
 
template<class T >
noEPS (T value, T eps=1e-9)
 如果abs(輸入的數值) < eps, 則回傳0, 否則回傳輸入的數值 More...
 
template<class T >
normalize (T lower, T upper, T value)
 (value-lower)/(upper-lower) More...
 
template<class T >
denormalize (T lower, T upper, T _ratio)
 (lower+_ratio*(upper-lower)) More...
 
template<class T >
ratioMapping (T l1, T u1, T m1, T l2, T u2)
 denormalize(l2,u2,normalize(l1,u1,m1)) More...
 
template<class T >
inRange (T const &mn, T const &mx, T const &v)
 std::min(mx,std::max(mn,v)) More...
 
template<class T >
isInRange (T const &mn, T const &mx, T const &x)
 (mn <= x && x <= mx) More...
 
template<class T >
squ (T const &x)
 x*x More...
 
template<class T >
cub (T const &x)
 x*x*x More...
 
template<class T >
double average (T const &beg, T const &end, double sigs)
 只將 sigs 個標準差以內的數據拿來取平均 More...
 
template<class T >
double average (T const &beg, T const &end, T const &p, double sigs)
 只將 sigs 個標準差以內的數據拿來取平均, 不過這次用 p 來加權平均 More...
 
template<class T >
tAbs (T const &t)
 就只是個取絕對值 More...
 
std::string stringPrintf (char const *fmt,...)
 類似C的printf, 不過是將格式化的字串丟到 std::string 裡回傳 More...
 
std::string stringReplace (std::string str, std::string const &from, std::string const &to)
 將輸入字串中的某個pattern取代成另一個pattern More...
 
bool cstringEndWith (char const *str, int n,...)
 檢查給定字串的結尾是否符合給定的數個patterns中的一個 More...
 
void debugPrintf_ (char const *file, char const *func, size_t line, char const *msg)
 
void messagePrintf (int level_change, char const *fmt,...)
 階層式輸出 More...
 
bool filenameCompare (std::string const &f1, std::string const &f2)
 將兩個字串用人類習慣的檔名排序方式排序 More...
 

Variables

const unsigned int kBitmapReadWritePixels = 0x1
 
static const double PI = 3.14159265358979323846264338327950288
 圓周率... More...
 
static const size_t kGlobalSeletorID = 0
 

Typedef Documentation

typedef PairToPair<size_t, size_t, size_t, size_t> meow::FeaturePointIndexPair

Definition at line 13 of file FeaturePointsMatch.h.

Definition at line 14 of file FeaturePointsMatch.h.

Definition at line 196 of file ObjTypes.h.

Definition at line 194 of file ObjTypes.h.

Definition at line 195 of file ObjTypes.h.

Definition at line 197 of file ObjTypes.h.

Enumeration Type Documentation

Enumerator
CAN_OFFSET 
CAN_ROTATE 
CAN_ZOOM 

Definition at line 10 of file BundleAdjustment.h.

Function Documentation

template<class T >
double meow::average ( T const &  beg,
T const &  end,
double  sigs 
)
inline

只將 sigs 個標準差以內的數據拿來取平均

Definition at line 83 of file utility.h.

template<class T >
double meow::average ( T const &  beg,
T const &  end,
T const &  p,
double  sigs 
)
inline

只將 sigs 個標準差以內的數據拿來取平均, 不過這次用 p 來加權平均

Definition at line 110 of file utility.h.

void meow::colorTransformate ( RGBf_Space const &  rgb,
YUVf_Space *  yuv 
)
inline

RGBf_Space to YUVf_Space

Definition at line 84 of file YUV_Space.h.

void meow::colorTransformate ( RGBf_Space const &  rgb,
HSLf_Space *  hsl 
)
inline

RGBf_Space to HSLf_Space

Definition at line 85 of file HSL_Space.h.

void meow::colorTransformate ( RGBf_Space const &  rgb,
HSVf_Space *  hsv 
)
inline

RGBf_Space to HSVf_Space

Definition at line 86 of file HSV_Space.h.

void meow::colorTransformate ( YUVf_Space const &  yuv,
RGBf_Space *  rgb 
)
inline

YUVf_Space to RGBf_Space

Definition at line 99 of file YUV_Space.h.

void meow::colorTransformate ( YUVf_Space const &  yuv,
HSVf_Space *  hsv 
)
inline

YUVf_Space to HSVf_Space

Definition at line 109 of file HSV_Space.h.

void meow::colorTransformate ( YUVf_Space const &  yuv,
HSLf_Space *  hsl 
)
inline

YUVf_Space to HSLf_Space

Definition at line 109 of file HSL_Space.h.

void meow::colorTransformate ( RGBi_Space const &  rgb,
YUVf_Space *  yuv 
)
inline

RGBi_Space to YUVf_Space

Definition at line 114 of file YUV_Space.h.

void meow::colorTransformate ( HSLf_Space const &  hsl,
HSVf_Space *  hsv 
)
inline

HSLf_Space to HSVf_Space

Definition at line 118 of file HSV_Space.h.

void meow::colorTransformate ( HSLf_Space const &  hsl,
RGBf_Space *  rgb 
)
inline

HSLf_Space to RGBf_Space

Definition at line 118 of file HSL_Space.h.

void meow::colorTransformate ( YUVf_Space const &  yuv,
RGBi_Space *  rgb 
)
inline

YUVf_Space to RGBi_Space

Definition at line 123 of file YUV_Space.h.

void meow::colorTransformate ( HSVf_Space const &  hsv,
RGBf_Space *  rgb 
)
inline

HSVf_Space to RGBf_Space

Definition at line 127 of file HSV_Space.h.

void meow::colorTransformate ( RGBi_Space const &  a,
RGBf_Space *  b 
)
inline

RGBi_Space to RGBf_Space

Definition at line 149 of file RGB_Space.h.

void meow::colorTransformate ( HSVf_Space const &  hsv,
YUVf_Space *  yuv 
)
inline

HSVf_Space to YUVf_Space

Definition at line 151 of file HSV_Space.h.

void meow::colorTransformate ( RGBf_Space const &  a,
RGBi_Space *  b 
)
inline

RGBf_Space to RGBi_Space

Definition at line 159 of file RGB_Space.h.

void meow::colorTransformate ( HSLf_Space const &  hsl,
YUVf_Space *  yuv 
)
inline

HSLf_Space to YUVf_Space

Definition at line 160 of file HSL_Space.h.

void meow::colorTransformate ( HSVf_Space const &  hsv,
HSLf_Space *  hsl 
)
inline

HSVf_Space to HSLf_Space

Definition at line 160 of file HSV_Space.h.

void meow::colorTransformate ( HSLf_Space const &  hsl,
RGBi_Space *  rgb 
)
inline

HSLf_Space to RGBi_Space

Definition at line 169 of file HSL_Space.h.

void meow::colorTransformate ( HSVf_Space const &  hsv,
RGBi_Space *  rgb 
)
inline

HSVf_Space to RGBi_Space

Definition at line 169 of file HSV_Space.h.

void meow::colorTransformate ( RGBi_Space const &  rgb,
HSLf_Space *  hsl 
)
inline

RGBi_Space to HSLf_Space

Definition at line 179 of file HSL_Space.h.

void meow::colorTransformate ( RGBi_Space const &  rgb,
HSVf_Space *  hsv 
)
inline

RGBi_Space to HSVf_Space

Definition at line 179 of file HSV_Space.h.

bool meow::cstringEndWith ( char const *  str,
int  n,
  ... 
)
inline

檢查給定字串的結尾是否符合給定的數個patterns中的一個

Parameters
[in]str愈檢查的字串
[in]npattern數
[in]...各種pattern
Returns
true/false 表示 是否有符合
Note
參數中所有的字串都是用cstring 來傳遞, 也就是 char const* 型態

Definition at line 82 of file utility.h.

template<class T >
T meow::cub ( T const &  x)
inline

x*x*x

Definition at line 75 of file utility.h.

void meow::debugPrintf_ ( char const *  file,
char const *  func,
size_t  line,
char const *  msg 
)
inline

Definition at line 110 of file utility.h.

template<class T >
T meow::denormalize ( lower,
upper,
_ratio 
)
inline

(lower+_ratio*(upper-lower))

Definition at line 35 of file utility.h.

bool meow::filenameCompare ( std::string const &  f1,
std::string const &  f2 
)
inline

將兩個字串用人類習慣的檔名排序方式排序

例如 a1 < a2 < a3 < a10 < a12 < a20, 而不是 a1 < a10 < a12 < a2 < a20 < a3

Parameters
[in]f1第一個字串
[in]f2第二個字串
Returns
true/falsef1是否該排在f2前面

Definition at line 179 of file utility.h.

template<class T >
T meow::inRange ( T const &  mn,
T const &  mx,
T const &  v 
)
inline

std::min(mx,std::max(mn,v))

Definition at line 51 of file utility.h.

template<class T >
T meow::isInRange ( T const &  mn,
T const &  mx,
T const &  x 
)
inline

(mn <= x && x <= mx)

Definition at line 59 of file utility.h.

template<class Scalar , class Function >
Vector<Scalar> meow::levenbergMarquardt ( Function const &  f,
Vector< Scalar > const &  init,
int  counter = -1 
)
inline

Definition at line 163 of file methods.h.

template<class Scalar , class Function >
Vector<Scalar> meow::levenbergMarquardtTraining ( Function &  f,
Vector< Scalar > const &  init,
Scalar const &  init_mu,
Scalar const &  mu_pow,
Scalar const &  er_max,
int  retry_number,
int  counter 
)
inline

Definition at line 183 of file methods.h.

void meow::messagePrintf ( int  level_change,
char const *  fmt,
  ... 
)
inline

階層式輸出

像是printf, 但多了一個 巢狀 的概念, 例如:

message1(level = 0)
message2(level = 1)
information1(level = 2)
information2(level = 2)
... ok(for message2)
message3(level = 1) ... ok
information3(level = 1)
message4(level = 1)
message5(level = 2) ... ok
message6(level = 2) ... ok
information4(level = 2)
... ok(for message4)
... ok(for message5)
Parameters
[in]level_change分以下三種情況:
  • == 0, 只是印出一個information
  • == 1, 印出一個message, 並且level++
  • == -1, 表示此訊息相對應最近一次level++的那個message
[in]fmt,...跟printf一樣
Returns

Definition at line 146 of file utility.h.

template<class T >
T meow::noEPS ( value,
eps = 1e-9 
)
inline

如果abs(輸入的數值) < eps, 則回傳0, 否則回傳輸入的數值

Definition at line 18 of file utility.h.

template<class T >
T meow::normalize ( lower,
upper,
value 
)
inline

(value-lower)/(upper-lower)

Definition at line 27 of file utility.h.

template<class Data , class WeightingClass >
std::vector<Data> meow::ransac ( std::vector< Data > const &  data,
WeightingClass const &  w,
size_t  N,
double  p0,
double  P 
)
inline

Run the RANSAC method to approach the best solution.

RANdom SAmple Consensus is an iterative method to estimate parameters of a mathematical model from a set of observed data which contains outliers.
Each iterator it will choose a subset of elements, the smallest set which can form a valid parameters, from the data set. And then calculate how many elements in the whole data set is inliers. After iterator much times, we just say the best solution is the parameters that has the much inliers elements in whole iterators.

Assume:

  • We need at least $ N $ element to form a valid parameters.
  • The probability of choosing a right element from data set each time is $ p_0 $.
  • We want the probability of our solution actually being the best solution be $ P $.
  • We need to iterator $ M $ times.

Then we can estimate the number of iterations $ M $ :

\[ \begin{aligned} & (1 - p_0^N)^M \leq(1 - P) \\ \Rightarrow & M \log(1 - p_0^N) \leq \log(1 - P) \\ \Rightarrow & M \geq \frac{\log(1 - p)}{\log(1 - p_0^N)},~~ \because (1-p_0^N<1 \Rightarrow \log(1-p_0^N)<0) \end{aligned} \]

So in this function we choose $ M = \lceil \frac{\log(1 - P)}{\log(1 - p_0^N)} \rceil $

Parameters
[in]dataThe whole data sett
[in]wWeight function to give a floating number for a given parameters which means how best this solution is. Negitave number means invalid parameters.
[in]N$ N $, defined above
[in]p0$ p_0 $, defined above
[in]P$ P $, defined above
Returns
solution.
Author
cat_leopard

Definition at line 58 of file methods.h.

template<class T >
T meow::ratioMapping ( l1,
u1,
m1,
l2,
u2 
)
inline

denormalize(l2,u2,normalize(l1,u1,m1))

Definition at line 43 of file utility.h.

template<class T >
T meow::squ ( T const &  x)
inline

x*x

Definition at line 67 of file utility.h.

std::string meow::stringPrintf ( char const *  fmt,
  ... 
)
inline

類似C的printf, 不過是將格式化的字串丟到 std::string 裡回傳

Parameters
[in]fmt,...同printf
Returns
一個 std::string
Warning
目前格式化字串最長只支援8191個字元

Definition at line 43 of file utility.h.

std::string meow::stringReplace ( std::string  str,
std::string const &  from,
std::string const &  to 
)
inline

將輸入字串中的某個pattern取代成另一個pattern

Parameters
[in]str輸入的字串
[in]from要被取代的pattern
[in]to將要取代的pattern
Returns
取代後的字串
Warning
有礙於目前實作方法很低級暴力, 時間複雜度神高

Definition at line 61 of file utility.h.

template<class T >
T meow::tAbs ( T const &  t)
inline

就只是個取絕對值

Definition at line 141 of file utility.h.

Variable Documentation

const unsigned int meow::kBitmapReadWritePixels = 0x1

Definition at line 17 of file Bitmap.h.

const size_t meow::kGlobalSeletorID = 0
static

Definition at line 210 of file ObjSelector.h.

const double meow::PI = 3.14159265358979323846264338327950288
static

圓周率...

Definition at line 12 of file utility.h.