Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 29th July 2012, 00:56   #1  |  Link
althor1138
Registered User
 
Join Date: Jan 2012
Location: Sweden
Posts: 19
Stabilize via sprocket holes?

I have a short film that is less than a minute long that I have captured with a digital camera and slide copier. The frames are captured entirely, including the sprocket holes. I want to stabilize the film but I don't want to use Depan or Deshaker because it is hard to tweak from scene to scene and it ends up cutting off some of the image at times.

Is it possible to somehow in Avisynth align the sprocket holes of each frame to match the first frame?

Thanks in advance. Even if the answer is simply no it will save me some time .
althor1138 is offline   Reply With Quote
Old 29th July 2012, 03:54   #2  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,862
Yes, there's been cases where I've wanted to stabilize one object and depan is more for global stabilization.
Try Centertracker, it's meant to focus on one thing.
jmac698 is offline   Reply With Quote
Old 30th July 2012, 06:54   #3  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Gent, Flanders, Belgium, Europe, Earth, Milky Way,Universe
Posts: 616
With Depan, it is possible to do the motion detection on the sprocket holes only, and then apply the result on the entire clip.

Please try this script:


Code:
# film stabilisation script by videoFred.
# modified june 2012
#=============================================================================================




film= "C:\Users\You\Documents\Yourfile.avi"  # source clip, you must specify the full path here




#PARAMETERS
#----------------------------------------------------------------------------------------------------------------------------
result="stabS" # specify the wanted output here stab= stabilised clip, stabS= comparison before/after

trim_begin=2  play_speed= 18   #trim frames and play speed 




#SIZE, CROP AND BORDERS PARAMETERS
#----------------------------------------------------------------------------------------------------------------------------
CLeft=20  CTop=20  CRight=20  CBottom=20  #crop values after Depan and before final resizing 

W=720  H=576  #final size after cropping 

bord_left=0  bord_top=0  bord_right=0  bord_bot=0  #720p= borders 150


#STABILISING PARAMETERS, YOU REALY MUST USE STABS TO CHECK STABILISATION!
#----------------------------------------------------------------------------------------------------------------------------
maxstabH=40 
maxstabV=40 #maximum values for the stabiliser (in pixels) 20 is a good start value

est_left=40   est_top=40  est_right=40  est_bottom=40  #crop values for special Estimate clip

trust_value= 1.0     # scene change detection, higher= more sensitive
cutoff_value= 0.5   # no need to change this, but you can play with it and see what you get




# END VARIABLES, BEGIN SCRIPT
#=================================================================================================================================


SetMemoryMax(800)  #set this to 1/3 of the available memory





Loadplugin("plugins/Depan.dll")
LoadPlugin("plugins/DepanEstimate.dll")




source1= AviSource(film).assumefps(play_speed).trim(trim_begin,0).converttoYV12()




#STABILIZING/CROPPING
#..........................................................................................................................................
stab_reference= source1.crop(est_left,est_top,-est_right,-est_bottom)

mdata=DePanEstimate(stab_reference,trust=trust_value,dxmax=maxstabH,dymax=maxstabV)
stab=DePanStabilize(source1,data=mdata,cutoff=cutoff_value,dxmax=maxstabH,dymax=maxstabV,method=0,mirror=15)
stab2= stab.crop(CLeft,CTop,-CRight,-CBottom)
stab3=DePanStabilize(source1,data=mdata,cutoff=cutoff_value,dxmax=maxstabH,dymax=maxstabV,method=0,info=true)

WS= width(stab)
HS= height(stab)
stab4= stab3.addborders(10,10,10,10,$B1B1B1).Lanczos4Resize(WS,HS)
stab5= Lanczos4Resize(stab2,W,H).sharpen(0.5)







#RESULT5: SPECIAL SERVICE CLIP FOR RESULT S5
#..................................................................................................................................................
result5= overlay(source1,greyscale(stab_reference),x=est_left,y=est_top).addborders(2,2,2,2,$FFFFFF).Lanczos4Resize(WS,HS)




#PARAMETERS FOR THE COMPARISONS
#..................................................................................................................................................
W2= W+bord_left+bord_right
H2= H+bord_top+bord_bot





source4=Lanczos4Resize(source1,W2,H2)





#SPECIAL COMPARISON CLIP FOR TESTING THE STABILIZER
#.........................................................................................................................................................................
stabS= stackhorizontal(subtitle(result5,"baseclip for stabiliser -only the B/W clip is used",size=32,align=2),\
subtitle(stab4,"test stabiliser: dx=horizontal, dy=vertical",size=32,align=5)).converttoYUY2()



Eval(result)
With est_left etc.. you can crop the Depan Estimate clip to the sprocket holes only. With stabS you can see what is happening.

Fred.
__________________
About 8mm film:
http://www.super-8.be
Film Transfer Tutorial and example clips:
https://www.youtube.com/watch?v=W4QBsWXKuV8
More Example clips:
http://www.vimeo.com/user678523/videos/sort:newest
videoFred is offline   Reply With Quote
Old 30th July 2012, 07:02   #4  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,862
That's an obvious solution Fred, great idea. I was always wondering if depan can be set to have zero inertia, meaning it absolutely stabilizes the scene for each frame, in this case a sprocket image.
jmac698 is offline   Reply With Quote
Old 30th July 2012, 21:24   #5  |  Link
althor1138
Registered User
 
