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