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
85880397
Commit
85880397
authored
Nov 05, 2012
by
Jason Newton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
connectedcomponents: use opencv integral types, add to docs, fix up things for a python export
parent
4c0cb257
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
15 deletions
+75
-15
structural_analysis_and_shape_descriptors.rst
...imgproc/doc/structural_analysis_and_shape_descriptors.rst
+42
-0
imgproc.hpp
modules/imgproc/include/opencv2/imgproc/imgproc.hpp
+12
-12
connectedcomponents.cpp
modules/imgproc/src/connectedcomponents.cpp
+11
-1
cv2.cpp
modules/python/src2/cv2.cpp
+10
-2
No files found.
modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst
View file @
85880397
...
...
@@ -118,6 +118,48 @@ These values are proved to be invariants to the image scale, rotation, and refle
.. seealso:: :ocv:func:`matchShapes`
connectedComponents
-----------
computes the connected components labeled image of boolean image I with 4 or 8 way connectivity - returns N, the total
number of labels [0, N-1] where 0 represents the background label. L's value type determines the label type, an important
consideration based on the total number of labels or alternatively the total number of pixels.
.. ocv:function:: uint64 connectedComponents(Mat &L, const Mat &I, int connectivity = 8)
.. ocv:function:: uint64 connectedComponentsWithStats(Mat &L, const Mat &I, std::vector<ConnectedComponentStats> &statsv, int connectivity = 8)
:param L: destitination Labeled image
:param I: the image to be labeled
:param connectivity: 8 or 4 for 8-way or 4-way connectivity respectively
:param statsv: statistics for each label, including the background label
Statistics information such as bounding box, area, and centroid is exported via the ``ConnectComponentStats`` structure defined as: ::
class CV_EXPORTS ConnectedComponentStats
{
public:
//! lower left corner column
int lower_x;
//! lower left corner row
int lower_y;
//! upper right corner column
int upper_x;
//! upper right corner row
int upper_y;
//! centroid column
double centroid_x;
//! centroid row
double centroid_y;
//! sum of all columns where the image was non-zero
uint64 integral_x;
//! sum of all rows where the image was non-zero
uint64 integral_y;
//! count of all non-zero pixels
unsigned int area;
};
findContours
----------------
...
...
modules/imgproc/include/opencv2/imgproc/imgproc.hpp
View file @
85880397
...
...
@@ -1091,24 +1091,24 @@ enum { TM_SQDIFF=0, TM_SQDIFF_NORMED=1, TM_CCORR=2, TM_CCORR_NORMED=3, TM_CCOEFF
CV_EXPORTS_W
void
matchTemplate
(
InputArray
image
,
InputArray
templ
,
OutputArray
result
,
int
method
);
struct
CV_EXPORTS
ConnectedComponentStats
{
int
32_t
lower_x
;
int
32_t
lower_y
;
int
32_t
upper_x
;
int
32_t
upper_y
;
double
centroid_x
;
double
centroid_y
;
uint64
_t
integral_x
;
uint64
_t
integral_y
;
u
int32_t
area
;
int
lower_x
;
//!< lower left corner column
int
lower_y
;
//!< lower left corner row
int
upper_x
;
//!< upper right corner column
int
upper_y
;
//!< upper right corner row
double
centroid_x
;
//!< centroid column
double
centroid_y
;
//!< centroid row
uint64
integral_x
;
//!< sum of all columns where the image was non-zero
uint64
integral_y
;
//!< sum of all rows where the image was non-zero
u
nsigned
int
area
;
//!< count of all non-zero pixels
};
//! computes the connected components labeled image of boolean image I with 4 or 8 way connectivity - returns N, the total
//number of labels [0, N-1] where 0 represents the background label. L's value type determines the label type, an important
//consideration based on the total number of labels or alternatively the total number of pixels.
CV_EXPORTS_W
uint64
_t
connectedComponents
(
Mat
&
L
,
const
Mat
&
I
,
int
connectivity
=
8
);
CV_EXPORTS_W
uint64
_t
connectedComponents
(
Mat
&
L
,
const
Mat
&
I
,
std
::
vector
<
ConnectedComponentStats
>
&
statsv
,
int
connectivity
=
8
);
CV_EXPORTS_W
uint64
connectedComponents
(
CV_OUT
Mat
&
L
,
const
Mat
&
I
,
int
connectivity
=
8
);
CV_EXPORTS_W
uint64
connectedComponentsWithStats
(
CV_OUT
Mat
&
L
,
const
Mat
&
I
,
CV_OUT
std
::
vector
<
ConnectedComponentStats
>
&
statsv
,
int
connectivity
=
8
);
//! mode of the contour retrieval algorithm
...
...
modules/imgproc/src/connectedcomponents.cpp
View file @
85880397
...
...
@@ -43,6 +43,16 @@
#include "precomp.hpp"
#include <vector>
//It's 2012 and we still let compilers get by without defining standard integer types...
typedef
schar
int8_t
;
typedef
uchar
uint8_t
;
typedef
short
int16_t
;
typedef
unsigned
short
uint16_t
;
typedef
int
int32_t
;
typedef
unsigned
int
uint32_t
;
typedef
int64
int64_t
;
typedef
uint64
uint64_t
;
namespace
cv
{
namespace
connectedcomponents
{
...
...
@@ -463,7 +473,7 @@ uint64_t connectedComponents(Mat &L, const Mat &I, int connectivity){
}
}
uint64_t
connectedComponents
(
Mat
&
L
,
const
Mat
&
I
,
std
::
vector
<
ConnectedComponentStats
>
&
statsv
,
int
connectivity
){
uint64_t
connectedComponents
WithStats
(
Mat
&
L
,
const
Mat
&
I
,
std
::
vector
<
ConnectedComponentStats
>
&
statsv
,
int
connectivity
){
int
lDepth
=
L
.
depth
();
if
(
lDepth
==
CV_8U
){
connectedcomponents
::
CCStatsOp
<
uint8_t
>
sop
(
statsv
);
return
connectedComponents_sub1
(
L
,
I
,
connectivity
,
sop
);
...
...
modules/python/src2/cv2.cpp
View file @
85880397
...
...
@@ -123,6 +123,7 @@ typedef Ptr<FeatureDetector> Ptr_FeatureDetector;
typedef
Ptr
<
DescriptorExtractor
>
Ptr_DescriptorExtractor
;
typedef
Ptr
<
Feature2D
>
Ptr_Feature2D
;
typedef
Ptr
<
DescriptorMatcher
>
Ptr_DescriptorMatcher
;
typedef
vector
<
ConnectedComponentStats
>
vector_ConnectedComponentStats
;
typedef
SimpleBlobDetector
::
Params
SimpleBlobDetector_Params
;
...
...
@@ -410,7 +411,7 @@ static bool pyopencv_to(PyObject* obj, bool& value, const char* name = "<unknown
static
PyObject
*
pyopencv_from
(
size_t
value
)
{
return
PyLong_From
UnsignedLong
((
unsigned
long
)
value
);
return
PyLong_From
Size_t
(
value
);
}
static
bool
pyopencv_to
(
PyObject
*
obj
,
size_t
&
value
,
const
char
*
name
=
"<unknown>"
)
...
...
@@ -497,9 +498,16 @@ static bool pyopencv_to(PyObject* obj, float& value, const char* name = "<unknow
static
PyObject
*
pyopencv_from
(
int64
value
)
{
return
Py
Float_FromDouble
((
double
)
value
);
return
Py
Long_FromLongLong
(
value
);
}
#if !defined(__LP64__)
static
PyObject
*
pyopencv_from
(
uint64
value
)
{
return
PyLong_FromUnsignedLongLong
(
value
);
}
#endif
static
PyObject
*
pyopencv_from
(
const
string
&
value
)
{
return
PyString_FromString
(
value
.
empty
()
?
""
:
value
.
c_str
());
...
...
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