Forums > Jitter

WideAngle/FishEye-Lens – How to compensate?

December 13, 2006 | 2:55 pm

Hi folks,

i was wondering how to process a live video input in order to get rid of the distortion…?! (because of the fisheye-lens)
are there already predefined-objects in JITTER to do so? are there externals out there?

if not, which expression has to be applied, i.e. on a slab?

thanks in adv.,

daniel


December 13, 2006 | 4:42 pm

jit.repos, and you could make a map with jit.expr, or create geometry
to texture on to in opengl

On Dec 13, 2006, at 9:55 AM, Daniel Klotz wrote:

>
> Hi folks,
>
> i was wondering how to process a live video input in order to get
> rid of the distortion…?! (because of the fisheye-lens)
> are there already predefined-objects in JITTER to do so? are there
> externals out there?
>
> if not, which expression has to be applied, i.e. on a slab?
>
> thanks in adv.,
>
> daniel

v a d e //

http://www.vade.info
abstrakt.vade.info


December 13, 2006 | 5:21 pm

Or use the td.fisheye.jxs shader :)

On Dec 13, 2006, at 11:42 AM, vade wrote:

> jit.repos, and you could make a map with jit.expr, or create
> geometry to texture on to in opengl
>
> On Dec 13, 2006, at 9:55 AM, Daniel Klotz wrote:
>
>>
>> Hi folks,
>>
>> i was wondering how to process a live video input in order to get
>> rid of the distortion…?! (because of the fisheye-lens)
>> are there already predefined-objects in JITTER to do so? are there
>> externals out there?
>>
>> if not, which expression has to be applied, i.e. on a slab?
>>
>> thanks in adv.,
>>
>> daniel
>
> v a d e //
>
> http://www.vade.info
> abstrakt.vade.info
>
>
>

v a d e //

http://www.vade.info
abstrakt.vade.info


December 13, 2006 | 5:55 pm

From the archives: (search on "lens distortion")

http://www.cycling74.com/forums/index.php?t=msg&goto=80211#msg_80211

I’ve included the patch below for your convenience. Unfortunately,
the forum/wiki software introduces linebreaks in screwy places so if
you just copy/paste from the forum, the patch won’t work since it
possibly adds a carriage return at places like:

"snorm
[0]"

which need to be "snorm[0]" for jit.expr to work. If you see patches
with weird linebreaks in the object boxes, I’d just try deleting the
line breaks from the boxes manually post paste (or subscribe to email
version of the forum, I guess).

This is *totally* annoying I know, but doubt we’ll get around to
changing this aspect for the forum software in the immediate future.
Sorry.

-Joshua

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 805 113 188 196617 anamorphic barrel/pin;
#P flonum 844 129 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 805 129 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 805 149 49 196617 pak 0. 0.;
#P newex 306 138 48 196617 loadbang;
#P comment 541 219 97 196617 feed radius as input;
#P newex 306 215 220 196617 jit.expr @expr "hypot(snorm[0]\,snorm
[1])";
#P number 121 252 35 9 0 4 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 121 271 71 196617 boundmode $1;
#P user jit.pwindow 445 364 322 242 0 0 0 0 1 0;
#P flonum 637 130 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 186 295 127 196617 jit.matrix 2 long 320 240;
#P newex 446 295 68 196617 jit.normalize;
#P window linecount 2;
#P newex 306 238 341 196617 jit.expr @expr "256*(dim[0]-1)*(0.5
+0.5*snorm[0]/(1.+in[1]*in[0]*in[0]))" "256*(dim[1]-1)*(0.5+0.5*snorm
[1]/(1.+in[1]*in[0]*in[0]))";
#P window linecount 1;
#P newex 306 193 142 196617 jit.matrix 2 float32 320 240;
#P user jit.fpsgui 83 610 60 196617 0;
#P message 192 141 28 196617 stop;
#P button 306 174 15 0;
#P user jit.pwindow 82 364 322 242 0 1 0 0 1 0;
#P newex 83 319 113 196617 jit.repos @interpbits 8;
#B color 5;
#P flonum 224 120 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 224 141 42 196617 rate $1;
#P message 161 141 28 196617 read;
#P flonum 117 120 35 9 0.5 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 83 120 15 0;
#P newex 83 140 44 196617 metro 2;
#P newex 83 176 103 196617 jit.qt.movie 320 240;
#P comment 637 114 100 196617 barrel/pin;
#P window linecount 5;
#P comment 703 244 341 196617 expr version of the following , using
snorm for delta , zero centered coordinates , and taking into
account interpbits ; delta = incoord-center ; radius = hypot
(delta.x , delta.y) ; outcoord = center + (delta/(1.
+k*radius*radius)) ;;
#P fasten 25 0 11 0 810 169 311 169;
#P fasten 25 0 15 1 810 216 642 216;
#P fasten 18 0 11 0 642 169 311 169;
#P connect 18 0 15 1;
#P connect 15 0 17 0;
#P connect 15 0 16 0;
#P connect 22 0 15 0;
#P connect 14 0 22 0;
#P connect 4 0 3 0;
#P fasten 3 0 2 0 88 169 88 169;
#P fasten 12 0 2 0 197 169 88 169;
#P fasten 7 0 2 0 229 169 88 169;
#P fasten 6 0 2 0 166 169 88 169;
#P connect 2 0 9 0;
#P connect 20 0 9 0;
#P connect 9 0 10 0;
#P connect 10 0 13 0;
#P connect 5 0 3 1;
#P connect 21 0 20 0;
#P connect 17 0 9 1;
#P connect 8 0 7 0;
#P connect 24 0 11 0;
#P connect 11 0 14 0;
#P connect 16 0 19 0;
#P connect 26 0 25 0;
#P connect 27 0 25 1;
#P window clipboard copycount 29;


