Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
78ca5ddd
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
78ca5ddd
编写于
7月 19, 2016
作者:
M
MYLS
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
solve errors and warnings
上级
0823ec0e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
86 addition
and
70 deletion
+86
-70
modules/core/include/opencv2/core/core_c.h
modules/core/include/opencv2/core/core_c.h
+1
-1
modules/core/perf/perf_io_base64.cpp
modules/core/perf/perf_io_base64.cpp
+2
-2
modules/core/src/persistence.cpp
modules/core/src/persistence.cpp
+81
-65
modules/core/test/test_io_base64.cpp
modules/core/test/test_io_base64.cpp
+2
-2
未找到文件。
modules/core/include/opencv2/core/core_c.h
浏览文件 @
78ca5ddd
...
@@ -2236,7 +2236,7 @@ and
...
@@ -2236,7 +2236,7 @@ and
@param len Number of the array elements to write
@param len Number of the array elements to write
@param dt Specification of each array element, see @ref format_spec "format specification"
@param dt Specification of each array element, see @ref format_spec "format specification"
*/
*/
CVAPI
(
void
)
cvWriteRawDataBase64
(
CvFileStorage
*
fs
,
const
void
*
_data
,
CVAPI
(
void
)
cvWriteRawDataBase64
(
CvFileStorage
*
fs
,
const
void
*
src
,
int
len
,
const
char
*
dt
);
int
len
,
const
char
*
dt
);
/** @brief Returns a unique pointer for a given name.
/** @brief Returns a unique pointer for a given name.
...
...
modules/core/perf/perf_io_base64.cpp
浏览文件 @
78ca5ddd
...
@@ -48,7 +48,7 @@ PERF_TEST_P(Size_Mat_StrType, fs_text,
...
@@ -48,7 +48,7 @@ PERF_TEST_P(Size_Mat_StrType, fs_text,
remove
(
file_name
.
c_str
());
remove
(
file_name
.
c_str
());
SANITY_CHECK
(
dst
);
SANITY_CHECK
(
dst
,
1
);
}
}
PERF_TEST_P
(
Size_Mat_StrType
,
fs_base64
,
PERF_TEST_P
(
Size_Mat_StrType
,
fs_base64
,
...
@@ -83,5 +83,5 @@ PERF_TEST_P(Size_Mat_StrType, fs_base64,
...
@@ -83,5 +83,5 @@ PERF_TEST_P(Size_Mat_StrType, fs_base64,
}
}
remove
(
file_name
.
c_str
());
remove
(
file_name
.
c_str
());
SANITY_CHECK
(
dst
);
SANITY_CHECK
(
dst
,
1
);
}
}
modules/core/src/persistence.cpp
浏览文件 @
78ca5ddd
...
@@ -183,7 +183,17 @@ typedef struct CvXMLStackRecord
...
@@ -183,7 +183,17 @@ typedef struct CvXMLStackRecord
}
}
CvXMLStackRecord
;
CvXMLStackRecord
;
namespace
base64
{
class
Base64Writer
;
}
namespace
base64
{
class
Base64Writer
;
enum
Base64State
{
Uncertain
,
NotUse
,
InUse
,
};
}
#define CV_XML_OPENING_TAG 1
#define CV_XML_OPENING_TAG 1
#define CV_XML_CLOSING_TAG 2
#define CV_XML_CLOSING_TAG 2
...
@@ -244,11 +254,7 @@ typedef struct CvFileStorage
...
@@ -244,11 +254,7 @@ typedef struct CvFileStorage
base64
::
Base64Writer
*
base64_writer
;
base64
::
Base64Writer
*
base64_writer
;
bool
is_default_using_base64
;
bool
is_default_using_base64
;
enum
Base64State
{
base64
::
Base64State
state_of_writing_base64
;
/**< used in WriteRawData only */
Uncertain
,
NotUse
,
InUse
,
}
state_of_writing_base64
;
/**< used in WriteRawData only */
bool
is_write_struct_delayed
;
bool
is_write_struct_delayed
;
char
*
delayed_struct_key
;
char
*
delayed_struct_key
;
...
@@ -339,7 +345,6 @@ namespace base64
...
@@ -339,7 +345,6 @@ namespace base64
private:
private:
::
CvFileStorage
*
file_storage
;
Base64ContextEmitter
*
emitter
;
Base64ContextEmitter
*
emitter
;
std
::
string
data_type_string
;
std
::
string
data_type_string
;
};
};
...
@@ -1061,10 +1066,14 @@ static double icv_strtod( CvFileStorage* fs, char* ptr, char** endptr )
...
@@ -1061,10 +1066,14 @@ static double icv_strtod( CvFileStorage* fs, char* ptr, char** endptr )
static
std
::
vector
<
std
::
string
>
analyze_file_name
(
std
::
string
const
&
file_name
)
static
std
::
vector
<
std
::
string
>
analyze_file_name
(
std
::
string
const
&
file_name
)
{
{
static
const
char
not_file_name
=
'\n'
;
static
const
char
parameter_begin
=
'?'
;
static
const
char
parameter_begin
=
'?'
;
static
const
char
parameter_separator
=
'&'
;
static
const
char
parameter_separator
=
'&'
;
std
::
vector
<
std
::
string
>
result
;
std
::
vector
<
std
::
string
>
result
;
if
(
file_name
.
find
(
not_file_name
,
0U
)
!=
std
::
string
::
npos
)
return
result
;
size_t
beg
=
file_name
.
find_last_of
(
parameter_begin
);
size_t
beg
=
file_name
.
find_last_of
(
parameter_begin
);
size_t
end
=
file_name
.
size
();
size_t
end
=
file_name
.
size
();
result
.
push_back
(
file_name
.
substr
(
0U
,
beg
));
result
.
push_back
(
file_name
.
substr
(
0U
,
beg
));
...
@@ -1087,7 +1096,7 @@ static std::vector<std::string> analyze_file_name( std::string const & file_name
...
@@ -1087,7 +1096,7 @@ static std::vector<std::string> analyze_file_name( std::string const & file_name
return
result
;
return
result
;
}
}
static
bool
is_param_exist
(
std
::
vector
<
std
::
string
>
&
const
params
,
std
::
string
&
const
param
)
static
bool
is_param_exist
(
const
std
::
vector
<
std
::
string
>
&
params
,
const
std
::
string
&
param
)
{
{
if
(
params
.
size
()
<
2U
)
if
(
params
.
size
()
<
2U
)
return
false
;
return
false
;
...
@@ -1095,7 +1104,7 @@ static bool is_param_exist( std::vector<std::string> & const params, std::string
...
@@ -1095,7 +1104,7 @@ static bool is_param_exist( std::vector<std::string> & const params, std::string
return
std
::
find
(
params
.
begin
(),
params
.
end
(),
param
)
!=
params
.
end
();
return
std
::
find
(
params
.
begin
(),
params
.
end
(),
param
)
!=
params
.
end
();
}
}
static
void
switch_to_Base64_state
(
CvFileStorage
*
fs
,
CvFileStorage
::
Base64State
state
)
static
void
switch_to_Base64_state
(
CvFileStorage
*
fs
,
base64
::
Base64State
state
)
{
{
const
char
*
err_unkonwn_state
=
"Unexpected error, unable to determine the Base64 state."
;
const
char
*
err_unkonwn_state
=
"Unexpected error, unable to determine the Base64 state."
;
const
char
*
err_unable_to_switch
=
"Unexpected error, unable to switch to this state."
;
const
char
*
err_unable_to_switch
=
"Unexpected error, unable to switch to this state."
;
...
@@ -1103,30 +1112,30 @@ static void switch_to_Base64_state( CvFileStorage* fs, CvFileStorage::Base64Stat
...
@@ -1103,30 +1112,30 @@ static void switch_to_Base64_state( CvFileStorage* fs, CvFileStorage::Base64Stat
/* like a finite state machine */
/* like a finite state machine */
switch
(
fs
->
state_of_writing_base64
)
switch
(
fs
->
state_of_writing_base64
)
{
{
case
CvFileStorage
::
Base64State
::
Uncertain
:
case
base64
::
Base64State
::
Uncertain
:
switch
(
state
)
switch
(
state
)
{
{
case
CvFileStorage
::
Base64State
::
InUse
:
case
base64
::
Base64State
::
InUse
:
CV_DbgAssert
(
fs
->
base64_writer
==
0
);
CV_DbgAssert
(
fs
->
base64_writer
==
0
);
fs
->
base64_writer
=
new
base64
::
Base64Writer
(
fs
);
fs
->
base64_writer
=
new
base64
::
Base64Writer
(
fs
);
break
;
break
;
case
CvFileStorage
::
Base64State
::
Uncertain
:
case
base64
::
Base64State
::
Uncertain
:
break
;
break
;
case
CvFileStorage
::
Base64State
::
NotUse
:
case
base64
::
Base64State
::
NotUse
:
break
;
break
;
default:
default:
CV_Error
(
CV_StsError
,
err_unkonwn_state
);
CV_Error
(
CV_StsError
,
err_unkonwn_state
);
break
;
break
;
}
}
break
;
break
;
case
CvFileStorage
::
Base64State
::
InUse
:
case
base64
::
Base64State
::
InUse
:
switch
(
state
)
switch
(
state
)
{
{
case
CvFileStorage
::
Base64State
::
InUse
:
case
base64
::
Base64State
::
InUse
:
case
CvFileStorage
::
Base64State
::
NotUse
:
case
base64
::
Base64State
::
NotUse
:
CV_Error
(
CV_StsError
,
err_unable_to_switch
);
CV_Error
(
CV_StsError
,
err_unable_to_switch
);
break
;
break
;
case
CvFileStorage
::
Base64State
::
Uncertain
:
case
base64
::
Base64State
::
Uncertain
:
delete
fs
->
base64_writer
;
delete
fs
->
base64_writer
;
fs
->
base64_writer
=
0
;
fs
->
base64_writer
=
0
;
break
;
break
;
...
@@ -1135,14 +1144,14 @@ static void switch_to_Base64_state( CvFileStorage* fs, CvFileStorage::Base64Stat
...
@@ -1135,14 +1144,14 @@ static void switch_to_Base64_state( CvFileStorage* fs, CvFileStorage::Base64Stat
break
;
break
;
}
}
break
;
break
;
case
CvFileStorage
::
Base64State
::
NotUse
:
case
base64
::
Base64State
::
NotUse
:
switch
(
state
)
switch
(
state
)
{
{
case
CvFileStorage
::
Base64State
::
InUse
:
case
base64
::
Base64State
::
InUse
:
case
CvFileStorage
::
Base64State
::
NotUse
:
case
base64
::
Base64State
::
NotUse
:
CV_Error
(
CV_StsError
,
err_unable_to_switch
);
CV_Error
(
CV_StsError
,
err_unable_to_switch
);
break
;
break
;
case
CvFileStorage
::
Base64State
::
Uncertain
:
case
base64
::
Base64State
::
Uncertain
:
break
;
break
;
default:
default:
CV_Error
(
CV_StsError
,
err_unkonwn_state
);
CV_Error
(
CV_StsError
,
err_unkonwn_state
);
...
@@ -1191,16 +1200,16 @@ static void check_if_write_struct_is_delayed( CvFileStorage* fs, bool change_typ
...
@@ -1191,16 +1200,16 @@ static void check_if_write_struct_is_delayed( CvFileStorage* fs, bool change_typ
if
(
change_type_to_base64
)
if
(
change_type_to_base64
)
{
{
fs
->
start_write_struct
(
fs
,
struct_key
,
struct_flags
,
"binary"
);
fs
->
start_write_struct
(
fs
,
struct_key
,
struct_flags
,
"binary"
);
if
(
fs
->
state_of_writing_base64
!=
CvFileStorage
::
Base64State
::
Uncertain
)
if
(
fs
->
state_of_writing_base64
!=
base64
::
Base64State
::
Uncertain
)
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
Uncertain
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
Uncertain
);
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
InUse
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
InUse
);
}
}
else
else
{
{
fs
->
start_write_struct
(
fs
,
struct_key
,
struct_flags
,
type_name
);
fs
->
start_write_struct
(
fs
,
struct_key
,
struct_flags
,
type_name
);
if
(
fs
->
state_of_writing_base64
!=
CvFileStorage
::
Base64State
::
Uncertain
)
if
(
fs
->
state_of_writing_base64
!=
base64
::
Base64State
::
Uncertain
)
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
Uncertain
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
Uncertain
);
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
NotUse
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
NotUse
);
}
}
delete
struct_key
;
delete
struct_key
;
...
@@ -1351,7 +1360,9 @@ static char* icvYMLParseBase64(CvFileStorage* fs, char* ptr, int indent, CvFileN
...
@@ -1351,7 +1360,9 @@ static char* icvYMLParseBase64(CvFileStorage* fs, char* ptr, int indent, CvFileN
/* buffer for decoded data(exclude header) */
/* buffer for decoded data(exclude header) */
std
::
vector
<
uchar
>
binary_buffer
(
base64
::
base64_decode_buffer_size
(
base64_buffer
.
size
())
);
std
::
vector
<
uchar
>
binary_buffer
(
base64
::
base64_decode_buffer_size
(
base64_buffer
.
size
())
);
int
total_byte_size
=
base64
::
base64_decode_buffer_size
(
base64_buffer
.
size
(),
base64_buffer
.
data
(),
false
);
int
total_byte_size
=
static_cast
<
int
>
(
base64
::
base64_decode_buffer_size
(
base64_buffer
.
size
(),
base64_buffer
.
data
(),
false
)
);
{
{
base64
::
Base64ContextParser
parser
(
binary_buffer
.
data
(),
binary_buffer
.
size
()
);
base64
::
Base64ContextParser
parser
(
binary_buffer
.
data
(),
binary_buffer
.
size
()
);
const
uchar
*
buffer_beg
=
reinterpret_cast
<
const
uchar
*>
(
base64_buffer
.
data
()
);
const
uchar
*
buffer_beg
=
reinterpret_cast
<
const
uchar
*>
(
base64_buffer
.
data
()
);
...
@@ -1830,11 +1841,11 @@ static void
...
@@ -1830,11 +1841,11 @@ static void
icvYMLWrite
(
CvFileStorage
*
fs
,
const
char
*
key
,
const
char
*
data
)
icvYMLWrite
(
CvFileStorage
*
fs
,
const
char
*
key
,
const
char
*
data
)
{
{
check_if_write_struct_is_delayed
(
fs
);
check_if_write_struct_is_delayed
(
fs
);
if
(
fs
->
state_of_writing_base64
==
CvFileStorage
::
Base64State
::
Uncertain
)
if
(
fs
->
state_of_writing_base64
==
base64
::
Base64State
::
Uncertain
)
{
{
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
NotUse
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
NotUse
);
}
}
else
if
(
fs
->
state_of_writing_base64
==
CvFileStorage
::
Base64State
::
InUse
)
else
if
(
fs
->
state_of_writing_base64
==
base64
::
Base64State
::
InUse
)
{
{
CV_Error
(
CV_StsError
,
"At present, output Base64 data only."
);
CV_Error
(
CV_StsError
,
"At present, output Base64 data only."
);
}
}
...
@@ -2305,7 +2316,9 @@ static char* icvXMLParseBase64(CvFileStorage* fs, char* ptr, CvFileNode * node)
...
@@ -2305,7 +2316,9 @@ static char* icvXMLParseBase64(CvFileStorage* fs, char* ptr, CvFileNode * node)
/* alloc buffer for all decoded data(include header) */
/* alloc buffer for all decoded data(include header) */
std
::
vector
<
uchar
>
binary_buffer
(
base64
::
base64_decode_buffer_size
(
base64_buffer
.
size
())
);
std
::
vector
<
uchar
>
binary_buffer
(
base64
::
base64_decode_buffer_size
(
base64_buffer
.
size
())
);
int
total_byte_size
=
base64
::
base64_decode_buffer_size
(
base64_buffer
.
size
(),
base64_buffer
.
data
(),
false
);
int
total_byte_size
=
static_cast
<
int
>
(
base64
::
base64_decode_buffer_size
(
base64_buffer
.
size
(),
base64_buffer
.
data
(),
false
)
);
{
{
base64
::
Base64ContextParser
parser
(
binary_buffer
.
data
(),
binary_buffer
.
size
()
);
base64
::
Base64ContextParser
parser
(
binary_buffer
.
data
(),
binary_buffer
.
size
()
);
const
uchar
*
buffer_beg
=
reinterpret_cast
<
const
uchar
*>
(
base64_buffer
.
data
()
);
const
uchar
*
buffer_beg
=
reinterpret_cast
<
const
uchar
*>
(
base64_buffer
.
data
()
);
...
@@ -2980,11 +2993,11 @@ static void
...
@@ -2980,11 +2993,11 @@ static void
icvXMLWriteScalar
(
CvFileStorage
*
fs
,
const
char
*
key
,
const
char
*
data
,
int
len
)
icvXMLWriteScalar
(
CvFileStorage
*
fs
,
const
char
*
key
,
const
char
*
data
,
int
len
)
{
{
check_if_write_struct_is_delayed
(
fs
);
check_if_write_struct_is_delayed
(
fs
);
if
(
fs
->
state_of_writing_base64
==
CvFileStorage
::
Base64State
::
Uncertain
)
if
(
fs
->
state_of_writing_base64
==
base64
::
Base64State
::
Uncertain
)
{
{
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
NotUse
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
NotUse
);
}
}
else
if
(
fs
->
state_of_writing_base64
==
CvFileStorage
::
Base64State
::
InUse
)
else
if
(
fs
->
state_of_writing_base64
==
base64
::
Base64State
::
InUse
)
{
{
CV_Error
(
CV_StsError
,
"Currently only Base64 data is allowed."
);
CV_Error
(
CV_StsError
,
"Currently only Base64 data is allowed."
);
}
}
...
@@ -3206,14 +3219,18 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
...
@@ -3206,14 +3219,18 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
bool
write_base64
=
write_mode
&&
(
flags
&
CV_STORAGE_BASE64
)
!=
0
;
bool
write_base64
=
write_mode
&&
(
flags
&
CV_STORAGE_BASE64
)
!=
0
;
bool
isGZ
=
false
;
bool
isGZ
=
false
;
size_t
fnamelen
=
0
;
size_t
fnamelen
=
0
;
const
char
*
filename
=
0
;
const
char
*
filename
=
query
;
std
::
vector
<
std
::
string
>
params
=
analyze_file_name
(
query
);
std
::
vector
<
std
::
string
>
params
;
if
(
!
params
.
empty
()
)
if
(
!
mem
)
filename
=
params
.
begin
()
->
c_str
();
{
params
=
analyze_file_name
(
query
);
if
(
!
params
.
empty
()
)
filename
=
params
.
begin
()
->
c_str
();
if
(
write_base64
==
false
&&
is_param_exist
(
params
,
std
::
string
(
"base64"
)
)
)
if
(
write_base64
==
false
&&
is_param_exist
(
params
,
"base64"
)
)
write_base64
=
true
;
write_base64
=
true
;
}
if
(
!
filename
||
filename
[
0
]
==
'\0'
)
if
(
!
filename
||
filename
[
0
]
==
'\0'
)
{
{
...
@@ -3317,7 +3334,7 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
...
@@ -3317,7 +3334,7 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
fs
->
base64_writer
=
0
;
fs
->
base64_writer
=
0
;
fs
->
is_default_using_base64
=
write_base64
;
fs
->
is_default_using_base64
=
write_base64
;
fs
->
state_of_writing_base64
=
CvFileStorage
::
Base64State
::
Uncertain
;
fs
->
state_of_writing_base64
=
base64
::
Base64State
::
Uncertain
;
fs
->
is_write_struct_delayed
=
false
;
fs
->
is_write_struct_delayed
=
false
;
fs
->
delayed_struct_key
=
0
;
fs
->
delayed_struct_key
=
0
;
...
@@ -3499,10 +3516,10 @@ cvStartWriteStruct( CvFileStorage* fs, const char* key, int struct_flags,
...
@@ -3499,10 +3516,10 @@ cvStartWriteStruct( CvFileStorage* fs, const char* key, int struct_flags,
{
{
CV_CHECK_OUTPUT_FILE_STORAGE
(
fs
);
CV_CHECK_OUTPUT_FILE_STORAGE
(
fs
);
check_if_write_struct_is_delayed
(
fs
);
check_if_write_struct_is_delayed
(
fs
);
if
(
fs
->
state_of_writing_base64
==
CvFileStorage
::
Base64State
::
NotUse
)
if
(
fs
->
state_of_writing_base64
==
base64
::
Base64State
::
NotUse
)
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
Uncertain
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
Uncertain
);
if
(
fs
->
state_of_writing_base64
==
CvFileStorage
::
Base64State
::
Uncertain
if
(
fs
->
state_of_writing_base64
==
base64
::
Base64State
::
Uncertain
&&
&&
CV_NODE_IS_SEQ
(
struct_flags
)
CV_NODE_IS_SEQ
(
struct_flags
)
&&
&&
...
@@ -3519,26 +3536,26 @@ cvStartWriteStruct( CvFileStorage* fs, const char* key, int struct_flags,
...
@@ -3519,26 +3536,26 @@ cvStartWriteStruct( CvFileStorage* fs, const char* key, int struct_flags,
/* Must output Base64 data */
/* Must output Base64 data */
if
(
!
CV_NODE_IS_SEQ
(
struct_flags
)
)
if
(
!
CV_NODE_IS_SEQ
(
struct_flags
)
)
CV_Error
(
CV_StsBadArg
,
"must set 'struct_flags |= CV_NODE_SEQ' if using Base64."
);
CV_Error
(
CV_StsBadArg
,
"must set 'struct_flags |= CV_NODE_SEQ' if using Base64."
);
else
if
(
fs
->
state_of_writing_base64
!=
CvFileStorage
::
Base64State
::
Uncertain
)
else
if
(
fs
->
state_of_writing_base64
!=
base64
::
Base64State
::
Uncertain
)
CV_Error
(
CV_StsError
,
"function
\'
cvStartWriteStruct
\'
calls cannot be nested if using Base64."
);
CV_Error
(
CV_StsError
,
"function
\'
cvStartWriteStruct
\'
calls cannot be nested if using Base64."
);
fs
->
start_write_struct
(
fs
,
key
,
struct_flags
,
type_name
);
fs
->
start_write_struct
(
fs
,
key
,
struct_flags
,
type_name
);
if
(
fs
->
state_of_writing_base64
!=
CvFileStorage
::
Base64State
::
Uncertain
)
if
(
fs
->
state_of_writing_base64
!=
base64
::
Base64State
::
Uncertain
)
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
Uncertain
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
Uncertain
);
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
InUse
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
InUse
);
}
}
else
else
{
{
/* Won't output Base64 data */
/* Won't output Base64 data */
if
(
fs
->
state_of_writing_base64
==
CvFileStorage
::
Base64State
::
InUse
)
if
(
fs
->
state_of_writing_base64
==
base64
::
Base64State
::
InUse
)
CV_Error
(
CV_StsError
,
"At the end of the output Base64, `cvEndWriteStruct` is needed."
);
CV_Error
(
CV_StsError
,
"At the end of the output Base64, `cvEndWriteStruct` is needed."
);
fs
->
start_write_struct
(
fs
,
key
,
struct_flags
,
type_name
);
fs
->
start_write_struct
(
fs
,
key
,
struct_flags
,
type_name
);
if
(
fs
->
state_of_writing_base64
!=
CvFileStorage
::
Base64State
::
Uncertain
)
if
(
fs
->
state_of_writing_base64
!=
base64
::
Base64State
::
Uncertain
)
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
Uncertain
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
Uncertain
);
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
NotUse
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
NotUse
);
}
}
}
}
...
@@ -3549,8 +3566,8 @@ cvEndWriteStruct( CvFileStorage* fs )
...
@@ -3549,8 +3566,8 @@ cvEndWriteStruct( CvFileStorage* fs )
CV_CHECK_OUTPUT_FILE_STORAGE
(
fs
);
CV_CHECK_OUTPUT_FILE_STORAGE
(
fs
);
check_if_write_struct_is_delayed
(
fs
);
check_if_write_struct_is_delayed
(
fs
);
if
(
fs
->
state_of_writing_base64
!=
CvFileStorage
::
Base64State
::
Uncertain
)
if
(
fs
->
state_of_writing_base64
!=
base64
::
Base64State
::
Uncertain
)
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
Uncertain
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
Uncertain
);
fs
->
end_write_struct
(
fs
);
fs
->
end_write_struct
(
fs
);
}
}
...
@@ -3730,14 +3747,14 @@ CV_IMPL void
...
@@ -3730,14 +3747,14 @@ CV_IMPL void
cvWriteRawData
(
CvFileStorage
*
fs
,
const
void
*
_data
,
int
len
,
const
char
*
dt
)
cvWriteRawData
(
CvFileStorage
*
fs
,
const
void
*
_data
,
int
len
,
const
char
*
dt
)
{
{
if
(
fs
->
is_default_using_base64
||
if
(
fs
->
is_default_using_base64
||
fs
->
state_of_writing_base64
==
CvFileStorage
::
Base64State
::
InUse
)
fs
->
state_of_writing_base64
==
base64
::
Base64State
::
InUse
)
{
{
base64
::
cvWriteRawDataBase64
(
fs
,
_data
,
len
,
dt
);
base64
::
cvWriteRawDataBase64
(
fs
,
_data
,
len
,
dt
);
return
;
return
;
}
}
else
if
(
fs
->
state_of_writing_base64
==
CvFileStorage
::
Base64State
::
Uncertain
)
else
if
(
fs
->
state_of_writing_base64
==
base64
::
Base64State
::
Uncertain
)
{
{
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
NotUse
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
NotUse
);
}
}
const
char
*
data0
=
(
const
char
*
)
_data
;
const
char
*
data0
=
(
const
char
*
)
_data
;
...
@@ -7259,8 +7276,7 @@ private:
...
@@ -7259,8 +7276,7 @@ private:
base64
::
Base64Writer
::
Base64Writer
(
::
CvFileStorage
*
fs
)
base64
::
Base64Writer
::
Base64Writer
(
::
CvFileStorage
*
fs
)
:
file_storage
(
fs
)
:
emitter
(
new
Base64ContextEmitter
(
fs
))
,
emitter
(
new
Base64ContextEmitter
(
fs
))
,
data_type_string
()
,
data_type_string
()
{
{
CV_CHECK_OUTPUT_FILE_STORAGE
(
fs
);
CV_CHECK_OUTPUT_FILE_STORAGE
(
fs
);
...
@@ -7325,11 +7341,11 @@ void base64::cvWriteRawDataBase64(::CvFileStorage* fs, const void* _data, int le
...
@@ -7325,11 +7341,11 @@ void base64::cvWriteRawDataBase64(::CvFileStorage* fs, const void* _data, int le
check_if_write_struct_is_delayed
(
fs
,
true
);
check_if_write_struct_is_delayed
(
fs
,
true
);
if
(
fs
->
state_of_writing_base64
==
CvFileStorage
::
Base64State
::
Uncertain
)
if
(
fs
->
state_of_writing_base64
==
base64
::
Base64State
::
Uncertain
)
{
{
switch_to_Base64_state
(
fs
,
CvFileStorage
::
Base64State
::
InUse
);
switch_to_Base64_state
(
fs
,
base64
::
Base64State
::
InUse
);
}
}
else
if
(
fs
->
state_of_writing_base64
!=
CvFileStorage
::
Base64State
::
InUse
)
else
if
(
fs
->
state_of_writing_base64
!=
base64
::
Base64State
::
InUse
)
{
{
CV_Error
(
CV_StsError
,
"Base64 should not be used at present."
);
CV_Error
(
CV_StsError
,
"Base64 should not be used at present."
);
}
}
...
@@ -7376,13 +7392,13 @@ void base64::cvWriteMat_Base64(::CvFileStorage * fs, const char * name, ::cv::Ma
...
@@ -7376,13 +7392,13 @@ void base64::cvWriteMat_Base64(::CvFileStorage * fs, const char * name, ::cv::Ma
* Interface
* Interface
***************************************************************************/
***************************************************************************/
CV_IMPL
void
cvWriteMatBase64
(
::
CvFileStorage
*
fs
,
const
char
*
name
,
const
::
CvMat
*
mat
)
void
cvWriteMatBase64
(
::
CvFileStorage
*
fs
,
const
char
*
name
,
const
::
CvMat
*
mat
)
{
{
::
cv
::
Mat
holder
=
::
cv
::
cvarrToMat
(
mat
);
::
cv
::
Mat
holder
=
::
cv
::
cvarrToMat
(
mat
);
::
base64
::
cvWriteMat_Base64
(
fs
,
name
,
holder
);
::
base64
::
cvWriteMat_Base64
(
fs
,
name
,
holder
);
}
}
CV_IMPL
void
cvWriteMatNDBase64
(
::
CvFileStorage
*
fs
,
const
char
*
name
,
const
::
CvMatND
*
mat
)
void
cvWriteMatNDBase64
(
::
CvFileStorage
*
fs
,
const
char
*
name
,
const
::
CvMatND
*
mat
)
{
{
::
cv
::
Mat
holder
=
::
cv
::
cvarrToMat
(
mat
);
::
cv
::
Mat
holder
=
::
cv
::
cvarrToMat
(
mat
);
::
base64
::
cvWriteMat_Base64
(
fs
,
name
,
holder
);
::
base64
::
cvWriteMat_Base64
(
fs
,
name
,
holder
);
...
...
modules/core/test/test_io_base64.cpp
浏览文件 @
78ca5ddd
...
@@ -182,7 +182,7 @@ TEST(Core_InputOutput_Base64, valid)
...
@@ -182,7 +182,7 @@ TEST(Core_InputOutput_Base64, valid)
cvStartWriteStruct
(
*
fs
,
"manydata"
,
CV_NODE_SEQ
);
cvStartWriteStruct
(
*
fs
,
"manydata"
,
CV_NODE_SEQ
);
cvStartWriteStruct
(
*
fs
,
0
,
CV_NODE_SEQ
|
CV_NODE_FLOW
);
cvStartWriteStruct
(
*
fs
,
0
,
CV_NODE_SEQ
|
CV_NODE_FLOW
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
for
(
int
i
=
0
;
i
<
10
;
i
++
)
cvWriteRawData
(
*
fs
,
rawdata
.
data
(),
rawdata
.
size
(
),
"i"
);
cvWriteRawData
(
*
fs
,
rawdata
.
data
(),
static_cast
<
int
>
(
rawdata
.
size
()
),
"i"
);
cvEndWriteStruct
(
*
fs
);
cvEndWriteStruct
(
*
fs
);
cvWriteString
(
*
fs
,
0
,
str_out
.
c_str
(),
1
);
cvWriteString
(
*
fs
,
0
,
str_out
.
c_str
(),
1
);
cvEndWriteStruct
(
*
fs
);
cvEndWriteStruct
(
*
fs
);
...
@@ -211,7 +211,7 @@ TEST(Core_InputOutput_Base64, valid)
...
@@ -211,7 +211,7 @@ TEST(Core_InputOutput_Base64, valid)
cvWriteString
(
*
fs
,
0
,
str_out
.
c_str
(),
1
);
cvWriteString
(
*
fs
,
0
,
str_out
.
c_str
(),
1
);
cvStartWriteStruct
(
*
fs
,
0
,
CV_NODE_SEQ
|
CV_NODE_FLOW
,
"binary"
);
cvStartWriteStruct
(
*
fs
,
0
,
CV_NODE_SEQ
|
CV_NODE_FLOW
,
"binary"
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
for
(
int
i
=
0
;
i
<
10
;
i
++
)
cvWriteRawData
(
*
fs
,
rawdata
.
data
(),
rawdata
.
size
(
),
"i"
);
cvWriteRawData
(
*
fs
,
rawdata
.
data
(),
static_cast
<
int
>
(
rawdata
.
size
()
),
"i"
);
cvEndWriteStruct
(
*
fs
);
cvEndWriteStruct
(
*
fs
);
cvEndWriteStruct
(
*
fs
);
cvEndWriteStruct
(
*
fs
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录