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
f8e9f65e
Commit
f8e9f65e
authored
Feb 07, 2011
by
Ilya Lysenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added detection of asymmetric circles' pattern
parent
885cef76
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
62 deletions
+97
-62
calib3d.hpp
modules/calib3d/include/opencv2/calib3d/calib3d.hpp
+3
-1
calibinit.cpp
modules/calib3d/src/calibinit.cpp
+22
-6
circlesgrid.cpp
modules/calib3d/src/circlesgrid.cpp
+0
-0
circlesgrid.hpp
modules/calib3d/src/circlesgrid.hpp
+0
-0
blobdetector.cpp
modules/features2d/src/blobdetector.cpp
+72
-55
No files found.
modules/calib3d/include/opencv2/calib3d/calib3d.hpp
View file @
f8e9f65e
...
@@ -543,10 +543,12 @@ CV_EXPORTS void drawChessboardCorners( Mat& image, Size patternSize,
...
@@ -543,10 +543,12 @@ CV_EXPORTS void drawChessboardCorners( Mat& image, Size patternSize,
const
vector
<
Point2f
>&
corners
,
const
vector
<
Point2f
>&
corners
,
bool
patternWasFound
);
bool
patternWasFound
);
enum
{
CALIB_CB_SYMMETRIC_GRID
=
1
,
CALIB_CB_ASYMMETRIC_GRID
=
2
};
//! finds circles' grid pattern of the specified size in the image
//! finds circles' grid pattern of the specified size in the image
CV_EXPORTS_W
bool
findCirclesGrid
(
const
Mat
&
image
,
Size
patternSize
,
CV_EXPORTS_W
bool
findCirclesGrid
(
const
Mat
&
image
,
Size
patternSize
,
CV_OUT
vector
<
Point2f
>&
centers
,
CV_OUT
vector
<
Point2f
>&
centers
,
int
flags
=
0
);
int
flags
=
CALIB_CB_SYMMETRIC_GRID
);
enum
enum
{
{
...
...
modules/calib3d/src/calibinit.cpp
View file @
f8e9f65e
...
@@ -1935,7 +1935,7 @@ void drawChessboardCorners( Mat& image, Size patternSize,
...
@@ -1935,7 +1935,7 @@ void drawChessboardCorners( Mat& image, Size patternSize,
}
}
bool
findCirclesGrid
(
const
Mat
&
image
,
Size
patternSize
,
bool
findCirclesGrid
(
const
Mat
&
image
,
Size
patternSize
,
vector
<
Point2f
>&
centers
,
int
)
vector
<
Point2f
>&
centers
,
int
flags
)
{
{
Ptr
<
SimpleBlobDetector
>
detector
=
new
SimpleBlobDetector
();
Ptr
<
SimpleBlobDetector
>
detector
=
new
SimpleBlobDetector
();
//Ptr<FeatureDetector> detector = new MserFeatureDetector();
//Ptr<FeatureDetector> detector = new MserFeatureDetector();
...
@@ -1944,7 +1944,7 @@ bool findCirclesGrid( const Mat& image, Size patternSize,
...
@@ -1944,7 +1944,7 @@ bool findCirclesGrid( const Mat& image, Size patternSize,
vector
<
Point2f
>
points
;
vector
<
Point2f
>
points
;
for
(
size_t
i
=
0
;
i
<
keypoints
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
keypoints
.
size
();
i
++
)
{
{
points
.
push_back
(
keypoints
[
i
].
pt
);
points
.
push_back
(
keypoints
[
i
].
pt
);
}
}
CirclesGridFinderParameters
parameters
;
CirclesGridFinderParameters
parameters
;
...
@@ -1954,8 +1954,13 @@ bool findCirclesGrid( const Mat& image, Size patternSize,
...
@@ -1954,8 +1954,13 @@ bool findCirclesGrid( const Mat& image, Size patternSize,
parameters
.
edgeGain
=
1
;
parameters
.
edgeGain
=
1
;
parameters
.
edgePenalty
=
-
0.6
f
;
parameters
.
edgePenalty
=
-
0.6
f
;
if
(
flags
&
CALIB_CB_ASYMMETRIC_GRID
)
parameters
.
gridType
=
CirclesGridFinderParameters
::
ASYMMETRIC_GRID
;
if
(
flags
&
CALIB_CB_SYMMETRIC_GRID
)
parameters
.
gridType
=
CirclesGridFinderParameters
::
SYMMETRIC_GRID
;
const
int
attempts
=
2
;
const
int
attempts
=
2
;
const
in
t
minHomographyPoints
=
4
;
const
size_
t
minHomographyPoints
=
4
;
Mat
H
;
Mat
H
;
for
(
int
i
=
0
;
i
<
attempts
;
i
++
)
for
(
int
i
=
0
;
i
<
attempts
;
i
++
)
{
{
...
@@ -1970,10 +1975,20 @@ bool findCirclesGrid( const Mat& image, Size patternSize,
...
@@ -1970,10 +1975,20 @@ bool findCirclesGrid( const Mat& image, Size patternSize,
{
{
}
}
boxFinder
.
getHoles
(
centers
);
if
(
isFound
)
if
(
isFound
)
{
{
switch
(
parameters
.
gridType
)
{
case
CirclesGridFinderParameters
:
:
SYMMETRIC_GRID
:
boxFinder
.
getHoles
(
centers
);
break
;
case
CirclesGridFinderParameters
:
:
ASYMMETRIC_GRID
:
boxFinder
.
getAsymmetricHoles
(
centers
);
break
;
default
:
CV_Error
(
CV_StsBadArg
,
"Unkown pattern type"
);
}
if
(
i
!=
0
)
if
(
i
!=
0
)
{
{
Mat
orgPointsMat
;
Mat
orgPointsMat
;
...
@@ -1983,7 +1998,8 @@ bool findCirclesGrid( const Mat& image, Size patternSize,
...
@@ -1983,7 +1998,8 @@ bool findCirclesGrid( const Mat& image, Size patternSize,
return
true
;
return
true
;
}
}
boxFinder
.
getHoles
(
centers
);
if
(
i
!=
attempts
-
1
)
if
(
i
!=
attempts
-
1
)
{
{
if
(
centers
.
size
()
<
minHomographyPoints
)
if
(
centers
.
size
()
<
minHomographyPoints
)
...
...
modules/calib3d/src/circlesgrid.cpp
View file @
f8e9f65e
This diff is collapsed.
Click to expand it.
modules/calib3d/src/circlesgrid.hpp
View file @
f8e9f65e
This diff is collapsed.
Click to expand it.
modules/features2d/src/blobdetector.cpp
View file @
f8e9f65e
/*M///////////////////////////////////////////////////////////////////////////////////////
/*M///////////////////////////////////////////////////////////////////////////////////////
//
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//
// By downloading, copying, installing or using the software you agree to this license.
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// If you do not agree to this license, do not download, install,
// copy or use the software.
// copy or use the software.
//
//
//
//
// License Agreement
// License Agreement
// For Open Source Computer Vision Library
// For Open Source Computer Vision Library
//
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
// Third party copyrights are property of their respective owners.
//
//
// Redistribution and use in source and binary forms, with or without modification,
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
// are permitted provided that the following conditions are met:
//
//
// * Redistribution's of source code must retain the above copyright notice,
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// this list of conditions and the following disclaimer.
//
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// and/or other materials provided with the distribution.
//
//
// * The name of the copyright holders may not be used to endorse or promote products
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
// derived from this software without specific prior written permission.
//
//
// This software is provided by the copyright holders and contributors "as is" and
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
// the use of this software, even if advised of the possibility of such damage.
//
//
//M*/
//M*/
#include "precomp.hpp"
#include "precomp.hpp"
//#define DEBUG_BLOB_DETECTOR
#ifdef DEBUG_BLOB_DETECTOR
#include <opencv2/highgui/highgui.hpp>
#endif
using
namespace
cv
;
using
namespace
cv
;
/*
/*
...
@@ -116,17 +122,19 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm
...
@@ -116,17 +122,19 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm
{
{
centers
.
clear
();
centers
.
clear
();
vector
<
vector
<
Point
>
>
contours
;
vector
<
vector
<
Point
>
>
contours
;
Mat
tmpBinaryImage
=
binaryImage
.
clone
();
Mat
tmpBinaryImage
=
binaryImage
.
clone
();
findContours
(
tmpBinaryImage
,
contours
,
CV_RETR_LIST
,
CV_CHAIN_APPROX_NONE
);
findContours
(
tmpBinaryImage
,
contours
,
CV_RETR_LIST
,
CV_CHAIN_APPROX_NONE
);
//Mat keypointsImage;
#ifdef DEBUG_BLOB_DETECTOR
//cvtColor( binaryImage, keypointsImage, CV_GRAY2RGB );
Mat
keypointsImage
;
cvtColor
(
binaryImage
,
keypointsImage
,
CV_GRAY2RGB
);
//Mat contoursImage;
Mat
contoursImage
;
//cvtColor( binaryImage, contoursImage, CV_GRAY2RGB );
cvtColor
(
binaryImage
,
contoursImage
,
CV_GRAY2RGB
);
//drawContours( contoursImage, contours, -1, Scalar(0,255,0) );
drawContours
(
contoursImage
,
contours
,
-
1
,
Scalar
(
0
,
255
,
0
)
);
//imshow("contours", contoursImage );
imshow
(
"contours"
,
contoursImage
);
#endif
for
(
size_t
contourIdx
=
0
;
contourIdx
<
contours
.
size
();
contourIdx
++
)
for
(
size_t
contourIdx
=
0
;
contourIdx
<
contours
.
size
();
contourIdx
++
)
{
{
...
@@ -178,7 +186,7 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm
...
@@ -178,7 +186,7 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm
if
(
params
.
filterByConvexity
)
if
(
params
.
filterByConvexity
)
{
{
vector
<
Point
>
hull
;
vector
<
Point
>
hull
;
convexHull
(
Mat
(
contours
[
contourIdx
]),
hull
);
convexHull
(
Mat
(
contours
[
contourIdx
]),
hull
);
double
area
=
contourArea
(
Mat
(
contours
[
contourIdx
]));
double
area
=
contourArea
(
Mat
(
contours
[
contourIdx
]));
double
hullArea
=
contourArea
(
Mat
(
hull
));
double
hullArea
=
contourArea
(
Mat
(
hull
));
...
@@ -212,14 +220,19 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm
...
@@ -212,14 +220,19 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm
centers
.
push_back
(
center
);
centers
.
push_back
(
center
);
//circle( keypointsImage, center.location, 1, Scalar(0,0,255), 1 );
#ifdef DEBUG_BLOB_DETECTOR
circle
(
keypointsImage
,
center
.
location
,
1
,
Scalar
(
0
,
0
,
255
),
1
);
#endif
}
}
//imshow("bk", keypointsImage );
#ifdef DEBUG_BLOB_DETECTOR
//waitKey();
imshow
(
"bk"
,
keypointsImage
);
waitKey
();
#endif
}
}
void
SimpleBlobDetector
::
detectImpl
(
const
cv
::
Mat
&
image
,
std
::
vector
<
cv
::
KeyPoint
>&
keypoints
,
const
cv
::
Mat
&
mask
)
const
void
SimpleBlobDetector
::
detectImpl
(
const
cv
::
Mat
&
image
,
std
::
vector
<
cv
::
KeyPoint
>&
keypoints
,
const
cv
::
Mat
&
)
const
{
{
//TODO: support mask
keypoints
.
clear
();
keypoints
.
clear
();
Mat
grayscaleImage
;
Mat
grayscaleImage
;
if
(
image
.
channels
()
==
3
)
if
(
image
.
channels
()
==
3
)
...
@@ -227,7 +240,7 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector<cv::KeyPoi
...
@@ -227,7 +240,7 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector<cv::KeyPoi
else
else
grayscaleImage
=
image
;
grayscaleImage
=
image
;
vector
<
vector
<
Center
>
>
centers
;
vector
<
vector
<
Center
>
>
centers
;
for
(
double
thresh
=
params
.
minThreshold
;
thresh
<
params
.
maxThreshold
;
thresh
+=
params
.
thresholdStep
)
for
(
double
thresh
=
params
.
minThreshold
;
thresh
<
params
.
maxThreshold
;
thresh
+=
params
.
thresholdStep
)
{
{
Mat
binarizedImage
;
Mat
binarizedImage
;
...
@@ -236,8 +249,9 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector<cv::KeyPoi
...
@@ -236,8 +249,9 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector<cv::KeyPoi
//Mat keypointsImage;
//Mat keypointsImage;
//cvtColor( binarizedImage, keypointsImage, CV_GRAY2RGB );
//cvtColor( binarizedImage, keypointsImage, CV_GRAY2RGB );
vector
<
Center
>
curCenters
;
vector
<
Center
>
curCenters
;
findBlobs
(
grayscaleImage
,
binarizedImage
,
curCenters
);
findBlobs
(
grayscaleImage
,
binarizedImage
,
curCenters
);
vector
<
vector
<
Center
>
>
newCenters
;
for
(
size_t
i
=
0
;
i
<
curCenters
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
curCenters
.
size
();
i
++
)
{
{
//circle(keypointsImage, curCenters[i].location, 1, Scalar(0,0,255),-1);
//circle(keypointsImage, curCenters[i].location, 1, Scalar(0,0,255),-1);
...
@@ -262,9 +276,12 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector<cv::KeyPoi
...
@@ -262,9 +276,12 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector<cv::KeyPoi
}
}
if
(
isNew
)
if
(
isNew
)
{
{
centers
.
push_back
(
vector
<
Center
>
(
1
,
curCenters
[
i
]));
newCenters
.
push_back
(
vector
<
Center
>
(
1
,
curCenters
[
i
]));
//centers.push_back(vector<Center> (1, curCenters[i]));
}
}
}
}
std
::
copy
(
newCenters
.
begin
(),
newCenters
.
end
(),
std
::
back_inserter
(
centers
));
//imshow("binarized", keypointsImage );
//imshow("binarized", keypointsImage );
//waitKey();
//waitKey();
}
}
...
...
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