How to read the .mat file from Visual SFM in Python Code?

285 views Asked by At

Can someone help me with the Python code to read the .mat file generated from Visual SFM? You can download the .mat file from the link:

https://github.com/cvlab-epfl/tf-lift/tree/master/example

You can get a .mat file in the zip in the link and the file is what I am asking for help. It seems to be an ASCII file. I do not know how to read the data in the file. I tried to load the data in the .mat file with scipy.io.loadmat() but an error occurred as:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
raise ValueError('Unknown mat file type, version %s, %s' % ret)
ValueError: Unknown mat file type, version 20, 0

Can someone help me to load the data in the file with Python code?

Thanks for your help and replies sincerely.

1

There are 1 answers

5
Alan Race On BEST ANSWER

If you mean this VisualSFM (http://ccwu.me/vsfm/doc.html), then the .mat file isn't a MATLAB .mat file, but a 'match' file.

From the website:

[name].sift stores all the detected SIFT features, and [name].mat stores the feature matches.

It seems there is C++ code for reading this file (http://ccwu.me/vsfm/MatchFile.zip) which you could use to write a python parser.

Additionally, it seems like there is a python socket interface to VSFM, which may allow you to do what you want https://github.com/nrhine1/vsfm_util