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. |
28th January 2020, 07:38 | #1 | Link |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
Rotation: New script!
EDIT:Hours and hours and I didn't give up.
Script for camera rotation around x and y axes in the attachment. You need to enter FoV, direction and amount of the rotation ... all in degrees. Basic usage: Code:
FoV=65 deg_dir=30 deg_amt=10 ColorBars().Trim(0,1000).Killaudio() RotateCamera(FoV, deg_dir, deg_amt, add_borders=-512) Code:
borders=240 FoV=65 dir_speed=5.0 amt_speed=0.5 ColorBars(pixel_type="YV12").Trim(0,10000).Killaudio() AddBorders(borders,borders,borders,borders,$000000) ScriptClip(""" RotateCamera(FoV, dir_speed*current_frame, amt_speed*current_frame, has_borders=borders, info=true, qq=4) ConvertToYV12 """) Code:
tested_frame=3167 #### camera FoV=62.55934 #### script layers=8 base_dir_step=45 ################## setup amount # borders for amount 2 maxamt=8.0 max_borders=160 min_borders=80 # borders for amount 3 #maxamt=3.0 #max_borders=80 #min_borders=40 # borders for amount 4 #maxamt=4.0 #max_borders=120 #min_borders=60 ##### precalc frcnt=floor(layers*(layers+1)*180/base_dir_step) amt_step=maxamt/layers #clip a=LSMASHVideoSource("....",format="RGB32").AddBorders(max_borders,max_borders,max_borders,max_borders,$FF00FF) c0=a.Trim(tested_frame,-1).Loop(frcnt+1) c0.ScriptClip(""" c=last cf=current_frame-1 lvl=(cf<0) ? 0 : floor((1+sqrt(1+4*cf*base_dir_step/180))/2) dir=(cf<0) ? 0 : cf*base_dir_step/lvl-(lvl-1)*180 amt=lvl*amt_step c.RotateCamera(FoV, dir, amt, has_borders=max_borders, info=false, qq=4, lock_central=true) (1==1) ? last : last.Subtitle("current_frame = "+string(current_frame)+"\n" +\ "layers = "+string(layers)+"\n" +\ "frcnt = "+string(frcnt)+"\n" +\ "base_dir_step = "+string(base_dir_step)+"\n" +\ "lvl = "+string(lvl)+"\n" +\ "dir = "+string(dir)+"\n" +\ "amt = "+string(amt)+"\n" +\ "amt_step = "+string(amt_step)+"\n" \ ,lsp=0) #ConvertToYV12 """) Crop(max_borders-min_borders,max_borders-min_borders,-(max_borders-min_borders),-(max_borders-min_borders)) Warp needed Last edited by redfordxx; 6th February 2020 at 14:36. Reason: Heureka! |
28th January 2020, 11:30 | #3 | Link |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
I thought it would be unerstandable from the other post. My fault.
Ok. I cannot draw right now, but... I have four points in the real world. They will appear as four pixels on the screen with coordinates (x1,y1) ... (x4,y4). I will rotate the camera down around the x axis. What will be the new pixel coordinates of these four points? |
28th January 2020, 11:32 | #4 | Link |
Excessively jovial fellow
Join Date: Jun 2004
Location: rude
Posts: 1,100
|
The problem is I don't know which convention you're using for axis naming. Let's do some ascii art. Say we're looking at a camera from directly above it:
Code:
+--+ | | +------+ | | | +------+ | | | +--+ |
28th January 2020, 16:27 | #7 | Link |
Registered User
Join Date: Feb 2002
Location: California
Posts: 2,695
|
Not sure where the tangent function comes in.
The camera rotates horizontally and, in most systems, that angle of rotation would be described by either a sine or cosine function (they are, as you probably know, pretty much interchangeable in many equations). The camera can then go up or down, and that too would be described in the same way. You also might have a camera rotation. There can also be an up or down and back and forth (basicially, a dolly move). Finally, the camera itself might rotate on some sort of gimbal so it can it can rotate upside down. If you want answers, you might get help by Googling: drone camera gimbal "equations" sin cos [edit]I just glanced at some of the results and the modeling can get pretty hairy, depending on what you're trying to do, because when you change one of the servo motors, depending on how the gimbal is contructed, that can alter the mechanics of the other parts of the mechanism. Last edited by johnmeyer; 28th January 2020 at 16:33. Reason: modified search string |
28th January 2020, 17:04 | #8 | Link | |
Excessively jovial fellow
Join Date: Jun 2004
Location: rude
Posts: 1,100
|
Quote:
As far as I understand it, what OP is asking for is basically a 3D perspective transform, except in a rather roundabout way. Consider the upper diagram in this image: We have a camera located at C and a camera-referenced coordinate system with three axes denoted by capital X, Y and Z. We're pretending that the video frame is the image plane (perhaps thinking of it as a flat plane that perfectly fills the camera viewport at this particular distance from C), and so we also have a two-dimensional view-referenced coordinate system with two axes (x and y). Now, if we tilt the camera down by some angle (rotating it around the X axis), we want to find the view-referenced coordinates for the corners of the image, so we can feed them to the quad() filter. I'm not experienced enough with 3D to solve this, but it seems relatively obnoxious and probably involves some coordinate transforms (c.f. OpenGL's various coordinate systems). I think it's actually made more complex by involving quad(), but again I'm not all that well versed in 3D graphics. Last edited by TheFluff; 28th January 2020 at 17:10. |
|
28th January 2020, 18:22 | #10 | Link |
Excessively jovial fellow
Join Date: Jun 2004
Location: rude
Posts: 1,100
|
I don't really know, to be honest. I don't know of any other filter that can do this sort of perspective transform off the top of my head. Something about the conversion to view-referenced coordinates seems like overcomplicating things to me, but that's just a hunch. Don't take my word for it, I've barely touched 3D stuff at all.
|
31st January 2020, 21:30 | #14 | Link |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
Simplification?
Code:
d=x*SIN(rad_dir)+y*COS(rad_dir) r=Sqrt( (Pow(TAN(ATAN(d)+rad_amt),2)+1)/(Pow(d,2)+1) ) x_new=x*r+TAN(ATAN(d)+rad_amt)*SIN(rad_dir)-d*SIN(rad_dir)*r #new value x y_new=y*r+TAN(ATAN(d)+rad_amt)*COS(rad_dir)-d*COS(rad_dir)*r #new value y Before that...can anyone simplify this? |
2nd February 2020, 15:57 | #16 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Thanks for your herculean effort red, much appreciated.
Can attachment be approved please Mr Moderator. [EDIT: In 1st post]
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 2nd February 2020 at 17:47. |
4th February 2020, 12:37 | #17 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Bump!
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
4th February 2020, 13:33 | #18 | Link | |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
Quote:
StainlessS, you have full PM quota...😉 |
|
4th February 2020, 16:32 | #19 | Link | ||
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
https://www.sendspace.com/ https://pastebin.com/ https://postimage.org/ PostImage sometimes slips in a link (following forum embedded image) that points to some advert, just need edit out the appended link [does not happen if register]. MediaFire(big files, req register), I currently have more than 50GB free storage(not sure exactly how much, I only use a few hundred MB, allowance grows with membership time). Quote:
Cleared to 99.0%.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
||
|
|