MCPcopy Create free account
hub / github.com/creatale/node-dv / grow

Method grow

deps/lswms/LSWMS.cpp:677–1027  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

675 return RET_OK;
676}
677float LSWMS::grow(const DIR_POINT &dpOrig, cv::Point &ptDst, int dir)
678{
679 // **********************************************
680 // Finds end-point ptDst starting from dpOrig
681 //
682 // Args:
683 // -> dpOrig - starting DIR_POINT
684 // <- ptDst - end-point
685 // -> dir - growing direction (1(+) or 2(-))
686 // Ret:
687 // error - error of line segment
688 //
689 // Called from lineSegmentGeneration
690 // **********************************************
691 cv::Point ptEnd1, ptEnd2; //auxiliar
692 DIR_POINT dpEnd, dpRef; // auxiliar
693
694 // Init output
695 ptDst = dpOrig.pt;
696
697 // Starting gradient vector and director vector
698 float gX, gY;
699 if(dir == 1)
700 {
701 gX = dpOrig.vx;
702 gY = dpOrig.vy;
703 }
704 else if(dir == 2)
705 {
706 gX = -dpOrig.vx;
707 gY = -dpOrig.vy;
708 }
709 else return RET_ERROR;
710
711 // Compute currentAngle in 1º4º
712 float error1 = 0;
713 float growAngle, auxAngle, minAngle, maxAngle, diffAngle;
714 //if(gX < 0) // In this case, direction must not be fliped to 1º4º, because otherwise the sense is lost for the second grow procedure...
715 //{
716 // // Move to 1º4º
717 // gX = -gX;
718 // gY = -gY;
719 //}
720 growAngle = atan2(gY, gX);
721
722 // Starting point and angle - Bresenham
723 cv::Point pt1 = dpOrig.pt;
724 cv::Point pt2(pt1.x + (int)(1000*(-gY)), pt1.y + (int)(1000*(gX)));
725 cv::clipLine(__imPadSize, pt1, pt2);
726
727 // Loop - Bresenham
728 int k1=0;
729
730 int x1 = pt1.x, x2 = pt2.x, y1 = pt1.y, y2 = pt2.y;
731 int dx = ABS(x2-x1);
732 int dy = ABS(y2-y1);
733 int sx, sy, err, e2;
734

Callers

nothing calls this directly

Calls 3

clipLineFunction · 0.85
sqrtFunction · 0.85
PointClass · 0.50

Tested by

no test coverage detected