corner pin adjustement of plane/quad with videotexture?

Jan 19, 2009 at 4:36pm

corner pin adjustement of plane/quad with videotexture?

Before I twist my brain yet another turn:

I am trying to achieve something which seems simple in environments like quartz composer/vdmx and vvvv: corner pin positioning of a quad/plane.

If you take a look at this link there is an example video and also the shader used to create the warp for qc/vdmx: http://www.memo.tv/projection_mapping_quad_warping_with_quartz_composer_vdmx

In vvvv there is the homography module which does the same thing.

I have looked at different keystone examples on the list (particularly jasch and robtherich), but they seem quite complex to achieve a simple corner pinning (and also I would want many instances in my setup).

I have figured out how to capture parts of or the whole gl scene to a texture, and then ideally I would want a shader based on the code from the link above:

uniform vec2 BL, BR, TL, TR;
uniform vec2 renderSize;

void main() {
// transform from QC object coords to 0…1
vec2 p = (vec2(gl_Vertex.x, gl_Vertex.y) + 1.) * 0.5;

// interpolate bottom edge x coordinate
vec2 x1 = mix(BL, BR, p.x);

// interpolate top edge x coordinate
vec2 x2 = mix(TL, TR, p.x);

// interpolate y position
p = mix(x1, x2, p.y);

// transform from 0…1 to QC screen coords
p = (p – 0.5) * renderSize;

gl_Position = gl_ModelViewProjectionMatrix * vec4(p, 0, 1);
gl_FrontColor = gl_Color;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
}

I have so far not been able to get this shader code to work in jitter, I haven

#41839
Jan 19, 2009 at 5:04pm

On Jan 19, 2009, at 8:36 AM, hc gilje wrote:

> I am trying to achieve something which seems simple in environments
> like quartz composer/vdmx and vvvv: corner pin positioning of a quad/
> plane.

Something like the following email coding should be all you need. You
might need to flip the texture coordinates to get the proper texture
orientation. Check out the redbook if the following doesn’t make sense.

glbindtexture texname,
glbegin quads,
gltexcoord 0 0,
glvertex left top 0,
gltexcoord 1 0,
glvertex right top 0,
gltexcoord 1 1,
glvertex right bottom 0,
gltexcoord 0 1,
glvertex left bottom 0,
glend

-Joshua

#149189
Jan 19, 2009 at 9:18pm

here is a simple patch with a quad using a video texture, but the texture gets a pretty nasty distortion even with moderate tweaks of the quad, so I need to do something with the texture coordinates as well I assume?

hc

– Pasted Max Patch, click to expand. –
#149190
Jan 19, 2009 at 9:57pm

On Jan 19, 2009, at 1:18 PM, hc gilje wrote:

>
> here is a simple patch with a quad using a video texture, but the
> texture gets a pretty nasty distortion even with moderate tweaks of
> the quad, so I need to do something with the texture coordinates as
> well I assume?

Sorry about that. Yeah, you’ll be better off using either a more dense
vertex mesh, since a simple quad breaks down into two triangles and
interpolates only within each triangle.

The basic idea would be to make a 4 cell matrix containing each of
your corner xyz values, and the standard texture coordinates, and then
send it to a 20×20 or whatever jit.matrix @interp 1. This will make a
mesh which can be sent on to jit.gl.mesh, jit.gl.sketch drawmatrix, or
jit.gl.render or whatever your preferred means of drawing vertex data
as a trigrid/quadgrid. The more vertices in your mesh the better it
should look.

-Joshua

#149191
Jan 19, 2009 at 10:18pm

I was sort of guessing that was the problem, but that still makes me wonder why such a simple shader as the one I linked to for quartz composer doesn

#149192
Jan 19, 2009 at 10:34pm

#149193
Jan 19, 2009 at 10:50pm

Here’s what I’m suggesting. Took about 10 minutes to make from your
existing patch.

– Pasted Max Patch, click to expand. –
#149194
Jan 19, 2009 at 10:52pm

ok, I am not obsessed with shaders myself,
I just look at the output and see no unwanted distortion in the video texture in the qc example, and lots of distortion with my jitter test.
So obviously I am missing something?

hc

#149195
Jan 19, 2009 at 10:55pm

that was quick, thanks!
I would have spent a bit more than 10 minutes on that :-)

So if get rid of the aliasing I will be happy, and maybe I will force myself to make a shader out of it. Maybe that

