How to specify camera parameters in the case of single_camera_per_folder=1?

2,320 views
Skip to first unread message

ibd

unread,
Jun 27, 2018, 9:46:01 AM6/27/18
to COLMAP
I am trying to create a script that can take stereo camera images and do a reconstruction based on that.

When I specify camera parameters manually while using single_camera_per_folder=1, all the cameras (i.e., every camera from every subfolder) will take the camera parameters.

How am I supposed to pass in the (known, pre-calibrated) camera parameters in this case?
Ideally, I would pass in a list of list of parameters, one list of parameters for every camera (since I know the number of cameras beforehand).
Another workaround I have in mind is to do the feature extraction step with single_camera_per_folder=1, then change the camera parameters via the script, but I don't see a possibility besides directly changing the SQLite database.

Johannes Schönberger

unread,
Jun 28, 2018, 12:24:48 AM6/28/18
to col...@googlegroups.com
Your best bet is to write a small Python script that executes an SQL statement. You can have a look at the scripts/python/database.db for an example. Let me know if you have further questions. 
--
You received this message because you are subscribed to the Google Groups "COLMAP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to colmap+un...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/colmap/88c54445-ef45-4ba8-bcd4-41e7eaa7cb3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ibd

unread,
Jun 28, 2018, 10:36:28 AM6/28/18
to COLMAP
Hi Johannes

Thank you for the support and the excellent software in general!

I was able to insert the data into the database like the following:
params = [np.array((699.316, 665.998, 378.275, -0.171522, 0.0244116)),
           np.array((700.742, 628.812, 362.365, -0.173764, 0.0265925))]
 db = sqlite3.connect(dbPath)
 for i in range(len(params)):
   sqlCommand = "UPDATE cameras SET params=(?), prior_focal_length=1 WHERE camera_id=%d" % (i+1)
   db.execute(sqlCommand, (np.getbuffer(params[i]),))
 db.commit() # save data back to file
 db.close()

Now I'm wondering how to use the rig bundle adjuster / how to make a .json file containing the rig setup. Is there any documentation / tutorial / explanation for that? All I found was a github issue where someone figured it out by himself. :)

Cheers
-- ibd

Johannes Schönberger

unread,
Jul 1, 2018, 2:48:16 PM7/1/18
to COLMAP
This should hopefully answer your question: https://github.com/colmap/colmap/blob/dev/src/exe/colmap.cc#L1179

Let me know if anything is unclear.

Cheers, Johannes

ibd

unread,
Jul 4, 2018, 8:59:42 AM7/4/18
to COLMAP
Thank you, I finally got it working! I had some problems at first, but I found that it was related to my file naming.

One thing I'm confused as of yet: I would like to retrieve absolute scaling of the reconstruction, as given by the stereo system. Yet, there's no way to specify the extrinsics (baseline) for the camera. I have seen in the code that this is on your TODO list.
OTOH, I have also seen that there are "ComputeScale()" and related methods. Do they work with the rig extrinsics?

If it's not possible to specify the baseline (or stereo camera rotation R / translation t) explicitly through the .json or CLI, is there otherwise a way to modify the database to contain that info?

Johannes Schönberger

unread,
Jul 4, 2018, 4:48:18 PM7/4/18
to col...@googlegroups.com
The extrinsic parameters of the rig configuration is  urgently automatically computed from the sparse reconstruction. Scaling of the model could be done as a post processing step by loading the model using e.g. the provided Python or MATLAB scripts in scripts/python/read_model.py. I am planning to soon add more camera rig functionality. 
Reply all
Reply to author
Forward
0 new messages