示例#1
0
def process(path, label, threshold, scores, debug_path):
    clips = []
    if os.path.isdir(path):
        files = os.listdir(path)
        files.sort()
        clips = [os.path.join(path, file) for file in files]
    elif os.path.isfile(path):
        clips.append(path)

    json_config = {
        "mqtt": {
            "host": "mqtt"
        },
        "cameras": {
            "camera": {
                "ffmpeg": {
                    "inputs": [{
                        "path": "path.mp4",
                        "global_args": "",
                        "input_args": "",
                        "roles": ["detect"],
                    }]
                },
                "height": 1920,
                "width": 1080,
            }
        },
    }

    results = []
    for c in clips:
        logger.info(c)
        frame_shape = get_frame_shape(c)

        json_config["cameras"]["camera"]["height"] = frame_shape[0]
        json_config["cameras"]["camera"]["width"] = frame_shape[1]
        json_config["cameras"]["camera"]["ffmpeg"]["inputs"][0]["path"] = c

        config = FrigateConfig(config=FRIGATE_CONFIG_SCHEMA(json_config))

        process_clip = ProcessClip(c, frame_shape, config)
        process_clip.load_frames()
        process_clip.process_frames(objects_to_track=[label])

        results.append((c, process_clip.top_object(debug_path)))

    if not scores is None:
        with open(scores, "w") as writer:
            for result in results:
                writer.write(f"{result[0]},{result[1]['top_score']}\n")

    positive_count = sum(1 for result in results
                         if result[1]["object_detected"])
    print(
        f"Objects were detected in {positive_count}/{len(results)}({positive_count/len(results)*100:.2f}%) clip(s)."
    )
示例#2
0
def process(path, label, threshold, scores, debug_path):
    clips = []
    if os.path.isdir(path):
        files = os.listdir(path)
        files.sort()
        clips = [os.path.join(path, file) for file in files]
    elif os.path.isfile(path):  
        clips.append(path)

    json_config = {
        'mqtt': {
            'host': 'mqtt'
        },
        'cameras': {
            'camera': {
                'ffmpeg': {
                    'inputs': [
                        { 'path': 'path.mp4', 'global_args': '', 'input_args': '', 'roles': ['detect'] }
                    ]
                },
                'height': 1920,
                'width': 1080
            }
        }
    }

    results = []
    for c in clips:
        logger.info(c)
        frame_shape = get_frame_shape(c)
        
        json_config['cameras']['camera']['height'] = frame_shape[0]
        json_config['cameras']['camera']['width'] = frame_shape[1]
        json_config['cameras']['camera']['ffmpeg']['inputs'][0]['path'] = c

        config = FrigateConfig(config=FRIGATE_CONFIG_SCHEMA(json_config))

        process_clip = ProcessClip(c, frame_shape, config)
        process_clip.load_frames()
        process_clip.process_frames(objects_to_track=[label])

        results.append((c, process_clip.top_object(debug_path)))

    if not scores is None:
        with open(scores, 'w') as writer:
            for result in results:
                writer.write(f"{result[0]},{result[1]['top_score']}\n")
    
    positive_count = sum(1 for result in results if result[1]['object_detected'])
    print(f"Objects were detected in {positive_count}/{len(results)}({positive_count/len(results)*100:.2f}%) clip(s).")
示例#3
0
 def test_minimal(self):
     FRIGATE_CONFIG_SCHEMA(self.minimal)
示例#4
0
 def test_empty(self):
     FRIGATE_CONFIG_SCHEMA({})