View Full Version : Crop question
jennymae
18th May 2006, 14:57
Hello,
I am sure this is way beyond what Avisynth can do but here goes. I want to crop a video so that the focus is on, for example, a face. Then as the video plays and the person moves around, I want to keep the face centered within the cropped area. Kind of a floating crop. Any way I can do this?
Thank you.
As far as I know nobody has written anything to explicitly track the motion of a face. There has been some work done with Motion Vector analysis, mostly towards interpolating missing frames and extra frames for intelligent frame rate conversion. Something possibly could be done with the raw motion vector data to track a given starting point through subsequent frames, at least for short durations.
For a brute force approach you could manually plot the motion of say the tip of the nose and produce some parameter files to use with ScriptClip and ConditionalReader. E.g. Take the X and Y position every 10 frames, put the data into Excel and fit a spline or curve to generate the 9 intervening values in a smooth manner.
...
ConvertToRGB32() # YUV formats have mod2 restrictions
ScriptClip("Crop(CropX, CropY, 160, 120)")
# CropX+160 must not exceed Width()
ConditionalReader("file_X.txt", "CropX", false)
# CropY+120 must not exceed Height()
ConditionalReader("file_Y.txt", "CropY", false)A more accurate approach might be to use the crop parameters of the resizers, these are floats and would give subpixel accuracy....
ScriptClip("LanzosResize(640, 480, CropX, CropY, 160.0, 120.0)")
# CropX+160.0 should not exceed input Width()
ConditionalReader("file_X.txt", "CropX", false)
# CropY+120.0 should not exceed input Height()
ConditionalReader("file_Y.txt", "CropY", false)
hanfrunz
29th May 2006, 20:27
Hello jennymae,
you have more fun doing that with a compositing tool like shake, combustion, after effects ...
Their trackers are very powerfull.
hanfrunz
Hmm.. what about saving image sequence, cropping manually and reencoding? It's slow but it should work..
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.