def testProjectPoint2Segment07(self): p1 = np.array([100, -7]) p2 = np.array([100, 5]) p = np.array([1, 1000]) res = loss.projectPoint2Segment(p, p1, p2) ans = np.array([100, 5]) self.assertTrue(np.allclose(res, ans))
def testProjectPoint2Segment04(self): p1 = np.array([0, 0]) p2 = np.array([1, 0]) p = np.array([0.2, -1]) res = loss.projectPoint2Segment(p, p1, p2) ans = np.array([0.2, 0]) self.assertTrue(np.allclose(res, ans))
import numpy as np import loss if __name__ == '__main__': import cv2 p1 = np.array([0, 0]) p2 = np.array([1, 0]) p = np.array([0, 1]) print loss.projectPoint2Segment(p, p1, p2)
def correspondeceLines(segments, targetPoints, targetPoints2SegmentsMap): return np.array([ (point, loss.projectPoint2Segment(point, seg[0], seg[1])) for point, seg in zip(targetPoints, segments[targetPoints2SegmentsMap]) ], dtype=np.float32)
import numpy as np import loss if __name__ == '__main__': import cv2 p1 = np.array([0, 0]) p2 = np.array([1, 0]) p = np.array([0, 1]) print loss.projectPoint2Segment(p, p1, p2)