split_merge.hpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  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.
  8. //
  9. //
  10. // License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  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.
  17. //
  18. // Redistribution and use in source and binary forms, with or without modification,
  19. // are permitted provided that the following conditions are met:
  20. //
  21. // * Redistribution's of source code must retain the above copyright notice,
  22. // this list of conditions and the following disclaimer.
  23. //
  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.
  27. //
  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.
  30. //
  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.
  41. //
  42. //M*/
  43. #pragma once
  44. #ifndef OPENCV_CUDEV_GRID_SPLIT_MERGE_HPP
  45. #define OPENCV_CUDEV_GRID_SPLIT_MERGE_HPP
  46. #include "../common.hpp"
  47. #include "../util/tuple.hpp"
  48. #include "../util/vec_traits.hpp"
  49. #include "../ptr2d/traits.hpp"
  50. #include "../ptr2d/gpumat.hpp"
  51. #include "../ptr2d/glob.hpp"
  52. #include "../ptr2d/mask.hpp"
  53. #include "detail/split_merge.hpp"
  54. namespace cv { namespace cudev {
  55. //! @addtogroup cudev
  56. //! @{
  57. template <class Policy, class SrcPtrTuple, typename DstType, class MaskPtr>
  58. __host__ void gridMerge_(const SrcPtrTuple& src, GpuMat_<DstType>& dst, const MaskPtr& mask, Stream& stream = Stream::Null())
  59. {
  60. CV_StaticAssert( VecTraits<DstType>::cn == tuple_size<SrcPtrTuple>::value, "" );
  61. const int rows = getRows(src);
  62. const int cols = getCols(src);
  63. CV_Assert( getRows(mask) == rows && getCols(mask) == cols );
  64. dst.create(rows, cols);
  65. grid_split_merge_detail::MergeImpl<VecTraits<DstType>::cn, Policy>::merge(shrinkPtr(src),
  66. shrinkPtr(dst),
  67. shrinkPtr(mask),
  68. rows, cols,
  69. StreamAccessor::getStream(stream));
  70. }
  71. template <class Policy, class SrcPtrTuple, typename DstType, class MaskPtr>
  72. __host__ void gridMerge_(const SrcPtrTuple& src, const GlobPtrSz<DstType>& dst, const MaskPtr& mask, Stream& stream = Stream::Null())
  73. {
  74. CV_StaticAssert( VecTraits<DstType>::cn == tuple_size<SrcPtrTuple>::value, "" );
  75. const int rows = getRows(src);
  76. const int cols = getCols(src);
  77. CV_Assert( getRows(dst) == rows && getCols(dst) == cols );
  78. CV_Assert( getRows(mask) == rows && getCols(mask) == cols );
  79. grid_split_merge_detail::MergeImpl<VecTraits<DstType>::cn, Policy>::merge(shrinkPtr(src),
  80. shrinkPtr(dst),
  81. shrinkPtr(mask),
  82. rows, cols,
  83. StreamAccessor::getStream(stream));
  84. }
  85. template <class Policy, class SrcPtrTuple, typename DstType>
  86. __host__ void gridMerge_(const SrcPtrTuple& src, GpuMat_<DstType>& dst, Stream& stream = Stream::Null())
  87. {
  88. CV_StaticAssert( VecTraits<DstType>::cn == tuple_size<SrcPtrTuple>::value, "" );
  89. const int rows = getRows(src);
  90. const int cols = getCols(src);
  91. dst.create(rows, cols);
  92. grid_split_merge_detail::MergeImpl<VecTraits<DstType>::cn, Policy>::merge(shrinkPtr(src),
  93. shrinkPtr(dst),
  94. WithOutMask(),
  95. rows, cols,
  96. StreamAccessor::getStream(stream));
  97. }
  98. template <class Policy, class SrcPtrTuple, typename DstType>
  99. __host__ void gridMerge_(const SrcPtrTuple& src, const GlobPtrSz<DstType>& dst, Stream& stream = Stream::Null())
  100. {
  101. CV_StaticAssert( VecTraits<DstType>::cn == tuple_size<SrcPtrTuple>::value, "" );
  102. const int rows = getRows(src);
  103. const int cols = getCols(src);
  104. CV_Assert( getRows(dst) == rows && getCols(dst) == cols );
  105. grid_split_merge_detail::MergeImpl<VecTraits<DstType>::cn, Policy>::merge(shrinkPtr(src),
  106. shrinkPtr(dst),
  107. WithOutMask(),
  108. rows, cols,
  109. StreamAccessor::getStream(stream));
  110. }
  111. template <class Policy, class SrcPtr, typename DstType, class MaskPtr>
  112. __host__ void gridSplit_(const SrcPtr& src, const tuple< GpuMat_<DstType>&, GpuMat_<DstType>& >& dst, const MaskPtr& mask, Stream& stream = Stream::Null())
  113. {
  114. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 2, "" );
  115. const int rows = getRows(src);
  116. const int cols = getCols(src);
  117. CV_Assert( getRows(mask) == rows && getCols(mask) == cols );
  118. get<0>(dst).create(rows, cols);
  119. get<1>(dst).create(rows, cols);
  120. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  121. shrinkPtr(get<0>(dst)), shrinkPtr(get<1>(dst)),
  122. shrinkPtr(mask),
  123. rows, cols,
  124. StreamAccessor::getStream(stream));
  125. }
  126. template <class Policy, class SrcPtr, typename DstType, class MaskPtr>
  127. __host__ void gridSplit_(const SrcPtr& src, GpuMat_<DstType> (&dst)[2], const MaskPtr& mask, Stream& stream = Stream::Null())
  128. {
  129. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 2, "" );
  130. const int rows = getRows(src);
  131. const int cols = getCols(src);
  132. CV_Assert( getRows(mask) == rows && getCols(mask) == cols );
  133. dst[0].create(rows, cols);
  134. dst[1].create(rows, cols);
  135. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  136. shrinkPtr(dst[0]), shrinkPtr(dst[1]),
  137. shrinkPtr(mask),
  138. rows, cols,
  139. StreamAccessor::getStream(stream));
  140. }
  141. template <class Policy, class SrcPtr, typename DstType, class MaskPtr>
  142. __host__ void gridSplit_(const SrcPtr& src, GlobPtrSz<DstType> (&dst)[2], const MaskPtr& mask, Stream& stream = Stream::Null())
  143. {
  144. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 2, "" );
  145. const int rows = getRows(src);
  146. const int cols = getCols(src);
  147. CV_Assert( getRows(dst[0]) == rows && getCols(dst[0]) == cols );
  148. CV_Assert( getRows(dst[1]) == rows && getCols(dst[1]) == cols );
  149. CV_Assert( getRows(mask) == rows && getCols(mask) == cols );
  150. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  151. shrinkPtr(dst[0]), shrinkPtr(dst[1]),
  152. shrinkPtr(mask),
  153. rows, cols,
  154. StreamAccessor::getStream(stream));
  155. }
  156. template <class Policy, class SrcPtr, typename DstType>
  157. __host__ void gridSplit_(const SrcPtr& src, const tuple< GpuMat_<DstType>&, GpuMat_<DstType>& >& dst, Stream& stream = Stream::Null())
  158. {
  159. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 2, "" );
  160. const int rows = getRows(src);
  161. const int cols = getCols(src);
  162. get<0>(dst).create(rows, cols);
  163. get<1>(dst).create(rows, cols);
  164. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  165. shrinkPtr(get<0>(dst)), shrinkPtr(get<1>(dst)),
  166. WithOutMask(),
  167. rows, cols,
  168. StreamAccessor::getStream(stream));
  169. }
  170. template <class Policy, class SrcPtr, typename DstType>
  171. __host__ void gridSplit_(const SrcPtr& src, GpuMat_<DstType> (&dst)[2], Stream& stream = Stream::Null())
  172. {
  173. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 2, "" );
  174. const int rows = getRows(src);
  175. const int cols = getCols(src);
  176. dst[0].create(rows, cols);
  177. dst[1].create(rows, cols);
  178. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  179. shrinkPtr(dst[0]), shrinkPtr(dst[1]),
  180. WithOutMask(),
  181. rows, cols,
  182. StreamAccessor::getStream(stream));
  183. }
  184. template <class Policy, class SrcPtr, typename DstType>
  185. __host__ void gridSplit_(const SrcPtr& src, GlobPtrSz<DstType> (&dst)[2], Stream& stream = Stream::Null())
  186. {
  187. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 2, "" );
  188. const int rows = getRows(src);
  189. const int cols = getCols(src);
  190. CV_Assert( getRows(dst[0]) == rows && getCols(dst[0]) == cols );
  191. CV_Assert( getRows(dst[1]) == rows && getCols(dst[1]) == cols );
  192. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  193. shrinkPtr(dst[0]), shrinkPtr(dst[1]),
  194. WithOutMask(),
  195. rows, cols,
  196. StreamAccessor::getStream(stream));
  197. }
  198. template <class Policy, class SrcPtr, typename DstType, class MaskPtr>
  199. __host__ void gridSplit_(const SrcPtr& src, const tuple< GpuMat_<DstType>&, GpuMat_<DstType>&, GpuMat_<DstType>& >& dst, const MaskPtr& mask, Stream& stream = Stream::Null())
  200. {
  201. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 3, "" );
  202. const int rows = getRows(src);
  203. const int cols = getCols(src);
  204. CV_Assert( getRows(mask) == rows && getCols(mask) == cols );
  205. get<0>(dst).create(rows, cols);
  206. get<1>(dst).create(rows, cols);
  207. get<2>(dst).create(rows, cols);
  208. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  209. shrinkPtr(get<0>(dst)), shrinkPtr(get<1>(dst)), shrinkPtr(get<2>(dst)),
  210. shrinkPtr(mask),
  211. rows, cols,
  212. StreamAccessor::getStream(stream));
  213. }
  214. template <class Policy, class SrcPtr, typename DstType, class MaskPtr>
  215. __host__ void gridSplit_(const SrcPtr& src, GpuMat_<DstType> (&dst)[3], const MaskPtr& mask, Stream& stream = Stream::Null())
  216. {
  217. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 3, "" );
  218. const int rows = getRows(src);
  219. const int cols = getCols(src);
  220. CV_Assert( getRows(mask) == rows && getCols(mask) == cols );
  221. dst[0].create(rows, cols);
  222. dst[1].create(rows, cols);
  223. dst[2].create(rows, cols);
  224. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  225. shrinkPtr(dst[0]), shrinkPtr(dst[1]), shrinkPtr(dst[2]),
  226. shrinkPtr(mask),
  227. rows, cols,
  228. StreamAccessor::getStream(stream));
  229. }
  230. template <class Policy, class SrcPtr, typename DstType, class MaskPtr>
  231. __host__ void gridSplit_(const SrcPtr& src, GlobPtrSz<DstType> (&dst)[3], const MaskPtr& mask, Stream& stream = Stream::Null())
  232. {
  233. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 3, "" );
  234. const int rows = getRows(src);
  235. const int cols = getCols(src);
  236. CV_Assert( getRows(dst[0]) == rows && getCols(dst[0]) == cols );
  237. CV_Assert( getRows(dst[1]) == rows && getCols(dst[1]) == cols );
  238. CV_Assert( getRows(dst[2]) == rows && getCols(dst[2]) == cols );
  239. CV_Assert( getRows(mask) == rows && getCols(mask) == cols );
  240. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  241. shrinkPtr(dst[0]), shrinkPtr(dst[1]), shrinkPtr(dst[2]),
  242. shrinkPtr(mask),
  243. rows, cols,
  244. StreamAccessor::getStream(stream));
  245. }
  246. template <class Policy, class SrcPtr, typename DstType>
  247. __host__ void gridSplit_(const SrcPtr& src, const tuple< GpuMat_<DstType>&, GpuMat_<DstType>&, GpuMat_<DstType>& >& dst, Stream& stream = Stream::Null())
  248. {
  249. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 3, "" );
  250. const int rows = getRows(src);
  251. const int cols = getCols(src);
  252. get<0>(dst).create(rows, cols);
  253. get<1>(dst).create(rows, cols);
  254. get<2>(dst).create(rows, cols);
  255. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  256. shrinkPtr(get<0>(dst)), shrinkPtr(get<1>(dst)), shrinkPtr(get<2>(dst)),
  257. WithOutMask(),
  258. rows, cols,
  259. StreamAccessor::getStream(stream));
  260. }
  261. template <class Policy, class SrcPtr, typename DstType>
  262. __host__ void gridSplit_(const SrcPtr& src, GpuMat_<DstType> (&dst)[3], Stream& stream = Stream::Null())
  263. {
  264. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 3, "" );
  265. const int rows = getRows(src);
  266. const int cols = getCols(src);
  267. dst[0].create(rows, cols);
  268. dst[1].create(rows, cols);
  269. dst[2].create(rows, cols);
  270. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  271. shrinkPtr(dst[0]), shrinkPtr(dst[1]), shrinkPtr(dst[2]),
  272. WithOutMask(),
  273. rows, cols,
  274. StreamAccessor::getStream(stream));
  275. }
  276. template <class Policy, class SrcPtr, typename DstType>
  277. __host__ void gridSplit_(const SrcPtr& src, GlobPtrSz<DstType> (&dst)[3], Stream& stream = Stream::Null())
  278. {
  279. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 3, "" );
  280. const int rows = getRows(src);
  281. const int cols = getCols(src);
  282. CV_Assert( getRows(dst[0]) == rows && getCols(dst[0]) == cols );
  283. CV_Assert( getRows(dst[1]) == rows && getCols(dst[1]) == cols );
  284. CV_Assert( getRows(dst[2]) == rows && getCols(dst[2]) == cols );
  285. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  286. shrinkPtr(dst[0]), shrinkPtr(dst[1]), shrinkPtr(dst[2]),
  287. WithOutMask(),
  288. rows, cols,
  289. StreamAccessor::getStream(stream));
  290. }
  291. template <class Policy, class SrcPtr, typename DstType, class MaskPtr>
  292. __host__ void gridSplit_(const SrcPtr& src, const tuple< GpuMat_<DstType>&, GpuMat_<DstType>&, GpuMat_<DstType>&, GpuMat_<DstType>& >& dst, const MaskPtr& mask, Stream& stream = Stream::Null())
  293. {
  294. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 4, "" );
  295. const int rows = getRows(src);
  296. const int cols = getCols(src);
  297. CV_Assert( getRows(mask) == rows && getCols(mask) == cols );
  298. get<0>(dst).create(rows, cols);
  299. get<1>(dst).create(rows, cols);
  300. get<2>(dst).create(rows, cols);
  301. get<3>(dst).create(rows, cols);
  302. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  303. shrinkPtr(get<0>(dst)), shrinkPtr(get<1>(dst)), shrinkPtr(get<2>(dst)), shrinkPtr(get<3>(dst)),
  304. shrinkPtr(mask),
  305. rows, cols,
  306. StreamAccessor::getStream(stream));
  307. }
  308. template <class Policy, class SrcPtr, typename DstType, class MaskPtr>
  309. __host__ void gridSplit_(const SrcPtr& src, GpuMat_<DstType> (&dst)[4], const MaskPtr& mask, Stream& stream = Stream::Null())
  310. {
  311. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 4, "" );
  312. const int rows = getRows(src);
  313. const int cols = getCols(src);
  314. CV_Assert( getRows(mask) == rows && getCols(mask) == cols );
  315. dst[0].create(rows, cols);
  316. dst[1].create(rows, cols);
  317. dst[2].create(rows, cols);
  318. dst[3].create(rows, cols);
  319. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  320. shrinkPtr(dst[0]), shrinkPtr(dst[1]), shrinkPtr(dst[2]), shrinkPtr(dst[3]),
  321. shrinkPtr(mask),
  322. rows, cols,
  323. StreamAccessor::getStream(stream));
  324. }
  325. template <class Policy, class SrcPtr, typename DstType, class MaskPtr>
  326. __host__ void gridSplit_(const SrcPtr& src, GlobPtrSz<DstType> (&dst)[4], const MaskPtr& mask, Stream& stream = Stream::Null())
  327. {
  328. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 4, "" );
  329. const int rows = getRows(src);
  330. const int cols = getCols(src);
  331. CV_Assert( getRows(dst[0]) == rows && getCols(dst[0]) == cols );
  332. CV_Assert( getRows(dst[1]) == rows && getCols(dst[1]) == cols );
  333. CV_Assert( getRows(dst[2]) == rows && getCols(dst[2]) == cols );
  334. CV_Assert( getRows(dst[3]) == rows && getCols(dst[3]) == cols );
  335. CV_Assert( getRows(mask) == rows && getCols(mask) == cols );
  336. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  337. shrinkPtr(dst[0]), shrinkPtr(dst[1]), shrinkPtr(dst[2]), shrinkPtr(dst[3]),
  338. shrinkPtr(mask),
  339. rows, cols,
  340. StreamAccessor::getStream(stream));
  341. }
  342. template <class Policy, class SrcPtr, typename DstType>
  343. __host__ void gridSplit_(const SrcPtr& src, const tuple< GpuMat_<DstType>&, GpuMat_<DstType>&, GpuMat_<DstType>&, GpuMat_<DstType>& >& dst, Stream& stream = Stream::Null())
  344. {
  345. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 4, "" );
  346. const int rows = getRows(src);
  347. const int cols = getCols(src);
  348. get<0>(dst).create(rows, cols);
  349. get<1>(dst).create(rows, cols);
  350. get<2>(dst).create(rows, cols);
  351. get<3>(dst).create(rows, cols);
  352. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  353. shrinkPtr(get<0>(dst)), shrinkPtr(get<1>(dst)), shrinkPtr(get<2>(dst)), shrinkPtr(get<3>(dst)),
  354. WithOutMask(),
  355. rows, cols,
  356. StreamAccessor::getStream(stream));
  357. }
  358. template <class Policy, class SrcPtr, typename DstType>
  359. __host__ void gridSplit_(const SrcPtr& src, GpuMat_<DstType> (&dst)[4], Stream& stream = Stream::Null())
  360. {
  361. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 4, "" );
  362. const int rows = getRows(src);
  363. const int cols = getCols(src);
  364. dst[0].create(rows, cols);
  365. dst[1].create(rows, cols);
  366. dst[2].create(rows, cols);
  367. dst[3].create(rows, cols);
  368. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  369. shrinkPtr(dst[0]), shrinkPtr(dst[1]), shrinkPtr(dst[2]), shrinkPtr(dst[3]),
  370. WithOutMask(),
  371. rows, cols,
  372. StreamAccessor::getStream(stream));
  373. }
  374. template <class Policy, class SrcPtr, typename DstType>
  375. __host__ void gridSplit_(const SrcPtr& src, GlobPtrSz<DstType> (&dst)[4], Stream& stream = Stream::Null())
  376. {
  377. CV_StaticAssert( VecTraits<typename PtrTraits<SrcPtr>::value_type>::cn == 4, "" );
  378. const int rows = getRows(src);
  379. const int cols = getCols(src);
  380. CV_Assert( getRows(dst[0]) == rows && getCols(dst[0]) == cols );
  381. CV_Assert( getRows(dst[1]) == rows && getCols(dst[1]) == cols );
  382. CV_Assert( getRows(dst[2]) == rows && getCols(dst[2]) == cols );
  383. CV_Assert( getRows(dst[3]) == rows && getCols(dst[3]) == cols );
  384. grid_split_merge_detail::split<Policy>(shrinkPtr(src),
  385. shrinkPtr(dst[0]), shrinkPtr(dst[1]), shrinkPtr(dst[2]), shrinkPtr(dst[3]),
  386. WithOutMask(),
  387. rows, cols,
  388. StreamAccessor::getStream(stream));
  389. }
  390. // Default Policy
  391. struct DefaultSplitMergePolicy
  392. {
  393. enum {
  394. block_size_x = 32,
  395. block_size_y = 8
  396. };
  397. };
  398. template <class SrcPtrTuple, typename DstType, class MaskPtr>
  399. __host__ void gridMerge(const SrcPtrTuple& src, GpuMat_<DstType>& dst, const MaskPtr& mask, Stream& stream = Stream::Null())
  400. {
  401. gridMerge_<DefaultSplitMergePolicy>(src, dst, mask, stream);
  402. }
  403. template <class SrcPtrTuple, typename DstType, class MaskPtr>
  404. __host__ void gridMerge(const SrcPtrTuple& src, const GlobPtrSz<DstType>& dst, const MaskPtr& mask, Stream& stream = Stream::Null())
  405. {
  406. gridMerge_<DefaultSplitMergePolicy>(src, dst, mask, stream);
  407. }
  408. template <class SrcPtrTuple, typename DstType>
  409. __host__ void gridMerge(const SrcPtrTuple& src, GpuMat_<DstType>& dst, Stream& stream = Stream::Null())
  410. {
  411. gridMerge_<DefaultSplitMergePolicy>(src, dst, stream);
  412. }
  413. template <class SrcPtrTuple, typename DstType>
  414. __host__ void gridMerge(const SrcPtrTuple& src, const GlobPtrSz<DstType>& dst, Stream& stream = Stream::Null())
  415. {
  416. gridMerge_<DefaultSplitMergePolicy>(src, dst, stream);
  417. }
  418. template <class SrcPtr, typename DstType, class MaskPtr>
  419. __host__ void gridSplit(const SrcPtr& src, const tuple< GpuMat_<DstType>&, GpuMat_<DstType>& >& dst, const MaskPtr& mask, Stream& stream = Stream::Null())
  420. {
  421. gridSplit_<DefaultSplitMergePolicy>(src, dst, mask, stream);
  422. }
  423. template <class SrcPtr, typename DstType>
  424. __host__ void gridSplit(const SrcPtr& src, const tuple< GpuMat_<DstType>&, GpuMat_<DstType>& >& dst, Stream& stream = Stream::Null())
  425. {
  426. gridSplit_<DefaultSplitMergePolicy>(src, dst, stream);
  427. }
  428. template <class SrcPtr, typename DstType, class MaskPtr>
  429. __host__ void gridSplit(const SrcPtr& src, const tuple< GpuMat_<DstType>&, GpuMat_<DstType>&, GpuMat_<DstType>& >& dst, const MaskPtr& mask, Stream& stream = Stream::Null())
  430. {
  431. gridSplit_<DefaultSplitMergePolicy>(src, dst, mask, stream);
  432. }
  433. template <class SrcPtr, typename DstType>
  434. __host__ void gridSplit(const SrcPtr& src, const tuple< GpuMat_<DstType>&, GpuMat_<DstType>&, GpuMat_<DstType>& >& dst, Stream& stream = Stream::Null())
  435. {
  436. gridSplit_<DefaultSplitMergePolicy>(src, dst, stream);
  437. }
  438. template <class SrcPtr, typename DstType, class MaskPtr>
  439. __host__ void gridSplit(const SrcPtr& src, const tuple< GpuMat_<DstType>&, GpuMat_<DstType>&, GpuMat_<DstType>&, GpuMat_<DstType>& >& dst, const MaskPtr& mask, Stream& stream = Stream::Null())
  440. {
  441. gridSplit_<DefaultSplitMergePolicy>(src, dst, mask, stream);
  442. }
  443. template <class SrcPtr, typename DstType>
  444. __host__ void gridSplit(const SrcPtr& src, const tuple< GpuMat_<DstType>&, GpuMat_<DstType>&, GpuMat_<DstType>&, GpuMat_<DstType>& >& dst, Stream& stream = Stream::Null())
  445. {
  446. gridSplit_<DefaultSplitMergePolicy>(src, dst, stream);
  447. }
  448. template <class SrcPtr, typename DstType, int COUNT, class MaskPtr>
  449. __host__ void gridSplit(const SrcPtr& src, GpuMat_<DstType> (&dst)[COUNT], const MaskPtr& mask, Stream& stream = Stream::Null())
  450. {
  451. gridSplit_<DefaultSplitMergePolicy>(src, dst, mask, stream);
  452. }
  453. template <class SrcPtr, typename DstType, int COUNT, class MaskPtr>
  454. __host__ void gridSplit(const SrcPtr& src, GlobPtrSz<DstType> (&dst)[COUNT], const MaskPtr& mask, Stream& stream = Stream::Null())
  455. {
  456. gridSplit_<DefaultSplitMergePolicy>(src, dst, mask, stream);
  457. }
  458. template <class SrcPtr, typename DstType, int COUNT>
  459. __host__ void gridSplit(const SrcPtr& src, GpuMat_<DstType> (&dst)[COUNT], Stream& stream = Stream::Null())
  460. {
  461. gridSplit_<DefaultSplitMergePolicy>(src, dst, stream);
  462. }
  463. template <class SrcPtr, typename DstType, int COUNT>
  464. __host__ void gridSplit(const SrcPtr& src, GlobPtrSz<DstType> (&dst)[COUNT], Stream& stream = Stream::Null())
  465. {
  466. gridSplit_<DefaultSplitMergePolicy>(src, dst, stream);
  467. }
  468. //! @}
  469. }}
  470. #endif