Permalink
Browse files

Add scale control to SyGeo

for non-default geometries
  • Loading branch information...
julik committed May 29, 2012
1 parent 68c2892 commit 44cd51955a93dfdebf2820886b2b39f24c6275fb
Showing with 100 additions and 84 deletions.
  1. +6 −0 README.markdown
  2. +78 −81 sample_scripts/sample.nk
  3. +2 −0 src/SyDistorter.cpp
  4. +14 −3 src/SyGeo.cpp
View
@@ -189,6 +189,12 @@ Sometimes you are dealing with off-center lens distortion. This can occur when a
Sometimes you are dealing with off-center lens distortion. This can occur when a lens is fitted onto the camera but not properly centered onto the sensor (some lens adapters are especially susceptible to this, like the anamorphic Alexa fittings). Apply some margin here to shift your distortion midpoint up or down with regards to the center of your digital plate.
+#### scale
+
+This defines the relationship between the coordinates in the camera frustum and your geometry. When using SyGeo
+with Card nodes, for example, the factor is set to 2 since the outermost left and right points are offset by 0.5 from
+the origin of the Card. The Syntheyes algorithm, however, needs the coordinates to be in the -1..1 range so there is a
+scaling operation involved when doing distortions. For Card nodes you can leave this parameter at it's default setting.
## The SyCamera node
View
@@ -180,31 +180,31 @@ Dot {
xpos 191
ypos -1172
}
-set N5b18a00 [stack 0]
+set N5dcb600 [stack 0]
Dot {
name Dot4
xpos 531
ypos -1172
}
-set N5dbae00 [stack 0]
+set N5ddd800 [stack 0]
Dot {
name Dot5
xpos 663
ypos -1172
}
-set N5cc0600 [stack 0]
+set N5dccc00 [stack 0]
Dot {
name Dot10
xpos 1936
ypos -1172
}
-set N5cc0a00 [stack 0]
+set N5dcd000 [stack 0]
Dot {
name Dot6
xpos 1936
ypos -812
}
-set N5cb9800 [stack 0]
+set N5a87800 [stack 0]
Dot {
name Dot7
xpos 1390
@@ -256,19 +256,19 @@ StickyNote {
xpos 2438
ypos -439
}
-push $N5cc0a00
+push $N5dcd000
Dot {
name Dot11
xpos 2843
ypos -1172
}
-set N5d53e00 [stack 0]
+set N5cc5200 [stack 0]
Dot {
name Dot13
xpos 3823
ypos -1176
}
-set N5d54200 [stack 0]
+set N5cc5600 [stack 0]
Card2 {
lens_in_distortion -0.01826
control_points {3 3 3 6
@@ -312,7 +312,7 @@ Camera2 {
xpos 354
ypos -665
}
-push $N5dbae00
+push $N5ddd800
Card2 {
rows 32
columns 32
@@ -359,22 +359,21 @@ ScanlineRender {
xpos 497
ypos -501
}
-set N5df5e00 [stack 0]
-push $N5cc0600
+push $N5dccc00
Difference {
inputs 2
output rgba.red
name Difference1
xpos 629
ypos -506
}
-push $N5d53e00
+push $N5cc5200
Dot {
name Dot8
xpos 2849
ypos -802
}
-set N5df8a00 [stack 0]
+set N5cce000 [stack 0]
Dot {
name Dot9
xpos 3341
@@ -393,7 +392,7 @@ Camera2 {
xpos 2961
ypos -614
}
-push $N5df8a00
+push $N5cce000
SyShader {
shader_type "fragment shader"
k {{parent.SyLens1.k i}}
@@ -445,7 +444,7 @@ SyCamera {
xpos 2049
ypos -617
}
-push $N5cb9800
+push $N5a87800
SyShader {
k {{parent.SyLens2.k i}}
kcube {{parent.SyLens2.kcube i}}
@@ -493,7 +492,7 @@ Camera2 {
xpos 4492
ypos -657
}
-push $N5d54200
+push $N5cc5600
BlackOutside {
name BlackOutside1
xpos 4509
@@ -504,7 +503,7 @@ Dot {
xpos 4647
ypos -1172
}
-set N5e0e400 [stack 0]
+set N5e10000 [stack 0]
Cube {
cube {-0.5099999905 -0.5 -0.5 0.5 0.3950000107 0.4839999974}
translate {-1.876000047 0 0}
@@ -518,8 +517,8 @@ SyUV {
xpos 4674
ypos -859
}
-set C5e11a00 [stack 0]
-push $N5e0e400
+set C5e16400 [stack 0]
+push $N5e10000
Sphere {
rows 32
columns 32
@@ -528,12 +527,12 @@ Sphere {
xpos 4474
ypos -905
}
-clone $C5e11a00 {
+clone $C5e16400 {
xpos 4474
ypos -861
selected false
}
-push $N5e0e400
+push $N5e10000
Card2 {
rows 32
columns 32
@@ -553,7 +552,7 @@ Card2 {
xpos 4867
ypos -912
}
-clone $C5e11a00 {
+clone $C5e16400 {
xpos 4867
ypos -866
selected false
@@ -596,7 +595,7 @@ Camera2 {
xpos 3980
ypos -930
}
-push $N5d54200
+push $N5cc5600
SyShader {
shader_type "fragment shader"
k -0.01826
@@ -637,56 +636,6 @@ ScanlineRender {
xpos 3789
ypos -759
}
-SyCamera {
- inputs 0
- translate {-9.442873001 0 14.11524296}
- rotate {0 -33.60035406 0}
- focal 149
- k {{curve x17 -0.01826}}
- aspect 1.316195373
- name SyCamera3
- xpos 5101
- ypos -650
-}
-push $N5e0e400
-Dot {
- name Dot17
- xpos 5269
- ypos -1172
-}
-Card2 {
- rows 16
- columns 16
- control_points {3 3 3 6
-
-1 {-0.5 -0.5 0} 0 {0.1666666865 0 0} 0 {0 0 0} 0 {0 0.1666666865 0} 0 {0 0 0} 0 {0 0 0}
-1 {0 -0.5 0} 0 {0.1666666716 0 0} 0 {-0.1666666716 0 0} 0 {0 0.1666666865 0} 0 {0 0 0} 0 {0.5 0 0}
-1 {0.5 -0.5 0} 0 {0 0 0} 0 {-0.1666666865 0 0} 0 {0 0.1666666865 0} 0 {0 0 0} 0 {1 0 0}
-1 {-0.5 0 0} 0 {0.1666666865 0 0} 0 {0 0 0} 0 {0 0.1666666716 0} 0 {0 -0.1666666716 0} 0 {0 0.5 0}
-1 {0 0 0} 0 {0.1666666716 0 0} 0 {-0.1666666716 0 0} 0 {0 0.1666666716 0} 0 {0 -0.1666666716 0} 0 {0.5 0.5 0}
-1 {0.5 0 0} 0 {0 0 0} 0 {-0.1666666865 0 0} 0 {0 0.1666666716 0} 0 {0 -0.1666666716 0} 0 {1 0.5 0}
-1 {-0.5 0.5 0} 0 {0.1666666865 0 0} 0 {0 0 0} 0 {0 0 0} 0 {0 -0.1666666865 0} 0 {0 1 0}
-1 {0 0.5 0} 0 {0.1666666716 0 0} 0 {-0.1666666716 0 0} 0 {0 0 0} 0 {0 -0.1666666865 0} 0 {0.5 1 0}
-1 {0.5 0.5 0} 0 {0 0 0} 0 {-0.1666666865 0 0} 0 {0 0 0} 0 {0 -0.1666666865 0} 0 {1 1 0} }
- name Card6
- xpos 5235
- ypos -749
-}
-SyGeo {
- k -0.01826
- aspect 1.31619537
- name SyGeo1
- xpos 5235
- ypos -725
-}
-push 0
-ScanlineRender {
- inputs 3
- output_motion_vectors_type accurate
- name ScanlineRender6
- xpos 5235
- ypos -629
-}
StickyNote {
inputs 0
name StickyNote7
@@ -695,7 +644,7 @@ StickyNote {
xpos 5049
ypos -544
}
-push $N5b18a00
+push $N5dcb600
Dot {
name Dot2
xpos 191
@@ -706,7 +655,7 @@ Dot {
xpos -11
ypos -657
}
-set N5d76200 [stack 0]
+set N5e31a00 [stack 0]
SyLens {
k {{curve i x50 -0.01826 x114 -0.01826}}
filter Parzen
@@ -715,7 +664,7 @@ SyLens {
xpos -172
ypos -665
}
-set N5d76600 [stack 0]
+set N5e31e00 [stack 0]
Transform {
scale {1 1.56}
center {1024 617}
@@ -734,7 +683,7 @@ SyLens {
xpos -172
ypos -542
}
-push $N5b18a00
+push $N5dcb600
Dot {
name Dot16
xpos -454
@@ -764,7 +713,7 @@ SyLens {
xpos -690
ypos -583
}
-push $N5d76600
+push $N5e31e00
SyLens {
output "apply disto"
k {{curve x1 -0.01826 x114 -0.01826}}
@@ -775,19 +724,67 @@ SyLens {
xpos 50
ypos -547
}
-push $N5d76200
+push $N5e31a00
Difference {
inputs 2
output rgba.red
name Difference2
xpos -45
ypos -483
}
-push $N5df5e00
+SyCamera {
+ inputs 0
+ translate {-9.442873001 0 14.11524296}
+ rotate {0 -33.60035406 0}
+ focal 149
+ k {{curve i x17 -0.01826}}
+ aspect 1.316195373
+ name SyCamera3
+ xpos 5101
+ ypos -650
+}
+push $N5e10000
+Dot {
+ name Dot17
+ xpos 5269
+ ypos -1172
+}
+Card2 {
+ rows 16
+ columns 16
+ control_points {3 3 3 6
+
+1 {-0.5 -0.5 0} 0 {0.1666666865 0 0} 0 {0 0 0} 0 {0 0.1666666865 0} 0 {0 0 0} 0 {0 0 0}
+1 {0 -0.5 0} 0 {0.1666666716 0 0} 0 {-0.1666666716 0 0} 0 {0 0.1666666865 0} 0 {0 0 0} 0 {0.5 0 0}
+1 {0.5 -0.5 0} 0 {0 0 0} 0 {-0.1666666865 0 0} 0 {0 0.1666666865 0} 0 {0 0 0} 0 {1 0 0}
+1 {-0.5 0 0} 0 {0.1666666865 0 0} 0 {0 0 0} 0 {0 0.1666666716 0} 0 {0 -0.1666666716 0} 0 {0 0.5 0}
+1 {0 0 0} 0 {0.1666666716 0 0} 0 {-0.1666666716 0 0} 0 {0 0.1666666716 0} 0 {0 -0.1666666716 0} 0 {0.5 0.5 0}
+1 {0.5 0 0} 0 {0 0 0} 0 {-0.1666666865 0 0} 0 {0 0.1666666716 0} 0 {0 -0.1666666716 0} 0 {1 0.5 0}
+1 {-0.5 0.5 0} 0 {0.1666666865 0 0} 0 {0 0 0} 0 {0 0 0} 0 {0 -0.1666666865 0} 0 {0 1 0}
+1 {0 0.5 0} 0 {0.1666666716 0 0} 0 {-0.1666666716 0 0} 0 {0 0 0} 0 {0 -0.1666666865 0} 0 {0.5 1 0}
+1 {0.5 0.5 0} 0 {0 0 0} 0 {-0.1666666865 0 0} 0 {0 0 0} 0 {0 -0.1666666865 0} 0 {1 1 0} }
+ name Card6
+ xpos 5235
+ ypos -749
+}
+SyGeo {
+ k -0.01826
+ aspect 1.31619537
+ name SyGeo2
+ xpos 5235
+ ypos -725
+}
+push 0
+ScanlineRender {
+ inputs 3
+ output_motion_vectors_type accurate
+ name ScanlineRender6
+ xpos 5235
+ ypos -629
+}
Viewer {
input_process false
name Viewer3
- selected true
xpos 4349
ypos -759
}
View
@@ -120,6 +120,8 @@ with our given one. This has a number of disadvantages. First of all, it's going
more we go to the outside of the image frame since the same difference in radius will produce a bigger
distortion. Second, it's kind of slow. However, not many points outside of the image will be estimated that way
but only a handful, so this method will end up unused most of the time.
+At some point the f(r) function goes negative - this is where a wraparound occurs. At this point we will give
+up with undistortion because the image will likely wrap around and the alrogithm becomes kind of unpredictable.
*/
double SyDistorter::undistort_approximated(double rp)
{
Oops, something went wrong.

0 comments on commit 44cd519

Please sign in to comment.