ahojnnes / local-feature-evaluation

Comparative Evaluation of Hand-Crafted and Learned Local Features
227 stars 48 forks source link

colmap_import sqlite3 error #3

Closed andrefaraujo closed 7 years ago

andrefaraujo commented 7 years ago

Hi,

I was able to follow all steps from the instructions but am having a problem importing features/matches into colmap.

(I am using my own detector/descriptor, but I made sure the writing format is correct, by reading with the provided MATLAB functions and similarly by checking that the read_matrix function from colmap_import.py reads the features properly).

When running

python scripts/colmap_import.py --dataset_path path/to/Fountain

I get

Importing features for 0010.png
Traceback (most recent call last):
  File "scripts/colmap_import.py", line 94, in <module>
    main()
  File "scripts/colmap_import.py", line 65, in main
    memoryview(keypoints)))
sqlite3.InterfaceError: Error binding parameter 3 - probably unsupported type.

I have investigated quite a bit, but still cannot figure out what the problem is. It looks like the issue is with memoryview(keypoints). Could this potentially be a python version problem? (are you using python 2.7?)

Another thing I am thinking is: is the command (ie, the one that ends in line 65 of colmap_import.py) trying to just write the address of keypoints into data? I am not familiar with SQL, so apologies if this is a dumb question. If this is the case, maybe I could somehow cast the memory address returned by memoryview(keypoints) into an int before passing it into the cursor.execute call?

BTW, when I print as print(memoryview(keypoints)) (right before the error), I get: <memory at 0x7f39516b4478> -- does this look like what this should be?

Thanks for the help!

ahojnnes commented 7 years ago

This has to do with a changed buffer interface in Python 2 and 3. Can you try keypoints.tobytes() or alternatively np.getbuffer(keypoints) and report back which of the two worked for you?

andrefaraujo commented 7 years ago

The np.getbuffer(keypoints) option worked!

The tobytes() option did not work, it gave me:

Importing features for 0010.png
Importing features for 0009.png
Importing features for 0008.png
Traceback (most recent call last):
  File "scripts/colmap_import.py", line 94, in <module>
    main()
  File "scripts/colmap_import.py", line 65, in main
    keypoints.tobytes()))
sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.
ahojnnes commented 7 years ago

If you pull the latest changes from Github, it should be fixed and working for Python 2 and 3. Thanks for reporting. (see https://github.com/ahojnnes/local-feature-evaluation/commit/dba9ce95fd23a297dee6e7220013c756843f3100)

andrefaraujo commented 7 years ago

The to_string version you pushed does not work for me. I get:

Importing features for 0010.png
Traceback (most recent call last):
  File "scripts/reconstruction_pipeline.py", line 265, in <module>
    main()
  File "scripts/reconstruction_pipeline.py", line 231, in main
    matching_stats = import_matches(args)
  File "scripts/reconstruction_pipeline.py", line 70, in import_matches
    keypoints.tostring()))
sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.

When I change to using the np.getbuffer(keypoints), all works fine.

andrefaraujo commented 7 years ago

Also, it looks like some files were deleted? eg, scripts/colmap_import.py from step 5 in the instructions

ahojnnes commented 7 years ago

Yes, there is a fully automated reconstruction pipeline now. Please, refer to the new instructions.

andrefaraujo commented 7 years ago

Oh, it looks like your current version of the instructions still mentions the scripts/colmap_import.py script. Maybe you want to remove that section not to confuse people :)

But most importantly, I was able to get the scripts/reconstruction_pipeline.py script to work. (note that I had to do the change to using np.getbuffer(keypoints) as mentioned a few comments above)

Thanks a lot for your help!

ahojnnes commented 7 years ago

I added back the script. Thanks for the feedback.