Log in

View Full Version : Similar scenes detection


Ponder
12th May 2011, 06:22
@Gavino
I want to construct "YDifferenceFrom_frame_5" in a Runtime environment. Can this be done?
Could you provide some insight, I may be already on the wrong approach. :-()

For example:
Given a clip has four scenes(mostly static, with very litte panning), basic scenes are A,B,C,D.
The whole clip is a random combinations of these 4 scenes' - ABADCABCBACD...

Want to do this, if scene A found, perform some operations, if scene B found, speed up 15%
if scene C found do nothing. If scene D found, delete these frames.

By browsing through the clip, I can choose 4 reference pictures from A B C D, say, frame 5 for A,
frame 270 for B, frame 100 for C, frame 900 for D. In order to find similar scenes,

The comparison to will be done in the Runtime environment, but what syntax do I need to store these
4 reference frames, meanwhile? or, how do one refer to a frame by an exact location
(frame number)?

Pseudo codes:

c = GFrameEvaluate(c, "global diff = 0.50*YDifferenceFrom_frame_5(clip)
\ + 0.25*UDifferenceFrom_frame_5(clip) + 0.25*VDifferenceFrom_frame_5(clip)")
return c

eventually..
c = GFrameEvaluate(c, ... diff( frame5 - current_frame) < 10... found scene A
.
c = GFrameEvaluate(c, ... diff( frame270 - current_frame) < 10... found scene B
c = GFrameEvaluate(c, ... diff( frame900 - current_frame) < 10... found scene D

At the end, the clip will be ABACABC.. with no scene D.

Gavino
12th May 2011, 10:15
You can extract the reference frames using Trim, eg
RefA = A.Trim(5, 5)
and then use LumaDifference(RefA) etc in your comparisons.

Can you assume that within each section of the source clip, the reference frame will be in the 'right' place? That would simplify the detection logic. For example, to determine whether the first section is an A, B, C or D you would only need to look at frames 5, 270, 100 and 900.

Ponder
22nd May 2011, 16:22
Yes, I assumed(picked visually) just that. It worked out nicely in a 2 similar scenes situation.
If there are more moderation motion within a particular section, may need to take 2 frames and
average them into one Ref. frame. Have not test that, but should work.

Thanks Gavino. :)