Is there any way I can fix an image that got quite a bit of a barrel distortion. I got this image from a camera with wide lens and I’m looking to straighten up the image as much as possible.
I tried using Stoner, but it’s quite hard for me (maybe I need more practice). But, is there any other way/workaround? Maybe something like undistort() in Open CV?
yes, but that link showed how to read image from file in computer. now I wonder how can I use an image from a Video Device In TOP? Do you know how? I’m pretty lost here, sorry.
oops sorry totally misread your last question, thought you asked how to read files.
No, I don’t know how to get TOP → OpenCV, I have a feeling this functionality is not implemented yet.
we currently don’t have a direct way of reading in values from a TOP into python cv.
Most probably it would be useful to save out a single camera frame, read it in via cv2.imread, solve for the distortion ones and save those values out.
Seems like you should be able to tackle this kind of barrel distortion with a shader - shouldn’t be too hard to port something from the web on this one.
Thank you for pointing this. So, how can I use the saved values? How to feed it into the video? Should I use shader? Or is there any other transformation/warping operator?
Therefore, my question is, how can I use both vertex and fragment shader in GLSL TOP? The wiki said most of the time I don’t need to use vertex shader. I tried to use both shaders in one GLSL TOP, obviously that won’t work, because then I’d have 2 main(). So, how can I use both shaders?
Also, another question is, the code I got, uses vUVDot and vUV. Are these similar to the vUV available in GLSL TOP?
Sorry for the beginner level question, but I’d really want to learn more about shader in TouchDesigner
In the parameter window of the GLSL TOP you can specify which Text DAT you want to use as your vertex shader.
If you want to write a GLSL TOP, all the TD information you need is on the wikipage How to write a GLSL TOP.
You will see several errors when trying to run this shader as some of the code is deprecated (for instance, instead of ‘varying’ you now have to use ‘in/out’ to pass variables from the vertexshader to the pixelshader). When it can’t compile you’ll see a blue/red checkerboard pattern in the GLSL TOP. So place an INFO DAT and point it to the GLSL TOP. This will display all lines which give an error. Google them all, and you’ll soon learn a lot about GLSL.
And in this code vUV and vUVDot are local variables calculated by the vertex shader so you can leave them as is.
Hi guys, thanks a lot for replying with very valuable resources. So, I had a quick read and practice, it was OK. Then I tried to implement the aforementioned shader code.I thought I get it, but then I got this error message
0(16) : error C1020: invalid operands to "+"
And the line that produces that error is
vec2 signedUV = ((2.0 * uv) + vec2(-1.0, -1.0));
Does anybody knows what make such error? I thought that operation was totally valid.
Also, uv variable in that vertex shader wasn’t declared or initiated. The only line I see uv made and assigned with value is the main() of the pixel shader.
Does pixxel shader able to transfer variable with vertex shader?