Thursday, 19 February 2009

Photosynth point cloud in c# (alpha...)

Recent posts concerned with Photosynth and its availability on Silverlight 2.0 (and Moonlight) lead me to thinking about how to utilize the data generated by Photosynth (in Deep Zoom Viewer for example).

The first post - Exporting point clouds from Photosynth - was linked directly from Blaise Aguera y Arcas himself; it linked to another with some more detailed instructions - Photosynth Export Tutorial. Unfortunately all the code is in Python.

It seemed obvious to try and convert the Python script bin_to_csv.py to C#. At the risk of embarrassing myself with a poor translation, I'm posting the "work in progress" here in case it's of interest.

You can view the code for the .NET Console application (excerpt below) or download the Visual Studio project and test data ZIPped (238Kb)
code excerpt
NOTE: that I couldn't get the offset calculation to work - I ended up manually cycling through even numbers to get decent output for each .bin file - obviously this suggests perhaps I've screwed something up; but until I get time to test/work on it further, I'm not sure what...

I was testing data from this synth of Sydney



which seems to be just two files: points_0_0.bin and points_0_1.bin.
The output from the C# is points_0_0.txt (216Kb) and points_0_1.txt (109Kb).

Here's the first few lines
-6.723576, -1.410307 ,0.5756224, 4, 60, 8
-4.927393, -0.02451534 ,0.8836676, 21, 41, 21
-1.982108, 3.687859 ,0.03735788, 22, 45, 22
-1.845265, 3.327285 ,0.2232598, 6, 13, 6
-1.977082, 3.292458 ,0.3644025, 2, 8, 6
-1.478826, 3.45144 ,0.3358887, 9, 17, 9


I'm pretty sure at least some of the data is good - I could plot the first 56 points on Vladimir Bodurov's Silverlight 3D project, but I haven't had a chance to validate them any further.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.