#149196
Jan 19, 2009 at 11:08pm

On Jan 19, 2009, at 2:55 PM, hc gilje wrote:

> So if get rid of the aliasing I will be happy

Here you go with a natively sized jit.gl.texture object and @fsaa 1.
That’s as good as you’ll get without some alternate form of texture
filtering. Bilinear filtering (which is most likely the same as is
used in QC/vvvv), will have visible aliasing artifacts when
downsampling by large amounts. Performing gaussian/bicubic/mitchell/
etc filtering is more of an endeavor.

-Joshua

– Pasted Max Patch, click to expand. –
#149197
Jan 19, 2009 at 11:16pm

thanks,
yes it looks quite good here. I didn

#149198
Jan 19, 2009 at 11:16pm

On Jan 19, 2009, at 2:52 PM, hc gilje wrote:

> I just look at the output and see no unwanted distortion in the
> video texture in the qc example, and lots of distortion with my
> jitter test.

Texture size? Use jit.qt.movie @adapt 1-> jit.gl.texture to make sure
that’s not the issue.

Dimensions of the plane’s vertex mesh? Try 40×40 rather than 20×20.

I’m pretty sure it’s only one of those two possibilities. In your
first example you were using a 320×240 -> 256×256 down sampling
without any antialiasing, which of course would have significant
artifacts.

-Joshua

#149199
Jan 19, 2009 at 11:30pm

your patch came while I was writing my post, so that is why my message about texture distortion appears after your example, sorry for the confusion.
it works beautifully with 20×20 here.
thanks again!

hc

#149200
Jan 19, 2009 at 11:36pm

On Jan 19, 2009, at 3:16 PM, hc gilje wrote:

> I am just wondering if this approach would work if I wanted to
> apply different warpings to different videoplanes. Since the matrix
> transform goes directly to the renderer in this example, I would
> need some way to connect individual matrix transforms to each
> separate plane.
> This is where I thought it would be handy to have a shader version,
> but would it work with your method if things are banged in the right
> order?

Sure. You can also use jit.gl.mesh if it makes your patch organization
simpler… So many different ways to do the same thing.

-Joshua

– Pasted Max Patch, click to expand. –
#149201
Jan 19, 2009 at 11:50pm

excellent, thanks for sharing!
I have had quite a few false starts trying to get this working, so glad you took the time to help me out. This should be useful for a few others than me as well.

hc

#149202
Jan 19, 2009 at 11:56pm

I am one of those few others, was going to be asking a similar
question in a few days if I couldn’t get it right.

Thanks to you both!

~s

On Mon, Jan 19, 2009 at 6:50 PM, hc gilje wrote:
>
> excellent, thanks for sharing!
> I have had quite a few false starts trying to get this working, so glad you took the time to help me out. This should be useful for a few others than me as well.
>
> hc

#149203
Jan 20, 2009 at 12:33pm

Here is a modified version of the patch, now easy to use as a fullscreen keystone tool.
By clicking directly on the output screen, you can easily place/displace the image by corner pinning.

hc

– Pasted Max Patch, click to expand. –
#149204
Jan 20, 2009 at 12:57pm

hi,

just by curiosity.
how to just crop with your solution ?
and keep the possibility to choose between “crop” and “adapt”.

thx.
f./

i had it by this way :

– Pasted Max Patch, click to expand. –
#149205
Jan 20, 2009 at 3:36pm

I haven

#149206
Jan 20, 2009 at 11:14pm

This makes the texture part a bit more efficient. You can send messages to
the slabs to change the dimensions of their texture units if you need to.

– Pasted Max Patch, click to expand. –
#149207
Jun 2, 2010 at 2:32am

I am new with max/msp, and not where paste the key patcher, tell me please

#149208
Nov 2, 2010 at 4:49pm

hi, joshua! nice tip with 4 cell matrix!
but I try to add 5th control point in center without success (
matrix must be 3×3 now?

humbala ! ;-)

#149209
Mar 18, 2011 at 3:19am

#149210
Mar 18, 2011 at 3:19am

someone sent me another version of this patch, looking to make it flexible in terms of vertex points. i moved it to javascript.

– Pasted Max Patch, click to expand. –

and this is the keygen.js javascript:

// keygen.js
// joshua goldberg 2011
// defines control points for keystoning video

// initialization code

