def annotate_video(video_filepath):
    reader = VideofileReader(video_filepath)
    frame = FrameIndexSplitter()(reader)
    results = Detectron2HumanPose(architecture = 'R50_FPN_3x', device_type = 'cpu')(frame)
    keypoints = KeypointsExtractor()(results)
    annotated_frame = HumanPoseAnnotator()(frame, keypoints)
    writer = VideofileWriter('pose.avi')(annotated_frame)
    fl = flow.Flow([reader], [], flow_type = BATCH)
    fl.run()
    fl.join()
Ejemplo n.º 2
0
def main():
    input_file = get_file(VIDEO_NAME, URL_VIDEO)
    output_file = "output.avi"
    reader = VideofileReader(input_file)
    frame = FrameIndexSplitter()(reader)
    detector = TensorflowObjectDetector()(frame)
    annotator = BoundingBoxAnnotator()(frame, detector)
    writer = VideofileWriter(output_file, fps=30)(annotator)
    fl = flow.Flow([reader], [writer], flow_type=BATCH)
    fl.run()
    fl.join()
Ejemplo n.º 3
0
def main():
    output_file = sys.argv[1]
    input_file = get_file(VIDEO_NAME, URL_VIDEO)
    reader = VideofileReader(input_file)
    frame = FrameIndexSplitter()(reader)
    tracks = TracktorFromFrames()(frame)
    tracks_to_annotator = TracksToAnnotator()(tracks)
    annotator = TrackerAnnotator()(frame, tracks_to_annotator)
    writer = VideofileWriter(output_file, fps=30)(annotator)
    fl = flow.Flow([reader], [writer], flow_type=BATCH)
    fl.run()
    fl.join()
Ejemplo n.º 4
0
def obfuscate_faces(video_filepath):
    reader = VideofileReader(video_filepath)
    frame = FrameIndexSplitter()(reader)
    faces = TensorflowObjectDetector(num_classes=1,
                                     architecture='ssd-mobilenetv2',
                                     dataset='faces',
                                     min_score_threshold=0.2)(frame)
    blurred_faces = BoundingboxObfuscator()(frame, faces)
    writer = VideofileWriter('blurred_video.mp4', codec='avc1')(blurred_faces)
    fl = flow.Flow([reader], [writer], flow_type=BATCH)
    fl.run()
    fl.join()
def main():
    # i.e: 10.23.232.43
    stream_address = sys.argv[1]
    username = sys.argv[2]
    password = sys.argv[3]
    output_file = "output.avi"

    stream_url = f'rtsp://{username}:{password}@{stream_address}'
    reader = VideoUrlReader(stream_url)
    frame = FrameIndexSplitter()(reader)
    writer = VideofileWriter(output_file, fps=30)(frame)
    fl = flow.Flow([reader], [writer], flow_type=REALTIME)
    fl.run()
    fl.join()
Ejemplo n.º 6
0
def main():
    input_file = get_file(VIDEO_NAME, URL_VIDEO)
    output_file = "output.avi"
    
    reader = VideofileReader(input_file)
    frame = FrameIndexSplitter()(reader)
    detector = TensorflowObjectDetector(num_classes = 2, architecture = 'fasterrcnn-resnet101', dataset = 'kitti')(frame)
    # keeps only automobile classes: autos, buses, cycles, etc.
    tracker = KalmanFilterBoundingBoxTracker()(detector)
    annotator = TrackerAnnotator()(frame, tracker)
    writer = VideofileWriter(output_file, fps = 30)(annotator)
    fl = flow.Flow([reader], [writer], flow_type = BATCH)
    fl.run()
    fl.join()
Ejemplo n.º 7
0
def main():
    input_file = get_file(VIDEO_NAME, URL_VIDEO)
    output_file = "output.avi"

    reader = VideofileReader(input_file)
    frame = FrameIndexSplitter()(reader)
    detector = TensorflowObjectDetector()(frame)
    # keeps only automobile classes: autos, buses, cycles, etc.
    filter_ = BoundingBoxesFilter([1, 2, 3, 4, 6, 8, 10, 13])(detector)
    tracker = KalmanFilterBoundingBoxTracker()(filter_)
    annotator = TrackerAnnotator()(frame, tracker)
    writer = VideofileWriter(output_file, fps=30)(annotator)
    fl = flow.Flow([reader], [writer], flow_type=BATCH)
    fl.run()
    fl.join()
Ejemplo n.º 8
0
def track_humans():
    input_file_path = get_file(VIDEO_NAME, URL_VIDEO)
    output_file = 'annotated_video.avi'
    reader = VideofileReader(input_file_path)
    frame = FrameIndexSplitter()(reader)
    results = Detectron2HumanPose(architecture='R50_FPN_3x',
                                  device_type='cpu')(frame)
    keypoints = KeypointsExtractor()(results)
    bounding_boxes = BoundingBoxesExtractor()(results)
    anotated_keypoints = HumanPoseAnnotator()(frame, keypoints)
    cropped_humans = CropBoundingBoxes()(frame, bounding_boxes)
    human_features = HumanEncoder()(cropped_humans)
    tracker_input = AppendFeaturesToBoundingBoxes()(bounding_boxes,
                                                    human_features)
    tracks = DeepSort()(tracker_input)
    tracks_anotator_input = ConvertTracksForAnotation()(tracks)
    anotated_tracks = TrackerAnnotator()(anotated_keypoints,
                                         tracks_anotator_input)
    writer = VideofileWriter(output_file)(anotated_tracks)
    fl = flow.Flow([reader], [writer], flow_type=BATCH)
    fl.run()
    fl.join()
Ejemplo n.º 9
0
import videoflow
import videoflow.core.flow as flow
from videoflow.core.constants import BATCH
from videoflow.consumers import VideofileWriter
from videoflow.producers import VideofileReader
from videoflow.processors.vision.detectors import TensorflowObjectDetector
from videoflow.processors.vision.annotators import BoundingBoxAnnotator
from videoflow.utils.downloader import get_file


class FrameIndexSplitter(videoflow.core.node.ProcessorNode):
    def __init__(self):
        super(FrameIndexSplitter, self).__init__()

    def process(self, data):
        index, frame = data
        return frame


input_file = "input.mp4"
output_file = "output.avi"
reader = VideofileReader(input_file)
frame = FrameIndexSplitter()(reader)
detector = TensorflowObjectDetector()(frame)
annotator = BoundingBoxAnnotator()(frame, detector)
writer = VideofileWriter(output_file, fps=30)(annotator)
fl = flow.Flow([reader], [writer], flow_type=BATCH)
fl.run()
fl.join()