Skip to main content

g2o - General Graph Optimization

Ubicoders g2opy edition

Static Badge Static Badge Static Badge Static Badge

Build and Publishing

For build instructions and maintainer guidelines, please refer to manual.md.

ubuntu install

sudo apt-get install -qq qtdeclarative5-dev qt5-qmake libqglviewer-dev-qt5 libsuitesparse-dev libeigen3-dev -y

For the new conda env

conda install -y -c conda-forge "libstdcxx-ng>=12" "libgcc-ng>=12" libgomp

Then, install this package

pip install ubicoders-g2opy

windows dependencies

just do

pip install ubicoders-g2opy

intro

This project is based on the original g2o maintainer as below.

This porject provide windows and linux off the shelf packge including the .dll and .so files as well as the types of the apis for intellisense.

Otherthan that, same as g2o's pymem branch

Latest Commit base:

  • 70f058fde4516505ecb3b392b25bd66b2f4fdf47 (Sep 21, 2025)

How it works

Built the .whl with the damn .dll and .so files for god xxxxing sake.

The pip packge name is pyg2o. But import with import g2opy as g2o

Intellisense Enhanced

sample1 sample2

Supported Python Versions

  • 3.10 ✅
  • 3.11 ✅
  • 3.12 ✅
  • 3.13 ✅

Supproted Numpy Version

  • numpy 1 ⬜
  • numpy 2 ✅

Tested OS and Python

  • Windows 11 ✅
  • Ubuntu 20 ⬜
  • Ubuntu 22 ⬜
  • Ubuntu 24 ✅
  • Ubuntu 25 ✅

Test the installaton

create below and run

python tester.py

tester.py

import numpy as np
import g2opy as g2o
np.set_printoptions(precision=3)
np.set_printoptions(suppress=True)
from collections import defaultdict

def showCameraPoses(optim, idx, N):
    for i in range(idx, idx + N):
        T = optim.vertex(i).estimate().matrix()
        trans = T[:3, 3]
        print('camera pose at ', i, ': ', trans)

def calcSSE(optim, idx, wPts):
    sse = 0
    N = wPts.shape[0]
    for i in range(idx, idx + N):
        guessedWpt = optim.vertex(i)
        error = guessedWpt.estimate() - wPts[i-idx]
        sse += np.sum(error ** 2)
    return sse

def showWpts(optim, idx, N):
    for i in range(idx, idx + N):
        T = optim.vertex(i).estimate()
        #T = np.round(T, 0)
        print('guessed wPt at ', i-idx, ': ', T)

def main():   
    optimizer = g2o.SparseOptimizer()
    solver = g2o.BlockSolverSE3(g2o.LinearSolverCSparseSE3())
    solver = g2o.OptimizationAlgorithmLevenberg(solver)
    optimizer.set_algorithm(solver)

    f, p = 200, 256
    baseline = 0.3
    K = np.array([[f, 0, p],
                  [0, f, p],
                  [0, 0, 1]])

    wPts = np.array([
        [0, 0, 10],
        [-1, 3, 30],
        [2, 2, 37.2],
    ])

    num_pose = 10
    for i in range(0, int(num_pose/2)):
        pose = g2o.Isometry3d(np.identity(3), [(i-2)*10, 0, 0])
        v_se3 = g2o.VertexSCam()
        v_se3.set_cam(f, f, p, p, baseline)
        v_se3.set_id(i)
        v_se3.set_estimate(pose)
        if i < 2:
            v_se3.set_fixed(True)
        v_se3.set_all() # sets transfrom, projection, dR (angle)
        optimizer.add_vertex(v_se3)

    for i in range(int(num_pose/2), num_pose):
        pose = g2o.Isometry3d(np.identity(3), [0, (i - int(num_pose/2)- 2) * 10, 0])
        v_se3 = g2o.VertexSCam()
        v_se3.set_cam(f, f, p, p, baseline)
        v_se3.set_id(i)
        v_se3.set_estimate(pose)
        v_se3.set_fixed(False)
        v_se3.set_all() # sets transfrom, projection, dR (angle)
        optimizer.add_vertex(v_se3)

    point_id = 0

    for i, wpt in enumerate(wPts):
        guessed_wPt = g2o.VertexPointXYZ()
        guessed_wPt.set_id(num_pose + point_id)
        guessed_wPt.set_marginalized(True)
        guessed_wPt.set_estimate(wpt + np.random.randn(3) )
        optimizer.add_vertex(guessed_wPt)

        for j in range(num_pose):
            z = optimizer.vertex(j).map_point(wpt)
            if i > 1:
                z +=  np.random.randn(3)
            edge = g2o.EdgeXyzVsc()
            edge.set_vertex(0, guessed_wPt)
            edge.set_vertex(1, optimizer.vertex(j))
            edge.set_measurement(z)
            edge.set_information(np.identity(3))
            optimizer.add_edge(edge)

        point_id += 1

    sse0 = calcSSE(optimizer, num_pose, wPts)
    print('\nRMSE (inliers only):')
    print('before optimization:', np.sqrt(sse0 / wPts.shape[0]))
    showCameraPoses(optimizer, 0, num_pose)
    showWpts(optimizer, num_pose, 3)


    print('Performing full BA:')
    optimizer.initialize_optimization()
    optimizer.set_verbose(False)
    optimizer.optimize(100)

    sse1 = calcSSE(optimizer, num_pose, wPts)

    print('\nRMSE (inliers only):')
    print('after  optimization:', np.sqrt(sse1 / wPts.shape[0]))
    showCameraPoses(optimizer, 0, num_pose)
    showWpts(optimizer, num_pose, 3)