autowatch = 1; // why would you NOT use this
inlets = 1;
outlets = 1;
// X_WIDTH for 4:3= 1.33333. for 16:9= 1.777777
var X_WIDTH=1.333333;
var totalWidth = X_WIDTH * 2.0; // full GL width of image
var mySize=[3,3]; // size of ctlmatrix as global (dummy values)
// we put dummy values in ctlMatrix to make sure it’s globally available
var ctlMatrix = new JitterMatrix(5, “float32″, mySize[0], mySize[1]);
// and the name of the control matrix is also a global
var myName = ctlMatrix.name;
sizer(2,2); //preloads 2×2 values for placement
post(“keygen.js reloaded!n”); // so i know it’s been properly compiled

// functions

function sizer(x,y){
mySize=[x,y];
var sliceSize = totalWidth/(x-1) // size of each quantized Xslice
// this is the cell placement init code
// first redefine ctlMatrix with the proper size
ctlMatrix.dim = [x, y];
for (i=0; i

#149211
Mar 18, 2011 at 3:19am

someone sent me another version of this patch, looking to make it flexible in terms of vertex points. i moved it to javascript.

– Pasted Max Patch, click to expand. –

and this is the keygen.js javascript:

// keygen.js
// joshua goldberg 2011
// defines control points for keystoning video

// initialization code

autowatch = 1; // why would you NOT use this
inlets = 1;
outlets = 1;
// X_WIDTH for 4:3= 1.33333. for 16:9= 1.777777
var X_WIDTH=1.333333;
var totalWidth = X_WIDTH * 2.0; // full GL width of image
var mySize=[3,3]; // size of ctlmatrix as global (dummy values)
// we put dummy values in ctlMatrix to make sure it's globally available
var ctlMatrix = new JitterMatrix(5, “float32″, mySize[0], mySize[1]);
// and the name of the control matrix is also a global
var myName = ctlMatrix.name;
sizer(2,2); //preloads 2×2 values for placement
post(“keygen.js reloaded!n”); // so i know it's been properly compiled

// functions

function sizer(x,y){
mySize=[x,y];
var sliceSize = totalWidth/(x-1) // size of each quantized Xslice
// this is the cell placement init code
// first redefine ctlMatrix with the proper size
ctlMatrix.dim = [x, y];
for (i=0; i

#149212
Jun 10, 2011 at 7:47pm

I have a problem with multiple planesmeshes at same time. How can i change order of each?

#149213
Aug 19, 2011 at 2:59pm

Hi,
All this creates distortion.
Try the patches above with the file I joined, and please read this :
http://cycling74.com/forums/topic.php?id=34796
Cheers,
Eric

[attachment=169223,2545]

Attachments:
  1. flagTest1.jpg
#149214
Aug 23, 2011 at 9:28pm

@Eric
Yes you’re absolutley right. I noticed this for a while but I supposed it was impossible (and actually it is) to get something better.
I really hope cycling will solve it asap.

It seems the last js solution is ok. no ?

#149215
Aug 24, 2011 at 4:43pm

haha sorry, the js solution is not ok at all… the distortion just different… not a curve but an angle like missing the 20×20 matrix with interp 1.
if somebody find an adequate solution, please post it.
thx.

#149216
Aug 26, 2011 at 3:15am

I confirm, js solution is not the solution.
Well, I managed with nurbs, but this should be more easier to use :

http://cycling74.com/forums/topic.php?id=34796

#149217
Aug 26, 2011 at 11:09am

Hello Eric,

I also tryed to work with nurbs, but i did not get rid of the curved deformation :-(

Pehaps you could help me.

Here is what i have:

– Pasted Max Patch, click to expand. –
#149218
Aug 26, 2011 at 12:25pm

Hi timtom,
to achieve a clean cornerpin adjustment, I think that you have to implement some maths in your patch (have a look at my attached .gif) :
If you're working with 9 control points with jit.gl.nurbs :
A, B, C, D are known points, you have to calculate 0, w, x, y and z.

Cheers,

[attachment=169696,2576]

Attachments:
  1. schemacornerpin.gif
#149219
Aug 26, 2011 at 9:59pm

Hello Eric,

Thank you very much for the explanation !
Do you have a maxpatch, for the
transformation of A, B, C, D to 0, w, x, y and z.

I think this would help many people, who are not
good math coder ;-)

Best,
t

#149220
Aug 26, 2011 at 11:36pm

I’m very bad with math too, but some friends will help me…
So, perhaps later…

Have a look at this, it seem to be very interesting too :

http://cycling74.com/forums/topic.php?id=34796

Cheers,
Eric

#149221
Aug 28, 2011 at 11:45am

hi there,
i have a solution for you, BUT:
it is a bit difficult to share, since it has two major dependencies.
first, you need thomas grill´s python skripting objects from http://grrrr.org/research/software/ (that is easy)
second, you need a working opencv installation with python bindings: http://opencv.willowgarage.com/wiki/

i did this a year ago or so for an exhibition, and since then i was thinking about doing this whith a shareable external, never had the time to do so.
as eric pointed out, the problem is that what you guys do with the “mesh” or “nurbs” approach is a linear distortion of the movie, and what you want to do is a perspective transformation.
opencv has this wonderful function “findHomography” that does our math – finding the transformation matrix from a given set of points.

so the attached patch does exactly that: we know the “source points” (e.g a square), we can set the destination points (by draging the sliders), opencv (inside the python script) calculates the transformation matrix.

then i use this matrix to draw a transformed vidplane – with gl.sketch.
basically like this:
glmatrixmode perspective,
glmultmatrix TRANSFORM,
drawobject MOVIE #that´s the jit.gl.videoplane

so for all of you who have python and opencv running in your max environment (or are willing to set it up) please test this.
i am in the process of final mixdown and mastering of my upcoming album (yippieyeah !), so i am a bit short on time. still, i will try to come up with an external that has no dependencies for easier sharing.

yours truly,
hons

#149222
Aug 28, 2011 at 2:22pm

Ok, well that’s more complicated than I thought it was to do the transformations. I have been working on a toolkit to assist with projection mapping from directly inside jitter rather than using syphon and having to play around with the output as more things need mapping.

My attempted solution was to see if a simple texture map with the right coords onto the mesh would fix the problem. I haven’t managed to get this working properly yet, but thought I’d share anyway.

You need to go into the meshmap subpatch and enable the customTexMap to see the results. Does anyone know if this would be workable with the correct code or am I fighting a lost cause here?

DiGiTaLFX

ps interestingly I was experimenting in the Madmapper demo and noticed that you get exactly the same curved effect if you enable mesh mapping and use the mesh controls in there so I guess that it does have to be done with the homography stuff!

Attachments:
  1. meshmap.zip
#149223
Aug 28, 2011 at 4:55pm

well, that was my sunday.

i have managed to make an external “h.homography”, currently mac only, and absolutely fresh and untested (except by me).
it calculates the homography given a set of destination points (assuming the source is a square).
that gives you a perspective correct transformation of a plane – the thing you need for “keystoning”.

open “PerspectiveMovie++”, toggle on, read movie, drag the cornerpoints.
ah.

this is version 0.0, please test.
i will hopefully be able to post a better version (with sourcepoint input, and source-testing, and windows binary) and better help-file / description in the next days.

yours,
hungry hons (going to find something to eat now)

#149224
Aug 28, 2011 at 4:59pm

ah yes, too big (debug version..)
here: http://dl.dropbox.com/u/1488161/h.perspectivemovie2.zip

humbly, hons

#149225
Aug 28, 2011 at 5:29pm

Sounds great. Cannot test unless on Windows.

Also, the input will rarely be square. Can size/proportions be derived from what the user provides or explicitly supplied by the user?

For reference, I include an image showing how it looks like in vvvv.

Thanks.

[attachment=169854,2582]

Attachments:
  1. pp.gif
#149226
Aug 28, 2011 at 5:46pm

Hello Hons,

Great work. Thanks for sharing :-)
you are my hero of the day !

After 2 years this problem is solved, yes !

best,
t

#149227
Aug 28, 2011 at 9:49pm

@jhdkfj39929: jep, that´s exactly what i am doing/going to do. non-square inputs will be provided in upcoming versions. (although in your example the source (“original points”) is actually a square from -1 -1 to 1 1 ). sorry that you have to wait, but the windows version will take a few days.

@timtom: thanks for the roses, very much appreciated. glad that it works

good night,
hons

#149228
Aug 28, 2011 at 9:52pm

Works perfectly on Max 5 Mac OS 10.6
Great work, congratulations !
Many thanks for sharing.
Cheers,
Eric

#149229
Aug 29, 2011 at 2:11am

@hons: super, sounds great. let’s see if i can wait several days. cannot promise.

Attachments:
  1. ggg.gif
#149230
Aug 29, 2011 at 9:57am

thanks hons !!!

Works perfectly on Max 5 Mac OS 10.7

fxw

#149231
Sep 2, 2011 at 11:55am

windows version available, tested only on xp.
i have set up a quick – kind of unofficial – sharing page at http://hons.at/software/
you will find the download there with both the windows and the mac external.
(my previous dropbox link will cease to exist as of now)

i have made minor changes to the code (checking the input matrix and stuff), so if you would be so nice test it, i hope i have not broken anything.

finding the homography for a given set of points can do much more as the external currently does, but for now this is a simple solution for “extreme keystoning”. but first things first, i have to get an album out…

humbly.hons

#149232
Sep 2, 2011 at 12:20pm

Thanks a lot. This is what I am getting. I am intending to install and explore OpenCV anyway but my understanding that it is meant to work without it.

[attachment=170181,2599]

Attachments:
  1. .gif
#149233
Sep 2, 2011 at 2:29pm

oh. my bad. yes, the idea was to link opencv statically, but i obviously failed to do so. at least i should have provided the dll´s ..
i am also wondering why i linked to cv version 1.1, hmm.
did i think, or did i just hurry.
i think i just hurried.

problem is, i am not on windows right now so i cannot change anything.
you probably also need cxcore110.dll (?) – that´s what i found lying around on my mac

http://dl.dropbox.com/u/1488161/cv-110dll.zip

you need to copy the dll´s to your max application path in the hope that this is what you need.

sorry for that,
hons

#149234
Sep 4, 2011 at 2:04am

Thanks. But even after putting both dlls into ..Cycling ’74jitter-externals, together with the mxe, the message is the same. Seems the path is hard coded somehow.

Would be great to have this all wrapped into one file. Or has someone else had better luck?

#149235
Sep 4, 2011 at 6:14am

@jhdkfj39929
place the dll's in max5 root folder , max5/supprot folder (or anywhere in your %path%), i use procmon from microsoft for tracing this things. its a great help.

[attachment=170266,2604]

Attachments:
  1. procmin.gif
#149236
Sep 4, 2011 at 7:47am

u r right. works now. procmon will also be very useful. thank u.

#149237
Sep 8, 2011 at 6:04pm

greeeeeeeaaaaaaaaaat. thx a lot. :-)

#149238
Sep 11, 2011 at 2:12pm

Hello, thx again Hons for your external. one problem is solved. :-)

One question : did you notice that when you move one corner, the others move too ?

I can manage it step by step to stick my corners exactly where they have to be but it’s not very convenient.

#149239
Sep 12, 2011 at 1:24am

ok, sorry for the noise it’s just because I scaled the movie in videoplane.

#149240
Sep 24, 2011 at 7:12pm

hons,

I”ve been using your patches as an example and porting to a dynamic render engine where I can have different viewpoints(cameras) on different render engines.

I do this in javascript making an array of sketch objects that I initita like so:
sketchArray[i].glviewport(0,0,windowSize[0],windowSize[1]);
sketchArray[i].glmatrixmode(“perspective”);
sketchArray[i].glscale(aspectRatio,1,1);
sketchArray[i].glmultmatrix(multMatrix[i]);

getting the I think I’m doing exactly the same as in the path you made but than in javascript.

the thing is that it seems to end up in a really strange deformation (everything seems to be just a line, could you guess why?

my multMatrix fynction is as follows:

function multiplyMatrix(){
var points =arrayfromargs(arguments);
var i=0;
var j=0;
//sketchArray[points[0]].glmultmatrix=multMatrix[points[0]];
for(i=0;i<4;i++){
for(j=0;j<4;j++){
multMatrix[points[0]].setcell2d(i,j,points[1+i+j]);
post(“cell “+i+” “+j+”val “+points[1+(i*4)+j]+”n”);
sketchArray[points[0]].glmultmatrix=multMatrix[points[0]];
//multpost(Matrix[points[0]].matrixcalc(multMatrix[points[0]],multMatrix[points[0]]);
outlet(0,”jit_matrix”,multMatrix[points[0]]);
}
}

}

#149241
Oct 4, 2011 at 4:46pm

@llumen – from what you posted i cannot see what you are doing, or what you are doing wrong. i don´t even know what you supply as an argument to your multiplyMatrix() function.
my guess would be that maybe the matrix you fill within this function is either transposed or otherwise not set up properly (row/column order). but that is of course a wild guess.

you could also try to simply use a poly~ object to set up variable viewports (or even rendercontexts).

i am currently a bit short on time so i do not have the time to look into it more deeply.

good luck,
hons

#149242
Oct 19, 2011 at 11:41pm

something in the example patch at http://hons.at/software/ relating to jit.gl.sketch when using the drawobject command doesn’t appear to work in max 6- tested on OSX 10.6.8. works in max 5

#149243
Nov 2, 2011 at 12:47pm

so bad, doesn’t work anymore with max6… osx10.6.8 too.

#149244
Nov 3, 2011 at 10:50am

just had a quick look with max 6:
h.homography itself seems to work fine, but jit.gl.sketch handles the gl-transformation-stack differently – and so the drawobject command does not behave exactly as in max 5. not sure if this was a max 5 bug or is a max 6 bug ..

quick solution (referring to the helpfile):
1) replace the “MOVIE” object (the jit.gl.videoplane) with only a texture:

jit.gl.texture HX @name TEX

2) and then replace the commandlist of the gl.sketch with:

