Plugin to Read Images

Hello everyone,

I am new to touch designer and I am a developer. So pardon my ignorance. I would like to write an operator (C++ )- I guess that would be a TOP to read an the input (image input) and do some processing on it.

Is there an example C++ plugin that does something like this so I can take this as an example ?

Kindly let me know.

Thank you
Ram.

Hey Ram,
There is a sample C++ project in the installation directory of TouchDesigner. In the later builds the one that is called MemoryTOP is a better example since that one you will just be able to copy your image data into a pointer we provide.

Thank you very much. I found the MemoryTOP - I was just looking at the TOP directory earlier.

Hello Malcolm,

I was able to get the memory top to work - thank you for that. But that example doesn’t seem to give any information on how to read the input data (texture or image stream which is passed along).

For example I just want to manipulate an input coming from a moviein . Could you point me to a snippet which might do this.

Thanks
Ram.

Hey Ram,
Are you looking to manipulate this incoming image data on the CPU or on the GPU?

Hi Malcolm,

Thanks for your response. Right now I want to manipulate the image on the CPU.

If I need to manipulate on the CPU - is that memory buffer you provide a common buffer for input and output ? or do I need to read the input image using glReadPixels ? or is there any other way ?

In case I need to do some GPU manipulations later on - could you also point me a way to do this ?

Thank you very much.
Ram.

You are given a GL texture ID, so you can use GL commands to download the image to your own buffers. It’s been on my todo to have an option to feed already downloaded data to the C++ TOP, but not implemented yet.

Actually sorry, you can’t use GL commands with doing a memory TOP. You’ll need to use the other example and do both GL downloads and uploads yourself.

Thank you Malcolm. That seems to have worked - (ie) to read using glGetTexImage -. Thanks for the help . Just one more hopefully final question about this topic . Sorry…

If we use a DirectShow input feed into the cplusplus node - is the texture GL_UNSIGNED_BYTE or is it some other type ? is there a way to get the type for the texture input ?

Also, which is the best way to debug c++ plugins ? I am writing to stdout and err but i tried various windows and output doesn’t seem to appear .

Kindly let me know and thank you for your responses. I tried to look into documentation and couldn’t find it .

The texture type depends on what the TOP is setup to be. Both for the input textures as well as the output texture.
Check the debugging section of this article for more information;
derivative.ca/wiki088/index. … #Debugging

Thank you Malcom. The Debugging worked using the link you suggested.

I still couldn’t find a way to see the output to stdout for print statements in my Cplusplus TOP . I tried to open the console window to see if it was printed there but it wasn’t.

Any suggestions for this ?

Thank you.
Ram.

I’ve updated the help with the answer to that question:
derivative.ca/wiki088/index. … ole_Output