示例#1
0
    def testLongIDs(self):
        """Ensure that arbitrary detection IDs are handled properly between
        findTracklets and collapseTracklets. This is necessary because the index
        fields in a tracklet can become confused between detection ID and
        position in the detection vector, leading to out of bounds errors.
        """
        detections = [
            daymops.MopsDetection(130344998938869947, 5330.0, 10.0, 10.0),
            daymops.MopsDetection(130344998938869948, 5331.0, 11.0, 11.0),
            daymops.MopsDetection(130344998938869949, 5332.0, 12.0, 12.0),
            daymops.MopsDetection(130344998938869950, 5333.0, 13.0, 13.0),
        ]

        # See tests/findTracklets.py testLongIds()
        for n, det in enumerate(detections):
            det.index = n

        config = daymops.findTrackletsConfig()
        config.maxV = 1.5
        config.maxDt = 3.0
        tracklets = daymops.findTracklets(detections, config)
        self.assertTrue(len(tracklets) > 2)
        output = daymops.TrackletSet()

        tolerances = [0.01, 0.01, 1.0, 0.01]
        daymops.doCollapsingPopulateOutputVector(detections, tracklets,
                                                 tolerances, output, False,
                                                 False, False, 0.0, False)
        print(output, len(output))
        self.assertEqual(len(output), 1)
        self.assertTrue(all([x in output[0].indices() for x in (0, 1, 2, 3)]))
示例#2
0
    def testSingleTracklet(self):
        detections = [
            daymops.MopsDetection(0, 53736.0, 100.0, 10.0),
            daymops.MopsDetection(1, 53737.0, 100.1, 10.1),
        ]
        config = daymops.findTrackletsConfig()
        config.maxV = 1.0
        config.maxDt = 1.5
        tracklets = daymops.findTracklets(detections, config)

        self.assertEqual(len(tracklets), 1)
示例#3
0
    def testVelocityFilter(self):
        detections = [
            daymops.MopsDetection(0, 53736.0, 100.0, 80.0),
            daymops.MopsDetection(1, 53737.0, 100.1, 80.1),
            daymops.MopsDetection(2, 53736.0, 150.0, 0.0),
            daymops.MopsDetection(3, 53737.0, 151.1, 0.1),
        ]
        config = daymops.findTrackletsConfig()
        config.maxV = 1.0
        config.maxDt = 3.0
        tracklets = daymops.findTracklets(detections, config)

        self.assertEqual(len(tracklets), 1)
        self.assertTrue(containsPair(0, 1, tracklets))
示例#4
0
    def testTwoPairs(self):
        detections = [
            daymops.MopsDetection(0, 53736.0, 100.0, -10.0),
            daymops.MopsDetection(1, 53737.0, 100.1, -10.1),
            daymops.MopsDetection(2, 53736.0, 150.0, -10.0),
            daymops.MopsDetection(3, 53737.0, 150.1, -10.1),
        ]
        config = daymops.findTrackletsConfig()
        config.maxV = 1.0
        config.maxDt = 3.0
        tracklets = daymops.findTracklets(detections, config)

        self.assertEqual(len(tracklets), 2)
        self.assertTrue(containsPair(0, 1, tracklets))
        self.assertTrue(containsPair(2, 3, tracklets))
示例#5
0
    def testSingleTracklet(self):
        detections = [
            daymops.MopsDetection(0, 53736.0, 100.0, 10.0),
            daymops.MopsDetection(1, 53737.0, 100.1, 10.1),
            daymops.MopsDetection(2, 53738.0, 100.2, 10.2),
        ]
        config = daymops.findTrackletsConfig()
        config.maxV = 1.0
        config.maxDt = 3.0
        tracklets = daymops.findTracklets(detections, config)

        self.assertEqual(len(tracklets), 3)
        self.assertTrue(containsPair(0, 1, tracklets))
        self.assertTrue(containsPair(0, 2, tracklets))
        self.assertTrue(containsPair(1, 2, tracklets))
示例#6
0
    def testCollapsing_lessPrecise(self):
        detections = [
            daymops.MopsDetection(0, 5330.0, 10.0, 10.0),
            daymops.MopsDetection(1, 5331.0, 11.0, 11.5),
            daymops.MopsDetection(2, 5332.0, 12.0, 12.0),
            daymops.MopsDetection(3, 5333.0, 13.0, 13.5),
        ]

        tolerances = [2.0, 2.0, 45.0, 1.0]
        t1 = daymops.Tracklet([0, 1])
        t2 = daymops.Tracklet([2, 3])

        tracklets = daymops.TrackletSet([t1, t2])
        output = daymops.TrackletSet()
        daymops.doCollapsingPopulateOutputVector(detections, tracklets,
                                                 tolerances, output, False,
                                                 False, False, 0.0, False)
        self.assertTrue(all([x in output[0].indices() for x in (0, 1, 2, 3)]))
示例#7
0
    def testCollapsing_morePrecise(self):
        # Should not collapse anything
        detections = [
            daymops.MopsDetection(0, 5330.0, 10.0, 10.0),
            daymops.MopsDetection(1, 5331.0, 11.0, 11.5),
            daymops.MopsDetection(2, 5332.0, 12.0, 12.0),
            daymops.MopsDetection(3, 5333.0, 13.0, 13.5),
        ]

        tolerances = [0.5, 0.5, 5.0, 0.5]
        t1 = daymops.Tracklet([0, 1])
        t2 = daymops.Tracklet([2, 3])

        tracklets = daymops.TrackletSet([t1, t2])
        output_tracklets = daymops.TrackletSet()
        daymops.doCollapsingPopulateOutputVector(detections, tracklets,
                                                 tolerances, output_tracklets,
                                                 False, False, False, 0.0,
                                                 False)
        self.assertTrue(len(output_tracklets) == 2)
示例#8
0
    def broken_test(self):
        detections = [  # 4 matching detections
            daymops.MopsDetection(5330.0, 1.0, 1.0),
            daymops.MopsDetection(5330.1, 0.0, 0.0),
            daymops.MopsDetection(5330.2, 359.0, 359.0),
            daymops.MopsDetection(5330.3, 358.0, 358.0),
            # 4 unrelated detections
            daymops.MopsDetection(5330.0, 1.0, 0.8),
            daymops.MopsDetection(5330.1, 0.0, 0.2),
            daymops.MopsDetection(5330.2, 359.0, 358.8),
            daymops.MopsDetection(5330.3, 358.0, 358.2),
        ]

        t1 = daymops.Tracklet([0, 1])
        t2 = daymops.Tracklet([4, 5])