reset, glscale 1 1 1 , glmultmatrix TRANSFORM, glbindtexture TEX, plane 1

3) set the gl.sketch color attribute to @color 1 1 1

i have tested this with max 6 and max 5 on OS X 10.6.8
i will update the helpfile accordingly,

yours, hons

#149245
Nov 3, 2011 at 7:57pm

Since Max 6 was released, I have been wondering whether it would be possible to implement this using jit.gl.camera instead of jit.gl.sketch now. Does anyone know if that would be possible or am I barking up the wrong tree?

DiGiTaLFX

#149246
Nov 3, 2011 at 8:15pm

I doubt jit.gl.camera has the means to accomplish transforming a homography matrix, but you could actually do it by passing the homography matrix into a shader. this might be a more ideal way of doing it… haven’t seen it implemented in Max yet, though.

#149247
Nov 3, 2011 at 10:46pm

Ah, now that sounds like a tidy way of accomplishing the task! :)

#149248
Nov 8, 2011 at 10:18pm

Nice work, Hons! Good help file, too.

#149249
Nov 9, 2011 at 9:11am

thx a lot Hons.
and how to add several textures. let say I would like to play 2 or more movie on the same plane, with the same keystone. thx.

#149250
Dec 17, 2011 at 10:38pm

@Brian.

