@@ -109,7 +109,6 @@ CylindricalSurfaceDewarper::CylindricalSurfaceDewarper(
109
109
, m_directrixArcLength(1.0 )
110
110
, m_imgDirectrix1Intersector(img_directrix1)
111
111
, m_imgDirectrix2Intersector(img_directrix2)
112
- , m_h_w(1.0 )
113
112
{
114
113
initArcLengthMapper (img_directrix1, img_directrix2);
115
114
}
@@ -242,14 +241,6 @@ CylindricalSurfaceDewarper::calcPlnToImgHomography(
242
241
QPointF const tr = img_directrix1.back ();
243
242
QPointF const bl = img_directrix2.front ();
244
243
QPointF const br = img_directrix2.back ();
245
- QPointF const top = tr - tl;
246
- QPointF const bottom = br - bl;
247
- QPointF const left = bl - tl;
248
- QPointF const right = br - tr;
249
- double const width2 = QPointF::dotProduct (top, top) + QPointF::dotProduct (bottom, bottom);
250
- double const height2 = QPointF::dotProduct (left, left) + QPointF::dotProduct (right, right);
251
- double const h_w_2 = (width2 > 0.0 ) ? (height2 / width2) : 1.0 ;
252
- m_h_w = sqrt (h_w_2);
253
244
254
245
boost::array<std::pair<QPointF, QPointF>, 4 > pairs;
255
246
pairs[0 ] = std::make_pair (QPointF (0 , 0 ), tl);
@@ -380,6 +371,13 @@ CylindricalSurfaceDewarper::initArcLengthMapper(
380
371
QPointF img_curve2_pt;
381
372
double prev_pln_x = NumericTraits<double >::min ();
382
373
double pln_x;
374
+
375
+ Matrix<double , 3 , 3 > const & coeff = m_pln2img.mat ();
376
+ double const cm0 = coeff (2 , 0 ) * coeff (2 , 0 );
377
+ double const cm1 = coeff (2 , 1 ) * coeff (2 , 1 );
378
+ double const cnorm = cm0 + cm1;
379
+ double const coeff_h_w = (cnorm > 0.0 ) ? (cm1 / cnorm) : 1.0 ;
380
+
383
381
while (it.next (img_curve1_pt, img_curve2_pt, pln_x))
384
382
{
385
383
if (pln_x <= prev_pln_x)
@@ -398,11 +396,10 @@ CylindricalSurfaceDewarper::initArcLengthMapper(
398
396
double const y1 = projector.projectionScalar (img_line1_pt);
399
397
double const y2 = projector.projectionScalar (img_line2_pt);
400
398
401
- double const bx = 0.5 * ((y2 + y1 ) - 1.0 ) * m_h_w ;
399
+ double const bx = 0.5 * ((y2 + y1 ) - 1.0 ) * coeff_h_w ;
402
400
double const by = 1.0 - (y2 - y1 );
403
- double const bb = 0.5 / sqrt (1.0 + bx * bx + by * by);
404
- double const bxy = (bx + by) * bb;
405
- double elevation = m_depthPerception * bxy;
401
+ double const bxy = bx + by;
402
+ double elevation = m_depthPerception / (1.0 + coeff_h_w) * bxy;
406
403
elevation = qBound (-0.5 , elevation, 0.5 );
407
404
408
405
m_arcLengthMapper.addSample (pln_x, elevation);
0 commit comments