matching.hpp 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. //By downloading, copying, installing or using the software you agree to this license.
  2. //If you do not agree to this license, do not download, install,
  3. //copy or use the software.
  4. //
  5. //
  6. // License Agreement
  7. // For Open Source Computer Vision Library
  8. // (3-clause BSD License)
  9. //
  10. //Copyright (C) 2000-2015, Intel Corporation, all rights reserved.
  11. //Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
  12. //Copyright (C) 2009-2015, NVIDIA Corporation, all rights reserved.
  13. //Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
  14. //Copyright (C) 2015, OpenCV Foundation, all rights reserved.
  15. //Copyright (C) 2015, Itseez Inc., 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. // * Redistributions of source code must retain the above copyright notice,
  22. // this list of conditions and the following disclaimer.
  23. //
  24. // * Redistributions 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. // * Neither the names of the copyright holders nor the names of the contributors
  29. // may be used to endorse or promote products derived from this software
  30. // without specific prior written permission.
  31. //
  32. //This software is provided by the copyright holders and contributors "as is" and
  33. //any express or implied warranties, including, but not limited to, the implied
  34. //warranties of merchantability and fitness for a particular purpose are disclaimed.
  35. //In no event shall copyright holders or contributors be liable for any direct,
  36. //indirect, incidental, special, exemplary, or consequential damages
  37. //(including, but not limited to, procurement of substitute goods or services;
  38. //loss of use, data, or profits; or business interruption) however caused
  39. //and on any theory of liability, whether in contract, strict liability,
  40. //or tort (including negligence or otherwise) arising in any way out of
  41. //the use of this software, even if advised of the possibility of such damage.
  42. /*****************************************************************************************************************\
  43. * The interface contains the main methods for computing the matching between the left and right images *
  44. * *
  45. \******************************************************************************************************************/
  46. #include <stdint.h>
  47. #ifndef _OPENCV_MATCHING_HPP_
  48. #define _OPENCV_MATCHING_HPP_
  49. #ifdef __cplusplus
  50. namespace cv
  51. {
  52. namespace stereo
  53. {
  54. class Matching
  55. {
  56. private:
  57. //!The maximum disparity
  58. int maxDisparity;
  59. //!the factor by which we are multiplying the disparity
  60. int scallingFactor;
  61. //!the confidence to which a min disparity found is good or not
  62. double confidenceCheck;
  63. //!the LUT used in case SSE is not available
  64. int hamLut[65537];
  65. //!function used for getting the minimum disparity from the cost volume"
  66. static int minim(short *c, int iwpj, int widthDisp,const double confidence, const int search_region)
  67. {
  68. double mini, mini2, mini3;
  69. mini = mini2 = mini3 = DBL_MAX;
  70. int index = 0;
  71. int iw = iwpj;
  72. int widthDisp2;
  73. widthDisp2 = widthDisp;
  74. widthDisp -= 1;
  75. for (int i = 0; i <= widthDisp; i++)
  76. {
  77. if (c[(iw + i * search_region) * widthDisp2 + i] < mini)
  78. {
  79. mini3 = mini2;
  80. mini2 = mini;
  81. mini = c[(iw + i * search_region) * widthDisp2 + i];
  82. index = i;
  83. }
  84. else if (c[(iw + i * search_region) * widthDisp2 + i] < mini2)
  85. {
  86. mini3 = mini2;
  87. mini2 = c[(iw + i * search_region) * widthDisp2 + i];
  88. }
  89. else if (c[(iw + i * search_region) * widthDisp2 + i] < mini3)
  90. {
  91. mini3 = c[(iw + i * search_region) * widthDisp2 + i];
  92. }
  93. }
  94. if(mini != 0)
  95. {
  96. if (mini3 / mini <= confidence)
  97. return index;
  98. }
  99. return -1;
  100. }
  101. //!Interpolate in order to obtain better results
  102. //!function for refining the disparity at sub pixel using simetric v
  103. static double symetricVInterpolation(short *c, int iwjp, int widthDisp, int winDisp,const int search_region)
  104. {
  105. if (winDisp == 0 || winDisp == widthDisp - 1)
  106. return winDisp;
  107. double m2m1, m3m1, m3, m2, m1;
  108. m2 = c[(iwjp + (winDisp - 1) * search_region) * widthDisp + winDisp - 1];
  109. m3 = c[(iwjp + (winDisp + 1) * search_region)* widthDisp + winDisp + 1];
  110. m1 = c[(iwjp + winDisp * search_region) * widthDisp + winDisp];
  111. m2m1 = m2 - m1;
  112. m3m1 = m3 - m1;
  113. if (m2m1 == 0 || m3m1 == 0) return winDisp;
  114. double p;
  115. p = 0;
  116. if (m2 > m3)
  117. {
  118. p = (0.5 - 0.25 * ((m3m1 * m3m1) / (m2m1 * m2m1) + (m3m1 / m2m1)));
  119. }
  120. else
  121. {
  122. p = -1 * (0.5 - 0.25 * ((m2m1 * m2m1) / (m3m1 * m3m1) + (m2m1 / m3m1)));
  123. }
  124. if (p >= -0.5 && p <= 0.5)
  125. p = winDisp + p;
  126. return p;
  127. }
  128. //!a pre processing function that generates the Hamming LUT in case the algorithm will ever be used on platform where SSE is not available
  129. void hammingLut()
  130. {
  131. for (int i = 0; i <= 65536; i++)
  132. {
  133. int dist = 0;
  134. int j = i;
  135. //we number the bits from our number
  136. while (j)
  137. {
  138. dist = dist + 1;
  139. j = j & (j - 1);
  140. }
  141. hamLut[i] = dist;
  142. }
  143. }
  144. //!the class used in computing the hamming distance
  145. class hammingDistance : public ParallelLoopBody
  146. {
  147. private:
  148. int *left, *right;
  149. short *c;
  150. int v,kernelSize, width;
  151. int MASK;
  152. int *hammLut;
  153. public :
  154. hammingDistance(const Mat &leftImage, const Mat &rightImage, short *cost, int maxDisp, int kerSize, int *hammingLUT):
  155. left((int *)leftImage.data), right((int *)rightImage.data), c(cost), v(maxDisp),kernelSize(kerSize),width(leftImage.cols), MASK(65535), hammLut(hammingLUT){}
  156. void operator()(const cv::Range &r) const {
  157. for (int i = r.start; i <= r.end ; i++)
  158. {
  159. int iw = i * width;
  160. for (int j = kernelSize; j < width - kernelSize; j++)
  161. {
  162. int j2;
  163. int xorul;
  164. int iwj;
  165. iwj = iw + j;
  166. for (int d = 0; d <= v; d++)
  167. {
  168. j2 = (0 > j - d) ? (0) : (j - d);
  169. xorul = left[(iwj)] ^ right[(iw + j2)];
  170. #if CV_SSE4_1
  171. c[(iwj)* (v + 1) + d] = (short)_mm_popcnt_u32(xorul);
  172. #else
  173. c[(iwj)* (v + 1) + d] = (short)(hammLut[xorul & MASK] + hammLut[(xorul >> 16) & MASK]);
  174. #endif
  175. }
  176. }
  177. }
  178. }
  179. };
  180. //!cost aggregation
  181. class agregateCost:public ParallelLoopBody
  182. {
  183. private:
  184. int win;
  185. short *c, *parSum;
  186. int maxDisp,width, height;
  187. public:
  188. agregateCost(const Mat &partialSums, int windowSize, int maxDispa, Mat &cost)
  189. {
  190. win = windowSize / 2;
  191. c = (short *)cost.data;
  192. maxDisp = maxDispa;
  193. width = cost.cols / ( maxDisp + 1) - 1;
  194. height = cost.rows - 1;
  195. parSum = (short *)partialSums.data;
  196. }
  197. void operator()(const cv::Range &r) const {
  198. for (int i = r.start; i <= r.end; i++)
  199. {
  200. int iwi = (i - 1) * width;
  201. for (int j = win + 1; j <= width - win - 1; j++)
  202. {
  203. int w1 = ((i + win + 1) * width + j + win) * (maxDisp + 1);
  204. int w2 = ((i - win) * width + j - win - 1) * (maxDisp + 1);
  205. int w3 = ((i + win + 1) * width + j - win - 1) * (maxDisp + 1);
  206. int w4 = ((i - win) * width + j + win) * (maxDisp + 1);
  207. int w = (iwi + j - 1) * (maxDisp + 1);
  208. for (int d = 0; d <= maxDisp; d++)
  209. {
  210. c[w + d] = parSum[w1 + d] + parSum[w2 + d]
  211. - parSum[w3 + d] - parSum[w4 + d];
  212. }
  213. }
  214. }
  215. }
  216. };
  217. //!class that is responsable for generating the disparity map
  218. class makeMap:public ParallelLoopBody
  219. {
  220. private:
  221. //enum used to notify wether we are searching on the vertical ie (lr) or diagonal (rl)
  222. enum {CV_VERTICAL_SEARCH, CV_DIAGONAL_SEARCH};
  223. int width,disparity,scallingFact,th;
  224. double confCheck;
  225. uint8_t *map;
  226. short *c;
  227. public:
  228. makeMap(const Mat &costVolume, int threshold, int maxDisp, double confidence,int scale, Mat &mapFinal)
  229. {
  230. c = (short *)costVolume.data;
  231. map = mapFinal.data;
  232. disparity = maxDisp;
  233. width = costVolume.cols / ( disparity + 1) - 1;
  234. th = threshold;
  235. scallingFact = scale;
  236. confCheck = confidence;
  237. }
  238. void operator()(const cv::Range &r) const {
  239. for (int i = r.start; i <= r.end ; i++)
  240. {
  241. int lr;
  242. int v = -1;
  243. double p1, p2;
  244. int iw = i * width;
  245. for (int j = 0; j < width; j++)
  246. {
  247. lr = Matching:: minim(c, iw + j, disparity + 1, confCheck,CV_VERTICAL_SEARCH);
  248. if (lr != -1)
  249. {
  250. v = Matching::minim(c, iw + j - lr, disparity + 1, confCheck,CV_DIAGONAL_SEARCH);
  251. if (v != -1)
  252. {
  253. p1 = Matching::symetricVInterpolation(c, iw + j - lr, disparity + 1, v,CV_DIAGONAL_SEARCH);
  254. p2 = Matching::symetricVInterpolation(c, iw + j, disparity + 1, lr,CV_VERTICAL_SEARCH);
  255. if (abs(p1 - p2) <= th)
  256. map[iw + j] = (uint8_t)((p2)* scallingFact);
  257. else
  258. {
  259. map[iw + j] = 0;
  260. }
  261. }
  262. else
  263. {
  264. if (width - j <= disparity)
  265. {
  266. p2 = Matching::symetricVInterpolation(c, iw + j, disparity + 1, lr,CV_VERTICAL_SEARCH);
  267. map[iw + j] = (uint8_t)(p2* scallingFact);
  268. }
  269. }
  270. }
  271. else
  272. {
  273. map[iw + j] = 0;
  274. }
  275. }
  276. }
  277. }
  278. };
  279. //!median 1x9 paralelized filter
  280. template <typename T>
  281. class Median1x9:public ParallelLoopBody
  282. {
  283. private:
  284. T *original;
  285. T *filtered;
  286. int height, width;
  287. public:
  288. Median1x9(const Mat &originalImage, Mat &filteredImage)
  289. {
  290. original = (T *)originalImage.data;
  291. filtered = (T *)filteredImage.data;
  292. height = originalImage.rows;
  293. width = originalImage.cols;
  294. }
  295. void operator()(const cv::Range &r) const{
  296. for (int m = r.start; m <= r.end; m++)
  297. {
  298. for (int n = 4; n < width - 4; ++n)
  299. {
  300. int k = 0;
  301. T window[9];
  302. for (int i = n - 4; i <= n + 4; ++i)
  303. window[k++] = original[m * width + i];
  304. for (int j = 0; j < 5; ++j)
  305. {
  306. int min = j;
  307. for (int l = j + 1; l < 9; ++l)
  308. if (window[l] < window[min])
  309. min = l;
  310. const T temp = window[j];
  311. window[j] = window[min];
  312. window[min] = temp;
  313. }
  314. filtered[m * width + n] = window[4];
  315. }
  316. }
  317. }
  318. };
  319. //!median 9x1 paralelized filter
  320. template <typename T>
  321. class Median9x1:public ParallelLoopBody
  322. {
  323. private:
  324. T *original;
  325. T *filtered;
  326. int height, width;
  327. public:
  328. Median9x1(const Mat &originalImage, Mat &filteredImage)
  329. {
  330. original = (T *)originalImage.data;
  331. filtered = (T *)filteredImage.data;
  332. height = originalImage.rows;
  333. width = originalImage.cols;
  334. }
  335. void operator()(const Range &r) const{
  336. for (int n = r.start; n <= r.end; ++n)
  337. {
  338. for (int m = 4; m < height - 4; ++m)
  339. {
  340. int k = 0;
  341. T window[9];
  342. for (int i = m - 4; i <= m + 4; ++i)
  343. window[k++] = original[i * width + n];
  344. for (int j = 0; j < 5; j++)
  345. {
  346. int min = j;
  347. for (int l = j + 1; l < 9; ++l)
  348. if (window[l] < window[min])
  349. min = l;
  350. const T temp = window[j];
  351. window[j] = window[min];
  352. window[min] = temp;
  353. }
  354. filtered[m * width + n] = window[4];
  355. }
  356. }
  357. }
  358. };
  359. protected:
  360. //arrays used in the region removal
  361. Mat speckleY;
  362. Mat speckleX;
  363. Mat puss;
  364. //int *specklePointX;
  365. //int *specklePointY;
  366. //long long *pus;
  367. int previous_size;
  368. //!method for setting the maximum disparity
  369. void setMaxDisparity(int val)
  370. {
  371. CV_Assert(val > 10);
  372. this->maxDisparity = val;
  373. }
  374. //!method for getting the disparity
  375. int getMaxDisparity()
  376. {
  377. return this->maxDisparity;
  378. }
  379. //! a number by which the disparity will be multiplied for better display
  380. void setScallingFactor(int val)
  381. {
  382. CV_Assert(val > 0);
  383. this->scallingFactor = val;
  384. }
  385. //!method for getting the scalling factor
  386. int getScallingFactor()
  387. {
  388. return scallingFactor;
  389. }
  390. //!setter for the confidence check
  391. void setConfidence(double val)
  392. {
  393. CV_Assert(val >= 1);
  394. this->confidenceCheck = val;
  395. }
  396. //getter for confidence check
  397. double getConfidence()
  398. {
  399. return confidenceCheck;
  400. }
  401. //! Hamming distance computation method
  402. //! leftImage and rightImage are the two transformed images
  403. //! the cost is the resulted cost volume and kernel Size is the size of the matching window
  404. void hammingDistanceBlockMatching(const Mat &leftImage, const Mat &rightImage, Mat &cost, const int kernelSize= 9)
  405. {
  406. CV_Assert(leftImage.cols == rightImage.cols);
  407. CV_Assert(leftImage.rows == rightImage.rows);
  408. CV_Assert(kernelSize % 2 != 0);
  409. CV_Assert(cost.rows == leftImage.rows);
  410. CV_Assert(cost.cols / (maxDisparity + 1) == leftImage.cols);
  411. short *c = (short *)cost.data;
  412. memset(c, 0, sizeof(c[0]) * leftImage.cols * leftImage.rows * (maxDisparity + 1));
  413. parallel_for_(cv::Range(kernelSize / 2,leftImage.rows - kernelSize / 2), hammingDistance(leftImage,rightImage,(short *)cost.data,maxDisparity,kernelSize / 2,hamLut));
  414. }
  415. //preprocessing the cost volume in order to get it ready for aggregation
  416. void costGathering(const Mat &hammingDistanceCost, Mat &cost)
  417. {
  418. CV_Assert(hammingDistanceCost.rows == hammingDistanceCost.rows);
  419. CV_Assert(hammingDistanceCost.type() == CV_16S);
  420. CV_Assert(cost.type() == CV_16S);
  421. int maxDisp = maxDisparity;
  422. int width = cost.cols / ( maxDisp + 1) - 1;
  423. int height = cost.rows - 1;
  424. short *c = (short *)cost.data;
  425. short *ham = (short *)hammingDistanceCost.data;
  426. memset(c, 0, sizeof(c[0]) * (width + 1) * (height + 1) * (maxDisp + 1));
  427. for (int i = 1; i <= height; i++)
  428. {
  429. int iw = i * width;
  430. int iwi = (i - 1) * width;
  431. for (int j = 1; j <= width; j++)
  432. {
  433. int iwj = (iw + j) * (maxDisp + 1);
  434. int iwjmu = (iw + j - 1) * (maxDisp + 1);
  435. int iwijmu = (iwi + j - 1) * (maxDisp + 1);
  436. for (int d = 0; d <= maxDisp; d++)
  437. {
  438. c[iwj + d] = ham[iwijmu + d] + c[iwjmu + d];
  439. }
  440. }
  441. }
  442. for (int i = 1; i <= height; i++)
  443. {
  444. for (int j = 1; j <= width; j++)
  445. {
  446. int iwj = (i * width + j) * (maxDisp + 1);
  447. int iwjmu = ((i - 1) * width + j) * (maxDisp + 1);
  448. for (int d = 0; d <= maxDisp; d++)
  449. {
  450. c[iwj + d] += c[iwjmu + d];
  451. }
  452. }
  453. }
  454. }
  455. //!The aggregation on the cost volume
  456. void blockAgregation(const Mat &partialSums, int windowSize, Mat &cost)
  457. {
  458. CV_Assert(windowSize % 2 != 0);
  459. CV_Assert(partialSums.rows == cost.rows);
  460. CV_Assert(partialSums.cols == cost.cols);
  461. int win = windowSize / 2;
  462. short *c = (short *)cost.data;
  463. int maxDisp = maxDisparity;
  464. int width = cost.cols / ( maxDisp + 1) - 1;
  465. int height = cost.rows - 1;
  466. memset(c, 0, sizeof(c[0]) * width * height * (maxDisp + 1));
  467. parallel_for_(cv::Range(win + 1,height - win - 1), agregateCost(partialSums,windowSize,maxDisp,cost));
  468. }
  469. //!remove small regions that have an area smaller than t, we fill the region with the average of the good pixels around it
  470. template <typename T>
  471. void smallRegionRemoval(const Mat &currentMap, int t, Mat &out)
  472. {
  473. CV_Assert(currentMap.cols == out.cols);
  474. CV_Assert(currentMap.rows == out.rows);
  475. CV_Assert(t >= 0);
  476. int *pus = (int *)puss.data;
  477. int *specklePointX = (int *)speckleX.data;
  478. int *specklePointY = (int *)speckleY.data;
  479. memset(pus, 0, previous_size * sizeof(pus[0]));
  480. T *map = (T *)currentMap.data;
  481. T *outputMap = (T *)out.data;
  482. int height = currentMap.rows;
  483. int width = currentMap.cols;
  484. T k = 1;
  485. int st, dr;
  486. int di[] = { -1, -1, -1, 0, 1, 1, 1, 0 },
  487. dj[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
  488. int speckle_size = 0;
  489. st = 0;
  490. dr = 0;
  491. for (int i = 1; i < height - 1; i++)
  492. {
  493. int iw = i * width;
  494. for (int j = 1; j < width - 1; j++)
  495. {
  496. if (map[iw + j] != 0)
  497. {
  498. outputMap[iw + j] = map[iw + j];
  499. }
  500. else if (map[iw + j] == 0)
  501. {
  502. T nr = 1;
  503. T avg = 0;
  504. speckle_size = dr;
  505. specklePointX[dr] = i;
  506. specklePointY[dr] = j;
  507. pus[i * width + j] = 1;
  508. dr++;
  509. map[iw + j] = k;
  510. while (st < dr)
  511. {
  512. int ii = specklePointX[st];
  513. int jj = specklePointY[st];
  514. //going on 8 directions
  515. for (int d = 0; d < 8; d++)
  516. {//if insisde
  517. if (ii + di[d] >= 0 && ii + di[d] < height && jj + dj[d] >= 0 && jj + dj[d] < width &&
  518. pus[(ii + di[d]) * width + jj + dj[d]] == 0)
  519. {
  520. T val = map[(ii + di[d]) * width + jj + dj[d]];
  521. if (val == 0)
  522. {
  523. map[(ii + di[d]) * width + jj + dj[d]] = k;
  524. specklePointX[dr] = (ii + di[d]);
  525. specklePointY[dr] = (jj + dj[d]);
  526. dr++;
  527. pus[(ii + di[d]) * width + jj + dj[d]] = 1;
  528. }//this means that my point is a good point to be used in computing the final filling value
  529. else if (val >= 1 && val < 250)
  530. {
  531. avg += val;
  532. nr++;
  533. }
  534. }
  535. }
  536. st++;
  537. }//if hole size is smaller than a specified threshold we fill the respective hole with the average of the good neighbours
  538. if (st - speckle_size <= t)
  539. {
  540. T fillValue = (T)(avg / nr);
  541. while (speckle_size < st)
  542. {
  543. int ii = specklePointX[speckle_size];
  544. int jj = specklePointY[speckle_size];
  545. outputMap[ii * width + jj] = fillValue;
  546. speckle_size++;
  547. }
  548. }
  549. }
  550. }
  551. }
  552. }
  553. //!Method responsible for generating the disparity map
  554. //!function for generating disparity maps at sub pixel level
  555. /* costVolume - represents the cost volume
  556. * width, height - represent the width and height of the iage
  557. *disparity - represents the maximum disparity
  558. *map - is the disparity map that will result
  559. *th - is the LR threshold
  560. */
  561. void dispartyMapFormation(const Mat &costVolume, Mat &mapFinal, int th)
  562. {
  563. uint8_t *map = mapFinal.data;
  564. int disparity = maxDisparity;
  565. int width = costVolume.cols / ( disparity + 1) - 1;
  566. int height = costVolume.rows - 1;
  567. memset(map, 0, sizeof(map[0]) * width * height);
  568. parallel_for_(Range(0,height - 1), makeMap(costVolume,th,disparity,confidenceCheck,scallingFactor,mapFinal));
  569. }
  570. public:
  571. //!a median filter of 1x9 and 9x1
  572. //!1x9 median filter
  573. template<typename T>
  574. void Median1x9Filter(const Mat &originalImage, Mat &filteredImage)
  575. {
  576. CV_Assert(originalImage.rows == filteredImage.rows);
  577. CV_Assert(originalImage.cols == filteredImage.cols);
  578. parallel_for_(Range(1,originalImage.rows - 2), Median1x9<T>(originalImage,filteredImage));
  579. }
  580. //!9x1 median filter
  581. template<typename T>
  582. void Median9x1Filter(const Mat &originalImage, Mat &filteredImage)
  583. {
  584. CV_Assert(originalImage.cols == filteredImage.cols);
  585. CV_Assert(originalImage.cols == filteredImage.cols);
  586. parallel_for_(Range(1,originalImage.cols - 2), Median9x1<T>(originalImage,filteredImage));
  587. }
  588. //!constructor for the matching class
  589. //!maxDisp - represents the maximum disparity
  590. Matching(void)
  591. {
  592. hammingLut();
  593. }
  594. ~Matching(void)
  595. {
  596. }
  597. //constructor for the matching class
  598. //maxDisp - represents the maximum disparity
  599. //confidence - represents the confidence check
  600. Matching(int maxDisp, int scalling = 4, int confidence = 6)
  601. {
  602. //set the maximum disparity
  603. setMaxDisparity(maxDisp);
  604. //set scalling factor
  605. setScallingFactor(scalling);
  606. //set the value for the confidence
  607. setConfidence(confidence);
  608. //generate the hamming lut in case SSE is not available
  609. hammingLut();
  610. }
  611. };
  612. }
  613. }
  614. #endif
  615. #endif
  616. /*End of file*/