Skip to content
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

(5.x) Merge 4.x #2919

Merged
merged 129 commits into from
Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
7883ec8
Add CUDA Stereo Semi Global Matching
sotsuka-fixstars Dec 21, 2018
166e302
add js to aruco module
urbste Dec 1, 2020
ec294f6
build warnings
alalek Dec 5, 2020
9d32f0c
Merge pull request #2775 from alalek:4.x_build_warnings_gcc_4.8.5
alalek Dec 6, 2020
5f99ff9
Update cudacodec to work with Nvidia Video Codec SDK 11.0
cudawarped Dec 7, 2020
cfcd5b6
surface_matching/PPF3DDetector::match : fix memory leak
eronconi Dec 7, 2020
9b5a801
Merge pull request #2776 from Kumataro:master_freetype2_doc
Kumataro Dec 7, 2020
21c14f5
Merge pull request #2778 from txpaper:master
alalek Dec 8, 2020
d0a5ecf
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Dec 9, 2020
bc1ea8f
Merge pull request #2774 from iago-suarez:master
iago-suarez Dec 9, 2020
4d9e025
[aruco] do not copy image if already a grey-image
esopalumpa Dec 10, 2020
332ae5b
Merge pull request #2785 from esopalumpa:3.4
alalek Dec 10, 2020
dda1f3d
Merge pull request #2772 from fixstars:add_cudastereo_semi_global_mat…
alalek Dec 11, 2020
24be5b8
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Dec 11, 2020
f10f4a6
Optimize calls to std::string::find() and friends for a single char.
vrabaud Dec 16, 2020
bf8e078
Merge pull request #2791 from vrabaud:3.4
alalek Dec 18, 2020
5d5be79
Merge pull request #2769 from ZEISS:feature/aruco_js
alalek Dec 18, 2020
ccdaf9d
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Dec 18, 2020
f01cc38
fix(aruco): add check to avoid infinite loop
alalek Dec 20, 2020
1186eaa
Merge pull request #2793 from alalek:workaround_2738
alalek Dec 20, 2020
913b446
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Dec 20, 2020
b91a781
Merge pull request #2795 from cudawarped:fix_nvidia_video_codec_11_0
alalek Dec 21, 2020
234bf19
ovis: implement real-time shadows
paroj Dec 26, 2020
6d5f440
Merge pull request #2799 from paroj:oshadow
alalek Dec 26, 2020
33ae078
Merge pull request #2801 from Atlas42:cuda-hough-stream-fix
Atlas42 Dec 31, 2020
d601d89
copyright: 2021
alalek Jan 1, 2021
55f5303
rlof optflow: fix crash when no match are found
MrKepzie Jan 4, 2021
697d9e2
Merge pull request #2804 from MrKepzie:optflow-rlof-crash
alalek Jan 11, 2021
768ad92
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Jan 12, 2021
ebf745e
xfeatures2d: disable BoostDesc/VGG in case of missing data
alalek Jan 14, 2021
7e992b8
replace lower with upper
Jan 15, 2021
0b6b8ff
Merge pull request #2822 from DumDereDum:hash_tsdf_bug_fix
alalek Jan 15, 2021
582fe44
NVIDIA_OPTICAL_FLOW_2_0_INTEGRATION
vchiluka5 May 20, 2020
1c957be
Merge pull request #2807 from vchiluka5:NVIDIA_OPTICAL_FLOW_SDK_2.0_I…
alalek Jan 16, 2021
e07c9fa
Merge pull request #2820 from alalek:3.4-issue_1301
alalek Jan 16, 2021
ea1081c
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Jan 16, 2021
f1c0b5e
Implement cv::cuda::inRange (Fixes OpenCV #6295)
amiller27 Jan 2, 2021
98acd62
add wechat qrcode module
dddzg Jan 20, 2021
af72ddd
remove useless license
dddzg Jan 20, 2021
06f690f
remove licenses in samples
dddzg Jan 20, 2021
7b872c9
add precomp
dddzg Jan 20, 2021
9750e14
use CV_Assert
dddzg Jan 21, 2021
be6718e
remove useless cv::
dddzg Jan 21, 2021
905994d
Merge pull request #2821 from WeChatCV:wechat_qrcode
vpisarev Jan 21, 2021
59a9c88
Merge pull request #2803 from amiller27:inrange
alalek Jan 21, 2021
edc5bb7
Merge pull request #2806 from vpisarev:kinfu_demo_orbbec
vpisarev Jan 21, 2021
962fd35
hopefully fixed compile error on Windows
vpisarev Jan 21, 2021
ae14c7c
Merge pull request #2827 from vpisarev:wechat_qrcode_win_fix
alalek Jan 21, 2021
d733a80
Merge pull request #2819 from LaurentBerger:pyb_qd
LaurentBerger Jan 22, 2021
60bd284
[moved from opencv] fix wrong index
tomoaki0705 Jan 24, 2021
6e52be3
disable NVIDIA Optical Flow SDK when CUDA < 10.0
tomoaki0705 Jan 24, 2021
0b8aecd
Merge pull request #2824 from tomoaki0705:fixBuildCudaOptFlow
alalek Jan 25, 2021
3778fa3
[moved from opencv] fix peaky test failure
tomoaki0705 Jan 25, 2021
33ed4c3
Merge moved code from opencv/3.4
alalek Jan 25, 2021
58ab920
fix build failure when CUDA >= 10.0
tomoaki0705 Jan 26, 2021
327a1da
Merge pull request #2836 from tomoaki0705:fixBuildCudaOptFlow
alalek Jan 26, 2021
4e60662
valid point issue 2818 fix
Jan 26, 2021
714f07d
fix readme typo inside modules
AAArthurLiu Jan 27, 2021
1d5b6ae
Merge pull request #2841 from AAArthurLiu:fix-typo-in-modules-readme
alalek Jan 27, 2021
5e8b651
Merge pull request #2839 from DumDereDum:issue_2818
alalek Jan 29, 2021
241579a
get rid of kernel build failure
tomoaki0705 Jan 30, 2021
3d8ec32
adjust threshold for Jetson TX1/TX2
tomoaki0705 Jan 30, 2021
43fff21
Merge pull request #2846 from tomoaki0705:fixCUDASurfFailure
alalek Jan 31, 2021
c10b07d
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Jan 31, 2021
8c385d5
ovis: also take down SceneManager when Window is deleted
paroj Feb 1, 2021
06d8b25
Merge pull request #2851 from paroj:ofix
alalek Feb 2, 2021
0def473
Merge pull request #2831 from tomoaki0705:fixRgbdOpenCL
alalek Feb 4, 2021
efbf1b8
fix segmentation fault on Arm 32bit platform
tomoaki0705 Feb 5, 2021
38f4687
issue 2817 fixed
DumDereDum Feb 1, 2021
461b56f
Merge pull request #2845 from kevineor:DeltaECIEDE2000-fix
kevineor Feb 5, 2021
c918b08
Test code - GpuMatND & Mat interoperability
cognex-nalee Feb 3, 2021
c56f818
ximgproc(ric): resolve issue 2796
tsenst Feb 6, 2021
c61fbc7
Merge pull request #2832 from tsenst:Resolve_Issue_2796_RICInterpolation
alalek Feb 6, 2021
483b396
fixes #2662
Feb 7, 2021
eaa4f33
Merge pull request #2860 from Sintun:master
alalek Feb 7, 2021
0f46d02
Merge pull request #2858 from tomoaki0705:fixRgbdSegmentationFault
alalek Feb 8, 2021
d98026b
Merge pull request #2853 from DumDereDum:iss2817
alalek Feb 8, 2021
6c42250
Merge pull request #2849 from WeChatCV:wechat_qrcode
dddzg Feb 8, 2021
1a5e6ed
ovis: also unregister SceneManager when Window is deleted
paroj Feb 8, 2021
5f8f4b5
ovis: do not leak camera when !SCENE_SEPARATE
paroj Feb 8, 2021
ca4955d
Merge pull request #2866 from paroj:ofix
alalek Feb 9, 2021
4e85f8c
Merge pull request #2805 from nglee:dev_gpumatnd1
alalek Feb 9, 2021
d1099dc
Fix CUDA GoodFeaturesToTrackDetector not threadsafe bug
Feb 5, 2021
24baeaa
Fix omnidir::undistortPoints
rgolovanov Feb 18, 2021
7ede658
Merge pull request #2734 from DumDereDum:new_HashTSDF_GPU_class
DumDereDum Feb 20, 2021
3ea4443
Merge pull request #2868 from nkwangyh:local
alalek Feb 20, 2021
61e0a2d
[moved from opencv] fix getDefaultName()
Feb 15, 2021
fdf80d7
[moved from opencv] remove danger race condition
tomoaki0705 Feb 15, 2021
8ab0020
Merge moved code from opencv/3.4
alalek Feb 21, 2021
974f90f
Merge pull request #2875 from rgolovanov:master
alalek Feb 23, 2021
0165d48
Merge pull request #2869 from dimitrisPs:QDS_getDisparity
dimitrisPs Mar 1, 2021
9240579
Update omnidir.cpp
dzywater Mar 11, 2021
eb2c9bd
Merge pull request #2890 from dzywater:master
alalek Mar 13, 2021
d882e6c
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Mar 13, 2021
22cbfd6
ximgproc: add an assert in thinning()
berak Mar 17, 2021
4de4ede
Merge pull request #2894 from berak:imgproc_fix_thinning
alalek Mar 17, 2021
bf067b4
ovis: add software-renderer based unit testing
paroj Mar 19, 2021
ba281ca
fix: add a safe score threshold(1E-5) to wechat_qrcode detector
Chester-zZz Mar 21, 2021
bc49c5a
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Mar 22, 2021
7f6004e
Merge pull request #2896 from paroj:otest
alalek Mar 24, 2021
068b6c7
Fix aruco _filterTooCloseCandidates
kris-varjo Mar 24, 2021
4739973
Merge pull request #2897 from Chester-zZz:wechat-qrcode
alalek Mar 30, 2021
0042b40
cmake: fix tracking detail headers
alalek Mar 31, 2021
4b20db5
[moved from opencv] cuda: fix inplace condition in cv::cuda::flip
alalek Apr 1, 2021
a124db8
Merge pull request #2900 from spirraw:master
alalek Apr 1, 2021
c287e52
Merge pull request #2854 from DumDereDum:rgbd_test_refactoring
DumDereDum Apr 1, 2021
38ab933
Merge pull request #2903 from alalek:cmake_fix_tracking_headers
alalek Apr 1, 2021
1341c05
Merge pull request #2892 from savuor:posegraph_no_ceres
savuor Apr 1, 2021
1491a5d
Merge moved code from opencv/3.4
alalek Apr 1, 2021
f7efcba
Merge pull request #2313 from sturkmen72:test_Edge_Drawing_Algos
sturkmen72 Apr 2, 2021
a75800a
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Apr 2, 2021
0b5300f
consider the rectangle marker in the future.
SunAriesCN Apr 2, 2021
5e0ff40
Merge pull request #2882 from LaurentBerger:python_viz
LaurentBerger Apr 2, 2021
f5d7f67
Merge pull request #2906 from SunAriesCN:patch-2
alalek Apr 2, 2021
e59b8f7
eliminate build warnings
alalek Apr 5, 2021
746acb9
Merge pull request #2909 from alalek:build_warnings
alalek Apr 5, 2021
87ce2b7
dnn_superres: Fix arXiv URL typos in README.md
pathbreak Apr 6, 2021
a4e601f
Merge pull request #2914 from pathbreak:dnn-sr-doc
alalek Apr 6, 2021
930eca1
3.4/ximgproc: Added edge input feature to fast_line_detector
tsukada-cs Oct 22, 2020
ee5c184
wechat_qr: disable iconv dependancy for mingw
berak Apr 7, 2021
cc36f58
Merge pull request #2915 from alalek:backport_2716
alalek Apr 7, 2021
dc3cd0e
Merge pull request #2916 from berak:wechat_qr_fix_iconv_mingw
alalek Apr 7, 2021
14b4301
update fast_line_detector.hpp
sturkmen72 Apr 7, 2021
da6a95e
Merge pull request #2878 from DumDereDum:colored_kinfu
DumDereDum Apr 7, 2021
31c657e
Merge pull request #2912 from sturkmen72:update_fast_line_detector
alalek Apr 8, 2021
4a36e77
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Apr 8, 2021
f7c034c
fix whitespace
alalek Apr 8, 2021
9163f86
Merge pull request #2918 from alalek:fix_whitespace
alalek Apr 9, 2021
68492c4
Merge branch 4.x
alalek Apr 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $ cmake -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules -D BUILD_opencv_<r

- **julia**: Julia language wrappers with samples and tests.

- **line_descriptor**: Line Segment Extract and Match -- Methods of extracting, describing and latching line segments using binary descriptors.
- **line_descriptor**: Line Segment Extract and Match -- Methods of extracting, describing and matching line segments using binary descriptors.

- **matlab**: Matlab Interface -- OpenCV Matlab Mex wrapper code generator for certain opencv core modules.

Expand Down
2 changes: 1 addition & 1 deletion modules/alphamat/src/cm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void lle(my_vector_of_vectors_t& indm, my_vector_of_vectors_t& samples, float ep
Mat ptDotN(20, 1, DataType<float>::type), imd(20, 1, DataType<float>::type);
Mat Cones(20, 1, DataType<float>::type), Cinv(20, 1, DataType<float>::type);
float alpha, beta, lagrangeMult;
Cones += 1;
Cones = 1;

C = 0;
rhs = 1;
Expand Down
2 changes: 1 addition & 1 deletion modules/aruco/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
set(the_description "ArUco Marker Detection")
ocv_define_module(aruco opencv_core opencv_imgproc opencv_3d opencv_calib WRAP python java objc)
ocv_define_module(aruco opencv_core opencv_imgproc opencv_3d opencv_calib WRAP python java objc js)
45 changes: 24 additions & 21 deletions modules/aruco/src/aruco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,34 +308,36 @@ static void _filterTooCloseCandidates(const vector< vector< Point2f > > &candida
vector< vector< Point > > smallerContours;

// save possible candidates
for( unsigned int i = 0; i < groupedCandidates.size(); i++ ) {
int smallerIdx = groupedCandidates[i][0];
int biggerIdx = -1;
for(unsigned int i = 0; i < groupedCandidates.size(); i++) {
unsigned int smallerIdx = groupedCandidates[i][0];
unsigned int biggerIdx = smallerIdx;
double smallerArea = contourArea(candidatesIn[smallerIdx]);
double biggerArea = smallerArea;

// evaluate group elements
for( unsigned int j = 1; j < groupedCandidates[i].size(); j++ ) {
size_t currPerim = contoursIn[ groupedCandidates[i][j] ].size();
for(unsigned int j = 1; j < groupedCandidates[i].size(); j++) {
unsigned int currIdx = groupedCandidates[i][j];
double currArea = contourArea(candidatesIn[currIdx]);

// check if current contour is bigger
if ( biggerIdx < 0 )
biggerIdx = groupedCandidates[i][j];
else if(currPerim >= contoursIn[ biggerIdx ].size())
biggerIdx = groupedCandidates[i][j];
if(currArea >= biggerArea) {
biggerIdx = currIdx;
biggerArea = currArea;
}

// check if current contour is smaller
if(currPerim < contoursIn[ smallerIdx ].size() && detectInvertedMarker)
smallerIdx = groupedCandidates[i][j];
if(currArea < smallerArea && detectInvertedMarker) {
smallerIdx = currIdx;
smallerArea = currArea;
}
}
// add contours und candidates
if(biggerIdx > -1){

biggerCandidates.push_back(candidatesIn[biggerIdx]);
biggerContours.push_back(contoursIn[biggerIdx]);

if( detectInvertedMarker ){
smallerCandidates.push_back(alignContourOrder(candidatesIn[biggerIdx][0], candidatesIn[smallerIdx]));
smallerContours.push_back(contoursIn[smallerIdx]);
}
// add contours and candidates
biggerCandidates.push_back(candidatesIn[biggerIdx]);
biggerContours.push_back(contoursIn[biggerIdx]);
if(detectInvertedMarker) {
smallerCandidates.push_back(alignContourOrder(candidatesIn[biggerIdx][0], candidatesIn[smallerIdx]));
smallerContours.push_back(contoursIn[smallerIdx]);
}
}
// to preserve the structure :: candidateSet< defaultCandidates, whiteCandidates >
Expand Down Expand Up @@ -564,7 +566,7 @@ static uint8_t _identifyOneCandidate(const Ptr<Dictionary>& dictionary, InputArr
Mat onlyBits =
candidateBits.rowRange(params->markerBorderBits,
candidateBits.rows - params->markerBorderBits)
.colRange(params->markerBorderBits, candidateBits.rows - params->markerBorderBits);
.colRange(params->markerBorderBits, candidateBits.cols - params->markerBorderBits);

// try to indentify the marker
if(!dictionary->identify(onlyBits, idx, rotation, params->errorCorrectionRate))
Expand Down Expand Up @@ -806,6 +808,7 @@ static void _refineCandidateLines(std::vector<Point>& nContours, std::vector<Poi

// saves extra group into corresponding
if( !cntPts[4].empty() ){
CV_CheckLT(group, 4, "FIXIT: avoiding infinite loop: implementation should be revised: https://github.com/opencv/opencv_contrib/issues/2738");
for( unsigned int i=0; i < cntPts[4].size() ; i++ )
cntPts[group].push_back(cntPts[4].at(i));
cntPts[4].clear();
Expand Down
4 changes: 2 additions & 2 deletions modules/aruco/src/charuco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ static int _selectAndRefineChessboardCorners(InputArray _allCorners, InputArray
if(_image.type() == CV_8UC3)
cvtColor(_image, grey, COLOR_BGR2GRAY);
else
_image.copyTo(grey);
grey = _image.getMat();

const Ptr<DetectorParameters> params = DetectorParameters::create(); // use default params for corner refinement

Expand Down Expand Up @@ -725,7 +725,7 @@ void detectCharucoDiamond(InputArray _image, InputArrayOfArrays _markerCorners,
if(_image.type() == CV_8UC3)
cvtColor(_image, grey, COLOR_BGR2GRAY);
else
_image.copyTo(grey);
grey = _image.getMat();

// for each of the detected markers, try to find a diamond
for(unsigned int i = 0; i < _markerIds.total(); i++) {
Expand Down
4 changes: 2 additions & 2 deletions modules/ccalib/src/omnidir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void cv::omnidir::undistortPoints( InputArray distorted, OutputArray undistorted
Vec3d Xs = Xw / cv::norm(Xw);

// reproject to camera plane
Vec3d ppu = Vec3d(Xs[0]/(Xs[2]+_xi), Xs[1]/(Xs[2]+_xi), 1.0);
Vec3d ppu = Vec3d(Xs[0]/Xs[2], Xs[1]/Xs[2], 1.0);
if (undistorted.depth() == CV_32F)
{
dstf[i] = Vec2f((float)ppu[0], (float)ppu[1]);
Expand Down Expand Up @@ -2223,7 +2223,7 @@ void cv::omnidir::stereoRectify(InputArray R, InputArray T, OutputArray R1, Outp
e1.copyTo(_R1.row(0));
e2.copyTo(_R1.row(1));
e3.copyTo(_R1.row(2));
_R2 = R21 * _R1;
_R2 = _R1 * R21;

}

Expand Down
25 changes: 25 additions & 0 deletions modules/cudaarithm/include/opencv2/cudaarithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,31 @@ threshold types are not supported.
*/
CV_EXPORTS_W double threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type, Stream& stream = Stream::Null());

/** @brief Checks if array elements lie between two scalars.

The function checks the range as follows:
- For every element of a single-channel input array:
\f[\texttt{dst} (I)= \texttt{lowerb}_0 \leq \texttt{src} (I)_0 \leq \texttt{upperb}_0\f]
- For two-channel arrays:
\f[\texttt{dst} (I)= \texttt{lowerb}_0 \leq \texttt{src} (I)_0 \leq \texttt{upperb}_0 \land \texttt{lowerb}_1 \leq \texttt{src} (I)_1 \leq \texttt{upperb}_1\f]
- and so forth.

That is, dst (I) is set to 255 (all 1 -bits) if src (I) is within the
specified 1D, 2D, 3D, ... box and 0 otherwise.

Note that unlike the CPU inRange, this does NOT accept an array for lowerb or
upperb, only a cv::Scalar.

@param src first input array.
@param lowerb inclusive lower boundary cv::Scalar.
@param upperb inclusive upper boundary cv::Scalar.
@param dst output array of the same size as src and CV_8U type.
@param stream Stream for the asynchronous version.

@sa cv::inRange
*/
CV_EXPORTS_W void inRange(InputArray src, const Scalar& lowerb, const Scalar& upperb, OutputArray dst, Stream& stream = Stream::Null());

/** @brief Computes magnitudes of complex matrix elements.

@param xy Source complex matrix in the interleaved format ( CV_32FC2 ).
Expand Down
21 changes: 20 additions & 1 deletion modules/cudaarithm/misc/python/test/test_cudaarithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,24 @@ def test_convolution(self):
self.assertTrue(np.allclose(cuMatDst.download(),
cv.filter2D(npMat,-1,kernel,anchor=(-1,-1))[iS[0]:iE[0]+1,iS[1]:iE[1]+1]))

def test_inrange(self):
npMat = (np.random.random((128, 128, 3)) * 255).astype(np.float32)

bound1 = np.random.random((4,)) * 255
bound2 = np.random.random((4,)) * 255
lowerb = np.minimum(bound1, bound2).tolist()
upperb = np.maximum(bound1, bound2).tolist()

cuMat = cv.cuda_GpuMat()
cuMat.upload(npMat)

self.assertTrue((cv.cuda.inRange(cuMat, lowerb, upperb).download() ==
cv.inRange(npMat, np.array(lowerb), np.array(upperb))).all())

cuMatDst = cv.cuda_GpuMat(cuMat.size(), cv.CV_8UC1)
cv.cuda.inRange(cuMat, lowerb, upperb, cuMatDst)
self.assertTrue((cuMatDst.download() ==
cv.inRange(npMat, np.array(lowerb), np.array(upperb))).all())

if __name__ == '__main__':
NewOpenCVTests.bootstrap()
NewOpenCVTests.bootstrap()
37 changes: 37 additions & 0 deletions modules/cudaarithm/perf/perf_element_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1501,4 +1501,41 @@ PERF_TEST_P(Sz_Depth_Op, Threshold,
}
}

//////////////////////////////////////////////////////////////////////
// InRange

PERF_TEST_P(Sz_Depth_Cn, InRange,
Combine(CUDA_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F, CV_64F),
CUDA_CHANNELS_1_3_4))
{
const cv::Size size = GET_PARAM(0);
const int depth = GET_PARAM(1);
const int channels = GET_PARAM(2);

cv::Mat src(size, CV_MAKE_TYPE(depth, channels));
declare.in(src, WARMUP_RNG);

const cv::Scalar lowerb(10, 50, 100);
const cv::Scalar upperb(70, 85, 200);

if (PERF_RUN_CUDA())
{
const cv::cuda::GpuMat d_src(src);
cv::cuda::GpuMat dst;

TEST_CYCLE() cv::cuda::inRange(d_src, lowerb, upperb, dst);

CUDA_SANITY_CHECK(dst, 0);
}
else
{
cv::Mat dst;

TEST_CYCLE() cv::inRange(src, lowerb, upperb, dst);

CPU_SANITY_CHECK(dst);
}
}

}} // namespace
2 changes: 1 addition & 1 deletion modules/cudaarithm/src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void cv::cuda::flip(InputArray _src, OutputArray _dst, int flipCode, Stream& str

_dst.create(src.size(), src.type());
GpuMat dst = getOutputMat(_dst, src.size(), src.type(), stream);
bool isInplace = (src.data == dst.data) || (src.refcount == dst.refcount);
bool isInplace = (src.data == dst.data);
bool isSizeOdd = (src.cols & 1) == 1 || (src.rows & 1) == 1;
if (isInplace && isSizeOdd)
CV_Error(Error::BadROISize, "In-place version of flip only accepts even width/height");
Expand Down
99 changes: 99 additions & 0 deletions modules/cudaarithm/src/cuda/in_range.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// 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 "opencv2/opencv_modules.hpp"

#ifndef HAVE_OPENCV_CUDEV

#error "opencv_cudev is required"

#else

#include "opencv2/core/private.cuda.hpp"
#include "opencv2/cudaarithm.hpp"
#include "opencv2/cudev.hpp"

using namespace cv;
using namespace cv::cuda;
using namespace cv::cudev;

namespace {

template <typename T, int cn>
void inRangeImpl(const GpuMat& src,
const Scalar& lowerb,
const Scalar& upperb,
GpuMat& dst,
Stream& stream) {
gridTransformUnary(globPtr<typename MakeVec<T, cn>::type>(src),
globPtr<uchar>(dst),
InRangeFunc<T, cn>(lowerb, upperb),
stream);
}

} // namespace

void cv::cuda::inRange(InputArray _src,
const Scalar& _lowerb,
const Scalar& _upperb,
OutputArray _dst,
Stream& stream) {
const GpuMat src = getInputMat(_src, stream);

typedef void (*func_t)(const GpuMat& src,
const Scalar& lowerb,
const Scalar& upperb,
GpuMat& dst,
Stream& stream);

// Note: We cannot support 16F with the current implementation because we
// use a CUDA vector (e.g. int3) to store the bounds, and there is no CUDA
// vector type for float16
static constexpr const int MAX_CHANNELS = 4;
static constexpr const int NUM_DEPTHS = CV_64F + 1;

static const std::array<std::array<func_t, NUM_DEPTHS>, MAX_CHANNELS>
funcs = {std::array<func_t, NUM_DEPTHS>{inRangeImpl<uchar, 1>,
inRangeImpl<schar, 1>,
inRangeImpl<ushort, 1>,
inRangeImpl<short, 1>,
inRangeImpl<int, 1>,
inRangeImpl<float, 1>,
inRangeImpl<double, 1>},
std::array<func_t, NUM_DEPTHS>{inRangeImpl<uchar, 2>,
inRangeImpl<schar, 2>,
inRangeImpl<ushort, 2>,
inRangeImpl<short, 2>,
inRangeImpl<int, 2>,
inRangeImpl<float, 2>,
inRangeImpl<double, 2>},
std::array<func_t, NUM_DEPTHS>{inRangeImpl<uchar, 3>,
inRangeImpl<schar, 3>,
inRangeImpl<ushort, 3>,
inRangeImpl<short, 3>,
inRangeImpl<int, 3>,
inRangeImpl<float, 3>,
inRangeImpl<double, 3>},
std::array<func_t, NUM_DEPTHS>{inRangeImpl<uchar, 4>,
inRangeImpl<schar, 4>,
inRangeImpl<ushort, 4>,
inRangeImpl<short, 4>,
inRangeImpl<int, 4>,
inRangeImpl<float, 4>,
inRangeImpl<double, 4>}};

CV_CheckLE(src.channels(), MAX_CHANNELS, "Src must have <= 4 channels");
CV_CheckLE(src.depth(),
CV_64F,
"Src must have depth 8U, 8S, 16U, 16S, 32S, 32F, or 64F");

GpuMat dst = getOutputMat(_dst, src.size(), CV_8UC1, stream);

const func_t func = funcs.at(src.channels() - 1).at(src.depth());
func(src, _lowerb, _upperb, dst, stream);

syncOutput(dst, _dst, stream);
}

#endif
2 changes: 2 additions & 0 deletions modules/cudaarithm/src/element_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ void cv::cuda::addWeighted(InputArray, double, InputArray, double, double, Outpu

double cv::cuda::threshold(InputArray, OutputArray, double, double, int, Stream&) {throw_no_cuda(); return 0.0;}

void cv::cuda::inRange(InputArray, const Scalar&, const Scalar&, OutputArray, Stream&) { throw_no_cuda(); }

void cv::cuda::magnitude(InputArray, OutputArray, Stream&) { throw_no_cuda(); }
void cv::cuda::magnitude(InputArray, InputArray, OutputArray, Stream&) { throw_no_cuda(); }
void cv::cuda::magnitudeSqr(InputArray, OutputArray, Stream&) { throw_no_cuda(); }
Expand Down
Loading