Skip to content

Commit

Permalink
expose threshold scores produced at detected shot boundaries
Browse files Browse the repository at this point in the history
Modified __init__.py to print out the score associated with each
detected boundary and altered scene lists to track these scores.
  • Loading branch information
albanie committed Mar 30, 2016
1 parent 5ff8f4d commit 0ba9759
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 7 additions & 6 deletions scenedetect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

# Standard Library Imports
from __future__ import print_function
from __future__ import division
import sys
import os
import argparse
Expand Down Expand Up @@ -350,10 +351,10 @@ def main():

# Create new list with scene cuts in milliseconds (original uses exact
# frame numbers) based on the video's framerate, and then timecodes.
scene_list_msec = [(1000.0 * x) / float(video_fps) for x in scene_list]
scene_list_msec = [(1000.0 * x[0]) / float(video_fps) for x in scene_list]
scene_list_tc = [scenedetect.timecodes.get_string(x) for x in scene_list_msec]
# Create new lists with scene cuts in seconds, and the length of each scene.
scene_start_sec = [(1.0 * x) / float(video_fps) for x in scene_list]
scene_start_sec = [(1.0 * x[0]) / float(video_fps) for x in scene_list]
scene_len_sec = []
if len(scene_list) > 0:
scene_len_sec = scene_list + [frames_read]
Expand All @@ -370,11 +371,11 @@ def main():
if args.list_scenes:
print('[PySceneDetect] List of detected scenes:')
print ('-------------------------------------------')
print (' Scene # | Frame # | Timecode ')
print (' Scene # | Frame # | Score # | Timecode ')
print ('-------------------------------------------')
for scene_idx, frame_num in enumerate(scene_list):
print (' %3d | %9d | %s' % (
scene_idx+1, frame_num, scene_list_tc[scene_idx]))
for scene_idx, frame_pair in enumerate(scene_list):
print (' %3d | %9d | %9d | %s' % (
scene_idx+1, frame_pair[0], frame_pair[1], scene_list_tc[scene_idx]))
print ('-------------------------------------------')
print('[PySceneDetect] Comma-separated timecode output:')

Expand Down
4 changes: 3 additions & 1 deletion scenedetect/detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
# OTHER DEALINGS IN THE SOFTWARE.
#

from __future__ import division

# Third-Party Library Imports
import cv2
import numpy
Expand Down Expand Up @@ -295,7 +297,7 @@ def process_frame(self, frame_num, frame_img, frame_metrics, scene_list):
if delta_hsv_avg >= self.threshold:
if self.last_scene_cut is None or (
(frame_num - self.last_scene_cut) >= self.min_scene_len):
scene_list.append(frame_num)
scene_list.append((frame_num, delta_hsv_avg))
self.last_scene_cut = frame_num
cut_detected = True

Expand Down

0 comments on commit 0ba9759

Please sign in to comment.