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
eee638fd
Commit
eee638fd
authored
Feb 24, 2017
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8244 from sovrasov:adjust_roi_fix
parents
c624d823
14451f3f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
4 deletions
+42
-4
matrix.cpp
modules/core/src/matrix.cpp
+7
-2
umatrix.cpp
modules/core/src/umatrix.cpp
+7
-2
test_operations.cpp
modules/core/test/test_operations.cpp
+14
-0
test_umat.cpp
modules/core/test/test_umat.cpp
+14
-0
No files found.
modules/core/src/matrix.cpp
View file @
eee638fd
...
@@ -997,8 +997,13 @@ Mat& Mat::adjustROI( int dtop, int dbottom, int dleft, int dright )
...
@@ -997,8 +997,13 @@ Mat& Mat::adjustROI( int dtop, int dbottom, int dleft, int dright )
Size
wholeSize
;
Point
ofs
;
Size
wholeSize
;
Point
ofs
;
size_t
esz
=
elemSize
();
size_t
esz
=
elemSize
();
locateROI
(
wholeSize
,
ofs
);
locateROI
(
wholeSize
,
ofs
);
int
row1
=
std
::
max
(
ofs
.
y
-
dtop
,
0
),
row2
=
std
::
min
(
ofs
.
y
+
rows
+
dbottom
,
wholeSize
.
height
);
int
row1
=
std
::
min
(
std
::
max
(
ofs
.
y
-
dtop
,
0
),
wholeSize
.
height
),
row2
=
std
::
max
(
0
,
std
::
min
(
ofs
.
y
+
rows
+
dbottom
,
wholeSize
.
height
));
int
col1
=
std
::
max
(
ofs
.
x
-
dleft
,
0
),
col2
=
std
::
min
(
ofs
.
x
+
cols
+
dright
,
wholeSize
.
width
);
int
col1
=
std
::
min
(
std
::
max
(
ofs
.
x
-
dleft
,
0
),
wholeSize
.
width
),
col2
=
std
::
max
(
0
,
std
::
min
(
ofs
.
x
+
cols
+
dright
,
wholeSize
.
width
));
if
(
row1
>
row2
)
std
::
swap
(
row1
,
row2
);
if
(
col1
>
col2
)
std
::
swap
(
col1
,
col2
);
data
+=
(
row1
-
ofs
.
y
)
*
step
+
(
col1
-
ofs
.
x
)
*
esz
;
data
+=
(
row1
-
ofs
.
y
)
*
step
+
(
col1
-
ofs
.
x
)
*
esz
;
rows
=
row2
-
row1
;
cols
=
col2
-
col1
;
rows
=
row2
-
row1
;
cols
=
col2
-
col1
;
size
.
p
[
0
]
=
rows
;
size
.
p
[
1
]
=
cols
;
size
.
p
[
0
]
=
rows
;
size
.
p
[
1
]
=
cols
;
...
...
modules/core/src/umatrix.cpp
View file @
eee638fd
...
@@ -599,8 +599,13 @@ UMat& UMat::adjustROI( int dtop, int dbottom, int dleft, int dright )
...
@@ -599,8 +599,13 @@ UMat& UMat::adjustROI( int dtop, int dbottom, int dleft, int dright )
Size
wholeSize
;
Point
ofs
;
Size
wholeSize
;
Point
ofs
;
size_t
esz
=
elemSize
();
size_t
esz
=
elemSize
();
locateROI
(
wholeSize
,
ofs
);
locateROI
(
wholeSize
,
ofs
);
int
row1
=
std
::
max
(
ofs
.
y
-
dtop
,
0
),
row2
=
std
::
min
(
ofs
.
y
+
rows
+
dbottom
,
wholeSize
.
height
);
int
row1
=
std
::
min
(
std
::
max
(
ofs
.
y
-
dtop
,
0
),
wholeSize
.
height
),
row2
=
std
::
max
(
0
,
std
::
min
(
ofs
.
y
+
rows
+
dbottom
,
wholeSize
.
height
));
int
col1
=
std
::
max
(
ofs
.
x
-
dleft
,
0
),
col2
=
std
::
min
(
ofs
.
x
+
cols
+
dright
,
wholeSize
.
width
);
int
col1
=
std
::
min
(
std
::
max
(
ofs
.
x
-
dleft
,
0
),
wholeSize
.
width
),
col2
=
std
::
max
(
0
,
std
::
min
(
ofs
.
x
+
cols
+
dright
,
wholeSize
.
width
));
if
(
row1
>
row2
)
std
::
swap
(
row1
,
row2
);
if
(
col1
>
col2
)
std
::
swap
(
col1
,
col2
);
offset
+=
(
row1
-
ofs
.
y
)
*
step
+
(
col1
-
ofs
.
x
)
*
esz
;
offset
+=
(
row1
-
ofs
.
y
)
*
step
+
(
col1
-
ofs
.
x
)
*
esz
;
rows
=
row2
-
row1
;
cols
=
col2
-
col1
;
rows
=
row2
-
row1
;
cols
=
col2
-
col1
;
size
.
p
[
0
]
=
rows
;
size
.
p
[
1
]
=
cols
;
size
.
p
[
0
]
=
rows
;
size
.
p
[
1
]
=
cols
;
...
...
modules/core/test/test_operations.cpp
View file @
eee638fd
...
@@ -1240,3 +1240,17 @@ protected:
...
@@ -1240,3 +1240,17 @@ protected:
};
};
TEST
(
Core_SparseMat
,
iterations
)
{
CV_SparseMatTest
test
;
test
.
safe_run
();
}
TEST
(
Core_SparseMat
,
iterations
)
{
CV_SparseMatTest
test
;
test
.
safe_run
();
}
TEST
(
MatTestRoi
,
adjustRoiOverflow
)
{
Mat
m
(
15
,
10
,
CV_32S
);
Mat
roi
(
m
,
cv
::
Range
(
2
,
10
),
cv
::
Range
(
3
,
6
));
int
rowsInROI
=
roi
.
rows
;
roi
.
adjustROI
(
1
,
0
,
0
,
0
);
ASSERT_EQ
(
roi
.
rows
,
rowsInROI
+
1
);
roi
.
adjustROI
(
-
m
.
rows
,
-
m
.
rows
,
0
,
0
);
ASSERT_EQ
(
roi
.
rows
,
m
.
rows
);
}
modules/core/test/test_umat.cpp
View file @
eee638fd
...
@@ -496,6 +496,20 @@ TEST_P(UMatTestRoi, adjustRoi)
...
@@ -496,6 +496,20 @@ TEST_P(UMatTestRoi, adjustRoi)
INSTANTIATE_TEST_CASE_P
(
UMat
,
UMatTestRoi
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
UMAT_TEST_SIZES
));
INSTANTIATE_TEST_CASE_P
(
UMat
,
UMatTestRoi
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
UMAT_TEST_SIZES
));
TEST
(
UMatTestRoi
,
adjustRoiOverflow
)
{
UMat
m
(
15
,
10
,
CV_32S
);
UMat
roi
(
m
,
cv
::
Range
(
2
,
10
),
cv
::
Range
(
3
,
6
));
int
rowsInROI
=
roi
.
rows
;
roi
.
adjustROI
(
1
,
0
,
0
,
0
);
ASSERT_EQ
(
roi
.
rows
,
rowsInROI
+
1
);
roi
.
adjustROI
(
-
m
.
rows
,
-
m
.
rows
,
0
,
0
);
ASSERT_EQ
(
roi
.
rows
,
m
.
rows
);
}
/////////////////////////////////////////////////////////////// Size ////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// Size ////////////////////////////////////////////////////////////////////
PARAM_TEST_CASE
(
UMatTestSizeOperations
,
int
,
int
,
Size
,
bool
)
PARAM_TEST_CASE
(
UMatTestSizeOperations
,
int
,
int
,
Size
,
bool
)
...
...
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