How to save images from viewer everytime it changes ?

hi everyone,

i have created a twitter streamer with the web comp that outputs each tweet to a window with a certain layout. each element from the tweet stream goes to a TOP that is then displayed with the layout options in the project window. i would now like to save a ‘screenshot’ of each tweet automatically to a folder everytime a new tweet arrives.

i assume i’d be using a moviefileout TOP at some point for this but am a bit lost as how and where to set this up.

i managed to generate and save an image by using an opview TOP and piping that into a moviefileout TOP and when i enable RECORD in the parameters of the moviefileout it will save a single image. how can i make it save an image each time a new tweet arrives ?

maybe use a counter triggered by a DAT Execute each time a new tweet arrives in the DAT Tables and use that to increase the frame counter of the moviefileout ?

not sure how to do this … :blush:

If you post your .toe file it’s easier for people to answer.

The TOE has got my app credentials in it so i’d rather not post it and without app credentials it won’t work, but here is a screenshot of the network.

Your thought of using a Dat Execute DAT is correct.
And the Movie File Out TOP is prepared for this. If you place a new Movie File Out TOP and set it to save images instead of movies, you’ll notice it uses its “n” parameter by default to change the number in the filename for each saved image.

I made an example for you. When you make any change in the table a new screenshot is saved in the project directory. You can also use the buttons to test.

record-image.zip (5.68 KB)
Explanation: the Dat execute DAT clicks a button, which triggers the count CHOP to increment, and we use that number to drive the n parameter, so we’ll have different filenames for each saved image. Next to that we use the same button signal which triggers the count chop, to also set the ‘record’ parameter of the Movie file out TOP on or off.

This patch uses the concept of referencing, where you drive the parameters of an operator with the values from another operator. This is a very powerful concept which you will use in almost all of your TD work, you can learn more about it in this tutorial:
Understanding referencing in TouchDesigner

thank you so much for helping out, good to know i was on the right track though :stuck_out_tongue: and many thx for the tutorial link, i’ve used referencing a bit but it will be helpful to look at this from the ground up again.

i think i have understood how your network worksand tried to integrate it into mine. For some reason it doesn’t work, the moviefileout stays black and no images are saved to the location i specify. I tried to go through the whole network again one by one and can’t see where i made a mistake. I’m still troubleshooting but in the meantime here’s an updated screenshot with your elements integrated:

EDIT, ok i found it, the N parameter and the file parameter was not switched to expression. It’s now working, thank you !!! :laughing:

now i’m trying to figure out how i can select the path for all images to go into a folder. For the moment the images are going into the project folder:

‘TDMovieOut.’+str(me.par.n.eval())+‘.jpg’

since i’m trying to learn while doing this i’ve been looking for documentation or tutorials to figure out what the syntax for file paths would be to use in this expression. Where would i go look for this info in the wiki or docs ?

if i just add the path like this:

Images/‘TDMovieOut.’+str(me.par.n.eval())+‘.jpg’ it shows an error

also do you know of a good general tutorial for expressions in Touch ?

expressions in TD parameters are by default written in Python. So if you have trouble creating the right expression, you can always just google how to combine text and numbers and variables in python.

The python term for combining multiple strings/numbers/variables to one expression is concatenating , so google on concatenating+python.

See also this basis tutorial about python variables and strings

see some examples of python expressions you can use in TD on the wiki

See also this video: Writing Python References in TD

In your case, look at where you placed the first ’ quote in your new expression, and where the other ’ quotes are.

this is great, it’s all working now … thx for the tip about the quotation marks :smiley:

now that the base is working i realize that there is of course a bottleneck and it takes longer to save a file than the interval between tweets on very active hashtags. i suppose i could save to a fast SSD to reduce the latency a bit but it would probably better to buffer the tweets somehow to make sure all tweets are caught.

Is there a standard way to manage a bottleneck like this in the moviefileout node and prevent lost data ? i suppose that’s always going to be an issue to adress when capturing images from a live network as image sequences ?

well done.
look into the Cache TOP to save all images to GPU memory and the Cache Select TOP to show one selected image from that cache.
If you open Help-> Operator Snippets you’ll see examples for both.

cool that sounds exactly like what i need. so now the question i guess is what expression or operator to plug into the Index parameter of the cacheselect.

one thing i don’t understand from the help of the cache top:

The Cache TOP acts as a delay if you set Output Index to negative numbers and leaving the On parameter at 1.

i can’t see any ON parameter :blush: and does that mean that if i set this to -20 it will hold 20 images in the cache ?

then in the cache select top it says:

Cache Index index - Specify the image to grab from the sequence of cached images. The index starts at 0, which is the current image. Images are then accessed backwards in time, such that the image before the current image has an index of -1, the image before that has an index of -2, and so on.

i’m rather confused :laughing:

i think i have it connected right but not yet figured out how the caching and indexing works, it’s a bit hard to figure this out from the little documentation.

and: operator snippets … very cool, did not know that resource yet. not that it makes me any the wiser for the moment but it’s great to get some examples to supplement the raw documentation

Hi,

This thread may be dead but will give it a go.

I successfully took the image save example and integrated it into my network and this is working.

I was looking for some help in taking that saved image and presenting it onto another screen / container - potentially emailing it out. Any one any ideas?

Any help would be greatly appreciated.