1
/*M///////////////////////////////////////////////////////////////////////////////////////
3
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5
// By downloading, copying, installing or using the software you agree to this license.
6
// If you do not agree to this license, do not download, install,
7
// copy or use the software.
11
// For Open Source Computer Vision Library
13
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
16
// Third party copyrights are property of their respective owners.
18
// Redistribution and use in source and binary forms, with or without modification,
19
// are permitted provided that the following conditions are met:
21
// * Redistribution's of source code must retain the above copyright notice,
22
// this list of conditions and the following disclaimer.
24
// * Redistribution's in binary form must reproduce the above copyright notice,
25
// this list of conditions and the following disclaimer in the documentation
26
// and/or other materials provided with the distribution.
28
// * The name of the copyright holders may not be used to endorse or promote products
29
// derived from this software without specific prior written permission.
31
// This software is provided by the copyright holders and contributors "as is" and
32
// any express or implied warranties, including, but not limited to, the implied
33
// warranties of merchantability and fitness for a particular purpose are disclaimed.
34
// In no event shall the Intel Corporation or contributors be liable for any direct,
35
// indirect, incidental, special, exemplary, or consequential damages
36
// (including, but not limited to, procurement of substitute goods or services;
37
// loss of use, data, or profits; or business interruption) however caused
38
// and on any theory of liability, whether in contract, strict liability,
39
// or tort (including negligence or otherwise) arising in any way out of
40
// the use of this software, even if advised of the possibility of such damage.
46
#ifndef __OPENCV_CUDEV_EXPR_REDUCTION_HPP__
47
#define __OPENCV_CUDEV_EXPR_REDUCTION_HPP__
49
#include "../common.hpp"
50
#include "../grid/reduce.hpp"
51
#include "../grid/histogram.hpp"
52
#include "../grid/integral.hpp"
53
#include "../grid/reduce_to_vec.hpp"
54
#include "../ptr2d/traits.hpp"
57
namespace cv { namespace cudev {
64
template <class SrcPtr> struct SumExprBody
69
__host__ void assignTo(GpuMat_<T>& dst, Stream& stream = Stream::Null()) const
71
gridCalcSum(src, dst, stream);
75
template <class SrcPtr>
76
__host__ Expr<SumExprBody<SrcPtr> >
77
sum_(const SrcPtr& src)
79
SumExprBody<SrcPtr> body;
81
return makeExpr(body);
86
template <class SrcPtr> struct FindMinValExprBody
91
__host__ void assignTo(GpuMat_<T>& dst, Stream& stream = Stream::Null()) const
93
gridFindMinVal(src, dst, stream);
97
template <class SrcPtr>
98
__host__ Expr<FindMinValExprBody<SrcPtr> >
99
minVal_(const SrcPtr& src)
101
FindMinValExprBody<SrcPtr> body;
103
return makeExpr(body);
108
template <class SrcPtr> struct FindMaxValExprBody
112
template <typename T>
113
__host__ void assignTo(GpuMat_<T>& dst, Stream& stream = Stream::Null()) const
115
gridFindMaxVal(src, dst, stream);
119
template <class SrcPtr>
120
__host__ Expr<FindMaxValExprBody<SrcPtr> >
121
maxVal_(const SrcPtr& src)
123
FindMaxValExprBody<SrcPtr> body;
125
return makeExpr(body);
130
template <class SrcPtr> struct FindMinMaxValExprBody
134
template <typename T>
135
__host__ void assignTo(GpuMat_<T>& dst, Stream& stream = Stream::Null()) const
137
gridFindMinMaxVal(src, dst, stream);
141
template <class SrcPtr>
142
__host__ Expr<FindMinMaxValExprBody<SrcPtr> >
143
minMaxVal_(const SrcPtr& src)
145
FindMinMaxValExprBody<SrcPtr> body;
147
return makeExpr(body);
152
template <class SrcPtr> struct CountNonZeroExprBody
156
template <typename T>
157
__host__ void assignTo(GpuMat_<T>& dst, Stream& stream = Stream::Null()) const
159
gridCountNonZero(src, dst, stream);
163
template <class SrcPtr>
164
__host__ Expr<CountNonZeroExprBody<SrcPtr> >
165
countNonZero_(const SrcPtr& src)
167
CountNonZeroExprBody<SrcPtr> body;
169
return makeExpr(body);
174
template <class Reductor, class SrcPtr> struct ReduceToRowBody
178
template <typename T>
179
__host__ void assignTo(GpuMat_<T>& dst, Stream& stream = Stream::Null()) const
181
gridReduceToRow<Reductor>(src, dst, stream);
185
template <class Reductor, class SrcPtr>
186
__host__ Expr<ReduceToRowBody<Reductor, SrcPtr> >
187
reduceToRow_(const SrcPtr& src)
189
ReduceToRowBody<Reductor, SrcPtr> body;
191
return makeExpr(body);
196
template <class Reductor, class SrcPtr> struct ReduceToColumnBody
200
template <typename T>
201
__host__ void assignTo(GpuMat_<T>& dst, Stream& stream = Stream::Null()) const
203
gridReduceToColumn<Reductor>(src, dst, stream);
207
template <class Reductor, class SrcPtr>
208
__host__ Expr<ReduceToColumnBody<Reductor, SrcPtr> >
209
reduceToColumn_(const SrcPtr& src)
211
ReduceToColumnBody<Reductor, SrcPtr> body;
213
return makeExpr(body);
218
template <int BIN_COUNT, class SrcPtr> struct HistogramBody
222
template <typename T>
223
__host__ void assignTo(GpuMat_<T>& dst, Stream& stream = Stream::Null()) const
225
gridHistogram<BIN_COUNT>(src, dst, stream);
229
template <int BIN_COUNT, class SrcPtr>
230
__host__ Expr<HistogramBody<BIN_COUNT, SrcPtr> >
231
histogram_(const SrcPtr& src)
233
HistogramBody<BIN_COUNT, SrcPtr> body;
235
return makeExpr(body);
240
template <class SrcPtr> struct IntegralBody
244
template <typename T>
245
__host__ void assignTo(GpuMat_<T>& dst, Stream& stream = Stream::Null()) const
247
gridIntegral(src, dst, stream);
251
template <class SrcPtr>
252
__host__ Expr<IntegralBody<SrcPtr> >
253
integral_(const SrcPtr& src)
255
IntegralBody<SrcPtr> body;
257
return makeExpr(body);