Join Date: Jan 2012
Location: Sweden
Posts: 19
Thanks. Jmac and VideoFred. I have tried both methods now and they both work fairly well.

Centertracker works very good other than the fact that I can't seem to get it to show the whole frame when I'm selecting the area for stabilization. (EDIT: What I mean is that centertracker will open and process the video but the GUI will only show a portion of the frame during area selection) This kind of prevents me from selecting exactly the area I would like. The frames were captured at around 2k resolution. If I could find a way to use centertracker with high resolution video it would be perfect.

Video Fred's script would also work quite well I think but I can't seem to crop down to an area small enough to select only the sprocket holes. It keeps telling me this:

DepanEstimate: DXMAX must be less than WINX/2!

It also doesn't stabilize as well as centertracker but it is pretty acceptable.

Last edited by althor1138; 30th July 2012 at 21:28.
althor1138 is offline   Reply With Quote
Old 30th July 2012, 21:38   #6  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,014
I know that you have already rejected the idea of using Deshaker, but I thought I should nonetheless point out that it does provide the ability to focus just on the outside edges of the video. You use the "Ignore Pixels" settings which lets you define areas of the image that you wish to ignore (the center, from top to bottom, in your case). Deshaker will then stabilize just on the sprockets.
johnmeyer is offline   Reply With Quote
Old 30th July 2012, 21:45   #7  |  Link
althor1138
Registered User
 
Join Date: Jan 2012
Location: Sweden
Posts: 19
I have tried it with many different settings and it never reliably seems to lock onto anything. A person I know has attempted the same thing and even talked with Gunnar about the problem and he said that it wouldn't work so well. Something about the light in the sprocket holes or something. I see that he has a newer version out since the last time I tried it so maybe it will produce better results?
althor1138 is offline   Reply With Quote
Old 30th July 2012, 21:55   #8  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,862
Hi,
Fixing these problems is easy Just crop to the sprocket holes yourself, save that as a script, then load the script as a video to centertracker. Then use it's output but compensate the coordinates to fix the whole frame, if you know what I mean.
jmac698 is offline   Reply With Quote
Old 30th July 2012, 22:16   #9  |  Link
althor1138
Registered User
 
Join Date: Jan 2012
Location: Sweden
Posts: 19
Quote:
Originally Posted by jmac698 View Post
Hi,
Fixing these problems is easy Just crop to the sprocket holes yourself, save that as a script, then load the script as a video to centertracker. Then use it's output but compensate the coordinates to fix the whole frame, if you know what I mean.
This worked nearly flawlessly. It is by far the most stable registration I've achieved. I cropped the image down to an area that covered 2 sprocket holes and stopped just before the next holes. Then set the area about 100 pixels above and below the holes and set the center in the middle.

The auto-generated avs file is flawed though. I had to create a variable that makes a blankclip from the source vid and feed it to scriptclip.
althor1138 is offline   Reply With Quote
Old 31st July 2012, 09:29   #10  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Gent, Flanders, Belgium, Europe, Earth, Milky Way,Universe
Posts: 616
Quote:
Originally Posted by althor1138 View Post
Video Fred's script would also work quite well I think but I can't seem to crop down to an area small enough to select only the sprocket holes. It keeps telling me this:

DepanEstimate: DXMAX must be less than WINX/2!
Try this:

maxstabH=10 (or less)
maxstabV=10

Fred.
__________________
About 8mm film:
http://www.super-8.be
Film Transfer Tutorial and example clips:
https://www.youtube.com/watch?v=W4QBsWXKuV8
More Example clips:
http://www.vimeo.com/user678523/videos/sort:newest
videoFred is offline   Reply With Quote
Old 3rd August 2012, 22:08   #11  |  Link
althor1138
Registered User
 
Join Date: Jan 2012
Location: Sweden
Posts: 19
Quote:
Originally Posted by videoFred View Post
Try this:

maxstabH=10 (or less)
maxstabV=10

Fred.
Thanks a bunch. It now works great and I can crop to the portion I want to.

As a side thing I'm wondering if anybody knows a good way of aligning the optical audio from a second worth of frames into 1 long frame?
althor1138 is offline   Reply With Quote
Old 4th August 2012, 14:41   #12  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,862
I think you want freezeframe.
jmac698 is offline   Reply With Quote
Old 24th August 2012, 18:57   #13  |  Link
happyvideo
Registered User
 
Join Date: Apr 2011
Posts: 3
Quote:
Originally Posted by althor1138 View Post
Centertracker works very good other than the fact that I can't seem to get it to show the whole frame when I'm selecting the area for stabilization. (EDIT: What I mean is that centertracker will open and process the video but the GUI will only show a portion of the frame during area selection) This kind of prevents me from selecting exactly the area I would like. The frames were captured at around 2k resolution. If I could find a way to use centertracker with high resolution video it would be perfect.
this is due to OpenCV's window handling. The maximum display size depends on the resultion of your screen. If it is for example 1280x800 that will be the maximum size. Anything larger than that will be cropped. I've checked if there's a workaround. Resizing is possible:

http://opencv.willowgarage.com/documentation/c/highgui_qt_new_functions.html

however, with the smaller image choosing the area becomes impossible. I will keep an eye on that issue and if there's a solution I'll implement it.

Thus, setting the screen resolution to the desired dimensions (if possible) is the only method to deal with it so far.

Stephan

ps. sry for the late reply, just found the topic
happyvideo is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:18.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.