3DOM-FBK / COLMAP_SLAM

Visual-SLAM based on COLMAP API
MIT License
245 stars 23 forks source link

Failed to launch Mapper (colmap) on windows on MachineHall exemple #2

Closed vestri closed 10 months ago

vestri commented 10 months ago

Hi, I have installed colmap_slam using conda and python 3.9.17 on a windows 10 machine. I downloaded EuRoC\MH_01_easy and updated the config.ini script with all path as you did in the sample ini files. I am using same Colmap version as yours: COLMAP-3.8-windows-cuda. When I launch main.py, everything is fine until mapper is called. I could see the simulator working and features tracked in the opened window. Unfortunately, mapper call does not work and I don't know why.

Here is the log: Processing image pair (imgs\cam0\1403636581363555584.jpg, imgs\cam0\1403636581763555584.jpg) 2023-10-20 09:45:35,838 - INFO - pointer 8 c 8 2023-10-20 09:45:35,980 - INFO - Pydegensac found 205/228 inliers 2023-10-20 09:45:35,980 - INFO - median_match_dist: 41.05 camera 0 camera 1 2023-10-20 09:45:35,998 - INFO - Frame accepted. New_keyframe image_id: 10 2023-10-20 09:45:36,027 - INFO - [Keyframe Selection] | features extraction=0.111, matching=0.030, innovation check=0.019, 2023-10-20 09:45:36,035 - INFO - Processing image pair (imgs\cam0\1403636581763555584.jpg, imgs\cam0\1403636581963555584.jpg) 2023-10-20 09:45:36,035 - INFO - pointer 10 c 9 2023-10-20 09:45:36,325 - INFO - Pydegensac found 222/248 inliers 2023-10-20 09:45:36,326 - INFO - median_match_dist: 23.61 2023-10-20 09:45:36,326 - INFO - Frame rejected 2023-10-20 09:45:36,349 - INFO - [Keyframe Selection] | features extraction=0.242, matching=0.047, innovation check=0.001, 2023-10-20 09:45:36,351 - INFO - DYNAMIC MATCHING WINDOW: 1 2023-10-20 09:45:36,352 - INFO - Initialize an empty database 2023-10-20 09:45:36,353 - INFO - Feature extraction 2023-10-20 09:45:36,762 - INFO - Sequential matcher 2023-10-20 09:45:39,871 - INFO - MAPPER Traceback (most recent call last): File "G:\RDVision\Micado\code\COLMAP_SLAM\main.py", line 497, in colmap.Mapper( File "G:\RDVision\Micado\code\COLMAP_SLAM\lib\colmapAPI.py", line 171, in Mapper subprocess.call( File "C:\Users\cvestri\miniconda3\envs\colmap_slam\lib\subprocess.py", line 349, in call with Popen(*popenargs, **kwargs) as p: File "C:\Users\cvestri\miniconda3\envs\colmap_slam\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\cvestri\miniconda3\envs\colmap_slam\lib\subprocess.py", line 1436, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable

When it crashes, I tried to run it manually like this (not all options in your config): .\COLMAP.bat mapper --image_path G:\RDVision\Micado\COLMAP_SLAM\imgs\ --database_path G:\RDVision\Micado\COLMAP_SLAM\outs\0\db.db --output_path G:\RDVision\Micado\COLMAP_SLAM\outs\0\ it works but failed to create a sparse model but at least it is launched

Here is the log:

============================================================================== Finding good initial image pair

=> No good initial image pair found. => Relaxing the initialization constraints.

============================================================================== Finding good initial image pair

=> No good initial image pair found. => Relaxing the initialization constraints.

============================================================================== Finding good initial image pair

=> No good initial image pair found.

Elapsed time: 0.017 [minutes] ERROR: failed to create sparse model

Do you experienced the same problem? Is colmap result the problem or do I have a problem in subsystem.call in colmapAPI.py? Thanks

lcmrl commented 10 months ago

Hi, it seems that it does not find the path to the executable. Have you set COLMAP_EXE_DIR variable in config.ini to point to the parent folder of COLMAP.bat? Something like: COLMAP_EXE_DIR = C:\Users...COLMAP\COLMAP-3.8-windows-cuda

vestri commented 10 months ago

yes I have set this path: COLMAP_EXE_DIR = G:\RDVision\Micado\raw_data\COLMAP-3.8-windows-cuda I think there is something wrong in the path but I do not understand why. I used anaconda powershell.

lcmrl commented 10 months ago

Ok, try to write a script to understand if you can run mapper API from colmap. Something like this

import subprocess

path_to_colmap_exe = blabla
path_to_images = blabla
database_path = blabla
output_path = blabla

subprocess.call(
    [
        str(path_to_colmap_exe),
        "mapper",
        "--image_path", path_to_images,
        "--database_path", database_path,
        "--output_path", output_path,
    ],
)

if it does not work try to substitute subprocess.call with subprocess.run

vestri commented 10 months ago

your script works with both subprocess.call and subprocess.run. But unfortunalety not in colmapAPI.py. I tested with and without other args/subprocess.run/stdout=subprocess.DEVNULL, but always the same error. I do not understand

vestri commented 10 months ago

If I put your code directly in main.py, it works and ended like this:

============================================================================== Finding good initial image pair

=> No good initial image pair found.

Elapsed time: 0.014 [minutes] ERROR: failed to create sparse model Traceback (most recent call last): File "G:\RDVision\Micado\code\COLMAP_SLAM\main.py", line 516, in colmap.Mapper( File "G:\RDVision\Micado\code\COLMAP_SLAM\lib\colmapAPI.py", line 171, in Mapper subprocess.call( File "C:\Users\cvestri\miniconda3\envs\colmap_slam\lib\subprocess.py", line 349, in call with Popen(*popenargs, **kwargs) as p: File "C:\Users\cvestri\miniconda3\envs\colmap_slam\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\cvestri\miniconda3\envs\colmap_slam\lib\subprocess.py", line 1436, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable

I thought that the error might comes from the returned error (ERROR: failed to create sparse model), but it points out colmap.Mapper( in line 516, so error seems to come from passing through colmapApi.py

lcmrl commented 10 months ago

Could you put a print() before this subprocess in colmapAPI.py, printing self.colmap_exe, image_path, database_path and output_path? and send the print result

            subprocess.call(
                [
                    str(self.colmap_exe),
                    "mapper",
                    "--image_path", path_to_images,
                    "--database_path", database_path,
                    "--output_path", output_path,

maybe you could also attach your config.ini

vestri commented 10 months ago

Sory for delay, had a lot of meeting this afternoon.

Ok, here is what I got with those extra lines: print("self.colmap_exe="+str(self.colmap_exe)) print(path_to_images) print(database_path) print(output_path)

self.colmap_exe=G:\RDVision\Micado\raw_data\COLMAP-3.8-windows-cuda\COLMAP.bat G:\RDVision\Micado\code\COLMAP_SLAM\colmap_imgs\0 G:\RDVision\Micado\code\COLMAP_SLAM\outs\0\db.db G:\RDVision\Micado\code\COLMAP_SLAM\outs\0 Traceback (most recent call last): File "G:\RDVision\Micado\code\COLMAP_SLAM\main.py", line 516, in colmap.Mapper( File "G:\RDVision\Micado\code\COLMAP_SLAM\lib\colmapAPI.py", line 179, in Mapper subprocess.call( File "C:\Users\cvestri\miniconda3\envs\colmap_slam\lib\subprocess.py", line 349, in call with Popen(*popenargs, **kwargs) as p: File "C:\Users\cvestri\miniconda3\envs\colmap_slam\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\cvestri\miniconda3\envs\colmap_slam\lib\subprocess.py", line 1436, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable

those paths look good to me. But when I tried to mixt with a string it does want because it is a WindowPath: print("path_to_images="+path_to_images) print("database_path="+database_path) print("output_path="+output_path)

self.colmap_exe=G:\RDVision\Micado\raw_data\COLMAP-3.8-windows-cuda\COLMAP.bat Traceback (most recent call last): File "G:\RDVision\Micado\code\COLMAP_SLAM\main.py", line 497, in colmap.Mapper( File "G:\RDVision\Micado\code\COLMAP_SLAM\lib\colmapAPI.py", line 175, in Mapper print("path_to_images="+path_to_images) TypeError: can only concatenate str (not "WindowsPath") to str

I then tried to use "--image_path", str(path_to_images), "--database_path", str(database_path), "--output_path", str(output_path),

but it does not solve the error. There might be something wrong with WindowsPath?

I attached the config.ini. config.ini.txt

lcmrl commented 10 months ago

Yes, something wrong with the path

  1. could you run again substituting all / with \ in config.ini?
  2. if it doesn't work try to substitute str(self.colmap_exe) in colmap.API with the path to the colmap exe something like r"path\to\COLMAP.bat"
vestri commented 10 months ago

1: and 2: did not work. But I finally got it this morning, it was because colmap was on disk G:/. I moved it on a C:/ path and it worked. Thanks a lot for your help. Nice work by the way. It is interresting to combine all those great tools. I will test it.

lcmrl commented 10 months ago

good! any feedback can help improving the repo