” but you could actually do it by passing the homography matrix into a shader. this might be a more ideal way of doing it… haven’t seen it implemented in Max yet, though.”

I have been trying to figure out how to do this, but I am relatively a rookie when it comes to shaders. could you post an example? That would be very much appreciated.

Hans! Great work.

#149251
Dec 17, 2011 at 10:57pm

sorry Ricardo I don’t have an example from Max/MSP, I’ve only done it in other environments. It’s not the most trivial thing for me to write one real fast, but if someone else wants to try, you’d pass your matrix into your vertex shader (below as myQuadWarpMatrix), and do something like the following:
gl_Position = gl_ModelViewProjectionMatrix * myQuadWarpMatrix * gl_Vertex;

#149252
Dec 17, 2011 at 11:12pm

Thanks. I am reading “OpenGL Shading Language Third Edition” by Randi J. Rost Bill Licea-Kane. I am new to this programming, but I will, if I can get it to work, post the final result here.

Thanks :)

Ricardo

#149253
Jan 11, 2012 at 12:52pm

oh, thanks for all the feedback. i have been travelling for a while and was offline (not too bad sometimes), but now i am back again – and i will have a look at it.
not that i would call myself “master of shader programming”, but i´ll give it a try, it´s only a multiplication (and a color passthrough) in the end..

