View Full Version : hmotion with mvtools2; undocumented 'levels'


jmac698
23rd December 2010, 00:23
Hi,
I need to analyze motion by line only. So I am using a trick, where I vertical pointresize by 8 (or whatever blksizeV is). I want to restrict the motion search quite a bit because I have a priori knowledge of the movement. The entire 720x8 block moves +-3 pixels. So I will use the new horizontal search feature, but I also want to use the levels parameter, which is not fully documented, to restrict the hierarchy because I know every pixel is moving the same way, and also to prevent false detection of individual pixels moving different from it's neighbours. Hint: the clip is extremely noisy. I'm trying to use the biggest blksize and most smoothing. This is part of a denoiser itself; I can't denoise beforehand. Detecting over as many pixels as possible at once (like a global motion) should work fine.
Here's what I'm trying to piece together so far but I can't finish this without advanced help:

bsizeH=16
bsizeV=8#valid for bsizeH=8 or 16
idontknow=0
a=avisource("test1.avi")
b=avisource("test2.avi")#exactly same as a, but with noise and hshift
interleave(b,a)
assumeframebased
pointresize(last.width,last.height*bsizeV)
video=last
super=MSuper(video,hpad=bsizeH,vpad=bsizeV,pel=2,levels=idontknow,chroma=false, sharp=0,rfilter=4)
vectors=MVAnalyse(super,blksize=bsizeH,blksizeV=bsizeV,levels=idontknow, search=6,isb=false,delta=1,truemotion=true).selectevery(2,0)#keep only b1 relative to a1 and ignore b2 relative to a1
MCompsensate(a,super,vectors)#make a shifted like b
newa=last
overlay(newa,b,opacity=.5)#average them to denoise
#return MShow#for tweaking

I would use MDepan but, it's slow and awkward to slice a clip into 720x8 sections of one long video.
This is pretty advanced I hope an expert can help! Thanks.

jmac698
23rd December 2010, 00:48
I'm getting no named argument blksizeV also truemotion and access violation...

yup
23rd December 2010, 07:43
jmac698
MVTools2 doc
blksize : Size of a block (horizontal). It's either 4, 8 or 16 ( default is 8 ). Larger blocks are less sensitive to noise, are faster, but also less accurate.

blksizeV : vertical size of a block. Default is equal to horizontal size. Additional options: 4 for blksize=8 and 8 or 2 for blksize=16.
You can use blksize=16 and blksizev=2.
If want get accuracy one line before increase clip vertically by 2 factor (any resizer or for best result nnedi3(dh=true,field=0)).
Try also hardware solution http://www.cypress.com.tw/english/display.asp?id=310&Time=1293090432460
When I starting use this unit between VCR and PC I get always stable left border.
yup.

Didée
23rd December 2010, 09:02
You're surely using a recent MVtools2 version? "No named argument blksizeV" shouldn't be with a recent version.

Script bugs:

- "levels" must not be zero. It has to be at least levels=1.
EDIT: Oops, it may be zero. It's actually the default, including ALL possible levels.

- "vectors" and "MCompensate" refer to a single clip, but "super" still refers to the interleave of two clips. I.e. within Mompensate, super clip and base clip are out of sync. MCompensate can not work correctly this way.

video=last
super=MSuper(video,hpad=bsizeH,vpad=bsizeV,pel=2,levels=idontknow,chroma=false, sharp=0,rfilter=4)
vectors=MVAnalyse(super,blksize=bsizeH,blksizeV=bsizeV,levels=idontknow, search=6,isb=false,delta=1,truemotion=true)
MCompsensate(video,super,vectors)#make a shifted like b
newa=last.selectevery(2,0) # maybe (2,1)

Gavino
23rd December 2010, 09:46
I'm getting no named argument blksizeV also truemotion and access violation...
vectors=MVAnalyse(super,blksize=bsizeH,blksizeV=bsizeV,levels=idontknow, search=6,isb=false,delta=1,truemotion=true)...
Should be MAnalyse(...)

Do you have both old and new MVTools in your plugins folder?

jmac698
28th December 2010, 08:19
Thanks, I got past those problems. I'm working on a slightly different problem now.
I have a square which is cut out of a rectangle (you can call this pan and scan or Ken Burns effect).
I'd like to find the rigid transformation between the two, that is find where the square corresponds in the rectangle.
Translating this problem into mvtools, first I use a trick to compare the two videos; interleave(square,rectangle). Thus on frame 1, I get the motion from square into rectangle. At the end I will use selectevery(2,1) to keep only these comparisons (where 2,0 would be the rectangle->square transform).
I noticed some odd things, for example search=4 will fail with a big error, when it works fine in the surrounding frames. I think it took a 'wrong turn' in estimating motion by blocks and couldn't find the result even though it's possible. That would be my first hint that only exhaustive search could work.

Q1. For this reason and for speed, I'd like to know when search failed in script and then fallback to a different search pattern, or else simply use the last working transform.

Q2. Ultimately I want to place the square back on top of the rectangle. Colorkey seems the only way to do this, although if MDepan could only give me dx,dy,zoom in script form I could just use overlay! Anyhow, how can I colorkey and use an out of range color which could never appear in any video?

Q3. I noticed that the match fails if the pixel aspects are not the same. I tried the pixaspect setting but it seemed to have no effect, but when I physically resize the square I can get it to match again. Is there no plugin that can match freely zoom in x and y? For example the simple problem of finding the anamorphic ratio between say, a DVD (~1.78:1) and a HD (1:1) (Why would I want to do this? We don't always know if DVD is ITU sized or some other ratio; just one picture say publicity still can give us the true squeeze).

Q4: Fizick, Manao, et all, I'd like to propose new feature, to return dx,dy,rot,zoom, err, match=true|false into runtime variables. That would help a lot! Second I would like semiglobal motion, by one horizontal line each.