December 13, 2006 | 6:14 pm

Take a look at the documentation offered with the MXR-toolkit:

http://mxrtoolkit.sourceforge.net/

It gives a very clear idea about what is involved, as well as the code necessary to do the work. One of the exe’s offered free spits out the necessary transformations as text, and this can serve as a general lense-calibration for you (you generally only have to do the test once and use it whenever you use the lense.)


December 14, 2006 | 10:52 pm

fantastic!

now i just need to rig up a shader for that, and you’ve got instant
perfect project-onto-geodesic-dome hotness.

On Dec 13, 2006, at 12:55 PM, Joshua Kit Clayton wrote:

>
> From the archives: (search on "lens distortion")
>
> http://www.cycling74.com/forums/index.php?t=msg&goto=80211#msg_80211
>
> I’ve included the patch below for your convenience. Unfortunately,
> the forum/wiki software introduces linebreaks in screwy places so
> if you just copy/paste from the forum, the patch won’t work since
> it possibly adds a carriage return at places like:
>
> "snorm
> [0]"
>
> which need to be "snorm[0]" for jit.expr to work. If you see
> patches with weird linebreaks in the object boxes, I’d just try
> deleting the line breaks from the boxes manually post paste (or
> subscribe to email version of the forum, I guess).
>
> This is *totally* annoying I know, but doubt we’ll get around to
> changing this aspect for the forum software in the immediate
> future. Sorry.
>
> -Joshua
>
>
>
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P comment 805 113 188 196617 anamorphic barrel/pin;
> #P flonum 844 129 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 805 129 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 805 149 49 196617 pak 0. 0.;
> #P newex 306 138 48 196617 loadbang;
> #P comment 541 219 97 196617 feed radius as input;
> #P newex 306 215 220 196617 jit.expr @expr "hypot(snorm[0]\,snorm
> [1])";
> #P number 121 252 35 9 0 4 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P message 121 271 71 196617 boundmode $1;
> #P user jit.pwindow 445 364 322 242 0 0 0 0 1 0;
> #P flonum 637 130 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 186 295 127 196617 jit.matrix 2 long 320 240;
> #P newex 446 295 68 196617 jit.normalize;
> #P window linecount 2;
> #P newex 306 238 341 196617 jit.expr @expr "256*(dim[0]-1)*(0.5
> +0.5*snorm[0]/(1.+in[1]*in[0]*in[0]))" "256*(dim[1]-1)*(0.5
> +0.5*snorm[1]/(1.+in[1]*in[0]*in[0]))";
> #P window linecount 1;
> #P newex 306 193 142 196617 jit.matrix 2 float32 320 240;
> #P user jit.fpsgui 83 610 60 196617 0;
> #P message 192 141 28 196617 stop;
> #P button 306 174 15 0;
> #P user jit.pwindow 82 364 322 242 0 1 0 0 1 0;
> #P newex 83 319 113 196617 jit.repos @interpbits 8;
> #B color 5;
> #P flonum 224 120 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P message 224 141 42 196617 rate $1;
> #P message 161 141 28 196617 read;
> #P flonum 117 120 35 9 0.5 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P toggle 83 120 15 0;
> #P newex 83 140 44 196617 metro 2;
> #P newex 83 176 103 196617 jit.qt.movie 320 240;
> #P comment 637 114 100 196617 barrel/pin;
> #P window linecount 5;
> #P comment 703 244 341 196617 expr version of the following ,
> using snorm for delta , zero centered coordinates , and taking
> into account interpbits ; delta = incoord-center ; radius = hypot
> (delta.x , delta.y) ; outcoord = center + (delta/(1.
> +k*radius*radius)) ;;
> #P fasten 25 0 11 0 810 169 311 169;
> #P fasten 25 0 15 1 810 216 642 216;
> #P fasten 18 0 11 0 642 169 311 169;
> #P connect 18 0 15 1;
> #P connect 15 0 17 0;
> #P connect 15 0 16 0;
> #P connect 22 0 15 0;
> #P connect 14 0 22 0;
> #P connect 4 0 3 0;
> #P fasten 3 0 2 0 88 169 88 169;
> #P fasten 12 0 2 0 197 169 88 169;
> #P fasten 7 0 2 0 229 169 88 169;
> #P fasten 6 0 2 0 166 169 88 169;
> #P connect 2 0 9 0;
> #P connect 20 0 9 0;
> #P connect 9 0 10 0;
> #P connect 10 0 13 0;
> #P connect 5 0 3 1;
> #P connect 21 0 20 0;
> #P connect 17 0 9 1;
> #P connect 8 0 7 0;
> #P connect 24 0 11 0;
> #P connect 11 0 14 0;
> #P connect 16 0 19 0;
> #P connect 26 0 25 0;
> #P connect 27 0 25 1;
> #P window clipboard copycount 29;
>
>


