Example #1
0
    def test_clone(self):
        do = DetectedObject(self.bbox)
        do_clone = do.clone()
        nt.ok_(self.check_det_objs_equal(do, do_clone))

        do = DetectedObject(self.bbox, self.conf, self.dot, self.mask)
        do_clone = do.clone()
        nt.ok_(self.check_det_objs_equal(do, do_clone))

        # Try setting some values
        do.geo_point = self.geo_point
        do.index = self.index
        do.detector_name = self.detector_name
        do.set_descriptor(self.descriptor)
        do.add_note(self.note_to_add)

        do.add_keypoint(self.keypoint_id, self.keypoint_to_add)
        # First show that its a deep copy. Should no longer be equal
        nt.assert_false(self.check_det_objs_equal(do, do_clone))

        # Now clone
        do_clone = do.clone()
        nt.ok_(self.check_det_objs_equal(do, do_clone))
Example #2
0
    def test_keypoints(self):
        # Check default
        do = DetectedObject(self.bbox)
        self.check_keypoints_equal(do.keypoints, dict())

        # Clearing empty is OK
        do.clear_keypoints()
        self.check_keypoints_equal(do.keypoints, dict())

        # Add a few values
        do.add_keypoint(self.keypoint_id, self.keypoint_to_add)
        exp_keypoints = {self.keypoint_id: self.keypoint_to_add}
        self.check_keypoints_equal(do.keypoints, exp_keypoints)

        new_keypoint_id = "other_example_keypoint_id"
        new_keypoint = Point2d()
        new_keypoint.value = self.loc1
        do.add_keypoint(new_keypoint_id, new_keypoint)
        exp_keypoints[new_keypoint_id] = new_keypoint
        self.check_keypoints_equal(do.keypoints, exp_keypoints)

        # Clearing works as expected
        do.clear_keypoints()
        self.check_keypoints_equal(do.keypoints, dict())