Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
a16254de
Commit
a16254de
authored
Jul 24, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12047 from alalek:issue_12045
parents
8a2ce75d
8f80565d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
42 deletions
+42
-42
test_qrcode.cpp
modules/objdetect/test/test_qrcode.cpp
+42
-42
No files found.
modules/objdetect/test/test_qrcode.cpp
View file @
a16254de
...
...
@@ -5,10 +5,9 @@
#include "test_precomp.hpp"
namespace
opencv_test
{
namespace
opencv_test
{
namespace
{
S
tring
qrcode_images_name
[]
=
{
std
::
s
tring
qrcode_images_name
[]
=
{
"20110817_030.jpg"
,
"20110817_048.jpg"
,
"img_20120226_161648.jpg"
,
...
...
@@ -25,24 +24,25 @@ String qrcode_images_name[] = {
TEST
(
Objdetect_QRCode
,
generate_test_data
)
{
String
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
"qrcode/"
;
String
dataset_config
=
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
"qrcode/dataset_config.json"
;
const
std
::
string
root
=
"qrcode/"
;
const
std
::
string
dataset_config
=
findDataFile
(
root
+
"dataset_config.json"
)
;
FileStorage
file_config
(
dataset_config
,
FileStorage
::
WRITE
);
file_config
<<
"test_images"
<<
"["
;
size_t
images_count
=
sizeof
(
qrcode_images_name
)
/
sizeof
(
String
);
size_t
images_count
=
sizeof
(
qrcode_images_name
)
/
sizeof
(
qrcode_images_name
[
0
]
);
for
(
size_t
i
=
0
;
i
<
images_count
;
i
++
)
{
file_config
<<
"{:"
<<
"image_name"
<<
qrcode_images_name
[
i
];
String
image_path
=
root
+
qrcode_images_name
[
i
]
;
std
::
vector
<
Point
>
transform
;
std
::
string
image_path
=
findDataFile
(
root
+
qrcode_images_name
[
i
])
;
std
::
vector
<
Point
>
corners
;
Mat
src
=
imread
(
image_path
,
IMREAD_GRAYSCALE
);
EXPECT_TRUE
(
detectQRCode
(
src
,
transform
));
ASSERT_FALSE
(
src
.
empty
())
<<
"Can't read image: "
<<
image_path
;
EXPECT_TRUE
(
detectQRCode
(
src
,
corners
));
file_config
<<
"x"
<<
"[:"
;
for
(
size_t
j
=
0
;
j
<
transform
.
size
();
j
++
)
{
file_config
<<
transform
[
j
].
x
;
}
for
(
size_t
j
=
0
;
j
<
corners
.
size
();
j
++
)
{
file_config
<<
corners
[
j
].
x
;
}
file_config
<<
"]"
;
file_config
<<
"y"
<<
"[:"
;
for
(
size_t
j
=
0
;
j
<
transform
.
size
();
j
++
)
{
file_config
<<
transform
[
j
].
y
;
}
for
(
size_t
j
=
0
;
j
<
corners
.
size
();
j
++
)
{
file_config
<<
corners
[
j
].
y
;
}
file_config
<<
"]"
<<
"}"
;
}
file_config
<<
"]"
;
...
...
@@ -51,65 +51,65 @@ TEST(Objdetect_QRCode, generate_test_data)
#else
typedef
testing
::
TestWithParam
<
S
tring
>
Objdetect_QRCode
;
typedef
testing
::
TestWithParam
<
std
::
s
tring
>
Objdetect_QRCode
;
TEST_P
(
Objdetect_QRCode
,
regression
)
{
String
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
"qrcode/"
;
String
dataset_config
=
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
"qrcode/dataset_config.json"
;
FileStorage
file_config
(
dataset_config
,
FileStorage
::
READ
);
const
std
::
string
name_current_image
=
GetParam
();
const
std
::
string
root
=
"qrcode/"
;
const
int
pixels_error
=
3
;
std
::
vector
<
Point
>
corners
;
String
image_path
=
root
+
String
(
GetParam
());
std
::
string
image_path
=
findDataFile
(
root
+
name_current_image
);
Mat
src
=
imread
(
image_path
,
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
src
.
empty
())
<<
"Can't read image: "
<<
image_path
;
std
::
vector
<
Point
>
corners
;
EXPECT_TRUE
(
detectQRCode
(
src
,
corners
));
if
(
file_config
.
isOpened
())
const
std
::
string
dataset_config
=
findDataFile
(
root
+
"dataset_config.json"
,
false
);
FileStorage
file_config
(
dataset_config
,
FileStorage
::
READ
);
ASSERT_TRUE
(
file_config
.
isOpened
())
<<
"Can't read validation data: "
<<
dataset_config
;
{
FileNode
images_list
=
file_config
[
"test_images"
];
int
index
=
0
,
images_count
=
static_cast
<
in
t
>
(
images_list
.
size
());
ASSERT_GT
(
images_count
,
0
)
;
size_t
images_count
=
static_cast
<
size_
t
>
(
images_list
.
size
());
ASSERT_GT
(
images_count
,
0
u
)
<<
"Can't find validation data entries in 'test_images': "
<<
dataset_config
;
bool
runTestsFlag
=
false
;
String
name_current_image
=
String
(
GetParam
());
for
(;
index
<
images_count
;
index
++
)
for
(
size_t
index
=
0
;
index
<
images_count
;
index
++
)
{
String
name_test_image
=
images_list
[
index
][
"image_name"
];
FileNode
config
=
images_list
[(
int
)
index
];
std
::
string
name_test_image
=
config
[
"image_name"
];
if
(
name_test_image
==
name_current_image
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
int
x
=
images_list
[
index
]
[
"x"
][
i
];
int
y
=
images_list
[
index
]
[
"y"
][
i
];
int
x
=
config
[
"x"
][
i
];
int
y
=
config
[
"y"
][
i
];
EXPECT_NEAR
(
x
,
corners
[
i
].
x
,
pixels_error
);
EXPECT_NEAR
(
y
,
corners
[
i
].
y
,
pixels_error
);
}
r
unTestsFlag
=
true
;
r
eturn
;
// done
}
}
if
(
!
runTestsFlag
)
{
std
::
cout
<<
"Not found results for "
<<
name_current_image
;
std
::
cout
<<
" image in dataset_config.json file."
<<
std
::
endl
;
}
file_config
.
release
();
}
else
{
std
::
cout
<<
" Not found dataset_config.json file."
<<
std
::
endl
;
std
::
cerr
<<
"Not found results for '"
<<
name_current_image
<<
"' image in config file:"
<<
dataset_config
<<
std
::
endl
<<
"Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data."
<<
std
::
endl
;
}
}
INSTANTIATE_TEST_CASE_P
(
objdetect
,
Objdetect_QRCode
,
testing
::
ValuesIn
(
qrcode_images_name
));
INSTANTIATE_TEST_CASE_P
(
/**/
,
Objdetect_QRCode
,
testing
::
ValuesIn
(
qrcode_images_name
));
TEST
(
Objdetect_QRCode
,
not_found_qrcode
)
TEST
(
Objdetect_QRCode_basic
,
not_found_qrcode
)
{
std
::
vector
<
Point
>
corners
;
Mat
zero_image
=
Mat
::
zeros
(
256
,
256
,
CV_8UC1
);
EXPECT_FALSE
(
detectQRCode
(
zero_image
,
corners
));
}
#endif
}
// namespace
#endif // UPDATE_QRCODE_TEST_DATA
}}
// namespace
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment