Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any Python demo to read the .sift file from VisualSFM? #43

Open
ZeroSteven618 opened this issue Jul 20, 2020 · 1 comment
Open

Comments

@ZeroSteven618
Copy link

After VisualSFM each image will generate a sift file and the SIFT feature points descriptors data is in the file. 
It seems vital to get the descriptors into h5 files as "img-kp-minsc-2.0.h5" files to finish LIFT training pre-processing. 

However,  the sift files from VisualSFM are binary files and according to: http://ccwu.me/vsfm/doc.html#usage
The sift files are in the format in description in **"Use your own feature detectors"** part as follows:

[Header][Location Data][Descriptor Data][EOF]
[Header] = int[5] = {name, version, npoint, 5, 128};
name = ('S'+ ('I'<<8)+('F'<<16)+('T'<<24));
version = ('V'+('4'<<8)+('.'<<16)+('0'<<24)); or ('V'+('5'<<8)+('.'<<16)+('0'<<24)) if containing color info
npoint = number of features.

[Location Data] is a npoint x 5 float matrix and each row is [x, y, color, scale, orientation].
Write color by casting the float to unsigned char[4]
scale & orientation are only used for visualization, so you can simply write 0 for them

  • Sort features in the order of decreasing importance, since VisualSFM may use only part of those features.
  • VisualSFM sorts the features in the order of decreasing scales.

[Descriptor Data] is a npoint x 128 unsigned char matrix. Note the feature descriptors are normalized to 512.

[EOF] int eof_marker = (0xff+('E'<<8)+('O'<<16)+('F'<<24));

But I still can not understand the instruction.
How to read the sift file properly in Python code?
What is the encoding parameter of the open("r", encoding) function? 'utf-8' is not right to read the sift files.
I tried encoding='utf-16' but also failed.

With the help of Notepad++ Hex-Editor plugin, I understand the [Header] part but I still can not work out the rest parts.
Can someone help me with the sift file data reading with Python? Thanks a lot!

@aditipanda
Copy link

Does anybody have this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants