Esempio n. 1
0
    def classify(self,
                 video_path: str,
                 data_home: str,
                 output_path: str = None,
                 compress_rate: float = 0.2,
                 limit: int = None):
        # TODO model?

        cut_result_json = os.path.join(data_home, 'cut_result.json')

        res = None
        stable = None
        if os.path.isfile(cut_result_json):
            res = VideoCutResult.load(cut_result_json)
            stable, _ = res.get_range(limit=limit)

        cl = SVMClassifier(compress_rate=compress_rate)
        cl.load(data_home)
        cl.train()
        classify_result = cl.classify(video_path, stable)

        # --- draw ---
        r = Reporter()
        r.add_dir_link(data_home)
        r.draw(
            classify_result,
            report_path=os.path.join(output_path or data_home, 'report.html'),
            cut_result=res,
        )
Esempio n. 2
0
def test_dump_and_load():
    cutter = VideoCutter()
    res = cutter.cut(VIDEO_PATH)
    json_path = "cutter_result.json"
    res.dump(json_path)

    res_from_file = VideoCutResult.load(json_path)
    assert res.dumps() == res_from_file.dumps()