Exemplo n.º 1
0
 def test_tracking(self):
     tracker = MOTReadingAsTracker()
     tracker.load_frames(root_images=_root_images, frame_num_start=1)
     hooks = [
         Recorder(),
         MOTReader(path_mot_txt=_input_mot_txt),
         ImageWriter(root_output_images=_root_output_images)
     ]
     tracker.register_hooks(hooks)
     tracker.track(0, 509)
Exemplo n.º 2
0
    def test_road_object_tracking_transdiff(self):
        tracker = IoUTracker()
        tracker.load_frames(root_images=_root_road_object_images,
                            frame_num_start=-1,
                            frame_num_end=-1)
        hooks = [
            RoadObjectDetection(score_thre=0.17),
            BoxCoordinateNormalizer(),
            ApproachingInitializer(),
            FeatureMatcher(interval=6, box_remove_margin=0.1),
            # TransformedMidpointCalculator(),
            TransformedMidpointDifferencer(),
            # HorizontalMovementCounter(right_trend_is_approaching=False),
            # AreaCalculator(),
            # MidpointCalculator(),
            # WidthAndHeihtCalculator(),
            RiskyJudger(),
            Recorder(),
            ImageWriter(root_output_images=_root_road_object_output_images),
            ImageWriterForApproaching(
                root_output_images=_root_road_object_output_approaching_images
            ),
            VideoWriterForTracking(
                root_output_video=_root_road_object_output_video,
                do_resize=True,
                fps=30.0),
            VideoWriterForApproaching(
                root_output_video=_root_road_object_output_approaching_video,
                do_resize=True,
                fps=30.0),
            VideoWriterForMatching(
                root_output_video=
                _root_road_object_output_feature_matching_video,
                size=(1024, 512),
                do_resize=True,
                fps=30.0),
            MOTWriter(root_output_mot=_root_road_object_output_mot,
                      labels=["vehicle"]),
            MOTWriterForApproaching(
                root_output_mot=_root_road_object_output_approaching_mot),
            MOTWriterForRisky(
                root_output_mot=_root_road_object_output_risky_mot),
            FeatureStatWriter(root_output_feature_stat=_root_feature_stat),
        ]

        tracker.register_hooks(hooks)
        tracker.track()
Exemplo n.º 3
0
 def test_mirror_tracking(self):
     tracker = IoUTracker()
     tracker.load_frames(root_images=_root_mirror_images,
                         frame_num_start=-1,
                         frame_num_end=-1)
     hooks = [
         MirrorDetection(0.3, 0.3),
         Recorder(),
         ImageWriter(root_output_images=_root_mirror_output_images),
         VideoWriterForTracking(root_output_video=_root_mirror_output_video,
                                do_resize=True,
                                fps=30.0,
                                size=(3840, 2160)),
         MOTWriter(root_output_mot=_root_mirror_output_mot)
     ]
     tracker.register_hooks(hooks)
     tracker.track()
Exemplo n.º 4
0
 def test_null_road_object_tracking(self):
     tracker = NullTracker()
     tracker.load_frames(root_images=_root_road_object_images,
                         frame_num_start=-1,
                         frame_num_end=-1)
     hooks = [
         MOTReader(path_mot_txt=_path_input_mot_txt),
         BoxCoordinateNormalizer(),
         ApproachingInitializer(),
         FeatureMatcher(interval=30),
         TransformedMidpointCalculator(),
         # HorizontalMovementCounter(right_trend_is_approaching=True),
         # AreaCalculator(),
         # MidpointCalculator(),
         # WidthAndHeihtCalculator(),
         RiskyJudger(),
         Recorder(),
         ImageWriter(root_output_images=_root_road_object_output_images),
         ImageWriterForApproaching(
             root_output_images=_root_road_object_output_approaching_images
         ),
         VideoWriterForTracking(
             root_output_video=_root_road_object_output_video,
             do_resize=True,
             fps=30.0),
         VideoWriterForApproaching(
             root_output_video=_root_road_object_output_approaching_video,
             do_resize=True,
             fps=30.0),
         VideoWriterForMatching(
             root_output_video=
             _root_road_object_output_feature_matching_video,
             size=(1024, 512),
             do_resize=True,
             fps=30.0),
         # MOTWriter(root_output_mot=_root_road_object_output_mot)
         MOTWriterForApproaching(
             root_output_mot=_root_road_object_output_approaching_mot),
         MOTWriterForRisky(
             root_output_mot=_root_road_object_output_risky_mot)
     ]
     tracker.register_hooks(hooks)
     tracker.track()
Exemplo n.º 5
0
            root_mirror_seqs=os.path.join(path_exp, seq_name, 'mirror_seqs'))

        for root_name, root in roots_for_input.items():
            assert os.path.isdir(root), f'Not exists: {root} for {seq_name}'

        for root_name, root in roots_for_output.items():
            os.makedirs(root, exist_ok=True)

        tracker = IoUTracker()
        tracker.load_frames(root_images=roots_for_input['root_mirror_images'],
                            frame_num_start=-1,
                            frame_num_end=-1)
        hooks = [
            MirrorDetection(0.3, 0.3),
            Recorder(),
            ImageWriter(root_output_images=roots_for_output[
                'root_mirror_output_images']),
            VideoWriterForTracking(
                root_output_video=roots_for_output['root_mirror_output_video'],
                do_resize=True,
                fps=30.0,
                size=(3840, 2160)),
            MOTWriter(
                root_output_mot=roots_for_output['root_mirror_output_mot'])
        ]
        tracker.register_hooks(hooks)

        if _IF_POSSIBLE_SKIP_MIR_RECOGNITION and (len(tracker.loader) == len(
                os.listdir(roots_for_output['root_mirror_output_images']))):
            logging.info('Mirror recoginition stage was skipped.')
        else:
            tracker.track()
