0

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.

Breadbao
  • 3
  • 1
  • This just looks like whatever Visual SFM is, its not saving the data correctly. – Ander Biguri Jul 09 '20 at 13:42
  • But Visual SFM can open those files and process the data. I need to read data in those files with Python3 but unfortunately I got stuck for a long time. – Breadbao Jul 10 '20 at 03:21
  • If visual SFM can write them badly, one can suspect that it can read them badly. It just seems that they assume the mat file version, which can not be done in general. But as it only reads/writes one, it does not save which version. Other readers need to know which file version though. – Ander Biguri Jul 10 '20 at 08:29

1 Answers1

0

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

Alan Race
  • 41
  • 3
  • Well, the Visual SFM is actually the (ccwu.me/vsfm/doc.html). And I will try with your hints in the following days. Thank you. – Breadbao Jul 10 '20 at 15:31
  • I tested with your hints with the C++ code for reading this file (http://ccwu.me/vsfm/MatchFile.zip) and the relevant operation in VisualSFM GUI and I have got the match information. Thank you. However, I need to additionally read the data in the .sift file for SIFT Feature Point Description information. How to solve the problem? – Breadbao Jul 15 '20 at 06:53
  • There seems to be some information on the website hinting at the file format for .sift, so perhaps you can use that to write a parser? It seems like a pretty simple binary format - check 'Option 3' in the section 'Use your own feature detectors'. – Alan Race Jul 15 '20 at 08:07
  • Excuse me, what is the difference between the option: SfM->Pairwise Matching->Export Feature Matches and the option:SfM->Pairwise Matching->Export F-Matrix Matches. Both can output the match results into txt format. I wonder whether they have difference of match results. – Breadbao Jul 16 '20 at 02:41
  • Until present, I found that in the same image pair: SfM->Pairwise Matching->Export Feature Matches will have more matches count than SfM->Pairwise Matching->Export F-Matrix Matches. It seems that the VSFM did selection from feature matches to F-matrix matches. What happened in the selection process? – Breadbao Jul 16 '20 at 03:03