-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Add Connected Components Labeling in CUDA #3153
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contribution!
// For Open Source Computer Vision Library | ||
// | ||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | ||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use short license header: https://github.com/opencv/opencv/wiki/Coding_Style_Guide#file-structure
// 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.
opencv_contrib_source_code/modules/cudaimgproc/samples/connected_components.cpp | ||
|
||
*/ | ||
CV_EXPORTS_AS(ConnectedComponentsWithAlgorithm) void connectedComponents(InputArray image, OutputArray labels, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please start from lower case:
connectedComponentsWithAlgorithm
Ref: https://github.com/opencv/opencv/wiki/Coding_Style_Guide#naming-conventions
|
||
*/ | ||
CV_EXPORTS_AS(ConnectedComponentsWithAlgorithm) void connectedComponents(InputArray image, OutputArray labels, | ||
int connectivity, int ltype, int ccltype); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to use enum
's name instead of int
in parameters.
namespace cv { namespace cuda { namespace device | ||
{ | ||
namespace imgproc | ||
{ | ||
|
||
constexpr int kblock_rows = 16; | ||
constexpr int kblock_cols = 16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid indentation in namespaces
case CV_16U: normalize_labels_impl<ushort>(labels); break; | ||
case CV_16S: normalize_labels_impl<short>(labels); break; | ||
case CV_32S: normalize_labels_impl<int>(labels); break; | ||
default: break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
break;
CV_Assert(0)
?
// Note that this is the maximum number of labels for 4-way connectivity | ||
{ | ||
input << | ||
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid using of MatCommaInitializer
. It generates very huge binary code.
Use ctors with C++11 std::initializer_list
instead.
Ref: https://github.com/opencv/opencv/blob/4.5.5/modules/core/include/opencv2/core/mat.hpp#L2247
Updated with the suggested improvements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for update!
LGTM 👍
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.
Pull Request Description
This pull request adds Connected Components Labeling in CUDA.
The implemented algorithm is Block-Based Komura Equivalence.