February 22, 2007 | 12:31 pm

i am using a mesh with a chopped, textured sphere matrixoutput as the source to compensate for the lens distortion. jkc posted a jit.repos way of doing this but it is cpu and expensive at that. i couldnt get the repos shader to work (simply applying the long matrix for jkc forumla wouldnt work in opengl land, right?).
so…
is there a better way of doing this. has somebody solved this more elegntly?
dayton suggest the mxrtoolkit, its broken and even if i couldnt get my lens correct transform, to what should i map it to?/?


October 2, 2007 | 2:05 pm

Hello,
Joshua’s patch works great, but yes it would be handy to make the process on GPU. has anyone worked on it?
I’d do it myself but I’m still getting in touch with shaders, and it’ll take a little while yet..
Thank you
GP



ico
October 2, 2007 | 3:21 pm

Max/MSP comes with a fisheye shader but it has not worked for me on either
Windows or a Mac machine. That being said, as an academic exercise I did
release a collection of shaders titled "shaders ahoy!" that are based on
photobooth filters which also include a fisheye shader that will offload
such processing to the GPU (obviously only if the GPU is shader-capable).

You can download the collection including example patch at

http://ico.bukvic.net/Max/

Hope this helps!

Best wishes,

Ivica Ico Bukvic, D.M.A.
Composition, Music Technology, CCTAD, CHCI
Virginia Tech
Dept. of Music – 0240
Blacksburg, VA 24061
(540) 231-6139
(540) 231-5034 (fax)
ico@vt.edu

http://www.music.vt.edu/people/faculty/bukvic/

> —–Original Message—–
> From: jitter-bounces@cycling74.com [mailto:jitter-bounces@cycling74.com]
> On Behalf Of livio
> Sent: Tuesday, October 02, 2007 10:05 AM
> Subject: [jitter] Re: WideAngle/FishEye-Lens – How to compensate?
>
>
> Hello,
> Joshua’s patch works great, but yes it would be handy to make the process
> on GPU. has anyone worked on it?
> I’d do it myself but I’m still getting in touch with shaders, and it’ll
> take a little while yet..
> Thank you
> GP
> –
> –
> oivil.eu



March 10, 2012 | 10:58 am

*time warp space bump*

im trying to run JKC patch for matrix based fisheye/barrel correction.
but getting errors in cosole abou8t
"jit.expr: GROUP node on clean pass has more than 1 child node"
"jit.expr: warning: extra arguments to op hypot"

btw. could be a nice example for the gen masters series (hhm..)

– Pasted Max Patch, click to expand. –

max 6.0.4 win64


January 29, 2014 | 2:40 pm

Yair Reshef did’t fix the errors that the copy and paste cause that Joshua mentioned, which produced the jit.expr errors. taking out the line breaks fixes the code. This process is probably better done with a shader, but I am reposting the fixed code for future reference.

<code>

– Pasted Max Patch, click to expand. –

</code>


Viewing 12 posts - 1 through 12 (of 12 total)