Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
e972d6b8
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e972d6b8
编写于
3月 31, 2013
作者:
A
Andrey Kamaev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Drop template Vector class
上级
3890a745
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
234 deletion
+16
-234
modules/core/include/opencv2/core/operations.hpp
modules/core/include/opencv2/core/operations.hpp
+16
-234
未找到文件。
modules/core/include/opencv2/core/operations.hpp
浏览文件 @
e972d6b8
...
...
@@ -330,250 +330,32 @@ SVD::backSubst( const Matx<_Tp, nm, 1>& w, const Matx<_Tp, m, nm>& u,
CV_Assert
(
_dst
.
data
==
(
uchar
*
)
&
dst
.
val
[
0
]);
}
//////////////////////////////// Vector ////////////////////////////////
// template vector class. It is similar to STL's vector,
// with a few important differences:
// 1) it can be created on top of user-allocated data w/o copying it
// 2) vector b = a means copying the header,
// not the underlying data (use clone() to make a deep copy)
template
<
typename
_Tp
>
class
CV_EXPORTS
Vector
{
public:
typedef
_Tp
value_type
;
typedef
_Tp
*
iterator
;
typedef
const
_Tp
*
const_iterator
;
typedef
_Tp
&
reference
;
typedef
const
_Tp
&
const_reference
;
struct
CV_EXPORTS
Hdr
{
Hdr
()
:
data
(
0
),
datastart
(
0
),
refcount
(
0
),
size
(
0
),
capacity
(
0
)
{};
_Tp
*
data
;
_Tp
*
datastart
;
int
*
refcount
;
size_t
size
;
size_t
capacity
;
};
Vector
()
{}
Vector
(
size_t
_size
)
{
resize
(
_size
);
}
Vector
(
size_t
_size
,
const
_Tp
&
val
)
{
resize
(
_size
);
for
(
size_t
i
=
0
;
i
<
_size
;
i
++
)
hdr
.
data
[
i
]
=
val
;
}
Vector
(
_Tp
*
_data
,
size_t
_size
,
bool
_copyData
=
false
)
{
set
(
_data
,
_size
,
_copyData
);
}
template
<
int
n
>
Vector
(
const
Vec
<
_Tp
,
n
>&
vec
)
{
set
((
_Tp
*
)
&
vec
.
val
[
0
],
n
,
true
);
}
Vector
(
const
std
::
vector
<
_Tp
>&
vec
,
bool
_copyData
=
false
)
{
set
(
!
vec
.
empty
()
?
(
_Tp
*
)
&
vec
[
0
]
:
0
,
vec
.
size
(),
_copyData
);
}
Vector
(
const
Vector
&
d
)
{
*
this
=
d
;
}
Vector
(
const
Vector
&
d
,
const
Range
&
r_
)
{
Range
r
=
r_
==
Range
::
all
()
?
Range
(
0
,
d
.
size
())
:
r_
;
/*if( r == Range::all() )
r = Range(0, d.size());*/
if
(
r
.
size
()
>
0
&&
r
.
start
>=
0
&&
r
.
end
<=
d
.
size
()
)
{
if
(
d
.
hdr
.
refcount
)
CV_XADD
(
d
.
hdr
.
refcount
,
1
);
hdr
.
refcount
=
d
.
hdr
.
refcount
;
hdr
.
datastart
=
d
.
hdr
.
datastart
;
hdr
.
data
=
d
.
hdr
.
data
+
r
.
start
;
hdr
.
capacity
=
hdr
.
size
=
r
.
size
();
}
}
Vector
<
_Tp
>&
operator
=
(
const
Vector
&
d
)
{
if
(
this
!=
&
d
)
{
if
(
d
.
hdr
.
refcount
)
CV_XADD
(
d
.
hdr
.
refcount
,
1
);
release
();
hdr
=
d
.
hdr
;
}
return
*
this
;
}
~
Vector
()
{
release
();
}
Vector
<
_Tp
>
clone
()
const
{
return
hdr
.
data
?
Vector
<
_Tp
>
(
hdr
.
data
,
hdr
.
size
,
true
)
:
Vector
<
_Tp
>
();
}
void
copyTo
(
Vector
<
_Tp
>&
vec
)
const
{
size_t
i
,
sz
=
size
();
vec
.
resize
(
sz
);
const
_Tp
*
src
=
hdr
.
data
;
_Tp
*
dst
=
vec
.
hdr
.
data
;
for
(
i
=
0
;
i
<
sz
;
i
++
)
dst
[
i
]
=
src
[
i
];
}
void
copyTo
(
std
::
vector
<
_Tp
>&
vec
)
const
{
size_t
i
,
sz
=
size
();
vec
.
resize
(
sz
);
const
_Tp
*
src
=
hdr
.
data
;
_Tp
*
dst
=
sz
?
&
vec
[
0
]
:
0
;
for
(
i
=
0
;
i
<
sz
;
i
++
)
dst
[
i
]
=
src
[
i
];
}
// operator CvMat() const
// { return cvMat((int)size(), 1, type(), (void*)hdr.data); }
_Tp
&
operator
[]
(
size_t
i
)
{
CV_DbgAssert
(
i
<
size
()
);
return
hdr
.
data
[
i
];
}
const
_Tp
&
operator
[]
(
size_t
i
)
const
{
CV_DbgAssert
(
i
<
size
()
);
return
hdr
.
data
[
i
];
}
Vector
operator
()
(
const
Range
&
r
)
const
{
return
Vector
(
*
this
,
r
);
}
_Tp
&
back
()
{
CV_DbgAssert
(
!
empty
());
return
hdr
.
data
[
hdr
.
size
-
1
];
}
const
_Tp
&
back
()
const
{
CV_DbgAssert
(
!
empty
());
return
hdr
.
data
[
hdr
.
size
-
1
];
}
_Tp
&
front
()
{
CV_DbgAssert
(
!
empty
());
return
hdr
.
data
[
0
];
}
const
_Tp
&
front
()
const
{
CV_DbgAssert
(
!
empty
());
return
hdr
.
data
[
0
];
}
_Tp
*
begin
()
{
return
hdr
.
data
;
}
_Tp
*
end
()
{
return
hdr
.
data
+
hdr
.
size
;
}
const
_Tp
*
begin
()
const
{
return
hdr
.
data
;
}
const
_Tp
*
end
()
const
{
return
hdr
.
data
+
hdr
.
size
;
}
void
addref
()
{
if
(
hdr
.
refcount
)
CV_XADD
(
hdr
.
refcount
,
1
);
}
void
release
()
{
if
(
hdr
.
refcount
&&
CV_XADD
(
hdr
.
refcount
,
-
1
)
==
1
)
{
delete
[]
hdr
.
datastart
;
delete
hdr
.
refcount
;
}
hdr
=
Hdr
();
}
void
set
(
_Tp
*
_data
,
size_t
_size
,
bool
_copyData
=
false
)
{
if
(
!
_copyData
)
{
release
();
hdr
.
data
=
hdr
.
datastart
=
_data
;
hdr
.
size
=
hdr
.
capacity
=
_size
;
hdr
.
refcount
=
0
;
}
else
{
reserve
(
_size
);
for
(
size_t
i
=
0
;
i
<
_size
;
i
++
)
hdr
.
data
[
i
]
=
_data
[
i
];
hdr
.
size
=
_size
;
}
}
void
reserve
(
size_t
newCapacity
)
{
_Tp
*
newData
;
int
*
newRefcount
;
size_t
i
,
oldSize
=
hdr
.
size
;
if
(
(
!
hdr
.
refcount
||
*
hdr
.
refcount
==
1
)
&&
hdr
.
capacity
>=
newCapacity
)
return
;
newCapacity
=
std
::
max
(
newCapacity
,
oldSize
);
newData
=
new
_Tp
[
newCapacity
];
newRefcount
=
new
int
(
1
);
for
(
i
=
0
;
i
<
oldSize
;
i
++
)
newData
[
i
]
=
hdr
.
data
[
i
];
release
();
hdr
.
data
=
hdr
.
datastart
=
newData
;
hdr
.
capacity
=
newCapacity
;
hdr
.
size
=
oldSize
;
hdr
.
refcount
=
newRefcount
;
}
void
resize
(
size_t
newSize
)
{
size_t
i
;
newSize
=
std
::
max
(
newSize
,
(
size_t
)
0
);
if
(
(
!
hdr
.
refcount
||
*
hdr
.
refcount
==
1
)
&&
hdr
.
size
==
newSize
)
return
;
if
(
newSize
>
hdr
.
capacity
)
reserve
(
std
::
max
(
newSize
,
std
::
max
((
size_t
)
4
,
hdr
.
capacity
*
2
)));
for
(
i
=
hdr
.
size
;
i
<
newSize
;
i
++
)
hdr
.
data
[
i
]
=
_Tp
();
hdr
.
size
=
newSize
;
}
Vector
<
_Tp
>&
push_back
(
const
_Tp
&
elem
)
{
if
(
hdr
.
size
==
hdr
.
capacity
)
reserve
(
std
::
max
((
size_t
)
4
,
hdr
.
capacity
*
2
)
);
hdr
.
data
[
hdr
.
size
++
]
=
elem
;
return
*
this
;
}
Vector
<
_Tp
>&
pop_back
()
{
if
(
hdr
.
size
>
0
)
--
hdr
.
size
;
return
*
this
;
}
size_t
size
()
const
{
return
hdr
.
size
;
}
size_t
capacity
()
const
{
return
hdr
.
capacity
;
}
bool
empty
()
const
{
return
hdr
.
size
==
0
;
}
void
clear
()
{
resize
(
0
);
}
int
type
()
const
{
return
DataType
<
_Tp
>::
type
;
}
protected:
Hdr
hdr
;
};
// Multiply-with-Carry RNG
inline
RNG
::
RNG
()
{
state
=
0xffffffff
;
}
inline
RNG
::
RNG
(
uint64
_state
)
{
state
=
_state
?
_state
:
0xffffffff
;
}
template
<
typename
_Tp
>
inline
typename
DataType
<
_Tp
>::
work_type
dot
(
const
Vector
<
_Tp
>&
v1
,
const
Vector
<
_Tp
>&
v2
)
{
typedef
typename
DataType
<
_Tp
>::
work_type
_Tw
;
size_t
i
=
0
,
n
=
v1
.
size
();
assert
(
v1
.
size
()
==
v2
.
size
());
inline
RNG
::
operator
uchar
()
{
return
(
uchar
)
next
();
}
inline
RNG
::
operator
schar
()
{
return
(
schar
)
next
();
}
inline
RNG
::
operator
ushort
()
{
return
(
ushort
)
next
();
}
inline
RNG
::
operator
short
()
{
return
(
short
)
next
();
}
inline
RNG
::
operator
int
()
{
return
(
int
)
next
();
}
inline
RNG
::
operator
unsigned
()
{
return
next
();
}
inline
RNG
::
operator
float
()
{
return
next
()
*
2.3283064365386962890625e-10
f
;
}
inline
RNG
::
operator
double
()
{
unsigned
t
=
next
();
return
(((
uint64
)
t
<<
32
)
|
next
())
*
5.4210108624275221700372640043497e-20
;
}
_Tw
s
=
0
;
const
_Tp
*
ptr1
=
&
v1
[
0
],
*
ptr2
=
&
v2
[
0
];
for
(
;
i
<
n
;
i
++
)
s
+=
(
_Tw
)
ptr1
[
i
]
*
ptr2
[
i
];
inline
unsigned
RNG
::
operator
()(
unsigned
N
)
{
return
(
unsigned
)
uniform
(
0
,
N
);
}
inline
unsigned
RNG
::
operator
()()
{
return
next
();
}
return
s
;
}
inline
int
RNG
::
uniform
(
int
a
,
int
b
)
{
return
a
==
b
?
a
:
(
int
)(
next
()
%
(
b
-
a
)
+
a
);
}
inline
float
RNG
::
uniform
(
float
a
,
float
b
)
{
return
((
float
)
*
this
)
*
(
b
-
a
)
+
a
;
}
inline
double
RNG
::
uniform
(
double
a
,
double
b
)
{
return
((
double
)
*
this
)
*
(
b
-
a
)
+
a
;
}
// Multiply-with-Carry RNG
inline
RNG
::
RNG
()
{
state
=
0xffffffff
;
}
inline
RNG
::
RNG
(
uint64
_state
)
{
state
=
_state
?
_state
:
0xffffffff
;
}
inline
unsigned
RNG
::
next
()
{
state
=
(
uint64
)(
unsigned
)
state
*
/*CV_RNG_COEFF*/
4164903690U
+
(
unsigned
)(
state
>>
32
);
return
(
unsigned
)
state
;
}
inline
RNG
::
operator
uchar
()
{
return
(
uchar
)
next
();
}
inline
RNG
::
operator
schar
()
{
return
(
schar
)
next
();
}
inline
RNG
::
operator
ushort
()
{
return
(
ushort
)
next
();
}
inline
RNG
::
operator
short
()
{
return
(
short
)
next
();
}
inline
RNG
::
operator
unsigned
()
{
return
next
();
}
inline
unsigned
RNG
::
operator
()(
unsigned
N
)
{
return
(
unsigned
)
uniform
(
0
,
N
);}
inline
unsigned
RNG
::
operator
()()
{
return
next
();}
inline
RNG
::
operator
int
()
{
return
(
int
)
next
();
}
// * (2^32-1)^-1
inline
RNG
::
operator
float
()
{
return
next
()
*
2.3283064365386962890625e-10
f
;
}
inline
RNG
::
operator
double
()
{
unsigned
t
=
next
();
return
(((
uint64
)
t
<<
32
)
|
next
())
*
5.4210108624275221700372640043497e-20
;
}
inline
int
RNG
::
uniform
(
int
a
,
int
b
)
{
return
a
==
b
?
a
:
(
int
)(
next
()
%
(
b
-
a
)
+
a
);
}
inline
float
RNG
::
uniform
(
float
a
,
float
b
)
{
return
((
float
)
*
this
)
*
(
b
-
a
)
+
a
;
}
inline
double
RNG
::
uniform
(
double
a
,
double
b
)
{
return
((
double
)
*
this
)
*
(
b
-
a
)
+
a
;
}
inline
uchar
*
LineIterator
::
operator
*
()
{
return
ptr
;
}
inline
LineIterator
&
LineIterator
::
operator
++
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录