Giter Club home page Giter Club logo

Comments (1)

DaddyWesker avatar DaddyWesker commented on August 11, 2024

Wrote drawer myself. If anyone needs it, here. THough it should be mentioned, that in my case i've inferenced model with seq_length 5 and it saved tons of files in the eval folder. If you somehow test this model other way, you'll probably need to change the code.

import os
import numpy as np
import matplotlib.pyplot as plt
path_to_poses = "/home/daddywesker/TestingNeuralSlam/GeoNet/eval/Pose/"

plt.switch_backend('agg')
def get_matrix_from_quat(quat):
    """Create a 4x4 homography matrix that represents the rotation
    of the quaternion.
    """
    #quat - x, y, z, qx, qy, qz, qw


    # Init matrix (remember, a matrix, not an array)
    a = np.zeros((4, 4), dtype=np.float32)
    quat = [float(x) for x in quat]
    x, y, z, qx, qy, qz, qw = quat
    # First row
    a[0, 0] = - 2.0 * (qy * qy + qz * qz) + 1.0
    a[1, 0] = + 2.0 * (qx * qy + qz * qw)
    a[2, 0] = + 2.0 * (qx * qz - qy * qw)
    a[3, 0] = 0.0
    # Second row
    a[0, 1] = + 2.0 * (qx * qy - qz * qw)
    a[1, 1] = - 2.0 * (qx * qx + qz * qz) + 1.0
    a[2, 1] = + 2.0 * (qz * qy + qx * qw)
    a[3, 1] = 0.0
    # Third row
    a[0, 2] = + 2.0 * (qx * qz + qy * qw)
    a[1, 2] = + 2.0 * (qy * qz - qx * qw)
    a[2, 2] = - 2.0 * (qx * qx + qy * qy) + 1.0
    a[3, 2] = 0.0
    # Fourth row
    a[0, 3] = x
    a[1, 3] = y
    a[2, 3] = z
    a[3, 3] = 1.0
    return a

res = sorted(os.listdir(path_to_poses))
opened = open(path_to_poses + res[0])
pose0 = opened.readline()
H0 = get_matrix_from_quat(pose0.split("\n")[0].split(" ")[1:])
traj = []
traj.append(np.asarray([H0[0, 3], H0[1, 3]]))
for i in range (4, len(res), 4):
    opened = open(path_to_poses + res[i])
    pose = opened.readlines()[-1]
    HLast = get_matrix_from_quat(pose.split("\n")[0].split(" ")[1:])
    H0 = np.matmul(H0, HLast)
    traj.append(np.asarray([H0[0, 3], H0[1, 3]]))

traj = np.asarray(traj)
plt.scatter(traj[:, 0], traj[:, 1])
plt.savefig('traj.jpg')

from geonet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.