提交 825b1427 编写于 作者: A Alexander Alekhin

core: fix persistence with deprecated traits

上级 b0bce60c
......@@ -851,7 +851,9 @@ namespace internal
size_t remaining = it->remaining;
size_t cn = DataType<_Tp>::channels;
int _fmt = traits::SafeFmt<_Tp>::fmt;
CV_Assert((_fmt >> 8) < 9);
char fmt[] = { (char)((_fmt >> 8)+'1'), (char)_fmt, '\0' };
CV_Assert((remaining % cn) == 0);
size_t remaining1 = remaining / cn;
count = count < remaining1 ? count : remaining1;
vec.resize(count);
......
......@@ -7367,8 +7367,18 @@ void read(const FileNode& node, std::vector<KeyPoint>& keypoints)
if (first_node.isSeq())
{
// modern scheme
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
FileNodeIterator it = node.begin();
size_t total = (size_t)it.remaining;
keypoints.resize(total);
for (size_t i = 0; i < total; ++i, ++it)
{
(*it) >> keypoints[i];
}
#else
FileNodeIterator it = node.begin();
it >> keypoints;
#endif
return;
}
keypoints.clear();
......@@ -7394,8 +7404,18 @@ void read(const FileNode& node, std::vector<DMatch>& matches)
if (first_node.isSeq())
{
// modern scheme
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
FileNodeIterator it = node.begin();
size_t total = (size_t)it.remaining;
matches.resize(total);
for (size_t i = 0; i < total; ++i, ++it)
{
(*it) >> matches[i];
}
#else
FileNodeIterator it = node.begin();
it >> matches;
#endif
return;
}
matches.clear();
......
......@@ -1199,6 +1199,7 @@ TEST(Core_InputOutput, FileStorage_DMatch_vector_vector)
EXPECT_NO_THROW(fs << "dvv" << dvv);
cv::String fs_result = fs.releaseAndGetString();
#ifndef OPENCV_TRAITS_ENABLE_DEPRECATED
#if defined _MSC_VER && _MSC_VER <= 1700 /* MSVC 2012 and older */
EXPECT_STREQ(fs_result.c_str(),
"%YAML:1.0\n"
......@@ -1226,6 +1227,7 @@ TEST(Core_InputOutput, FileStorage_DMatch_vector_vector)
" - [ 1, 2, 3, -1.5000000000000000e+00 ]\n"
);
#endif
#endif // OPENCV_TRAITS_ENABLE_DEPRECATED
cv::FileStorage fs_read(fs_result, cv::FileStorage::READ | cv::FileStorage::MEMORY);
......@@ -1344,6 +1346,7 @@ TEST(Core_InputOutput, FileStorage_KeyPoint_vector_vector)
EXPECT_NO_THROW(fs << "kvv" << kvv);
cv::String fs_result = fs.releaseAndGetString();
#ifndef OPENCV_TRAITS_ENABLE_DEPRECATED
EXPECT_STREQ(fs_result.c_str(),
"<?xml version=\"1.0\"?>\n"
"<opencv_storage>\n"
......@@ -1362,6 +1365,7 @@ TEST(Core_InputOutput, FileStorage_KeyPoint_vector_vector)
" 1. 2. 16. 0. 100. 1 -1</_></_></kvv>\n"
"</opencv_storage>\n"
);
#endif //OPENCV_TRAITS_ENABLE_DEPRECATED
cv::FileStorage fs_read(fs_result, cv::FileStorage::READ | cv::FileStorage::MEMORY);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册