MSERCalculation.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #include "MSERCalculation.h"
26 
27 
28 // IVT
29 #include <Calibration/Calibration.h>
30 #include <Calibration/StereoCalibration.h>
31 #include <Image/ByteImage.h>
32 #include <Image/ImageProcessor.h>
33 #include <Image/IplImageAdaptor.h>
34 
35 // system
36 #include <cmath>
37 #include <ctime>
38 
39 //#include <ArmarXCore/core/logging/Logging.h>
40 
41 
43 {
44 }
45 
47 {
48 }
49 
50 void
51 CMSERCalculation::FindMSERs2D(const CByteImage* pRGBImage,
52  const CByteImage* pHSVImage,
53  std::vector<CMSERDescriptor*>& aMSERDescriptors)
54 {
55 #if (CV_MAJOR_VERSION == 2)
56 #if (CV_MINOR_VERSION < 4)
57  //timeval tStart, tEnd;
58  //long tTimeDiff;
59  //gettimeofday(&tStart, 0);
60 
61  // int delta; //! delta, in the code, it compares (size_{i}-size_{i-delta})/size_{i-delta}
62  // int maxArea; //! prune the area which bigger than maxArea
63  // int minArea; //! prune the area which smaller than minArea
64  // float maxVariation; //! prune the area have simliar size to its children
65  // float minDiversity; //! trace back to cut off mser with diversity < min_diversity
66  // The next few params for MSER of color image:
67  // int maxEvolution; //! for color image, the evolution steps
68  // double areaThreshold; //! the area threshold to cause re-initialize
69  // double minMargin; //! ignore too small margin
70  // int edgeBlurSize; //! the aperture size for edge blur
71 
72  cv::MSER pMSERDetector = cv::MSER();
73 
74  // ARMARX_VERBOSE_S << "delta: %d maxArea: %d minArea: %d maxVariation: %.3f minDiversity: %.3f maxEvolution: %d areaThreshold: %.4f minMargin: %.4f edgeBlurSize: %d\n",
75  // pMSERDetector.delta, pMSERDetector.maxArea, pMSERDetector.minArea, pMSERDetector.maxVariation, pMSERDetector.minDiversity,
76  // pMSERDetector.maxEvolution, pMSERDetector.areaThreshold, pMSERDetector.minMargin, pMSERDetector.edgeBlurSize);
77 
78  pMSERDetector.maxArea *= 10;
79  pMSERDetector.maxVariation *= 3;
80  pMSERDetector.maxEvolution *= 3;
81  pMSERDetector.minMargin *= 0.33;
82 
83  // convert image
84  IplImage* pIplImage;
85  pIplImage = IplImageAdaptor::Adapt(pRGBImage);
86 
87  std::vector<std::vector<cv::Point>> aContoursCVLeft;
88  std::vector<std::vector<Vec2d>> aContoursLeft;
89 
90  //pMSERDetector(pIplImageLeft, aContoursCV, cv::Mat());
91 
92  cv::Seq<CvSeq*> contoursLeft;
93  cv::MemStorage storageLeft(cvCreateMemStorage(0));
94  cvExtractMSER(pIplImage, NULL, &contoursLeft.seq, storageLeft, pMSERDetector);
95 
96  cv::SeqIterator<CvSeq*> itLeft = contoursLeft.begin();
97  size_t i, ncontours = contoursLeft.size();
98  aContoursCVLeft.resize(ncontours);
99 
100  for (i = 0; i < ncontours; i++, ++itLeft)
101  {
102  while (cv::Seq<cv::Point>(*itLeft).size() > 0)
103  {
104  aContoursCVLeft[i].push_back(cv::Seq<cv::Point>(*itLeft).front());
105  cv::Seq<cv::Point>(*itLeft).pop_front();
106  }
107  }
108 
109  //storage.release();
110 
111  //std::vector<CMSERDescriptor*> aMSERDescriptorsLeft;
112  for (int i = 0; i < (int)aContoursCVLeft.size(); i++)
113  {
114  std::vector<Vec2d> aPoints;
115  aContoursLeft.push_back(aPoints);
116 
117  for (int j = 0; j < (int)aContoursCVLeft.at(i).size(); j++)
118  {
119  Vec2d vTemp = {(float)aContoursCVLeft.at(i).at(j).x,
120  (float)aContoursCVLeft.at(i).at(j).y};
121  aContoursLeft.at(i).push_back(vTemp);
122  }
123  }
124 
125  //gettimeofday(&tEnd, 0);
126  //tTimeDiff = (1000*tEnd.tv_sec+tEnd.tv_usec/1000) - (1000*tStart.tv_sec+tStart.tv_usec/1000);
127  //ARMARX_VERBOSE_S << "\nTime for 2D MSER detection: %d ms\n\n", tTimeDiff);
128  //
129  //gettimeofday(&tStart, 0);
130 
131  for (int i = 0; i < (int)aContoursLeft.size(); i++)
132  {
133  CMSERDescriptor* pDescriptor = CreateMSERDescriptor(&aContoursLeft.at(i), pHSVImage);
134  aMSERDescriptors.push_back(pDescriptor);
135  //ARMARX_VERBOSE_S << "\nCenter: (%.1f,%.1f) \nEW1: %.1f EV1: (%.3f, %.3f) \nEW2: %.1f EV2: (%.3f, %.3f) \n\n",
136  // pDescriptor->vMean.x, pDescriptor->vMean.y,
137  // sqrtf(pDescriptor->fEigenvalue1), pDescriptor->vEigenvector1.x, pDescriptor->vEigenvector1.y,
138  // sqrtf(pDescriptor->fEigenvalue2), pDescriptor->vEigenvector2.x, pDescriptor->vEigenvector2.y);
139  }
140 
141  //gettimeofday(&tEnd, 0);
142  //tTimeDiff = (1000*tEnd.tv_sec+tEnd.tv_usec/1000) - (1000*tStart.tv_sec+tStart.tv_usec/1000);
143  //ARMARX_VERBOSE_S << "\nTime for MSER descriptor creation: %d ms\n\n", tTimeDiff);
144 
145  cvReleaseImageHeader(&pIplImage);
146  storageLeft.release();
147 
148 #elif (CV_MINOR_VERSION == 4)
149  cv::MSER pMSERDetector = cv::MSER();
150  IplImage* pIplImage;
151  pIplImage = IplImageAdaptor::Adapt(pRGBImage);
152  std::vector<std::vector<cv::Point>> aContoursCVLeft;
153 
154  pMSERDetector(pIplImage, aContoursCVLeft, cv::Mat());
155 
156  std::vector<std::vector<Vec2d>> aContoursLeft;
157 
158  for (int i = 0; i < (int)aContoursCVLeft.size(); i++)
159  {
160  std::vector<Vec2d> aPoints;
161  aContoursLeft.push_back(aPoints);
162 
163  for (int j = 0; j < (int)aContoursCVLeft.at(i).size(); j++)
164  {
165  Vec2d vTemp = {(float)aContoursCVLeft.at(i).at(j).x,
166  (float)aContoursCVLeft.at(i).at(j).y};
167  aContoursLeft.at(i).push_back(vTemp);
168  }
169  }
170 
171  for (int i = 0; i < (int)aContoursLeft.size(); i++)
172  {
173  CMSERDescriptor* pDescriptor = CreateMSERDescriptor(&aContoursLeft.at(i), pHSVImage);
174  aMSERDescriptors.push_back(pDescriptor);
175  }
176 
177  cvReleaseImageHeader(&pIplImage);
178 #else
179  ARMARX_WARNING_S << "This code is not implemented for OpenCV Version " << CV_VERSION
180  << " (CV_MINOR_VERSION = " << CV_MINOR_VERSION << ")";
181 #endif
182 #else
183  ARMARX_WARNING_S << "This code is not implemented for OpenCV Version " << CV_VERSION
184  << " (CV_MAJOR_VERSION = " << CV_MAJOR_VERSION << ")";
185 #endif
186 }
187 
188 void
189 CMSERCalculation::StereoMatchMSERs(const std::vector<CMSERDescriptor*>& aMSERDescriptorsLeft,
190  const std::vector<CMSERDescriptor*>& aMSERDescriptorsRight,
191  CStereoCalibration* pStereoCalibration,
192  const float fToleranceFactor,
193  std::vector<CMSERDescriptor3D*>& aRegions3D)
194 {
195  // find stereo correspondences
196  const float fRatioThresholdHigh = 1.0f + fToleranceFactor * 0.25f; // 1.25
197  const float fRatioThresholdLow = 1.0f / fRatioThresholdHigh;
198  const float fRatioThresholdHigh2 = fRatioThresholdHigh * fRatioThresholdHigh;
199  const float fRatioThresholdLow2 = fRatioThresholdLow * fRatioThresholdLow;
200 
201  for (int i = 0; i < (int)aMSERDescriptorsLeft.size(); i++)
202  {
203  float fMinEpipolarDistance = fToleranceFactor * 2.0f; // 2
204  int nCorrespondenceIndex = -1;
205  const float fOwnEVRatio =
206  aMSERDescriptorsLeft.at(i)->fEigenvalue2 / aMSERDescriptorsLeft.at(i)->fEigenvalue1;
207 
208  for (int j = 0; j < (int)aMSERDescriptorsRight.size(); j++)
209  {
210  const float fSizeRatio = (float)aMSERDescriptorsLeft.at(i)->nSize /
211  (float)aMSERDescriptorsRight.at(j)->nSize;
212 
213  if ((fRatioThresholdLow < fSizeRatio) && (fSizeRatio < fRatioThresholdHigh))
214  {
215  const float fEV1Ratio = aMSERDescriptorsLeft.at(i)->fEigenvalue1 /
216  aMSERDescriptorsRight.at(j)->fEigenvalue1;
217  const float fEV2Ratio = aMSERDescriptorsLeft.at(i)->fEigenvalue2 /
218  aMSERDescriptorsRight.at(j)->fEigenvalue2;
219  const float fRatioRatio = (aMSERDescriptorsRight.at(j)->fEigenvalue2 /
220  aMSERDescriptorsRight.at(j)->fEigenvalue1) /
221  fOwnEVRatio;
222 
223  if ((fRatioThresholdLow2 < fEV1Ratio) && (fEV1Ratio < fRatioThresholdHigh2) &&
224  (fRatioThresholdLow2 < fEV2Ratio) && (fEV2Ratio < fRatioThresholdHigh2) &&
225  (fRatioThresholdLow2 < fRatioRatio) && (fRatioRatio < fRatioThresholdHigh2))
226  {
227  const float fEpipolarDistance =
228  fabsf(pStereoCalibration->CalculateEpipolarLineInLeftImageDistance(
229  aMSERDescriptorsLeft.at(i)->vMean, aMSERDescriptorsRight.at(j)->vMean));
230 
231  if (fEpipolarDistance < fMinEpipolarDistance)
232  {
233  Vec3d vPoint3D;
234  pStereoCalibration->Calculate3DPoint(aMSERDescriptorsLeft.at(i)->vMean,
235  aMSERDescriptorsRight.at(j)->vMean,
236  vPoint3D,
237  false,
238  false);
239 
240  if (vPoint3D.z < OLP_MAX_OBJECT_DISTANCE)
241  {
242  fMinEpipolarDistance = fEpipolarDistance;
243  nCorrespondenceIndex = j;
244  }
245  }
246  }
247  }
248  }
249 
250  if (nCorrespondenceIndex != -1)
251  {
252  CMSERDescriptor3D* pDescr3D =
253  CreateMSERDescriptor3D(aMSERDescriptorsLeft.at(i),
254  aMSERDescriptorsRight.at(nCorrespondenceIndex),
255  pStereoCalibration);
256  aRegions3D.push_back(pDescr3D);
257  }
258  }
259 }
260 
261 void
262 CMSERCalculation::FindMSERs3D(const CByteImage* pByteImageLeft,
263  const CByteImage* pByteImageRight,
264  CStereoCalibration* pStereoCalibration,
265  const float fToleranceFactor,
266  std::vector<CMSERDescriptor3D*>& aRegions3D)
267 {
268  //CByteImage* pByteImageLeftGrey = new CByteImage(pByteImageLeft->width, pByteImageLeft->height, CByteImage::eGrayScale);
269  //ImageProcessor::ConvertImage(pByteImageLeft, pByteImageLeftGrey);
270 
271  // create HSV images
272  CByteImage* pHSVImageLeft = new CByteImage(OLP_IMG_WIDTH, OLP_IMG_HEIGHT, CByteImage::eRGB24);
273  CByteImage* pHSVImageRight = new CByteImage(OLP_IMG_WIDTH, OLP_IMG_HEIGHT, CByteImage::eRGB24);
274  ImageProcessor::CalculateHSVImage(pByteImageLeft, pHSVImageLeft);
275  ImageProcessor::CalculateHSVImage(pByteImageRight, pHSVImageRight);
276 
277  //timeval tStart, tEnd;
278  //long tTimeDiff;
279  //gettimeofday(&tStart, 0);
280 
281  // find MSERs in left and right image
282  std::vector<CMSERDescriptor*> aMSERDescriptorsLeft;
283  std::vector<CMSERDescriptor*> aMSERDescriptorsRight;
284  FindMSERs2D(pByteImageLeft, pHSVImageLeft, aMSERDescriptorsLeft);
285  FindMSERs2D(pByteImageRight, pHSVImageRight, aMSERDescriptorsRight);
286 
287 
288  // find stereo correspondences
289  StereoMatchMSERs(aMSERDescriptorsLeft,
290  aMSERDescriptorsRight,
291  pStereoCalibration,
292  fToleranceFactor,
293  aRegions3D);
294 
295 
296  //// debug
297  //for (int i=0; i<(int)aRegions3D.size() && i<5; i++)
298  //{
299  // ARMARX_VERBOSE_S << "Region %d: histogram distance left-right %.4f\n", i, HistogramDistanceL2(aRegions3D.at(i)->pRegionLeft, aRegions3D.at(i)->pRegionRight));
300  // ARMARX_VERBOSE_S << "\nHistogram region %d inner points:\n", i);
301  // for (int j=0; j<OLP_SIZE_MSER_HISTOGRAM; j++)
302  // {
303  // ARMARX_VERBOSE_S << "%d\t", (int)(aRegions3D.at(i)->pRegionLeft->pHueHistogramInnerPoints[j] * 1000));
304  // }
305  // ARMARX_VERBOSE_S << "\nHistogram region %d surrounding region:\n", i);
306  // for (int j=0; j<OLP_SIZE_MSER_HISTOGRAM; j++)
307  // {
308  // ARMARX_VERBOSE_S << "%d\t", (int)(aRegions3D.at(i)->pRegionLeft->pHueHistogramSurroundingRegion[j] * 1000));
309  // }
310  // ARMARX_VERBOSE_S << "\n\n");
311  //}
312 
313 
314  //gettimeofday(&tEnd, 0);
315  //tTimeDiff = (1000*tEnd.tv_sec+tEnd.tv_usec/1000) - (1000*tStart.tv_sec+tStart.tv_usec/1000);
316  //ARMARX_VERBOSE_S << "\nTime for MSER detection and stereo matching: %d ms\n\n", tTimeDiff);
317 
318  for (size_t i = 0; i < aMSERDescriptorsLeft.size(); i++)
319  {
320  aMSERDescriptorsLeft.at(i)->pPoints2D->clear();
321  delete aMSERDescriptorsLeft.at(i)->pPoints2D;
322  delete aMSERDescriptorsLeft.at(i);
323  }
324 
325  for (size_t i = 0; i < aMSERDescriptorsRight.size(); i++)
326  {
327  aMSERDescriptorsRight.at(i)->pPoints2D->clear();
328  delete aMSERDescriptorsRight.at(i)->pPoints2D;
329  delete aMSERDescriptorsRight.at(i);
330  }
331 
332 
333  delete pHSVImageLeft;
334  delete pHSVImageRight;
335 
336  //ARMARX_VERBOSE_S << "\n%d 3D-MSERs found.\n\n", aRegions3D.size());
337 }
338 
339 void
340 CMSERCalculation::GetMeanAndCovariance2D(std::vector<Vec2d>& aPoints2D,
341  Vec2d& vMean,
342  Mat2d& mCovariance)
343 {
344  mCovariance.r1 = 0;
345  mCovariance.r2 = 0;
346  mCovariance.r3 = 0;
347  mCovariance.r4 = 0;
348 
349  if (aPoints2D.size() < 2)
350  {
351  return;
352  }
353 
354  vMean.x = 0;
355  vMean.y = 0;
356 
357  for (int i = 0; i < (int)aPoints2D.size(); i++)
358  {
359  vMean.x += (float)aPoints2D.at(i).x;
360  vMean.y += (float)aPoints2D.at(i).y;
361  }
362 
363  vMean.x /= aPoints2D.size();
364  vMean.y /= aPoints2D.size();
365 
366  for (int i = 0; i < (int)aPoints2D.size(); i++)
367  {
368  mCovariance.r1 +=
369  (vMean.x - (float)aPoints2D.at(i).x) * (vMean.x - (float)aPoints2D.at(i).x);
370  mCovariance.r2 +=
371  (vMean.x - (float)aPoints2D.at(i).x) * (vMean.y - (float)aPoints2D.at(i).y);
372  mCovariance.r4 +=
373  (vMean.y - (float)aPoints2D.at(i).y) * (vMean.y - (float)aPoints2D.at(i).y);
374  }
375 
376  mCovariance.r1 /= aPoints2D.size() - 1;
377  mCovariance.r2 /= aPoints2D.size() - 1;
378  mCovariance.r3 = mCovariance.r2;
379  mCovariance.r4 /= aPoints2D.size() - 1;
380 }
381 
382 void
384  float& fLambda1,
385  float& fLambda2,
386  Vec2d& vE1,
387  Vec2d& vE2)
388 {
389  float fTemp1 = 0.5f * (mMatrix2D.r1 + mMatrix2D.r4);
390  float fTemp2 =
391  sqrtf(fTemp1 * fTemp1 - mMatrix2D.r1 * mMatrix2D.r4 + mMatrix2D.r2 * mMatrix2D.r3);
392 
393  fLambda1 = fTemp1 + fTemp2;
394  fLambda2 = fTemp1 - fTemp2;
395 
396  vE1.x = fLambda1 - mMatrix2D.r4;
397  vE1.y = mMatrix2D.r3;
398  Math2d::NormalizeVec(vE1);
399 
400  vE2.x = fLambda2 - mMatrix2D.r4;
401  vE2.y = mMatrix2D.r3;
402  Math2d::NormalizeVec(vE2);
403 }
404 
406 CMSERCalculation::CreateMSERDescriptor(std::vector<Vec2d>* aPoints2D, const CByteImage* pHSVImage)
407 {
408  if (aPoints2D->size() < 2)
409  {
410  return NULL;
411  }
412 
413  CMSERDescriptor* pDescr = new CMSERDescriptor();
414 
415  pDescr->nSize = (int)aPoints2D->size();
416 
417  pDescr->pPoints2D = new std::vector<Vec2d>;
418 
419  for (int i = 0; i < (int)aPoints2D->size(); i++)
420  {
421  pDescr->pPoints2D->push_back(aPoints2D->at(i));
422  }
423 
424 
425  Mat2d mCovariance;
426  GetMeanAndCovariance2D(*aPoints2D, pDescr->vMean, mCovariance);
427 
429  pDescr->fEigenvalue1,
430  pDescr->fEigenvalue2,
431  pDescr->vEigenvector1,
432  pDescr->vEigenvector2);
433 
434  CreateHSVHistograms(pDescr, pHSVImage);
435 
436  return pDescr;
437 }
438 
441  CMSERDescriptor* pMSERRight,
442  CStereoCalibration* pStereoCalibration)
443 {
444  CMSERDescriptor3D* pDescr3D = new CMSERDescriptor3D();
445 
446 
447  pDescr3D->pRegionLeft = pMSERLeft->GetCopy();
448  //pDescr3D->pRegionLeft = new CMSERDescriptor();
449  //*(pDescr3D->pRegionLeft) = *pMSERLeft;
450  //std::vector<Vec2d>* pPoints2D = new std::vector<Vec2d>();
451  //for (int k=0; k<(int)pMSERLeft->pPoints2D->size(); k++)
452  //{
453  // pPoints2D->push_back(pMSERLeft->pPoints2D->at(k));
454  //}
455  //pDescr3D->pRegionLeft->pPoints2D = pPoints2D;
456 
457  pDescr3D->pRegionRight = pMSERRight->GetCopy();
458  //pDescr3D->pRegionRight = new CMSERDescriptor();
459  //*(pDescr3D->pRegionRight)= *pMSERRight;
460  //pPoints2D = new std::vector<Vec2d>();
461  //for (int k=0; k<(int)pMSERRight->pPoints2D->size(); k++)
462  //{
463  // pPoints2D->push_back(pMSERRight->pPoints2D->at(k));
464  //}
465  //pDescr3D->pRegionRight->pPoints2D = pPoints2D;
466 
467 
468  pStereoCalibration->Calculate3DPoint(
469  pMSERLeft->vMean, pMSERRight->vMean, pDescr3D->vPosition, false, false);
470 
471 
472  Vec2d vSigmaPointLeft, vSigmaPointRight, vTemp;
473 
474  const float fSigmaPointFactor = 1.0f;
475 
476  Math2d::MulVecScalar(
477  pMSERLeft->vEigenvector1, -fSigmaPointFactor * sqrtf(pMSERLeft->fEigenvalue1), vTemp);
478  Math2d::AddVecVec(pMSERLeft->vMean, vTemp, vSigmaPointLeft);
479  Math2d::MulVecScalar(
480  pMSERRight->vEigenvector1, -fSigmaPointFactor * sqrtf(pMSERRight->fEigenvalue1), vTemp);
481  Math2d::AddVecVec(pMSERRight->vMean, vTemp, vSigmaPointRight);
482  pStereoCalibration->Calculate3DPoint(
483  vSigmaPointLeft, vSigmaPointRight, pDescr3D->vSigmaPoint1a, false, false);
484 
485  Math2d::MulVecScalar(
486  pMSERLeft->vEigenvector1, fSigmaPointFactor * sqrtf(pMSERLeft->fEigenvalue1), vTemp);
487  Math2d::AddVecVec(pMSERLeft->vMean, vTemp, vSigmaPointLeft);
488  Math2d::MulVecScalar(
489  pMSERRight->vEigenvector1, fSigmaPointFactor * sqrtf(pMSERRight->fEigenvalue1), vTemp);
490  Math2d::AddVecVec(pMSERRight->vMean, vTemp, vSigmaPointRight);
491  pStereoCalibration->Calculate3DPoint(
492  vSigmaPointLeft, vSigmaPointRight, pDescr3D->vSigmaPoint1b, false, false);
493 
494  Math2d::MulVecScalar(
495  pMSERLeft->vEigenvector2, -fSigmaPointFactor * sqrtf(pMSERLeft->fEigenvalue2), vTemp);
496  Math2d::AddVecVec(pMSERLeft->vMean, vTemp, vSigmaPointLeft);
497  Math2d::MulVecScalar(
498  pMSERRight->vEigenvector2, -fSigmaPointFactor * sqrtf(pMSERRight->fEigenvalue2), vTemp);
499  Math2d::AddVecVec(pMSERRight->vMean, vTemp, vSigmaPointRight);
500  pStereoCalibration->Calculate3DPoint(
501  vSigmaPointLeft, vSigmaPointRight, pDescr3D->vSigmaPoint2a, false, false);
502 
503  Math2d::MulVecScalar(
504  pMSERLeft->vEigenvector2, fSigmaPointFactor * sqrtf(pMSERLeft->fEigenvalue2), vTemp);
505  Math2d::AddVecVec(pMSERLeft->vMean, vTemp, vSigmaPointLeft);
506  Math2d::MulVecScalar(
507  pMSERRight->vEigenvector2, fSigmaPointFactor * sqrtf(pMSERRight->fEigenvalue2), vTemp);
508  Math2d::AddVecVec(pMSERRight->vMean, vTemp, vSigmaPointRight);
509  pStereoCalibration->Calculate3DPoint(
510  vSigmaPointLeft, vSigmaPointRight, pDescr3D->vSigmaPoint2b, false, false);
511 
512 
513  return pDescr3D;
514 }
515 
516 inline void
517 CMSERCalculation::CreateHSVHistograms(CMSERDescriptor* pDescriptor, const CByteImage* pHSVImage)
518 {
519  for (int i = 0; i < OLP_SIZE_MSER_HISTOGRAM; i++)
520  {
521  pDescriptor->pHueHistogramInnerPoints[i] = 0;
522  pDescriptor->pHueHistogramSurroundingRegion[i] = 0;
523  }
524 
525  //**************************************************************************************************************
526  // histogram of the inner points of the region
527  //**************************************************************************************************************
528 
529  const int nBucketSize = (int)(ceil(256.0f / (float)OLP_SIZE_MSER_HISTOGRAM));
530  int nPixelIndex, nSaturationValue, nHistogramIndex;
531  float fWeight;
532  int nSaturationSum = 0;
533 
534  for (int i = 0; i < (int)pDescriptor->pPoints2D->size(); i++)
535  {
536  nPixelIndex = 3 * (int)(pDescriptor->pPoints2D->at(i).y * OLP_IMG_WIDTH +
537  pDescriptor->pPoints2D->at(i).x);
538  nSaturationValue = pHSVImage->pixels[nPixelIndex + 1];
539  nSaturationSum += nSaturationValue;
540  nHistogramIndex = pHSVImage->pixels[nPixelIndex] / nBucketSize;
541  fWeight = 1.0f - 1.0f / (1.0f + 0.0025f * (nSaturationValue * nSaturationValue));
542  pDescriptor->pHueHistogramInnerPoints[nHistogramIndex] += 0.4f * fWeight;
543  pDescriptor->pHueHistogramInnerPoints[(nHistogramIndex + OLP_SIZE_MSER_HISTOGRAM + 1) %
544  OLP_SIZE_MSER_HISTOGRAM] += 0.2f * fWeight;
545  pDescriptor->pHueHistogramInnerPoints[(nHistogramIndex + OLP_SIZE_MSER_HISTOGRAM - 1) %
546  OLP_SIZE_MSER_HISTOGRAM] += 0.2f * fWeight;
547  pDescriptor->pHueHistogramInnerPoints[(nHistogramIndex + OLP_SIZE_MSER_HISTOGRAM + 2) %
548  OLP_SIZE_MSER_HISTOGRAM] += 0.1f * fWeight;
549  pDescriptor->pHueHistogramInnerPoints[(nHistogramIndex + OLP_SIZE_MSER_HISTOGRAM - 2) %
550  OLP_SIZE_MSER_HISTOGRAM] += 0.1f * fWeight;
551  }
552 
553  // normalize
554  float fSum = 0;
555 
556  for (int i = 0; i < OLP_SIZE_MSER_HISTOGRAM; i++)
557  {
558  fSum += pDescriptor->pHueHistogramInnerPoints[i];
559  }
560 
561  if (fSum != 0)
562  {
563  const float fOneBySum = 1.0f / fSum;
564 
565  for (int i = 0; i < OLP_SIZE_MSER_HISTOGRAM; i++)
566  {
567  pDescriptor->pHueHistogramInnerPoints[i] *= fOneBySum;
568  }
569  }
570  else // set to equally distributed values
571  {
572  const float fDummy = 1.0f / (float)OLP_SIZE_MSER_HISTOGRAM;
573 
574  for (int i = 0; i < OLP_SIZE_MSER_HISTOGRAM; i++)
575  {
576  pDescriptor->pHueHistogramInnerPoints[i] = fDummy;
577  }
578  }
579 
580  pDescriptor->fAverageSaturationInnerPoints =
581  ((float)nSaturationSum) / ((float)(255 * pDescriptor->pPoints2D->size()));
582 
583 
584  //**************************************************************************************************************
585  // histogram of the rectangular region spanned by the eigenvectors of the MSER
586  //**************************************************************************************************************
587 
588  Vec2d pCorners[4];
589  Vec2d vTemp1, vTemp2;
590  const float fStdDevFactor = 2.5f;
591  const float fAdditionalPixels = 2.0f;
592  const float fRegionSize =
593  (fStdDevFactor * sqrtf(pDescriptor->fEigenvalue1) + fAdditionalPixels) *
594  (fStdDevFactor * sqrtf(pDescriptor->fEigenvalue2) + fAdditionalPixels);
595 
596  //// rhombus / Raute
597  //Math2d::MulVecScalar(pDescriptor->vEigenvector1, (fStdDevFactor*sqrtf(pDescriptor->fEigenvalue1)+fAdditionalPixels), vTemp);
598  //Math2d::SubtractVecVec(pDescriptor->vMean, vTemp, pCorners[0]);
599  //Math2d::AddVecVec(pDescriptor->vMean, vTemp, pCorners[1]);
600  //Math2d::MulVecScalar(pDescriptor->vEigenvector2, (fStdDevFactor*sqrtf(pDescriptor->fEigenvalue2)+fAdditionalPixels), vTemp);
601  //Math2d::SubtractVecVec(pDescriptor->vMean, vTemp, pCorners[2]);
602  //Math2d::AddVecVec(pDescriptor->vMean, vTemp, pCorners[3]);
603 
604  // parallelogramm
605  Math2d::MulVecScalar(pDescriptor->vEigenvector1,
606  (fStdDevFactor * sqrtf(pDescriptor->fEigenvalue1) + fAdditionalPixels),
607  vTemp1);
608  Math2d::MulVecScalar(pDescriptor->vEigenvector2,
609  (fStdDevFactor * sqrtf(pDescriptor->fEigenvalue2) + fAdditionalPixels),
610  vTemp2);
611  Math2d::SubtractVecVec(pDescriptor->vMean, vTemp1, pCorners[0]);
612  Math2d::SubtractVecVec(pCorners[0], vTemp2, pCorners[0]);
613  Math2d::AddVecVec(pDescriptor->vMean, vTemp1, pCorners[1]);
614  Math2d::SubtractVecVec(pCorners[1], vTemp2, pCorners[1]);
615  Math2d::SubtractVecVec(pDescriptor->vMean, vTemp1, pCorners[2]);
616  Math2d::AddVecVec(pCorners[2], vTemp2, pCorners[2]);
617  Math2d::AddVecVec(pDescriptor->vMean, vTemp1, pCorners[3]);
618  Math2d::AddVecVec(pCorners[3], vTemp2, pCorners[3]);
619 
620 
621  // determine which corner is up, low, left, right
622  Vec2d vUp, vLow, vLeft, vRight;
623  SortQuadrangleCorners(pCorners, vUp, vLow, vLeft, vRight);
624 
626  vLow,
627  vLeft,
628  vRight,
629  pHSVImage,
630  pDescriptor->pHueHistogramSurroundingRegion,
632  nSaturationSum);
633 
634  pDescriptor->fAverageSaturationSurroundingRegion = ((float)nSaturationSum) / fRegionSize;
635 }
636 
637 float
639 {
640  float fSum = 0;
641 
642  for (int i = 0; i < OLP_SIZE_MSER_HISTOGRAM; i++)
643  {
644  fSum += (pDescriptor1->pHueHistogramInnerPoints[i] -
645  pDescriptor2->pHueHistogramInnerPoints[i]) *
646  (pDescriptor1->pHueHistogramInnerPoints[i] -
647  pDescriptor2->pHueHistogramInnerPoints[i]) +
648  (pDescriptor1->pHueHistogramSurroundingRegion[i] -
649  pDescriptor2->pHueHistogramSurroundingRegion[i]) *
650  (pDescriptor1->pHueHistogramSurroundingRegion[i] -
651  pDescriptor2->pHueHistogramSurroundingRegion[i]);
652  }
653 
654  float fRet = sqrtf(fSum / (float)(2 * OLP_SIZE_MSER_HISTOGRAM));
655 
656  //if ( (fRet!=fRet) || _isnan(fRet) || (fRet>100) )
657  //{
658  // for (int i=0; i<OLP_SIZE_MSER_HISTOGRAM; i++)
659  // {
660  // ARMARX_VERBOSE_S << "%.2f\t%.2f\n", pDescriptor1->pHueHistogramInnerPoints[i], pDescriptor2->pHueHistogramInnerPoints[i]);
661  // }
662  //}
663 
664  return fRet;
665 }
666 
667 float
669  CMSERDescriptor* pDescriptor2)
670 {
671  float fSum = 0;
672 
673  for (int i = 0; i < OLP_SIZE_MSER_HISTOGRAM; i++)
674  {
675  fSum += (pDescriptor1->pHueHistogramInnerPoints[i] -
676  pDescriptor2->pHueHistogramInnerPoints[i]) *
677  (pDescriptor1->pHueHistogramInnerPoints[i] -
678  pDescriptor2->pHueHistogramInnerPoints[i]) /
679  (pDescriptor1->pHueHistogramInnerPoints[i] +
680  pDescriptor2->pHueHistogramInnerPoints[i] + 0.00001f) +
681  (pDescriptor1->pHueHistogramSurroundingRegion[i] -
682  pDescriptor2->pHueHistogramSurroundingRegion[i]) *
683  (pDescriptor1->pHueHistogramSurroundingRegion[i] -
684  pDescriptor2->pHueHistogramSurroundingRegion[i]) /
685  (pDescriptor1->pHueHistogramSurroundingRegion[i] +
686  pDescriptor2->pHueHistogramSurroundingRegion[i] + 0.00001f);
687  }
688 
689  float fRet = sqrtf(fSum / (float)(2 * OLP_SIZE_MSER_HISTOGRAM));
690 
691  return fRet;
692 }
693 
694 // determine upper, lower, left and right corner. up = min y value
695 void
697  Vec2d& vUp,
698  Vec2d& vLow,
699  Vec2d& vLeft,
700  Vec2d& vRight)
701 {
702  int nUp1, nUp2, nLow1, nLow2, nTemp;
703 
704  if (pCorners[0].y < pCorners[1].y)
705  {
706  nUp1 = 0;
707  nLow1 = 1;
708  }
709  else
710  {
711  nUp1 = 1;
712  nLow1 = 0;
713  }
714 
715  if (pCorners[2].y < pCorners[3].y)
716  {
717  nUp2 = 2;
718  nLow2 = 3;
719  }
720  else
721  {
722  nUp2 = 3;
723  nLow2 = 2;
724  }
725 
726  if (pCorners[nUp1].y > pCorners[nUp2].y)
727  {
728  nTemp = nUp1;
729  nUp1 = nUp2;
730  nUp2 = nTemp;
731  }
732 
733  if (pCorners[nLow1].y < pCorners[nLow2].y)
734  {
735  nTemp = nLow1;
736  nLow1 = nLow2;
737  nLow2 = nTemp;
738  }
739 
740  Math2d::SetVec(vUp, pCorners[nUp1]);
741  Math2d::SetVec(vLow, pCorners[nLow1]);
742 
743  if (pCorners[nUp2].x < pCorners[nLow2].x)
744  {
745  Math2d::SetVec(vLeft, pCorners[nUp2]);
746  Math2d::SetVec(vRight, pCorners[nLow2]);
747  }
748  else
749  {
750  Math2d::SetVec(vLeft, pCorners[nLow2]);
751  Math2d::SetVec(vRight, pCorners[nUp2]);
752  }
753 }
754 
755 inline void
757  Vec2d vLow,
758  Vec2d vLeft,
759  Vec2d vRight,
760  const CByteImage* pHSVImage,
761  float* pHistogram,
762  const int nHistogramSize,
763  int& nSaturationSum)
764 {
765 
766  const int nBucketSize = (int)(ceil(256.0f / (float)nHistogramSize));
767  int nPixelIndex, nSaturationValue, nHistogramIndex;
768  float fWeight;
769 
770  // stay within the image
771  if (vUp.x < 0)
772  {
773  vUp.x = 0;
774  }
775  else if (vUp.x >= OLP_IMG_WIDTH)
776  {
777  vUp.x = OLP_IMG_WIDTH - 1;
778  }
779 
780  if (vUp.y < 0)
781  {
782  vUp.y = 0;
783  }
784  else if (vUp.y >= OLP_IMG_HEIGHT)
785  {
786  vUp.y = OLP_IMG_HEIGHT - 1;
787  }
788 
789  if (vLow.x < 0)
790  {
791  vLow.x = 0;
792  }
793  else if (vLow.x >= OLP_IMG_WIDTH)
794  {
795  vLow.x = OLP_IMG_WIDTH - 1;
796  }
797 
798  if (vLow.y < 0)
799  {
800  vLow.y = 0;
801  }
802  else if (vLow.y >= OLP_IMG_HEIGHT)
803  {
804  vLow.y = OLP_IMG_HEIGHT - 1;
805  }
806 
807  if (vLeft.x < 0)
808  {
809  vLeft.x = 0;
810  }
811  else if (vLeft.x >= OLP_IMG_WIDTH)
812  {
813  vLeft.x = OLP_IMG_WIDTH - 1;
814  }
815 
816  if (vLeft.y < 0)
817  {
818  vLeft.y = 0;
819  }
820  else if (vLeft.y >= OLP_IMG_HEIGHT)
821  {
822  vLeft.y = OLP_IMG_HEIGHT - 1;
823  }
824 
825  if (vRight.x < 0)
826  {
827  vRight.x = 0;
828  }
829  else if (vRight.x >= OLP_IMG_WIDTH)
830  {
831  vRight.x = OLP_IMG_WIDTH - 1;
832  }
833 
834  if (vRight.y < 0)
835  {
836  vRight.y = 0;
837  }
838  else if (vRight.y >= OLP_IMG_HEIGHT)
839  {
840  vRight.y = OLP_IMG_HEIGHT - 1;
841  }
842 
843 
844  nSaturationSum = 0;
845  float fDeltaLeft, fDeltaRight;
846  int nLeft, nRight;
847  const int nUp = (int)vUp.y;
848  const int nLow = (int)vLow.y;
849 
850  if (vLeft.y < vRight.y)
851  {
852  const int nMiddle1 = (int)vLeft.y;
853  const int nMiddle2 = (int)vRight.y;
854  fDeltaLeft = (vLeft.x - vUp.x) / (vLeft.y - vUp.y);
855  fDeltaRight = (vRight.x - vUp.x) / (vRight.y - vUp.y);
856 
857  for (int i = nUp; i < nMiddle1; i++)
858  {
859  nLeft = (int)(vUp.x + (i - nUp) * fDeltaLeft);
860  nRight = (int)(vUp.x + (i - nUp) * fDeltaRight);
861 
862  for (int j = nLeft; j <= nRight; j++)
863  {
864  nPixelIndex = 3 * (i * OLP_IMG_WIDTH + j);
865  nSaturationValue = pHSVImage->pixels[nPixelIndex + 1];
866  nSaturationSum += nSaturationValue;
867  nHistogramIndex = pHSVImage->pixels[nPixelIndex] / nBucketSize;
868  fWeight = 1.0f - 1.0f / (1.0f + 0.0025f * (nSaturationValue * nSaturationValue));
869  pHistogram[nHistogramIndex] += 0.4f * fWeight;
870  pHistogram[(nHistogramIndex + nHistogramSize + 1) % nHistogramSize] +=
871  0.2f * fWeight;
872  pHistogram[(nHistogramIndex + nHistogramSize - 1) % nHistogramSize] +=
873  0.2f * fWeight;
874  pHistogram[(nHistogramIndex + nHistogramSize + 2) % nHistogramSize] +=
875  0.1f * fWeight;
876  pHistogram[(nHistogramIndex + nHistogramSize - 2) % nHistogramSize] +=
877  0.1f * fWeight;
878  }
879  }
880 
881  fDeltaLeft = (vLow.x - vLeft.x) / (vLow.y - vLeft.y);
882 
883  for (int i = nMiddle1; i < nMiddle2; i++)
884  {
885  nLeft = (int)(vLeft.x + (i - nMiddle1) * fDeltaLeft);
886  nRight = (int)(vUp.x + (i - nUp) * fDeltaRight);
887 
888  for (int j = nLeft; j <= nRight; j++)
889  {
890  nPixelIndex = 3 * (i * OLP_IMG_WIDTH + j);
891  nSaturationValue = pHSVImage->pixels[nPixelIndex + 1];
892  nSaturationSum += nSaturationValue;
893  nHistogramIndex = pHSVImage->pixels[nPixelIndex] / nBucketSize;
894  fWeight = 1.0f - 1.0f / (1.0f + 0.0025f * (nSaturationValue * nSaturationValue));
895  pHistogram[nHistogramIndex] += 0.4f * fWeight;
896  pHistogram[(nHistogramIndex + nHistogramSize + 1) % nHistogramSize] +=
897  0.2f * fWeight;
898  pHistogram[(nHistogramIndex + nHistogramSize - 1) % nHistogramSize] +=
899  0.2f * fWeight;
900  pHistogram[(nHistogramIndex + nHistogramSize + 2) % nHistogramSize] +=
901  0.1f * fWeight;
902  pHistogram[(nHistogramIndex + nHistogramSize - 2) % nHistogramSize] +=
903  0.1f * fWeight;
904  }
905  }
906 
907  fDeltaRight = (vLow.x - vRight.x) / (vLow.y - vRight.y);
908 
909  for (int i = nMiddle2; i < nLow; i++)
910  {
911  nLeft = (int)(vLeft.x + (i - nMiddle1) * fDeltaLeft);
912  nRight = (int)(vRight.x + (i - nMiddle2) * fDeltaRight);
913 
914  for (int j = nLeft; j <= nRight; j++)
915  {
916  nPixelIndex = 3 * (i * OLP_IMG_WIDTH + j);
917  nSaturationValue = pHSVImage->pixels[nPixelIndex + 1];
918  nSaturationSum += nSaturationValue;
919  nHistogramIndex = pHSVImage->pixels[nPixelIndex] / nBucketSize;
920  fWeight = 1.0f - 1.0f / (1.0f + 0.0025f * (nSaturationValue * nSaturationValue));
921  pHistogram[nHistogramIndex] += 0.4f * fWeight;
922  pHistogram[(nHistogramIndex + nHistogramSize + 1) % nHistogramSize] +=
923  0.2f * fWeight;
924  pHistogram[(nHistogramIndex + nHistogramSize - 1) % nHistogramSize] +=
925  0.2f * fWeight;
926  pHistogram[(nHistogramIndex + nHistogramSize + 2) % nHistogramSize] +=
927  0.1f * fWeight;
928  pHistogram[(nHistogramIndex + nHistogramSize - 2) % nHistogramSize] +=
929  0.1f * fWeight;
930  }
931  }
932  }
933  else
934  {
935  const int nMiddle1 = (int)vRight.y;
936  const int nMiddle2 = (int)vLeft.y;
937  fDeltaLeft = (vLeft.x - vUp.x) / (vLeft.y - vUp.y);
938  fDeltaRight = (vRight.x - vUp.x) / (vRight.y - vUp.y);
939 
940  for (int i = nUp; i < nMiddle1; i++)
941  {
942  nLeft = (int)(vUp.x + (i - nUp) * fDeltaLeft);
943  nRight = (int)(vUp.x + (i - nUp) * fDeltaRight);
944 
945  for (int j = nLeft; j <= nRight; j++)
946  {
947  nPixelIndex = 3 * (i * OLP_IMG_WIDTH + j);
948  nSaturationValue = pHSVImage->pixels[nPixelIndex + 1];
949  nSaturationSum += nSaturationValue;
950  nHistogramIndex = pHSVImage->pixels[nPixelIndex] / nBucketSize;
951  fWeight = 1.0f - 1.0f / (1.0f + 0.0025f * (nSaturationValue * nSaturationValue));
952  pHistogram[nHistogramIndex] += 0.4f * fWeight;
953  pHistogram[(nHistogramIndex + nHistogramSize + 1) % nHistogramSize] +=
954  0.2f * fWeight;
955  pHistogram[(nHistogramIndex + nHistogramSize - 1) % nHistogramSize] +=
956  0.2f * fWeight;
957  pHistogram[(nHistogramIndex + nHistogramSize + 2) % nHistogramSize] +=
958  0.1f * fWeight;
959  pHistogram[(nHistogramIndex + nHistogramSize - 2) % nHistogramSize] +=
960  0.1f * fWeight;
961  }
962  }
963 
964  fDeltaRight = (vLow.x - vRight.x) / (vLow.y - vRight.y);
965 
966  for (int i = nMiddle1; i < nMiddle2; i++)
967  {
968  nLeft = (int)(vUp.x + (i - nUp) * fDeltaLeft);
969  nRight = (int)(vRight.x + (i - nMiddle1) * fDeltaRight);
970 
971  for (int j = nLeft; j <= nRight; j++)
972  {
973  nPixelIndex = 3 * (i * OLP_IMG_WIDTH + j);
974  nSaturationValue = pHSVImage->pixels[nPixelIndex + 1];
975  nSaturationSum += nSaturationValue;
976  nHistogramIndex = pHSVImage->pixels[nPixelIndex] / nBucketSize;
977  fWeight = 1.0f - 1.0f / (1.0f + 0.0025f * (nSaturationValue * nSaturationValue));
978  pHistogram[nHistogramIndex] += 0.4f * fWeight;
979  pHistogram[(nHistogramIndex + nHistogramSize + 1) % nHistogramSize] +=
980  0.2f * fWeight;
981  pHistogram[(nHistogramIndex + nHistogramSize - 1) % nHistogramSize] +=
982  0.2f * fWeight;
983  pHistogram[(nHistogramIndex + nHistogramSize + 2) % nHistogramSize] +=
984  0.1f * fWeight;
985  pHistogram[(nHistogramIndex + nHistogramSize - 2) % nHistogramSize] +=
986  0.1f * fWeight;
987  }
988  }
989 
990  fDeltaLeft = (vLow.x - vLeft.x) / (vLow.y - vLeft.y);
991 
992  for (int i = nMiddle2; i < nLow; i++)
993  {
994  nLeft = (int)(vLeft.x + (i - nMiddle2) * fDeltaLeft);
995  nRight = (int)(vRight.x + (i - nMiddle1) * fDeltaRight);
996 
997  for (int j = nLeft; j <= nRight; j++)
998  {
999  nPixelIndex = 3 * (i * OLP_IMG_WIDTH + j);
1000  nSaturationValue = pHSVImage->pixels[nPixelIndex + 1];
1001  nSaturationSum += nSaturationValue;
1002  nHistogramIndex = pHSVImage->pixels[nPixelIndex] / nBucketSize;
1003  fWeight = 1.0f - 1.0f / (1.0f + 0.0025f * (nSaturationValue * nSaturationValue));
1004  pHistogram[nHistogramIndex] += 0.4f * fWeight;
1005  pHistogram[(nHistogramIndex + nHistogramSize + 1) % nHistogramSize] +=
1006  0.2f * fWeight;
1007  pHistogram[(nHistogramIndex + nHistogramSize - 1) % nHistogramSize] +=
1008  0.2f * fWeight;
1009  pHistogram[(nHistogramIndex + nHistogramSize + 2) % nHistogramSize] +=
1010  0.1f * fWeight;
1011  pHistogram[(nHistogramIndex + nHistogramSize - 2) % nHistogramSize] +=
1012  0.1f * fWeight;
1013  }
1014  }
1015  }
1016 
1017 
1018  // normalize
1019  float fSum = 0;
1020 
1021  for (int i = 0; i < nHistogramSize; i++)
1022  {
1023  fSum += pHistogram[i];
1024  }
1025 
1026  if (fSum != 0)
1027  {
1028  const float fOneBySum = 1.0f / fSum;
1029 
1030  for (int i = 0; i < nHistogramSize; i++)
1031  {
1032  pHistogram[i] *= fOneBySum;
1033  }
1034  }
1035  else // set to equally distributed values
1036  {
1037  const float fDummy = 1.0f / (float)nHistogramSize;
1038 
1039  for (int i = 0; i < nHistogramSize; i++)
1040  {
1041  pHistogram[i] = fDummy;
1042  }
1043  }
1044 }
CMSERDescriptor
Definition: ObjectHypothesis.h:34
OLP_IMG_HEIGHT
#define OLP_IMG_HEIGHT
Definition: ObjectLearningByPushingDefinitions.h:69
CMSERDescriptor3D::vSigmaPoint1a
Vec3d vSigmaPoint1a
Definition: ObjectHypothesis.h:158
CMSERCalculation::CreateWeightedHueHistogramWithinQuadrangle
static void CreateWeightedHueHistogramWithinQuadrangle(Vec2d vUp, Vec2d vLow, Vec2d vLeft, Vec2d vRight, const CByteImage *pHSVImage, float *pHistogram, const int nHistogramSize, int &nSaturationSum)
Definition: MSERCalculation.cpp:756
GfxTL::Vec3d
VectorXD< 3, double > Vec3d
Definition: VectorXD.h:737
OLP_IMG_WIDTH
#define OLP_IMG_WIDTH
Definition: ObjectLearningByPushingDefinitions.h:68
CMSERCalculation::GetMeanAndCovariance2D
static void GetMeanAndCovariance2D(std::vector< Vec2d > &aPoints2D, Vec2d &vMean, Mat2d &mCovariance)
Definition: MSERCalculation.cpp:340
CMSERDescriptor::vEigenvector1
Vec2d vEigenvector1
Definition: ObjectHypothesis.h:86
CMSERCalculation::CreateMSERDescriptor
static CMSERDescriptor * CreateMSERDescriptor(std::vector< Vec2d > *aPoints2D, const CByteImage *pHSVImage)
Definition: MSERCalculation.cpp:406
CMSERDescriptor3D::vSigmaPoint2a
Vec3d vSigmaPoint2a
Definition: ObjectHypothesis.h:158
MSERCalculation.h
OLP_MAX_OBJECT_DISTANCE
#define OLP_MAX_OBJECT_DISTANCE
Definition: ObjectLearningByPushingDefinitions.h:106
CMSERDescriptor::vEigenvector2
Vec2d vEigenvector2
Definition: ObjectHypothesis.h:86
CMSERCalculation::FindMSERs3D
static void FindMSERs3D(const CByteImage *pByteImageLeft, const CByteImage *pByteImageRight, CStereoCalibration *pStereoCalibration, const float fToleranceFactor, std::vector< CMSERDescriptor3D * > &aRegions3D)
Definition: MSERCalculation.cpp:262
CMSERDescriptor::fAverageSaturationSurroundingRegion
float fAverageSaturationSurroundingRegion
Definition: ObjectHypothesis.h:91
CMSERDescriptor::pPoints2D
std::vector< Vec2d > * pPoints2D
Definition: ObjectHypothesis.h:78
OLP_SIZE_MSER_HISTOGRAM
#define OLP_SIZE_MSER_HISTOGRAM
Definition: ObjectLearningByPushingDefinitions.h:230
CMSERDescriptor3D::vPosition
Vec3d vPosition
Definition: ObjectHypothesis.h:156
CMSERDescriptor3D::vSigmaPoint1b
Vec3d vSigmaPoint1b
Definition: ObjectHypothesis.h:158
CMSERCalculation::SortQuadrangleCorners
static void SortQuadrangleCorners(Vec2d *pCorners, Vec2d &vUp, Vec2d &vLow, Vec2d &vLeft, Vec2d &vRight)
Definition: MSERCalculation.cpp:696
CMSERDescriptor3D
Definition: ObjectHypothesis.h:94
CMSERCalculation::CreateHSVHistograms
static void CreateHSVHistograms(CMSERDescriptor *pDescriptor, const CByteImage *pHSVImage)
Definition: MSERCalculation.cpp:517
CMSERCalculation::CreateMSERDescriptor3D
static CMSERDescriptor3D * CreateMSERDescriptor3D(CMSERDescriptor *pMSERLeft, CMSERDescriptor *pMSERRight, CStereoCalibration *pStereoCalibration)
Definition: MSERCalculation.cpp:440
CMSERDescriptor::nSize
int nSize
Definition: ObjectHypothesis.h:80
CMSERDescriptor::fEigenvalue1
float fEigenvalue1
Definition: ObjectHypothesis.h:84
CMSERCalculation::HistogramDistanceL2
static float HistogramDistanceL2(CMSERDescriptor *pDescriptor1, CMSERDescriptor *pDescriptor2)
Definition: MSERCalculation.cpp:638
CMSERDescriptor3D::pRegionLeft
CMSERDescriptor * pRegionLeft
Definition: ObjectHypothesis.h:153
CMSERDescriptor3D::pRegionRight
CMSERDescriptor * pRegionRight
Definition: ObjectHypothesis.h:153
CMSERDescriptor3D::vSigmaPoint2b
Vec3d vSigmaPoint2b
Definition: ObjectHypothesis.h:159
ARMARX_WARNING_S
#define ARMARX_WARNING_S
Definition: Logging.h:213
CMSERDescriptor::fAverageSaturationInnerPoints
float fAverageSaturationInnerPoints
Definition: ObjectHypothesis.h:89
GfxTL::Vec2d
VectorXD< 2, double > Vec2d
Definition: VectorXD.h:736
CMSERCalculation::CMSERCalculation
CMSERCalculation(void)
Definition: MSERCalculation.cpp:42
CMSERCalculation::HistogramDistanceChi2
static float HistogramDistanceChi2(CMSERDescriptor *pDescriptor1, CMSERDescriptor *pDescriptor2)
Definition: MSERCalculation.cpp:668
CMSERDescriptor::vMean
Vec2d vMean
Definition: ObjectHypothesis.h:82
CMSERDescriptor::GetCopy
CMSERDescriptor * GetCopy()
Definition: ObjectHypothesis.h:43
CMSERCalculation::StereoMatchMSERs
static void StereoMatchMSERs(const std::vector< CMSERDescriptor * > &aMSERDescriptorsLeft, const std::vector< CMSERDescriptor * > &aMSERDescriptorsRight, CStereoCalibration *pStereoCalibration, const float fToleranceFactor, std::vector< CMSERDescriptor3D * > &aRegions3D)
Definition: MSERCalculation.cpp:189
float
#define float
Definition: 16_Level.h:22
CMSERCalculation::GetEigenvaluesAndEigenvectors2D
static void GetEigenvaluesAndEigenvectors2D(Mat2d mMatrix2D, float &fLambda1, float &fLambda2, Vec2d &vE1, Vec2d &vE2)
Definition: MSERCalculation.cpp:383
CMSERCalculation::~CMSERCalculation
~CMSERCalculation(void)
Definition: MSERCalculation.cpp:46
CMSERCalculation::FindMSERs2D
static void FindMSERs2D(const CByteImage *pRGBImage, const CByteImage *pHSVImage, std::vector< CMSERDescriptor * > &aMSERDescriptors)
Definition: MSERCalculation.cpp:51
CMSERDescriptor::fEigenvalue2
float fEigenvalue2
Definition: ObjectHypothesis.h:84
CMSERDescriptor::pHueHistogramSurroundingRegion
float pHueHistogramSurroundingRegion[OLP_SIZE_MSER_HISTOGRAM]
Definition: ObjectHypothesis.h:90
CMSERDescriptor::pHueHistogramInnerPoints
float pHueHistogramInnerPoints[OLP_SIZE_MSER_HISTOGRAM]
Definition: ObjectHypothesis.h:88