Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
aa5281c1
Commit
aa5281c1
authored
Sep 22, 2016
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #784 from sovrasov:freak_input_fix
parents
da7cc66c
4b00e414
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
14 deletions
+26
-14
freak.cpp
modules/xfeatures2d/src/freak.cpp
+2
-6
test_features2d.cpp
modules/xfeatures2d/test/test_features2d.cpp
+9
-5
test_rotation_and_scale_invariance.cpp
...s/xfeatures2d/test/test_rotation_and_scale_invariance.cpp
+15
-3
No files found.
modules/xfeatures2d/src/freak.cpp
View file @
aa5281c1
...
...
@@ -334,8 +334,7 @@ void FREAK_Impl::compute( InputArray _image, std::vector<KeyPoint>& keypoints, O
// Convert to gray if not already
Mat
grayImage
=
image
;
// if( image.channels() > 1 )
// cvtColor( image, grayImage, COLOR_BGR2GRAY );
CV_Assert
(
grayImage
.
channels
()
==
1
);
// Use 32-bit integers if we won't overflow in the integral image
if
((
image
.
depth
()
==
CV_8U
||
image
.
depth
()
==
CV_8S
)
&&
...
...
@@ -682,10 +681,7 @@ imgType FREAK_Impl::meanIntensity( InputArray _image, InputArray _integral,
ret_val
+=
integral
.
at
<
iiType
>
(
y_top
,
x_left
);
ret_val
-=
integral
.
at
<
iiType
>
(
y_top
,
x_right
);
const
int
area
=
(
x_right
-
x_left
)
*
(
y_bottom
-
y_top
);
if
(
ret_val
>
0
)
ret_val
=
(
ret_val
+
area
/
2
)
/
area
;
else
ret_val
=
(
ret_val
-
area
/
2
)
/
area
;
ret_val
=
(
ret_val
+
area
/
2
)
/
area
;
//~ std::cout<<integral.step[1]<<std::endl;
return
static_cast
<
imgType
>
(
ret_val
);
}
...
...
modules/xfeatures2d/test/test_features2d.cpp
View file @
aa5281c1
...
...
@@ -298,8 +298,8 @@ public:
typedef
typename
Distance
::
ResultType
DistanceType
;
CV_DescriptorExtractorTest
(
const
string
_name
,
DistanceType
_maxDist
,
const
Ptr
<
DescriptorExtractor
>&
_dextractor
,
Distance
d
=
Distance
()
)
:
name
(
_name
),
maxDist
(
_maxDist
),
dextractor
(
_dextractor
),
distance
(
d
)
{}
int
imgMode
=
IMREAD_COLOR
,
Distance
d
=
Distance
()
)
:
name
(
_name
),
maxDist
(
_maxDist
),
dextractor
(
_dextractor
),
imgLoadMode
(
imgMode
),
distance
(
d
)
{}
protected
:
virtual
void
createDescriptorExtractor
()
{}
...
...
@@ -356,7 +356,10 @@ protected:
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
}
image
.
create
(
50
,
50
,
CV_8UC3
);
if
(
imgLoadMode
==
IMREAD_GRAYSCALE
)
image
.
create
(
50
,
50
,
CV_8UC1
);
else
image
.
create
(
50
,
50
,
CV_8UC3
);
try
{
dextractor
->
compute
(
image
,
keypoints
,
descriptors
);
...
...
@@ -389,7 +392,7 @@ protected:
// Read the test image.
string
imgFilename
=
string
(
ts
->
get_data_path
())
+
FEATURES2D_DIR
+
"/"
+
IMAGE_FILENAME
;
Mat
img
=
imread
(
imgFilename
);
Mat
img
=
imread
(
imgFilename
,
imgLoadMode
);
if
(
img
.
empty
()
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Image %s can not be read.
\n
"
,
imgFilename
.
c_str
()
);
...
...
@@ -493,6 +496,7 @@ protected:
string
name
;
const
DistanceType
maxDist
;
Ptr
<
DescriptorExtractor
>
dextractor
;
int
imgLoadMode
;
Distance
distance
;
private
:
...
...
@@ -1021,7 +1025,7 @@ TEST( Features2d_DescriptorExtractor_FREAK, regression )
{
// TODO adjust the parameters below
CV_DescriptorExtractorTest
<
Hamming
>
test
(
"descriptor-freak"
,
(
CV_DescriptorExtractorTest
<
Hamming
>::
DistanceType
)
12.
f
,
FREAK
::
create
()
);
FREAK
::
create
()
,
IMREAD_GRAYSCALE
);
test
.
safe_run
();
}
...
...
modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp
View file @
aa5281c1
...
...
@@ -318,11 +318,12 @@ public:
DescriptorRotationInvarianceTest
(
const
Ptr
<
FeatureDetector
>&
_featureDetector
,
const
Ptr
<
DescriptorExtractor
>&
_descriptorExtractor
,
int
_normType
,
float
_minDescInliersRatio
)
:
float
_minDescInliersRatio
,
int
imgLoad
=
IMREAD_COLOR
)
:
featureDetector
(
_featureDetector
),
descriptorExtractor
(
_descriptorExtractor
),
normType
(
_normType
),
minDescInliersRatio
(
_minDescInliersRatio
)
minDescInliersRatio
(
_minDescInliersRatio
),
imgLoadMode
(
imgLoad
)
{
CV_Assert
(
featureDetector
);
CV_Assert
(
descriptorExtractor
);
...
...
@@ -335,7 +336,7 @@ protected:
const
string
imageFilename
=
string
(
ts
->
get_data_path
())
+
IMAGE_TSUKUBA
;
// Read test data
Mat
image0
=
imread
(
imageFilename
),
image1
,
mask1
;
Mat
image0
=
imread
(
imageFilename
,
imgLoadMode
),
image1
,
mask1
;
if
(
image0
.
empty
())
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Image %s can not be read.
\n
"
,
imageFilename
.
c_str
());
...
...
@@ -398,6 +399,7 @@ protected:
Ptr
<
DescriptorExtractor
>
descriptorExtractor
;
int
normType
;
float
minDescInliersRatio
;
int
imgLoadMode
;
};
...
...
@@ -696,6 +698,16 @@ TEST(Features2d_RotationInvariance_Descriptor_BRIEF_16, regression)
test
.
safe_run
();
}
TEST
(
Features2d_RotationInvariance_Descriptor_FREAK
,
regression
)
{
Ptr
<
Feature2D
>
f2d
=
FREAK
::
create
();
DescriptorRotationInvarianceTest
test
(
SURF
::
create
(),
f2d
,
f2d
->
defaultNorm
(),
0.9
f
,
IMREAD_GRAYSCALE
);
test
.
safe_run
();
}
/*
* Detector's scale invariance check
*/
...
...
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