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 28th January 2020, 07:38   #1  |  Link
redfordxx
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)
Script example:
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
""")
Another script:
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
Attached Files
File Type: zip Rotations.0.2.avsi.zip (2.3 KB, 13 views)

Last edited by redfordxx; 6th February 2020 at 14:36. Reason: Heureka!
redfordxx is offline   Reply With Quote
Old 28th January 2020, 10:31   #2  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,101
I don't understand what you are trying to do. Please draw a diagram of the camera and the subject and mark the axis of rotation.
TheFluff is offline   Reply With Quote
Old 28th January 2020, 11:30   #3  |  Link
redfordxx
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?
redfordxx is offline   Reply With Quote
Old 28th January 2020, 11:32   #4  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,101
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:
          +--+
          |  |
   +------+  |
   |         |
   +------+  |
          |  |
          +--+
The lens is pointing to the left, of course. Now, is the X axis parallel with the the lens (as in, horizontal in the diagram), is it parallel with the ground but perpendicular to the lens (as in, vertical in the diagram), or is it perpendicular to both of them (coming out of the screen in the diagram)?
TheFluff is offline   Reply With Quote
Old 28th January 2020, 11:37   #5  |  Link
redfordxx
Registered User
 
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
No.
I thought the lens is looking as I am looking on the monitor. In your picture x is vertical.
redfordxx is offline   Reply With Quote
Old 28th January 2020, 11:44   #6  |  Link
redfordxx
Registered User
 
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
... and z is in your picture horizontal and y is going though the ground.
redfordxx is offline   Reply With Quote
Old 28th January 2020, 16:27   #7  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,343
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
johnmeyer is offline   Reply With Quote
Old 28th January 2020, 17:04   #8  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,101
Quote:
Originally Posted by johnmeyer View Post
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.
I... don't think has anything to do with the question in the OP.

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.
TheFluff is offline   Reply With Quote
Old 28th January 2020, 17:58   #9  |  Link
redfordxx
Registered User
 
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
Exactly Fluff... thank you.
You assume quad is not the way to do in in avs?
redfordxx is offline   Reply With Quote
Old 28th January 2020, 18:22   #10  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,101
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.
TheFluff is offline   Reply With Quote
Old 29th January 2020, 10:06   #11  |  Link
redfordxx
Registered User
 
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
I am starting to be mad...
I am drawing triangles everywhere... and still no success.
I didn.t think it would be difficult. But I don't know what I am missing.
redfordxx is offline   Reply With Quote
Old 29th January 2020, 18:39   #12  |  Link
redfordxx
Registered User
 
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
I think I figured it out. I am gonna test it.
redfordxx is offline   Reply With Quote
Old 30th January 2020, 10:50   #13  |  Link
redfordxx
Registered User
 
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
I have some results already. Only it is misbehaving when rotating along two axes.
I will share soon results hopefully...
redfordxx is offline   Reply With Quote
Old 31st January 2020, 21:30   #14  |  Link
redfordxx
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
These are working formulas. I'll soon share the finished function.

Before that...can anyone simplify this?
redfordxx is offline   Reply With Quote
Old 2nd February 2020, 14:42   #15  |  Link
redfordxx
Registered User
 
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
I finished the script and posted.... there are still some todos...
redfordxx is offline   Reply With Quote
Old 2nd February 2020, 15:57   #16  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 8,466
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.
StainlessS is offline   Reply With Quote
Old 4th February 2020, 12:37   #17  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 8,466
Bump!

Quote:
Originally Posted by stainlesss View Post
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 ???
StainlessS is offline   Reply With Quote
Old 4th February 2020, 13:33   #18  |  Link
redfordxx
Registered User
 
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
Quote:
Originally Posted by StainlessS View Post
Can attachment be approved please Mr Moderator. [EDIT: In 1st post]
Should I better share attachments via links? What is best server easier without registering?

StainlessS, you have full PM quota...😉
redfordxx is offline   Reply With Quote
Old 4th February 2020, 16:32   #19  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 8,466
Quote:
What is best server easier without registering?
SendSpace(30 day storage), and Pastebin(text only), PostImage (images only) do not req register
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:
you have full PM quota
Yep, stops people like you from bothering me.
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 ???
StainlessS is offline   Reply With Quote
Old 4th February 2020, 17:25   #20  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,372
Nice work!
poisondeathray 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 15:32.


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