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
8c349ff8
Commit
8c349ff8
authored
Apr 26, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: added MatSize::dims() method
to avoid accessing of 'p[-1]' (static code analysers dislike this)
parent
87a4f4ab
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
11 deletions
+27
-11
cvstd.inl.hpp
modules/core/include/opencv2/core/cvstd.inl.hpp
+2
-2
mat.hpp
modules/core/include/opencv2/core/mat.hpp
+2
-1
mat.inl.hpp
modules/core/include/opencv2/core/mat.inl.hpp
+17
-3
shape_utils.hpp
modules/dnn/include/opencv2/dnn/shape_utils.hpp
+1
-1
slice_layer.cpp
modules/dnn/src/layers/slice_layer.cpp
+2
-2
op_halide.cpp
modules/dnn/src/op_halide.cpp
+3
-2
No files found.
modules/core/include/opencv2/core/cvstd.inl.hpp
View file @
8c349ff8
...
...
@@ -265,10 +265,10 @@ std::ostream& operator << (std::ostream& out, const Rect_<_Tp>& rect)
static
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
MatSize
&
msize
)
{
int
i
,
dims
=
msize
.
p
[
-
1
]
;
int
i
,
dims
=
msize
.
dims
()
;
for
(
i
=
0
;
i
<
dims
;
i
++
)
{
out
<<
msize
.
p
[
i
];
out
<<
msize
[
i
];
if
(
i
<
dims
-
1
)
out
<<
" x "
;
}
...
...
modules/core/include/opencv2/core/mat.hpp
View file @
8c349ff8
...
...
@@ -548,10 +548,11 @@ struct CV_EXPORTS UMatData
struct
CV_EXPORTS
MatSize
{
explicit
MatSize
(
int
*
_p
);
int
dims
()
const
;
Size
operator
()()
const
;
const
int
&
operator
[](
int
i
)
const
;
int
&
operator
[](
int
i
);
operator
const
int
*
()
const
;
operator
const
int
*
()
const
;
// TODO OpenCV 4.0: drop this
bool
operator
==
(
const
MatSize
&
sz
)
const
;
bool
operator
!=
(
const
MatSize
&
sz
)
const
;
...
...
modules/core/include/opencv2/core/mat.inl.hpp
View file @
8c349ff8
...
...
@@ -1411,22 +1411,36 @@ inline
MatSize
::
MatSize
(
int
*
_p
)
:
p
(
_p
)
{}
inline
int
MatSize
::
dims
()
const
{
return
(
p
-
1
)[
0
];
}
inline
Size
MatSize
::
operator
()()
const
{
CV_DbgAssert
(
p
[
-
1
]
<=
2
);
CV_DbgAssert
(
dims
()
<=
2
);
return
Size
(
p
[
1
],
p
[
0
]);
}
inline
const
int
&
MatSize
::
operator
[](
int
i
)
const
{
CV_DbgAssert
(
i
<
dims
());
#ifdef __OPENCV_BUILD
CV_DbgAssert
(
i
>=
0
);
#endif
return
p
[
i
];
}
inline
int
&
MatSize
::
operator
[](
int
i
)
{
CV_DbgAssert
(
i
<
dims
());
#ifdef __OPENCV_BUILD
CV_DbgAssert
(
i
>=
0
);
#endif
return
p
[
i
];
}
...
...
@@ -1439,8 +1453,8 @@ MatSize::operator const int*() const
inline
bool
MatSize
::
operator
==
(
const
MatSize
&
sz
)
const
{
int
d
=
p
[
-
1
]
;
int
dsz
=
sz
.
p
[
-
1
]
;
int
d
=
dims
()
;
int
dsz
=
sz
.
dims
()
;
if
(
d
!=
dsz
)
return
false
;
if
(
d
==
2
)
...
...
modules/dnn/include/opencv2/dnn/shape_utils.hpp
View file @
8c349ff8
...
...
@@ -134,7 +134,7 @@ static inline MatShape shape(const Mat& mat)
static
inline
MatShape
shape
(
const
MatSize
&
sz
)
{
return
shape
(
sz
.
p
,
sz
[
-
1
]
);
return
shape
(
sz
.
p
,
sz
.
dims
()
);
}
static
inline
MatShape
shape
(
const
UMat
&
mat
)
...
...
modules/dnn/src/layers/slice_layer.cpp
View file @
8c349ff8
...
...
@@ -161,14 +161,14 @@ public:
for
(
int
i
=
0
;
i
<
outputs
.
size
();
++
i
)
{
CV_Assert
(
sliceRanges
[
i
].
size
()
<=
inpShape
[
-
1
]
);
CV_Assert
(
sliceRanges
[
i
].
size
()
<=
inpShape
.
dims
()
);
// Clamp.
for
(
int
j
=
0
;
j
<
sliceRanges
[
i
].
size
();
++
j
)
{
sliceRanges
[
i
][
j
]
=
clamp
(
sliceRanges
[
i
][
j
],
inpShape
[
j
]);
}
// Fill the rest of ranges.
for
(
int
j
=
sliceRanges
[
i
].
size
();
j
<
inpShape
[
-
1
]
;
++
j
)
for
(
int
j
=
sliceRanges
[
i
].
size
();
j
<
inpShape
.
dims
()
;
++
j
)
{
sliceRanges
[
i
].
push_back
(
Range
::
all
());
}
...
...
modules/dnn/src/op_halide.cpp
View file @
8c349ff8
...
...
@@ -6,6 +6,7 @@
// Third party copyrights are property of their respective owners.
#include "precomp.hpp"
#include <opencv2/dnn/shape_utils.hpp>
#include "op_halide.hpp"
#ifdef HAVE_HALIDE
...
...
@@ -36,7 +37,7 @@ static MatShape getBufferShape(const MatShape& shape)
static
MatShape
getBufferShape
(
const
MatSize
&
size
)
{
return
getBufferShape
(
MatShape
(
size
.
p
,
size
.
p
+
size
[
-
1
]
));
return
getBufferShape
(
shape
(
size
));
}
Halide
::
Buffer
<
float
>
wrapToHalideBuffer
(
const
Mat
&
mat
)
...
...
@@ -160,7 +161,7 @@ void HalideBackendWrapper::setHostDirty()
void
getCanonicalSize
(
const
MatSize
&
size
,
int
*
w
,
int
*
h
,
int
*
c
,
int
*
n
)
{
getCanonicalSize
(
MatShape
(
size
.
p
,
size
.
p
+
size
[
-
1
]
),
w
,
h
,
c
,
n
);
getCanonicalSize
(
shape
(
size
),
w
,
h
,
c
,
n
);
}
void
getCanonicalSize
(
const
MatShape
&
shape
,
int
*
width
,
int
*
height
,
...
...
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