Add Connected Components Labeling in CUDA#3153
Add Connected Components Labeling in CUDA#3153opencv-pushbot merged 1 commit intoopencv:4.xfrom stal12:4.x
Conversation
| // 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.
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.
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.
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.
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; |
| // 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.
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 |
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.