jit.expr issue

Sep 11, 2009 at 2:15pm

jit.expr issue

Hi,

I am working with a a 2 plane char matrix and trying to convert pix to world range inside matrix land.

I can’t get results with this expr:
[jit.expr @expr "(in[0].p[0] / 320.)*2. -1.” “(in[0].p[1] / 240.)*2. -1.”]

any idea?

– Pasted Max Patch, click to expand. –
#45429
Sep 11, 2009 at 6:19pm

not sure exactly what you are trying to do.
the char matrix is spitting out values between 0 and 255. if you want to convert that to float, between 0. and 1., simply convert the type of the matrix to float32:

jit.expr 2 float32 4 1 @adapt 0 @expr in[0] in[0]

looks like maybe you want 0 255 to -1 to 1:

jit.expr 2 float32 4 1 @adapt 0 @expr (in[0]*2)-1 (in[0]*2)-1

not sure why you have 320 and 240 so maybe you can explain more what you’re trying to achieve.

#163792
Sep 11, 2009 at 7:31pm

Sorry, there was an error in my statement.
Yes, of course a char matrix goes up to 255.

I was trying to convert float32 matrix filled with values between 0-320. for plane 0 and 0-240 for plane 1 to world coordinates.
That is good now.

However I’d like now to tell my expr to convert plane 1 from 0. 240. to 1. -1. not -1. 1.

My patch allows to sort elmts from cv.jit.sort and fill a new matrix without “cell-jump”.

I tryed
(-in[0].p[1] / 240.)*2. -1.
(in[0].p[1] / -240.)*2. -1.

But don’t really know how to do this ..

Thank you.

– Pasted Max Patch, click to expand. –
#163793
Sep 11, 2009 at 7:45pm

(((in[0].p[1]/240.)*2.)-1.)*-1.

#163794
Sep 11, 2009 at 8:01pm

Yes, Thanks.

But is there a reason for [jit.expr] does’nt accept the “” in my second expression?

– Pasted Max Patch, click to expand. –
#163795
Jan 6, 2010 at 10:08am

Yes, thanks ej.

Other, I discovered that exprfill message to [jit.matrix] do not work as expr message do with [jit.expr].
I thought that they both would work the same way? But no?

It would be nice to have clarifications with expression syntaxe and features.
A special tutorial somewhere would be nice.

– Pasted Max Patch, click to expand. –
#163796
Jan 6, 2010 at 5:38pm

Writing an in-depth jit.expr/exprfill tutorial has been on my “Todo Someday” list for some time now. Some of the later Jitter Recipes in Book 3 make use of it to draw geometry.

For your particular problem, exprfill can’t understand the “in[0]” because, well the exprfill is a one time action on a jit.matrix. If you need a dynamic expression with inputs, you are better off using jit.expr.

Also, if you want to fill different planes with different expressions, you need to use separate exprfill messages with a plane argument before the expression, i.e. (exprfill 0 snorm[0],exprfill 1 snorm[1]).

Andrew B.

#163797
Jan 6, 2010 at 8:15pm

indeed, it would be fantastic to have a jit.expr tutorial as it is one of the most powerful objects within jitter. Please keep us informed if it happens!

#163798

You must be logged in to reply to this topic.