Import Particle data from an ASCII Text file

Discussions about SOFTIMAGEs© Interactive Creative Environment©
User avatar
blaxxun
Posts: 48
Joined: 04 Mar 2014, 13:23
Location: Austria
Contact:

Import Particle data from an ASCII Text file

Post by blaxxun » 05 Aug 2014, 17:00

Hello forum,

I made a nice Pointcloud of our garden with VisualSFM.
It generated a PLY ASCII textfile which iam able to view in meshlab.

I tryd already to use the Import Script from Dan Yargici "DY_CreatePointcloudFromPLY" which actually imports my point cloud with color information.
Unfortunatly it distributes all particles on a sphere. (Which is Photosynth related i guess..)

Since the text file format is very simple i thought it must be possible to achieve a parsing with ICE.

the nx ny nz data is actually not required.

Code: Select all

ply
format ascii 1.0
element vertex 111089
property float x
property float y
property float z
property float nx
property float ny
property float nz
property uchar diffuse_red
property uchar diffuse_green
property uchar diffuse_blue
end_header
16.1584 -0.103792 -0.377599 -0.934338 0.197876 -0.296407 151 145 117
16.1552 -0.0861699 -0.492039 -0.869241 0.344342 0.354752 116 124 90
16.1431 -0.101317 -0.522853 -0.970747 0.205974 0.123388 145 154 115
16.3199 -0.11485 -0.787862 -0.888426 0.342091 0.30606 134 93 84
16.1982 -0.100074 -0.903862 -0.703254 0.674441 -0.224866 135 90 84
16.1748 -0.0971197 -0.914778 -0.712424 0.701012 -0.0321534 131 88 83
16.1968 -0.098827 -0.907985 -0.739968 0.596807 0.310273 137 91 86
....
The problem is that iam not really very fit in ICE.
Maybe someone could point me in the right direction on how to do this?
Last edited by blaxxun on 06 Aug 2014, 23:34, edited 1 time in total.

Bullit
Moderator
Posts: 2621
Joined: 24 May 2012, 09:44

Re: Import Particle data from a ASCII Text file

Post by Bullit » 05 Aug 2014, 19:49

Are you aware of this thread? It has more than Dan script.

https://groups.google.com/forum/#!topic ... 0UpQLeb5Ho

User avatar
blaxxun
Posts: 48
Joined: 04 Mar 2014, 13:23
Location: Austria
Contact:

Re: Import Particle data from a ASCII Text file

Post by blaxxun » 05 Aug 2014, 22:33

hi bullit, yes i also stumbled over this thread already and trying to figure out how to fix the errors i get when i execute the script.

thanks!

User avatar
Hirazi Blue
Administrator
Posts: 5107
Joined: 04 Jun 2009, 12:15

Re: Import Particle data from a ASCII Text file

Post by Hirazi Blue » 05 Aug 2014, 22:57

What kind of errors do you get? :-\
And could you perhaps share the whole ply file (I assume the quoted text is only partial)?
Stay safe, sane & healthy!

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 15:31
Skype: csaezmargotta
Location: Sydney, Australia
Contact:

Re: Import Particle data from a ASCII Text file

Post by csaez » 06 Aug 2014, 02:56


User avatar
blaxxun
Posts: 48
Joined: 04 Mar 2014, 13:23
Location: Austria
Contact:

Re: Import Particle data from a ASCII Text file

Post by blaxxun » 06 Aug 2014, 23:00

Hello,

Actually the data that i need is only xyz and rgb.

A PLY File can also hold nx ny nz which are normals.

If i edit the VisualSFM point cloud i can save the result as .ASC which gives me only xyz and rgb.
A .xyz File can only hold xyz and normal data but not color information (as far as i experienced).

@Hirazi:
Yes you are totaly right, the code is of course only a snippet.
Here are the errors i get with "import_xyz_points_with_colours.py" with an PLY (xyz, asc, txt) file:

Code: Select all

This Error i get with an PLY File
# ERROR : Traceback (most recent call last):
#   File "<Script Block >", line 344, in <module>
#     main()
#   File "<Script Block >", line 31, in main
#     pointDataList = ParsePoints(pointsList, pointsPerc)
#   File "<Script Block >", line 187, in ParsePoints
#     tmpPosition = [v*oPset.pSpatialScale.value for v in map(float, kkpoint[:3])]
# ValueError: could not convert string to float: ply
#  - [line 187]

Code: Select all

This Error i get with an ASC and XYZ File
# ERROR : Traceback (most recent call last):
#   File "<Script Block >", line 344, in <module>
#     main()
#   File "<Script Block >", line 31, in main
#     pointDataList = ParsePoints(pointsList, pointsPerc)
#   File "<Script Block >", line 187, in ParsePoints
#     tmpPosition = [v*oPset.pSpatialScale.value for v in map(float, kkpoint[:3])]
# ValueError: invalid literal for float(): 9.384780 2.214790 0.866307 157 168 133
#  - [line 187]
I attached the .ASC File from our garden.


The Format is: xyz coordinates and RGB data

Code: Select all

9.384780 2.214790 0.866307 157 168 133
7.093220 2.314450 3.353310 152 138 119
-7.812230 -1.471130 2.500930 122 131 95
7.636800 2.234250 1.851530 175 183 146
-3.336110 1.051300 2.870490 113 118 104
-4.339330 1.332210 4.495970 46 57 49
-6.387460 -1.555460 1.845170 90 102 74
-6.135600 -1.261350 1.252850 160 168 125
8.078460 2.131940 -1.320730 159 167 126
8.305530 1.848030 3.582530 142 136 132
-6.572130 1.261340 -0.499007 34 38 31
....

Thanks for the link csaez,