Exemplo n.º 6
0
                     frame_num_start=-1,
                     frame_num_end=-1)
 hooks = [
     RoadObjectDetection(score_thre=0.17),
     BoxCoordinateNormalizer(),
     ApproachingInitializer(),
     FeatureMatcher(interval=6, box_remove_margin=0.1),
     # TransformedMidpointCalculator(),
     TransformedMidpointDifferencer(),
     # HorizontalMovementCounter(right_trend_is_approaching=False),
     # AreaCalculator(),
     # MidpointCalculator(),
     # WidthAndHeihtCalculator(),
     RiskyJudger(),
     Recorder(),
     ImageWriter(root_output_images=roots_for_output[
         'root_road_object_output_images']),
     ImageWriterForApproaching(root_output_images=roots_for_output[
         'root_road_object_output_approaching_images']),
     VideoWriterForTracking(root_output_video=roots_for_output[
         'root_road_object_output_video'],
                            do_resize=True,
                            fps=30.0),
     VideoWriterForApproaching(root_output_video=roots_for_output[
         'root_road_object_output_approaching_video'],
                               do_resize=True,
                               fps=30.0),
     VideoWriterForMatching(root_output_video=roots_for_output[
         'root_road_object_output_feature_matching_video'],
                            size=(1024, 512),
                            do_resize=True,
                            fps=30.0),
Exemplo n.º 7
0
_root_road_object_output_risky_mot = "/home/appuser/src/pipedet/simple_demonstration/output_risky_including_road_object_recognition/mot_for_risky"
_root_feature_stat = "/home/appuser/src/pipedet/simple_demonstration/output_risky_including_road_object_recognition/feature_stat"

if __name__ == '__main__':
    tracker = IoUTracker()
    tracker.load_frames(root_images=_root_cropped_images, frame_num_start=-1, frame_num_end=-1)
    hooks = [
        RoadObjectDetection(score_thre = 0.17),
        BoxCoordinateNormalizer(),
        ApproachingInitializer(),
        FeatureMatcher(interval=6, box_remove_margin=0.1),
        # TransformedMidpointCalculator(),
        TransformedMidpointDifferencer(),
        # HorizontalMovementCounter(right_trend_is_approaching=False),
        # AreaCalculator(),
        # MidpointCalculator(),
        # WidthAndHeihtCalculator(),
        RiskyJudger(),
        Recorder(),
        ImageWriter(_root_road_object_images=_root_road_object_output_tracking_images),
        ImageWriterForApproaching(root_output_images=_root_road_object_output_approaching_images),
        VideoWriterForTracking(root_output_video=_root_road_object_output_video_for_tracking, do_resize=True, fps=30.0),
        VideoWriterForApproaching(root_output_video=_root_road_object_output_approaching_video, do_resize=True, fps=30.0),
        VideoWriterForMatching(root_output_video=_root_road_object_output_feature_matching_video, size=(1024,512) ,do_resize=True, fps=30.0),
        MOTWriter(root_output_mot=_root_road_object_output_tracking_mot, labels=["vehicle"]),
        MOTWriterForApproaching(root_output_mot=_root_road_object_output_approaching_mot),
        MOTWriterForRisky(root_output_mot=_root_road_object_output_risky_mot),
        FeatureStatWriter(root_output_feature_stat=_root_feature_stat),
    ]
    tracker.register_hooks(hooks)
    tracker.track()
Exemplo n.º 8
0
from pipedet.solver.get_mirror_seq import MirrorSeq
"""
Mirror tracking demonstration.
"""

_root_in_vehicle_frames = '/home/appuser/src/pipedet/simple_demonstration/demo_in_vehicle_frame'

_root_output_video_for_tracking = '/home/appuser/src/pipedet/simple_demonstration/output_mirror_tracking/video_for_tracking'

_root_output_images_for_tracking = '/home/appuser/src/pipedet/simple_demonstration/output_mirror_tracking/images_for_tracking'

_root_output_mot_for_tracking = '/home/appuser/src/pipedet/simple_demonstration/output_mirror_tracking/mot_for_tracking'

if __name__ == '__main__':
    tracker = IoUTracker()
    tracker.load_frames(root_images=_root_in_vehicle_frames,
                        frame_num_start=-1,
                        frame_num_end=-1)
    hooks = [
        MirrorDetection(0.3, 0.3),
        Recorder(),
        ImageWriter(root_output_images=_root_output_images_for_tracking),
        VideoWriterForTracking(
            root_output_video=_root_output_video_for_tracking,
            do_resize=True,
            fps=30.0,
            size=(3840, 2160)),
        MOTWriter(root_output_mot=_root_output_mot_for_tracking)
    ]
    tracker.register_hooks(hooks)
    tracker.track()