if __name__ == '__main__':
    main()

see the orignal readme at https://github.com/RainerKuemmerle/g2o

Release files for ubicoders-g2opy 2.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for ubicoders-g2opy 2.1.9
File
ubicoders_g2opy-2.1.9-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
ubicoders_g2opy-2.1.9-cp313-cp313-manylinux_2_38_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.38+ x86-64 Details
ubicoders_g2opy-2.1.9-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details
ubicoders_g2opy-2.1.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
ubicoders_g2opy-2.1.9-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
ubicoders_g2opy-2.1.9-cp312-cp312-manylinux_2_38_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.38+ x86-64 Details
ubicoders_g2opy-2.1.9-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
ubicoders_g2opy-2.1.9-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
ubicoders_g2opy-2.1.9-cp311-cp311-manylinux_2_38_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.38+ x86-64 Details
ubicoders_g2opy-2.1.9-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details
ubicoders_g2opy-2.1.9-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
ubicoders_g2opy-2.1.9-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
ubicoders_g2opy-2.1.9-cp310-cp310-manylinux_2_38_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.38+ x86-64 Details
ubicoders_g2opy-2.1.9-cp310-cp310-manylinux_2_34_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64 Details
ubicoders_g2opy-2.1.9-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details

Total release size: 101.8 MB

Release files / ubicoders_g2opy-2.1.9-cp313-cp313-win_amd64.whl

Download URL ubicoders_g2opy-2.1.9-cp313-cp313-win_amd64.whl
Size 19.3 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
847c31bc57c29019b0fab4e976bb7920f61d743d35730fa4fffedd645cbac0d5
BLAKE2b-256 checksum
How to use checksums
1c767c2d2107b5e753d8f0c1fbc6ce50d43399fe0516d2925a327f631e445d17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp313-cp313-manylinux_2_38_x86_64.whl

Download URL ubicoders_g2opy-2.1.9-cp313-cp313-manylinux_2_38_x86_64.whl
Size 2.3 MB
Tags CPython 3.13 Linux glibc 2.38+ x86-64
SHA-256 checksum
How to use checksums
5da7cbd37d448688d29328d4a7e6c5dce5f2d0de04cf54fce24e3143744cd1f1
BLAKE2b-256 checksum
How to use checksums
aa560e73340d964545a9567444a81f4160b3691b2dec9c1e9c7ad05459e70045
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL ubicoders_g2opy-2.1.9-cp313-cp313-manylinux_2_34_x86_64.whl
Size 2.3 MB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
c92df1f8293e2b4a9e5f7f2e9d3231f2a6620393ddd4966f7ed5dccd6590168c
BLAKE2b-256 checksum
How to use checksums
00cb3b0eb0b5d0bbb46c48cfa5ec77d949227e6cd00ed8acc92024b71242572b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL ubicoders_g2opy-2.1.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 2.2 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
1807c2851242c7cd5009d58954749da17b31ad9b1d6da32a402c6d50c11f62b0
BLAKE2b-256 checksum
How to use checksums
3f4fb44d456c44cd904174c28ac48f12675eacdb16b7c7197725c9213d96161d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp312-cp312-win_amd64.whl

Download URL ubicoders_g2opy-2.1.9-cp312-cp312-win_amd64.whl
Size 19.3 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
524abeb2611384bb8f1054ca728d278f52fef05deb104bf645b7d56072ee4256
BLAKE2b-256 checksum
How to use checksums
e3bafb5f29759b2f9500ccb906706db3aaeeb5e1b9fa31c58d261bc7e20c18dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp312-cp312-manylinux_2_38_x86_64.whl

