Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

Count images in folder

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

joysprod
Posts: 201
Joined: 20 Jan 2012, 12:24
Location: United Kingdom

Count images in folder

Post by joysprod » 23 Oct 2012, 18:03

I have a project where I want to display a number of images that have been uploaded to a remote folder. The quantity of images will vary and I thought that there must be a way to have each image displayed on an individual polygon, although at present not certain the best way to achieve this. Ideas? I thought somehow of using multiple polygons arranged with an 'Arrange' node where each texture gets its file from an array obtained by somehow building an XML list of names in the folder.

In the course of my experiments I thought that it would be a good idea to start by counting somehow how many files in that folder. The DIR node has an AutoUpdate tick mark, but no matter what it is set at, does not update the file list of new jpgs added to the folder. Can it only detect the content of an image changing rather then a file being added or subtracted?

Is my idea only achievable via using a Script?

Peter

User avatar
Daniel Willer
Posts: 309
Joined: 06 Jan 2012, 18:12

Re: Count images in folder

Post by Daniel Willer » 24 Oct 2012, 09:36

Hey I do it always like that.

I build a Hierarchy container that contains a Rectangle a Color and a Texture loader. Each container also has a Stringsplitter node that gets the Current Element count from a ContainerInfo node and exposes the Input.
At the root level I read a Directory with a Directory node that gives me a Result string inlcuding all Pictures seperated by linebreaks (It will be seperated by commas in Ventuz4) so I pipe the result string in all the containers on the input of the StringSplitter so that each StringSplitter get the image based on the ContainerNameIndex.
On the root level I use another StringSplitter to get the Count of the Directory ResultString, each container blocks itself if his own ContainerNameIndex is bigger than the image count.

Cherio!

joysprod
Posts: 201
Joined: 20 Jan 2012, 12:24
Location: United Kingdom

Re: Count images in folder

Post by joysprod » 25 Oct 2012, 10:39

Hi Daniel,

Thanks for your ideas on this. I was 80% there when I read your reply. My idea was working but not as expandable as yours using the container information. Modified mine to work as per your idea.

I still think that the DIR node is not functioning as the book says. Have a look at my zip file where I have a folder of images and a VZA. According to the book the DIR should auto update on the contents of the folder. It does not detect an image bing moved in or out of the folder, and I am unable to have it detect if an image is overwritten with new content. Also the sort by date doesnt seem to correspond to either the 'date modified' or 'date created' as shown by Windows, so not certain what Ventuz is sorting on. See if you get the same results.

Regards

Peter
DIR.zip
(161.45 KiB) Downloaded 337 times

chriss0212
Posts: 666
Joined: 18 Jan 2012, 20:56
Location: wuppertal
Contact:

Re: Count images in folder

Post by chriss0212 » 25 Oct 2012, 14:26

hi daniel

i can agree with peter! the dir node is not updating if there is any change in the folder! you have to dectivate and reactivate the auto update function!

and the dir node and textsplitter: i thoght thats my idear....but good to know, that you do it same way ;)

greetz

christian

User avatar
Daniel Willer
Posts: 309
Joined: 06 Jan 2012, 18:12

Re: Count images in folder

Post by Daniel Willer » 25 Oct 2012, 16:17

Your are right the AutoUpdate property is not doing what it supposed to. I wrote a ticket in the interal wiki.

joschy
Posts: 142
Joined: 19 Jan 2012, 07:39
Location: Düsseldorf, Germany
Contact:

Re: Count images in folder

Post by joschy » 25 Oct 2012, 16:33

May be it is simpler to write a simple C# Script which get the directory path in.
using System.IO;

string[] filePaths = Directory.GetFiles(@"c:\MyDir\");
// returns:
// "c:\MyDir\my-car.BMP"
// "c:\MyDir\my-house.jpg"
and with wildcard
string[] filePaths = Directory.GetFiles(@"c:\MyDir\", "*.bmp");
// returns:
// "c:\MyDir\my-car.BMP"
When you use the Pro Version, sure.
3DJo - [Ventuz] freelancer and trainer

User avatar
Chris
Posts: 108
Joined: 14 Aug 2012, 09:10
Location: UK

Re: Count images in folder

Post by Chris » 25 Oct 2012, 23:54

Hi Peter
Just wondering about the background to the initial post? What's the plan for the scene?

I understand the basic idea, but do you want to change the image when new ones are added? is that why you need to keep track of the number of files in the folder?
.....every time an image is added to the folder, you want it to add to the scene along with all the others which are already present? or do you want new ones to appear on polygons which in turn pushes old ones out? ( so you only ever have say 6 rectangles at any one time in the scene and the images simply change)

Don't want to complicate things :P but the more understanding the more tailored the answer can be ;)

The way i see it so far is using an array in a script as Joschy says or a list in a script.


Chris

joysprod
Posts: 201
Joined: 20 Jan 2012, 12:24
Location: United Kingdom

Re: Count images in folder

Post by joysprod » 26 Oct 2012, 17:54

Hi Chris,

At the moment its at the idea stage after demoing to a client. They want to be able to take a load of photos that get automatically uploaded to the 'cloud' from a number of mobile phones at an exhibition. Haven't really thought much more about how to display or had a brief on the number of images to be kept on screen. Only at early stage with C# so may need to outsource some of that.

Regards

Peter

User avatar
Chris
Posts: 108
Joined: 14 Aug 2012, 09:10
Location: UK

Re: Count images in folder

Post by Chris » 28 Oct 2012, 12:32

I'm also at the early stages of C#, but I like a challenge :)
The result I came up with was using a List in a script. Convert the list to an array and pipe out the array into a string indexer.
can also add an int output from the script which gets the number of files from the "List.Count" command.

Seems to work ok, plus you can order the results in date created order (something i'm still trying to workout :?) which will be good for only showing newest pics ;)
sure you thought of this one but, also a good idea to link the rectangle sizes to the image node sizes and normalize ;) phones take many different pic sizes...this way the geometry resizes on the fly ;)

to all: would that be an efficient way to do it??

chris

User avatar
Chris
Posts: 108
Joined: 14 Aug 2012, 09:10
Location: UK

Re: Count images in folder

Post by Chris » 28 Oct 2012, 12:39

:P :lol:
now im looking at it the DIR node does all of that! :lol:

told you i like a challenge!

now where was I....oh yes....cup of tea ;)

Post Reply