you have to wait a few more days, i guess.

so long,
hons

#149254
Jan 16, 2012 at 5:32pm

ok – anyone cares to test (provided you have already downloaded the h.jit.homography external) ?

this is my attempt at a matrix transformation shader to be used with h.jit.homography – save as “h.mxform.jxs”:

this is the testpatch:

– Pasted Max Patch, click to expand. –

best,
hons

Attachments:
  1. h.mxform.jxs
#149255
Jan 16, 2012 at 6:03pm

hello hos,

thank you very much for your great work !!!
making a shader is a very cool :-)

i did some tests with it and one stange thing happend:

if i try to set the position of the gridshape with the position message, the
shape rotates …

here is a patch, which demonstate the issue.

lee

– Pasted Max Patch, click to expand. –
#149256
Jan 17, 2012 at 10:23am

thanks lee for testing.
the strange thing with the position is a feature, not a bug :)
h.jit.homography calculates the perspective transformation of a “standard plane” from (-1,-1) to (1,1) given the target projection points that you provide with your matrix.
then the same plane gets drawn with the appropriate perspective transformation applied (that´s what the shader does, simply ignoring the gl_projection_matrix and applying the homography matrix instead).
if you move the gridshape via position message, the plane that gets drawn and the plane that is used for calculating the homography do not match, resulting in this weird “rotation”.