maybe i can figure out how to use this code to build up something that works (which i doupt) since my
programming skills are not really good.
But until i have this pointcloud in Softimage i wont stop!

How do i integrate this python module by Bradley Gab so the python script imports/includes it?

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 15:31
Skype: csaezmargotta
Location: Sydney, Australia
Contact:

Re: Import Particle data from an ASCII Text file

Post by csaez » 07 Aug 2014, 00:13

Let's give it a try!

Do you have python installed?
If so, uncompress the attached file (the entire directory) and drag your data file into quick_parser.py, it should create a new .icecache file for you.

I tested it using the sample provided in your previous post (sample.txt) and it works :)

Image


Hope this helps,
Cheers
Attachments
quick_parser.zip
(3.78 KiB) Downloaded 150 times
quick_parser.jpg

User avatar
blaxxun
Posts: 48
Joined: 04 Mar 2014, 13:23
Location: Austria
Contact:

Re: Import Particle data from an ASCII Text file

Post by blaxxun » 07 Aug 2014, 14:00

Hello Csaez,

Thanks for this script.

I did what you sayd.

I had python 2.7.6 already installed on windows.
I extracted the whole quick_parser folder.

It contains icecache.py, quick_parser.py and sample.txt

When i drag the sample.txt file on the quick_parser.py file nothing happens.

When i open the quick_parser.py in Python 2.7.6 Shell and run it i get

Code: Select all

Traceback (most recent call last):
  File "C:\Users\blaxxun\Desktop\quick_parser\quick_parser\quick_parser.py", line 23, in <module>
    parse(sys.argv[1])
IndexError: list index out of range
When i open the quick_parser.py in Python 2.7.6 Shell and add the sample.txt numbers at the end of the script i get

Code: Select all

invalid syntax error
What exactly do you mean with:
drag your data file into quick_parser.py

Here is the Link to the whole pointcloud. Thought i attached it yesterday, but must have been to big.
http://www.c3d.at/si-community/Garden.zip

pezetko
Posts: 40
Joined: 09 Jun 2009, 01:58

Re: Import Particle data from an ASCII Text file

Post by pezetko » 07 Aug 2014, 16:22

Run cmd then type:

Code: Select all

python path\to\quick_parser.py path\to\your\file\Garden.asp

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 15:31
Skype: csaezmargotta
Location: Sydney, Australia
Contact:

Re: Import Particle data from an ASCII Text file

Post by csaez » 07 Aug 2014, 17:06

blaxxun wrote:When i drag the sample.txt file on the quick_parser.py file nothing happens
There must be a new icecache file in the same directory of the original file ;)

User avatar
blaxxun
Posts: 48
Joined: 04 Mar 2014, 13:23
Location: Austria
Contact:

Re: Import Particle data from an ASCII Text file

Post by blaxxun » 07 Aug 2014, 18:57

Okay,

i deleted now my Python installation and reinstalled the newest version 3.4

When i type the command in the windows shell i get several errors (see image)

I can not assotiate the .py files with python.exe, thats why there are no python icons on the quick_parser.py and icecache.py files.

Also i can still not drag and drop the garden.txt file on the quickparser.py. It doesent work.

When i execute the script from the command line a folder gets created called _pycache_
with a file inside called "icecache.cpython-34.pyc"

No icecache file is created.
Attachments
Python_Error.jpg

User avatar
blaxxun
Posts: 48
Joined: 04 Mar 2014, 13:23
Location: Austria
Contact:

Re: Import Particle data from an ASCII Text file

Post by blaxxun » 07 Aug 2014, 19:06

I deleted now the python 3.4 installation and installed python 2.7.8

The .py files are now registerd, the commandline execution creates the Garden.icecache file now.

Drag and drop still doesnt work.

Many thanks! :D

Now i try the created icecache file in XSI

User avatar
blaxxun
Posts: 48
Joined: 04 Mar 2014, 13:23
Location: Austria
Contact:

Re: Import Particle data from an ASCII Text file

Post by blaxxun » 07 Aug 2014, 19:26

Hello,

The import of the .icecache file works without problems.

Also the pointpositions seem to be ok.
Just the colors are somehow messed up.

I have to investigate on that further.
Attachments
comparison_XSIvsMeshlab_small.jpg

User avatar
blaxxun
Posts: 48
Joined: 04 Mar 2014, 13:23
Location: Austria
Contact:

Re: Import Particle data from an ASCII Text file

Post by blaxxun » 08 Aug 2014, 13:12

I looked into the code and i dont realy understand python.

What i can say is that the 255 range color information gets transferred into a float value and gets divided by 255 which should actually
give the correct 0-1 range of softimage.

But in the point cloud i get the colors are messed up and there are even black particles which are not present in the original
Garden point cloud.

@csaez

can you maybe figure out whats causing this? iam somehow lost with python code.

Thank you very much!

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 15:31
Skype: csaezmargotta
Location: Sydney, Australia
Contact:

Re: Import Particle data from an ASCII Text file

Post by csaez » 08 Aug 2014, 19:25

Hi blaxxun,
I gave it another try using the capture as reference and I think it's working fine now.

Image

BTW, nice garden ;)

Cheers!
Attachments
garden.jpg
quick_parser.zip
(3.4 KiB) Downloaded 127 times

User avatar
blaxxun
Posts: 48
Joined: 04 Mar 2014, 13:23
Location: Austria
Contact:

Re: Import Particle data from an ASCII Text file

Post by blaxxun » 08 Aug 2014, 22:58

Hello Csaez,

THANK YOU!!!!

It works now! And i really cant tell you how much you helped me out.
Thank you VERY much!

Please, i really wanna donate something to you for your efforts.

I wouldnt been able to do that by my own. No way ever!

PM'd you...

Post Reply

Who is online

Users browsing this forum: No registered users and 46 guests