I
- The type of imagepublic abstract class VideoShotDetector<I extends Image<?,I>> extends VideoProcessor<I> implements VideoDisplayListener<I>
The default threshold boundary should be set by implementing methods as the distances returned by those implementations will only sensibly understand where the threshold should be.
Only the last keyframe is stored during processing, so if you want to store a list of keyframes you must store this list yourself by listening to the ShotDetected event which provides a VideoKeyframe which has a timecode and an image. Each event will receive the same VideoKeyframe instance containing different information. Use VideoKeyframe#clone() to make a copy.
Modifier and Type | Field and Description |
---|---|
protected boolean |
lastFrameWasBoundary
Whether the last processed frame was a boundary
|
protected double |
threshold
The threshold to use to determine a shot boundary - this default is arbitrary
|
Constructor and Description |
---|
VideoShotDetector()
This constructor assumes that you will set the number of
frames per second your video uses (using
setFPS(double) )
when you know what that will be, otherwise your timecodes will
all be messed up. |
VideoShotDetector(double fps)
Default constructor that allows the processor to be used ad-hoc
on frames from any source.
|
VideoShotDetector(Video<I> video)
Constructor that takes the video file to process.
|
VideoShotDetector(Video<I> video,
boolean display)
Default constructor that takes the video file to process and
whether or not to display the video as it's being processed.
|
Modifier and Type | Method and Description |
---|---|
void |
addShotDetectedListener(ShotDetectedListener<I> sdl)
Add the given shot detected listener to the list of listeners in this
object
|
void |
afterUpdate(VideoDisplay<I> display)
Called when the video display is updated and the next frame
is displayed
|
void |
beforeUpdate(I frame)
Called when the video is about to update
|
protected void |
fireDifferentialCalculated(VideoTimecode vt,
double d,
I frame)
Fired each time a differential is calculated between frames.
|
protected void |
fireShotDetected(ShotBoundary<I> sb,
VideoKeyframe<I> vk)
Fire the event to the listeners that a new shot has been detected.
|
DoubleFV |
getDifferentials()
Get the differentials between frames (if storeAllDiff is true).
|
protected abstract double |
getInterframeDistance(I thisFrame)
Returns the inter-frame distance between this frame and the last.
|
VideoKeyframe<I> |
getLastKeyframe()
Returns the last video keyframe that was generated.
|
ShotBoundary<I> |
getLastShotBoundary()
Return the last shot boundary in the list.
|
List<ShotBoundary<I>> |
getShotBoundaries()
Get the list of shot boundaries that have been extracted so far.
|
double |
getThreshold()
Returns the current threshold value.
|
void |
process()
Process the video.
|
I |
processFrame(I frame)
Process a frame in this video.
|
void |
removeShotDetectedListener(ShotDetectedListener<I> sdl)
Remove the given shot detected listener from this object.
|
void |
reset()
No implementation.
|
void |
setFindKeyframes(boolean k)
Set whether to store keyframes of boundaries when they
have been found.
|
void |
setFPS(double fps)
Set the frames per second value for the video being processed.
|
void |
setStoreAllDifferentials(boolean d)
Set whether to store differentials during the processing
stage.
|
void |
setThreshold(double threshold)
Set the threshold that will determine a shot boundary.
|
boolean |
wasLastFrameBoundary()
Returns whether the last processed frame was a shot boundary - that is
the last processed frame marks a new scene.
|
countFrames, getCurrentFrame, getFPS, getHeight, getNextFrame, getTimeStamp, getWidth, hasNextFrame, process, processingComplete
close, getCurrentFrameIndex, iterator, seek, setCurrentFrameIndex
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
protected boolean lastFrameWasBoundary
protected double threshold
public VideoShotDetector()
setFPS(double)
)
when you know what that will be, otherwise your timecodes will
all be messed up.public VideoShotDetector(double fps)
fps
- The number of frames per second of the source materialpublic VideoShotDetector(Video<I> video)
video
- The video to process.public VideoShotDetector(Video<I> video, boolean display)
video
- The video to processdisplay
- Whether to display the video during processing.public boolean wasLastFrameBoundary()
public void process()
process
in class VideoProcessor<I extends Image<?,I>>
public void afterUpdate(VideoDisplay<I> display)
afterUpdate
in interface VideoDisplayListener<I extends Image<?,I>>
display
- the video displayVideoDisplayListener.afterUpdate(org.openimaj.video.VideoDisplay)
public void beforeUpdate(I frame)
beforeUpdate
in interface VideoDisplayListener<I extends Image<?,I>>
frame
- the frame about to be displayedVideoDisplayListener.beforeUpdate(org.openimaj.image.Image)
public void addShotDetectedListener(ShotDetectedListener<I> sdl)
sdl
- The shot detected listener to addpublic void removeShotDetectedListener(ShotDetectedListener<I> sdl)
sdl
- The shot detected listener to removepublic ShotBoundary<I> getLastShotBoundary()
public VideoKeyframe<I> getLastKeyframe()
protected abstract double getInterframeDistance(I thisFrame)
public List<ShotBoundary<I>> getShotBoundaries()
public void setThreshold(double threshold)
threshold
- The new threshold.public double getThreshold()
public void setFindKeyframes(boolean k)
k
- TRUE to store keyframes; FALSE otherwisepublic void setStoreAllDifferentials(boolean d)
d
- TRUE to store all differentials; FALSE otherwisepublic DoubleFV getDifferentials()
public I processFrame(I frame)
processFrame
in class VideoProcessor<I extends Image<?,I>>
frame
- The frame to process.VideoProcessor.processFrame(org.openimaj.image.Image)
protected void fireShotDetected(ShotBoundary<I> sb, VideoKeyframe<I> vk)
sb
- The shot boundary defintionvk
- The video keyframeprotected void fireDifferentialCalculated(VideoTimecode vt, double d, I frame)
vt
- The timecode of the differentiald
- The differential valueframe
- The different framepublic void reset()
reset
in class VideoProcessor<I extends Image<?,I>>
VideoProcessor.reset()
public void setFPS(double fps)
fps
- The number of frames per second.