Download URL ubicoders_g2opy-2.1.9-cp312-cp312-manylinux_2_38_x86_64.whl
Size 2.3 MB
Tags CPython 3.12 Linux glibc 2.38+ x86-64
SHA-256 checksum
How to use checksums
a27a14080c41c643a448cae3d224b655fca15a11d564349cf4f4903b3e0769ec
BLAKE2b-256 checksum
How to use checksums
bf9fccf0c63e68ae7eebe26499bed3bb17d44fd67e1993af94880194b1cc48d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL ubicoders_g2opy-2.1.9-cp312-cp312-manylinux_2_34_x86_64.whl
Size 2.3 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
d3fa8ec064030c45573e200a3bf57b1a29103d42734b78a6274ae773e480e86a
BLAKE2b-256 checksum
How to use checksums
da4a78b957c8ea80780411548cbe46f59c0f29d4c03a1d8b5e851d71e913440c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp311-cp311-win_amd64.whl

Download URL ubicoders_g2opy-2.1.9-cp311-cp311-win_amd64.whl
Size 19.3 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
242bd60e7baa9af5e77583c37ba74d750a1c26576a1bdf6bde691232f90ded96
BLAKE2b-256 checksum
How to use checksums
8756e540373c4721a7a9475fd5c219ed6e86d2d268a11b90e87c8b4bd72a5f5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp311-cp311-manylinux_2_38_x86_64.whl

Download URL ubicoders_g2opy-2.1.9-cp311-cp311-manylinux_2_38_x86_64.whl
Size 2.3 MB
Tags CPython 3.11 Linux glibc 2.38+ x86-64
SHA-256 checksum
How to use checksums
73b405a356d8e5c03c8a920ef8e4a32a53f849c7ae24f081d5b8162176cc9593
BLAKE2b-256 checksum
How to use checksums
c14b1f89d88d196e852e5ba9e4dd055d83edbeb8606a6f756c6d3c755026da85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL ubicoders_g2opy-2.1.9-cp311-cp311-manylinux_2_34_x86_64.whl
Size 2.3 MB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
3b18232a1efbadb2a46ccdd1a909a74de00804563d4f3c0c28ce0b40a7303017
BLAKE2b-256 checksum
How to use checksums
573d2212110f250d12adcb6291a980712847635d304b5eb8da99052cb88ae345
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL ubicoders_g2opy-2.1.9-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 2.2 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e8dcfaf86bce3f6adacba0207bb01df63a21a1db8ac583c9556443d65df3d847
BLAKE2b-256 checksum
How to use checksums
5bf1bdebe38a67c80d205870ad78e87cd45fea2440972ce3a90501a99a408b8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp310-cp310-win_amd64.whl

Download URL ubicoders_g2opy-2.1.9-cp310-cp310-win_amd64.whl
Size 19.3 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
9ca4bdbffbf65526eaa45a5945e0703c8475f3d9464f1be2a4c32fce10ad5cb4
BLAKE2b-256 checksum
How to use checksums
66de61f42dca09edd0efd37ff4440bcbf075f54a4c1faf19c8faaa9b9161b2c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp310-cp310-manylinux_2_38_x86_64.whl

Download URL ubicoders_g2opy-2.1.9-cp310-cp310-manylinux_2_38_x86_64.whl
Size 2.3 MB
Tags CPython 3.10 Linux glibc 2.38+ x86-64
SHA-256 checksum
How to use checksums
7bb77ebb263060aece9e47dec407e1428ac606e104bbebeabbd4196ae461479e
BLAKE2b-256 checksum
How to use checksums
02b52c0e2eeefc13d8108cef82b555598de26c2e69a1c9f9e529d42812b45623
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp310-cp310-manylinux_2_34_x86_64.whl

Download URL ubicoders_g2opy-2.1.9-cp310-cp310-manylinux_2_34_x86_64.whl
Size 2.3 MB
Tags CPython 3.10 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
a7eb56321f38bf50eafc024ed3e9193815c61e0305b9485839aed86d3701d413
BLAKE2b-256 checksum
How to use checksums
02751e726f4908584b725a1b38f906bef285b0c51fa55bfeb450a70764f0f00a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ubicoders_g2opy-2.1.9-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL ubicoders_g2opy-2.1.9-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 2.2 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
7cff241b16dc99bbc3005bb3154791f2017b2ed642fc3f0f7403ca494635d7e8
BLAKE2b-256 checksum
How to use checksums
d0b67b902bd1e2675803c390a2c3d97a57759dcc8a586c6803eabcdcb6a00cd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

2.1.9 This release

15 release files

2.1.7

3 release files

2.1.6

8 release files

2.1.5

8 release files

2.1.4

8 release files

2.1.3

8 release files

2.1.1

2 release files

2.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page