if you want to move the plane, simply change the input to h.jit.homography (with the sliders, or by adding some offset..)

i have already been asked to add source point input to h.jit.homography, which is possible, but has not happened yet due to time constraints on my side. mea culpa.

best, hons

#149257
Jan 17, 2012 at 5:39pm

hey guys, just wanted to give you a heads up.

for those interested in a simple object to perform a cornerpin projection, we will have something for this in the next update.

#149258
Jan 17, 2012 at 8:08pm

hey robert,
a bit late …. (this thread is 2 years old)
since years we told c74, that we need a solution for accurate cornerpin adjustment, which is a very basic thing.

now we helped ourself. you should give hons a free max licence !
he did the work for you. with this shader we have a solution for max5 and max6.

if you want to do somthing helpful for the jitter community,
there is another thing which need to be solved since years:

it would be great to play quicktime movies without hickups.
the forum is full with threads concerning this problem.

#149259
Jan 19, 2012 at 3:27am

oh yes, a free max6 licence would be greatly appreciated :)
but to be honest: my homography solution is very basic (only calculating the transformation for a standard plane) and is missing a few important things. it would also be possible to find transformations for real 3d objects, which would then enable us to do real architectural projections; virtual lighting of buildings comes to my mind .. i have just not implemented it yet.

so i am very much looking forward to the solution of our fellow cyclists as robert announced (or will it only be max6, hm) – and if your solution is a basic as mine, i’m gonna pimp up h.jit.homography, just to show off :)

humbly, hons

#149260
Jan 19, 2012 at 4:28am

the new object addresses only the problem of correctly projecting textured quads with adjustable corners, in a simple and user-friendly manner.

it does not replace hons’ object, which will still be useful for users wanting a lower-level solution, to use a shader, or transform geometry other than quads.

pimp away hons!

#149261
Feb 6, 2012 at 9:00am

how will the objekt be called, and when will the update come out? (just to know, when to look for…)

#149262
Feb 7, 2012 at 5:46pm

jit.gl.cornerpin.

it will be in the next update.

#149263
Mar 3, 2012 at 3:11pm

hey,
id like to apply prepective transform onto a jit.matrix (no opengl)
i think i need to translate the matrix to XY coordinateS, how to?

[EDIT]
ok, jit.mxform2d

#149264
Mar 3, 2012 at 3:31pm

whats wrong here?

– Pasted Max Patch, click to expand. –
#149265
Mar 13, 2012 at 7:44pm

*bump*
still having trouble figuring out how to convert transform matrix from h.jit.homography into a valid mxform message to jit.mxform2d

– Pasted Max Patch, click to expand. –
#149266
Mar 13, 2012 at 8:09pm

how about using jit.gl.corner

#149267
Mar 13, 2012 at 8:12pm

i need to stay in jit.matrix for further cv.jit processing

#149268
Mar 13, 2012 at 9:24pm

would been nice if jit.gl.cornerpin could output mxform+x/y_offset.
im trying to fiddle with the homography object and mxfrom
but seems it also needs control over the x/y_offset params because mxform will otherwise always “stick” to upper left corner otherwise.

#149269
Mar 12, 2013 at 11:16am

Hi yair reshef,
did you find a way to convert transform matrix from h.jit.homography into a valid mxform message to jit.mxform2d ?
I’m in that problem too…
the same problem of my old post

http://cycling74.com/forums/topic.php?id=42996

#149271

You must be logged in to reply to this topic.