OpenSfM
OpenSfM copied to clipboard
Set code inputs without using the command line
I want to debug the code line by line to understand more. I did the data address by changing the functionparser.add_argument("--dataset",default="data/lund/",help="dataset to process"). But I do not know where to set inputs like Extract _Metadata or Extract Features. Please help me
Hi @Alirezasoltani19951374 ,
You could just start a debugger with the same parameters you would use in a terminal. No need to change anything in the code.
Just in case you want to follow a different route:
extract_metadata
,create_tracks
,... are opensfm commands. The structure is a bit tricky to figure out. Every command is a class with a name
attribute that is then matched to the positional command
argument here:
https://github.com/mapillary/OpenSfM/blob/c250de55ee3053fc7d8b433860664206ba8b2841/opensfm/commands/command_runner.py#L33-L37
The commands themselves are imported from __init__.py
.
Good luck
Hi @fabianschenk, thanks for responding, I did not understand what you said.
I get this error when I go line by line of code. While I have specified the location of the data by functionparser.add_argument("--dataset",default="data/lund/",help="dataset to process")
Hi @Alirezasoltani19951374 ,
Even though I absolutely do not understand why you would set the parameters instead of passing them to the debugger, you could just set them above the with dataset_factory(....)
something like this (untested code!):
args.dataset = "data/berlin" # Here you might need the full path /home/OpenSfM/.../data/berlin
args.dataset_type = None # You might need a different value here.
args.command = "extract_metadata"
with dataset_factory(args.dataset, args.dataset_type) as data:
.....
If you have other problems with debugging in VS Code, please consult the VS Code documentation!
Best, Fabian
Hi@fabianschenk , I apologize for taking your time. When running a program through a command line, for example
python3 bin / opensfm_main.py extract_metadata data / lund /
Runs well.
But when I passing the parameters through Visual Studio code, I get the following error
Traceback (most recent call last):
File "/home/alireza/Test01/OpenSfM/bin/opensfm_main.py", line 28, in
Hi @Alirezasoltani19951374 ,
This is likely because the debugger starts in a folder (probably your home directory), where data/berlin/
does not exist.
Use the full path /home/OpenSfM/data/berlin
like I already wrote as comment above!
args.dataset = "data/berlin" # Here you might need the full path /home/OpenSfM/data/berlin
I've debugged OpenSfM quite often myself and it works. Please, make sure to double check file paths, read the VS Code doc and use Google search.