示例#1
0
data_home = res.pick_and_save(stable, 3)

# classify
cl = SVMClassifier()
cl.load(data_home)
cl.train()

# 注意,如果在classify方法指定了范围
# 那么分析时只会分析处于范围内的帧!
# 例如,这里只传入了stable的范围,那么非stable范围内的帧都会被忽略掉,标记为 -1
classify_result = cl.classify(
    video_path,
    stable,
    # 步长,可以自行设置用于平衡效率与颗粒度
    # 默认为1,即每帧都检测
    step=1)

# draw
r = Reporter()
r.add_dir_link(data_home)

# 你可以将 thumbnail 直接嵌入到report中
for each in unstable:
    r.add_thumbnail(
        f'{each.start}({each.start_time}) - {each.end}({each.end_time})',
        res.thumbnail(each))

# 在0.3.2及之后的版本,你可以在报告中加入一些自定义内容 (https://github.com/williamfzc/stagesepx/issues/13)
# r.add_extra('here is title', 'here is content')
r.draw(classify_result)
示例#2
0
video_path = '../test.mp4'
cutter = VideoCutter()
res = cutter.cut(video_path)
stable, unstable = res.get_range()
data_home = res.pick_and_save(stable, 5)

# classify
cl = SVMClassifier()
cl.load(data_home)
cl.train()

# 注意,如果在classify方法指定了范围
# 那么分析时只会分析处于范围内的帧!
# 例如,这里只传入了stable的范围,那么非stable范围内的帧都会被忽略掉,标记为 -1
classify_result = cl.classify(
    video_path,
    stable,
    # 步长,可以自行设置用于平衡效率与颗粒度
    # 默认为1,即每帧都检测
    step=1)

# draw
r = Reporter()
r.add_dir_link(data_home)

# 你可以将 thumbnail 直接嵌入到report中
for index, each in enumerate(unstable):
    r.add_thumbnail(f'unstable stage {index}', res.thumbnail(each))

r.draw(classify_result)
示例#3
0
stage_1_list = [each for each in classify_result if each.stage == '1']
# 然后计算出它的范围
print(stage_1_list[-1].timestamp - stage_1_list[0].timestamp)
# 你也可以参考 report.py 中 calc_changing_cost 的实现

# --- draw ---
r = Reporter()

# 你可以将 thumbnail 直接嵌入到report中
# 如果不手动设定的话,report也会在报告中自动加入 thumbnail
# 但如此做,你需要在 draw函数 传入 与你的 get_range 相同的参数
# 否则自动提取的阶段会采用默认参数,可能会与你希望的不太一样
# 可以参考 cli.py 中的实现
for each in unstable:
    r.add_thumbnail(
        f'{each.start}({each.start_time}) - {each.end}({each.end_time}), '
        f'duration: {each.end_time - each.start_time}', res.thumbnail(each))

# 你可以将把一些文件夹路径插入到报告中
# 这样你可以很方便地从报告中查看各项相关内容
# 当然,你需要想好这些路径与报告最后所在位置之间的相对位置,以确保他们能够被访问到
# r.add_dir_link(data_home)

# 在0.3.2及之后的版本,你可以在报告中加入一些自定义内容 (https://github.com/williamfzc/stagesepx/issues/13)
# r.add_extra('here is title', 'here is content')
r.draw(
    classify_result,
    report_path=os.path.join(data_home, 'report.html'),
    # 0.5.3新增的特性,多用于debug
    # 传入cutter的切割结果,能够在图表末尾追加 SSIM、MSE、PSNR 的变化趋势图
    cut_result=res,
示例#4
0
# 从而达到你希望的效果
data_list = classify_result.data
print(data_list)

# --- draw ---
r = Reporter()

# 你可以将 thumbnail 直接嵌入到report中
# 如果不手动设定的话,report也会在报告中自动加入 thumbnail
# 但如此做,你需要在 draw函数 传入 与你的 get_range 相同的参数
# 否则自动提取的阶段会采用默认参数,可能会与你希望的不太一样
# 可以参考 cli.py 中的实现
for each in unstable:
    r.add_thumbnail(
        f"{each.start}({each.start_time}) - {each.end}({each.end_time}), "
        f"duration: {each.end_time - each.start_time}",
        res.thumbnail(each),
    )

# 你可以将把一些文件夹路径插入到报告中
# 这样你可以很方便地从报告中查看各项相关内容
# 当然,你需要想好这些路径与报告最后所在位置之间的相对位置,以确保他们能够被访问到
# r.add_dir_link(data_home)

# 在0.3.2及之后的版本,你可以在报告中加入一些自定义内容 (https://github.com/williamfzc/stagesepx/issues/13)
# r.add_extra('here is title', 'here is content')
r.draw(
    classify_result,
    report_path=os.path.join(data_home, "report.html"),
    # 0.5.3新增的特性,多用于debug
    # 传入cutter的切割结果,能够在图表末尾追加 SSIM、MSE、PSNR 的变化趋势图