-
Notifications
You must be signed in to change notification settings - Fork 5.8k
new feature: update ellipse detector using projective invariant pruning #3322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
71b0e2b
update ellipse detector
haku-huang 024a112
update perf and docs
haku-huang 3620a68
update test images path
haku-huang 28e5817
update typos and perf
haku-huang 7238fe6
update function name and docs
haku-huang 557f541
fix some typos
haku-huang 4f0c1f9
fix some typos
haku-huang da8763b
fix some typos
haku-huang c111235
update sample and group
haku-huang 774223c
fix typos in sample
haku-huang 97c93b6
update source file and test
haku-huang b1f98be
update ellipse center position matching method in test
haku-huang 6c8b837
update namespace for norm
haku-huang ecfe0f1
update norm calculating method
haku-huang e280b00
use default destructor for macOS
haku-huang 7b70491
remove useless srand in source code
haku-huang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
modules/ximgproc/include/opencv2/ximgproc/find_ellipses.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// This file is part of OpenCV project. | ||
// It is subject to the license terms in the LICENSE file found in the top-level directory | ||
// of this distribution and at http://opencv.org/license.html. | ||
|
||
#ifndef __OPENCV_FIND_ELLIPSES_HPP__ | ||
#define __OPENCV_FIND_ELLIPSES_HPP__ | ||
|
||
#include <opencv2/core.hpp> | ||
|
||
namespace cv { | ||
namespace ximgproc { | ||
|
||
//! @addtogroup ximgproc | ||
//! @{ | ||
|
||
/** | ||
@brief Finds ellipses fastly in an image using projective invariant pruning. | ||
* | ||
* The function detects ellipses in images using projective invariant pruning. | ||
* For more details about this implementation, please see | ||
* [JIA2017FAST] Jia, Qi et al, (2017). | ||
* A Fast Ellipse Detector using Projective Invariant Pruning. IEEE Transactions on Image Processing. | ||
* | ||
@param image input image, could be gray or color. | ||
@param ellipses output vector of found ellipses. each vector is encoded as five float $x, y, a, b, radius, score$. | ||
@param scoreThreshold float, the threshold of ellipse score. | ||
@param reliabilityThreshold float, the threshold of reliability. | ||
@param centerDistanceThreshold float, the threshold of center distance. | ||
*/ | ||
CV_EXPORTS_W void findEllipses( | ||
InputArray image, OutputArray ellipses, | ||
float scoreThreshold = 0.7f, float reliabilityThreshold = 0.5f, | ||
float centerDistanceThreshold = 0.05f | ||
); | ||
//! @} ximgproc | ||
} | ||
} | ||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// This file is part of OpenCV project. | ||
// It is subject to the license terms in the LICENSE file found in the top-level directory | ||
// of this distribution and at http://opencv.org/license.html. | ||
#include "perf_precomp.hpp" | ||
|
||
namespace opencv_test { namespace { | ||
|
||
typedef tuple<Size, MatType, int> FindEllipsesTestParam; | ||
typedef TestBaseWithParam<FindEllipsesTestParam> FindEllipsesTest; | ||
|
||
PERF_TEST_P(FindEllipsesTest, perf, Combine(SZ_TYPICAL, Values(CV_8U), Values(1, 3))) | ||
{ | ||
FindEllipsesTestParam params = GetParam(); | ||
Size sz = get<0>(params); | ||
int matType = get<1>(params); | ||
int srcCn = get<2>(params); | ||
|
||
Mat src(sz, CV_MAKE_TYPE(matType, srcCn)); | ||
Mat dst(sz, CV_32FC(6)); | ||
|
||
declare.in(src, WARMUP_RNG).out(dst); | ||
|
||
TEST_CYCLE() findEllipses(src, dst, 0.7f, 0.5f, 0.05f); | ||
|
||
SANITY_CHECK_NOTHING(); | ||
} | ||
}} // namespace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// This file is part of OpenCV project. | ||
// It is subject to the license terms in the LICENSE file found in the top-level directory | ||
// of this distribution and at http://opencv.org/license.html. | ||
|
||
#include <iostream> | ||
#include <opencv2/imgproc.hpp> | ||
#include <opencv2/imgcodecs.hpp> | ||
#include <opencv2/ximgproc.hpp> | ||
#include <opencv2/highgui.hpp> | ||
|
||
using namespace cv; | ||
|
||
int main() { | ||
|
||
// load image | ||
Mat img = imread(samples::findFile("stuff.jpg"), IMREAD_COLOR); | ||
|
||
// check if image is loaded | ||
if (img.empty()) { | ||
std::cout << "fail to open image" << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
// create output array | ||
std::vector<Vec6f> ells; | ||
|
||
// test ellipse detection | ||
cv::ximgproc::findEllipses(img, ells, 0.4f, 0.7f, 0.02f); | ||
|
||
// print output | ||
for (unsigned i = 0; i < ells.size(); i++) { | ||
Vec6f ell = ells[i]; | ||
std::cout << ell << std::endl; | ||
Scalar color(0, 0, 255); | ||
// draw ellipse on image | ||
ellipse( | ||
img, | ||
Point(cvRound(ell[0]), cvRound(ell[1])), | ||
Size(cvRound(ell[2]), cvRound(ell[3])), | ||
ell[5] * 180 / CV_PI, 0.0, 360.0, color, 3 | ||
); | ||
} | ||
|
||
// show image | ||
imshow("result", img); | ||
waitKey(); | ||
|
||
// end | ||
return 0; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.