@@ -500,7 +500,7 @@ DetectorResult SampleQR(const BitMatrix& image, const FinderPatternSet& fp)
500500 for (int x = 0 ; x < N; ++x) {
501501 int x0 = apM[x], x1 = apM[x + 1 ], y0 = apM[y], y1 = apM[y + 1 ];
502502 rois.push_back ({x0 - (x == 0 ) * 6 , x1 + (x == N - 1 ) * 7 , y0 - (y == 0 ) * 6 , y1 + (y == N - 1 ) * 7 ,
503- PerspectiveTransform{Rectangle (x0, x1, y0, y1),
503+ PerspectiveTransform{Rectangle (x0, x1, y0, y1, 0.5 ),
504504 {*apP (x, y), *apP (x + 1 , y), *apP (x + 1 , y + 1 ), *apP (x, y + 1 )}}});
505505 }
506506
@@ -530,10 +530,9 @@ DetectorResult DetectPureQR(const BitMatrix& image)
530530 int left, top, width, height;
531531 if (!image.findBoundingBox (left, top, width, height, MIN_MODULES) || std::abs (width - height) > 1 )
532532 return {};
533- int right = left + width - 1 ;
534- int bottom = top + height - 1 ;
533+ auto pos = Rectangle<PointI>(left, top, width, height);
535534
536- PointI tl{left, top}, tr{right, top}, bl{left, bottom} ;
535+ const PointI &tl = pos. topLeft (), &tr = pos. topRight (), &bl = pos. bottomLeft () ;
537536 Pattern diagonal;
538537 // allow corners be moved one pixel inside to accommodate for possible aliasing artifacts
539538 for (auto [p, d] : {std::pair (tl, PointI{1 , 1 }), {tr, {-1 , 1 }}, {bl, {1 , -1 }}}) {
@@ -561,8 +560,7 @@ DetectorResult DetectPureQR(const BitMatrix& image)
561560#endif
562561
563562 // Now just read off the bits (this is a crop + subsample)
564- return {Deflate (image, dimension, dimension, top + moduleSize / 2 , left + moduleSize / 2 , moduleSize),
565- {{left, top}, {right, top}, {right, bottom}, {left, bottom}}};
563+ return {Deflate (image, dimension, dimension, top + moduleSize / 2 , left + moduleSize / 2 , moduleSize), std::move (pos)};
566564}
567565
568566DetectorResult DetectPureMQR (const BitMatrix& image)
@@ -574,8 +572,6 @@ DetectorResult DetectPureMQR(const BitMatrix& image)
574572 int left, top, width, height;
575573 if (!image.findBoundingBox (left, top, width, height, MIN_MODULES) || std::abs (width - height) > 1 )
576574 return {};
577- int right = left + width - 1 ;
578- int bottom = top + height - 1 ;
579575
580576 // allow corners be moved one pixel inside to accommodate for possible aliasing artifacts
581577 auto diagonal = BitMatrixCursorI (image, {left, top}, {1 , 1 }).readPatternFromBlack <Pattern>(1 );
@@ -601,7 +597,7 @@ DetectorResult DetectPureMQR(const BitMatrix& image)
601597
602598 // Now just read off the bits (this is a crop + subsample)
603599 return {Deflate (image, dimension, dimension, top + moduleSize / 2 , left + moduleSize / 2 , moduleSize),
604- {{ left, top}, {right, top}, {right, bottom}, {left, bottom}} };
600+ Rectangle<PointI>( left, top, width, height) };
605601}
606602
607603DetectorResult DetectPureRMQR (const BitMatrix& image)
@@ -622,10 +618,9 @@ DetectorResult DetectPureRMQR(const BitMatrix& image)
622618 int left, top, width, height;
623619 if (!image.findBoundingBox (left, top, width, height, MIN_MODULES) || height >= width)
624620 return {};
625- int right = left + width - 1 ;
626- int bottom = top + height - 1 ;
621+ auto pos = Rectangle<PointI>(left, top, width, height);
627622
628- PointI tl{left, top}, tr{right, top}, br{right, bottom}, bl{left, bottom} ;
623+ const PointI &tl = pos. topLeft (), &tr = pos. topRight (), &bl = pos. bottomLeft (), &br = pos. bottomRight () ;
629624
630625 // allow corners be moved one pixel inside to accommodate for possible aliasing artifacts
631626 auto diagonal = BitMatrixCursorI (image, tl, {1 , 1 }).readPatternFromBlack <Pattern>(1 );
@@ -662,11 +657,11 @@ DetectorResult DetectPureRMQR(const BitMatrix& image)
662657 LogMatrixWriter lmw (log, image, 5 , " grid2.pnm" );
663658 for (int y = 0 ; y < dimH; y++)
664659 for (int x = 0 ; x < dimW; x++)
665- log (PointF (left + (x + .5f ) * moduleSize, top + ( y + .5f ) * moduleSize ));
660+ log (pos. topLeft () + moduleSize * PointF (x + .5f , y + .5f ));
666661#endif
667662
668663 // Now just read off the bits (this is a crop + subsample)
669- return {Deflate (image, dimW, dimH, top + moduleSize / 2 , left + moduleSize / 2 , moduleSize), {tl, tr, br, bl} };
664+ return {Deflate (image, dimW, dimH, top + moduleSize / 2 , left + moduleSize / 2 , moduleSize), std::move (pos) };
670665}
671666
672667DetectorResult SampleMQR (const BitMatrix& image, const ConcentricPattern& fp)
0 commit comments