I have a transforms.json file which contains Intrinsic and Extrinsic for 23 cameras. I would like to visualize those using Python, colmap, pycolmap and jupyternotebook. Below is a part of the .json file
{
"w": 1920,
"h": 1080,
"fl_x": 1098.8550003271516,
"fl_y": 1110.2997543513977,
"cx": 970.1319034923014,
"cy": 542.0541746563172,
"k1": -0.28118870977442023,
"k2": 0.06674186867742171,
"p1": 0.0026768267765996103,
"p2": -0.00237229158478273,
"camera_model": "OPENCV",
"frames": [
{
"file_path": "images/frame_00023.jpg",
"transform_matrix": [
[
-0.07042611592680023,
-0.9713950978549236,
0.22678563900496068,
2.1881674886247935
],
[
0.9325864609677816,
0.016566699247072256,
0.3605662730978109,
1.7471888187630829
],
[
-0.3540093996139834,
0.2368904986264339,
0.9047431882282766,
-0.21938707719027645
],
[
0.0,
0.0,
0.0,
1.0
]
],
assuming you have
pycolmap
installed.In your Jupyter Notebook, you can use the following code to load the transforms from the JSON file and visualize the camera poses
Make sure to replace 'transforms.json' with the actual path to your JSON file.
This code uses Matplotlib to create a 3D plot showing the camera positions and their trajectory. The camera positions are represented by red spheres, and the trajectory is represented by blue lines connecting consecutive camera positions.
Note: Make sure that your Jupyter Notebook environment has access to the required packages, and you may need to adjust the code based on your specific JSON file structure.
here some resources: PyColmap Documentation:
PyColmap GitHub Repository: https://github.com/mihaidusmanu/pycolmap
PyColmap Documentation: https://mihaidusmanu.github.io/pycolmap/
Matplotlib Documentation:
Matplotlib Official Documentation:
https://matplotlib.org/stable/contents.html
Computer Vision and Structure from Motion:
OpenCV Tutorials: https://docs.opencv.org/4.x/contents.html
Multiple View Geometry in Computer Vision (Book by Richard Hartley and Andrew Zisserman): http://www.robots.ox.ac.uk/~vgg/hzbook/
3D Visualization with Matplotlib:
Matplotlib 3D Tutorial: https://matplotlib.org/stable/gallery/mplot3d/index.html