Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
6cf9070b
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 9 个月
通知
992
Star
71100
Fork
55581
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6cf9070b
编写于
8月 14, 2013
作者:
B
Bahram Dahi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added ability to read several opencv types (Size, Point, etc.) to FileStorage. Solves issue #3196
上级
43c7a8ae
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
87 addition
and
1 deletion
+87
-1
modules/core/include/opencv2/core/operations.hpp
modules/core/include/opencv2/core/operations.hpp
+52
-0
modules/core/test/test_io.cpp
modules/core/test/test_io.cpp
+35
-1
未找到文件。
modules/core/include/opencv2/core/operations.hpp
浏览文件 @
6cf9070b
...
...
@@ -3001,6 +3001,58 @@ static inline void read(const FileNode& node, string& value, const string& defau
value
=
!
node
.
node
?
default_value
:
CV_NODE_IS_STRING
(
node
.
node
->
tag
)
?
string
(
node
.
node
->
data
.
str
.
ptr
)
:
string
(
""
);
}
template
<
typename
_Tp
>
static
inline
void
read
(
const
FileNode
&
node
,
Point_
<
_Tp
>&
value
,
const
Point_
<
_Tp
>&
default_value
)
{
vector
<
_Tp
>
temp
;
FileNodeIterator
it
=
node
.
begin
();
it
>>
temp
;
value
=
temp
.
size
()
!=
2
?
default_value
:
Point_
<
_Tp
>
(
saturate_cast
<
_Tp
>
(
temp
[
0
]),
saturate_cast
<
_Tp
>
(
temp
[
1
]));
}
template
<
typename
_Tp
>
static
inline
void
read
(
const
FileNode
&
node
,
Point3_
<
_Tp
>&
value
,
const
Point3_
<
_Tp
>&
default_value
)
{
vector
<
_Tp
>
temp
;
FileNodeIterator
it
=
node
.
begin
();
it
>>
temp
;
value
=
temp
.
size
()
!=
3
?
default_value
:
Point3_
<
_Tp
>
(
saturate_cast
<
_Tp
>
(
temp
[
0
]),
saturate_cast
<
_Tp
>
(
temp
[
1
]),
saturate_cast
<
_Tp
>
(
temp
[
2
]));
}
template
<
typename
_Tp
>
static
inline
void
read
(
const
FileNode
&
node
,
Size_
<
_Tp
>&
value
,
const
Size_
<
_Tp
>&
default_value
)
{
vector
<
_Tp
>
temp
;
FileNodeIterator
it
=
node
.
begin
();
it
>>
temp
;
value
=
temp
.
size
()
!=
2
?
default_value
:
Size_
<
_Tp
>
(
saturate_cast
<
_Tp
>
(
temp
[
0
]),
saturate_cast
<
_Tp
>
(
temp
[
1
]));
}
template
<
typename
_Tp
>
static
inline
void
read
(
const
FileNode
&
node
,
Complex
<
_Tp
>&
value
,
const
Complex
<
_Tp
>&
default_value
)
{
vector
<
_Tp
>
temp
;
FileNodeIterator
it
=
node
.
begin
();
it
>>
temp
;
value
=
temp
.
size
()
!=
2
?
default_value
:
Complex
<
_Tp
>
(
saturate_cast
<
_Tp
>
(
temp
[
0
]),
saturate_cast
<
_Tp
>
(
temp
[
1
]));
}
template
<
typename
_Tp
>
static
inline
void
read
(
const
FileNode
&
node
,
Rect_
<
_Tp
>&
value
,
Rect_
<
_Tp
>&
default_value
)
{
vector
<
_Tp
>
temp
;
FileNodeIterator
it
=
node
.
begin
();
it
>>
temp
;
value
=
temp
.
size
()
!=
4
?
default_value
:
Rect_
<
_Tp
>
(
saturate_cast
<
_Tp
>
(
temp
[
0
]),
saturate_cast
<
_Tp
>
(
temp
[
1
]),
saturate_cast
<
_Tp
>
(
temp
[
2
]),
saturate_cast
<
_Tp
>
(
temp
[
3
]));
}
template
<
typename
_Tp
,
int
cn
>
static
inline
void
read
(
const
FileNode
&
node
,
Vec
<
_Tp
,
cn
>&
value
,
const
Vec
<
_Tp
,
cn
>&
default_value
)
{
vector
<
_Tp
>
temp
;
FileNodeIterator
it
=
node
.
begin
();
it
>>
temp
;
value
=
temp
.
size
()
!=
cn
?
default_value
:
Vec
<
_Tp
,
cn
>
(
&
temp
[
0
]);
}
template
<
typename
_Tp
>
static
inline
void
read
(
const
FileNode
&
node
,
Scalar_
<
_Tp
>&
value
,
const
Scalar_
<
_Tp
>&
default_value
)
{
vector
<
_Tp
>
temp
;
FileNodeIterator
it
=
node
.
begin
();
it
>>
temp
;
value
=
temp
.
size
()
!=
4
?
default_value
:
Scalar_
<
_Tp
>
(
saturate_cast
<
_Tp
>
(
temp
[
0
]),
saturate_cast
<
_Tp
>
(
temp
[
1
]),
saturate_cast
<
_Tp
>
(
temp
[
2
]),
saturate_cast
<
_Tp
>
(
temp
[
3
]));
}
static
inline
void
read
(
const
FileNode
&
node
,
Range
&
value
,
const
Range
&
default_value
)
{
Point2i
temp
(
value
.
start
,
value
.
end
);
const
Point2i
default_temp
=
Point2i
(
default_value
.
start
,
default_value
.
end
);
read
(
node
,
temp
,
default_temp
);
value
.
start
=
temp
.
x
;
value
.
end
=
temp
.
y
;
}
CV_EXPORTS_W
void
read
(
const
FileNode
&
node
,
Mat
&
mat
,
const
Mat
&
default_mat
=
Mat
()
);
CV_EXPORTS
void
read
(
const
FileNode
&
node
,
SparseMat
&
mat
,
const
SparseMat
&
default_mat
=
SparseMat
()
);
...
...
modules/core/test/test_io.cpp
浏览文件 @
6cf9070b
...
...
@@ -390,7 +390,6 @@ protected:
try
{
string
fname
=
cv
::
tempfile
(
".xml"
);
FileStorage
fs
(
fname
,
FileStorage
::
WRITE
);
vector
<
int
>
mi
,
mi2
,
mi3
,
mi4
;
vector
<
Mat
>
mv
,
mv2
,
mv3
,
mv4
;
Mat
m
(
10
,
9
,
CV_32F
);
...
...
@@ -398,24 +397,59 @@ protected:
randu
(
m
,
0
,
1
);
mi3
.
push_back
(
5
);
mv3
.
push_back
(
m
);
Point_
<
float
>
p1
(
1.1
f
,
2.2
f
),
op1
;
Point3i
p2
(
3
,
4
,
5
),
op2
;
Size
s1
(
6
,
7
),
os1
;
Complex
<
int
>
c1
(
9
,
10
),
oc1
;
Rect
r1
(
11
,
12
,
13
,
14
),
or1
;
Vec
<
int
,
5
>
v1
(
15
,
16
,
17
,
18
,
19
),
ov1
;
Scalar
sc1
(
20.0
,
21.1
,
22.2
,
23.3
),
osc1
;
Range
g1
(
7
,
8
),
og1
;
FileStorage
fs
(
fname
,
FileStorage
::
WRITE
);
fs
<<
"mi"
<<
mi
;
fs
<<
"mv"
<<
mv
;
fs
<<
"mi3"
<<
mi3
;
fs
<<
"mv3"
<<
mv3
;
fs
<<
"empty"
<<
empty
;
fs
<<
"p1"
<<
p1
;
fs
<<
"p2"
<<
p2
;
fs
<<
"s1"
<<
s1
;
fs
<<
"c1"
<<
c1
;
fs
<<
"r1"
<<
r1
;
fs
<<
"v1"
<<
v1
;
fs
<<
"sc1"
<<
sc1
;
fs
<<
"g1"
<<
g1
;
fs
.
release
();
fs
.
open
(
fname
,
FileStorage
::
READ
);
fs
[
"mi"
]
>>
mi2
;
fs
[
"mv"
]
>>
mv2
;
fs
[
"mi3"
]
>>
mi4
;
fs
[
"mv3"
]
>>
mv4
;
fs
[
"empty"
]
>>
empty
;
fs
[
"p1"
]
>>
op1
;
fs
[
"p2"
]
>>
op2
;
fs
[
"s1"
]
>>
os1
;
fs
[
"c1"
]
>>
oc1
;
fs
[
"r1"
]
>>
or1
;
fs
[
"v1"
]
>>
ov1
;
fs
[
"sc1"
]
>>
osc1
;
fs
[
"g1"
]
>>
og1
;
CV_Assert
(
mi2
.
empty
()
);
CV_Assert
(
mv2
.
empty
()
);
CV_Assert
(
norm
(
mi3
,
mi4
,
CV_C
)
==
0
);
CV_Assert
(
mv4
.
size
()
==
1
);
double
n
=
norm
(
mv3
[
0
],
mv4
[
0
],
CV_C
);
CV_Assert
(
n
==
0
);
CV_Assert
(
op1
==
p1
);
CV_Assert
(
op2
==
p2
);
CV_Assert
(
os1
==
s1
);
CV_Assert
(
oc1
==
c1
);
CV_Assert
(
or1
==
r1
);
CV_Assert
(
ov1
==
v1
);
CV_Assert
(
osc1
==
sc1
);
CV_Assert
(
og1
==
g1
);
}
catch
(...)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录