Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/RMonica/Hybrid_HMD_Tracking_RS
09 October 2024, 07:19:50 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    No releases to show
  • 0abb08a
  • /
  • src
  • /
  • tracking_parser_extract_matrices.cpp
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:610dd30a56cbdcdf35f5d16d95373d33bb0631a4
origin badgedirectory badge
swh:1:dir:64641fa369e2f30e00c95980e9e55de9c491536e
origin badgerevision badge
swh:1:rev:0a8db14161db9bc4e579790279580a9bb68755bc
origin badgesnapshot badge
swh:1:snp:0203d2f7ea07552ec1a63af56f020f4b91fd3b0a

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 0a8db14161db9bc4e579790279580a9bb68755bc authored by RMonica on 08 October 2024, 13:23:12 UTC
Minor changes in scripts for compatibility.
Tip revision: 0a8db14
tracking_parser_extract_matrices.cpp
/*
 * Copyright 2022-2024 Riccardo Monica
 * 
 * This software is distributed under the 3-clause BSD license.
 * You should have received a copy of the 3-clause BSD license
 * along with this software. If not, see
 * <https://opensource.org/license/bsd-3-clause>
 */

#include "tracking_parser.h"

#include <Eigen/Dense>
#include <Eigen/StdVector>

#include <stdint.h>

typedef std::vector<Eigen::Affine3f, Eigen::aligned_allocator<Eigen::Affine3f> > Affine3fVector;
typedef uint64_t uint64;

int main(int argc, char ** argv)
{
  if (argc < 4)
  {
    std::cout << "Usage: tracking_parser_extract_matrices filename.txt m_motive.txt m_oculus.txt [ALL]" << std::endl;
    std::exit(1);
  }

  std::string ifilename = argv[1];
  std::string mfilename = argv[2];
  std::string ofilename = argv[3];
  bool extract_lost_matrices = false;
  if (argc >= 5)
  {
    if (std::string(argv[4]) == "ALL")
    {
      extract_lost_matrices = true;
      std::cout << "MODE: ALL" << std::endl;
    }
  }

  std::cout << "Opening file: " << ifilename << std::endl;
  std::ifstream ifile(ifilename.c_str());
  if (!ifile)
  {
    std::cout << "Could not open file: " << ifilename << std::endl;
    std::exit(2);
  }

  TrackingParser parser;
  try
  {
    parser.Parse(ifile);
  }
  catch (std::string str)
  {
    std::cout << "Parsing error in file : " << str << std::endl;
    std::exit(3);
  }

  std::cout << "Writing file: " << mfilename << std::endl;
  std::cout << "Writing file: " << ofilename << std::endl;
  std::ofstream mfile(mfilename.c_str());
  std::ofstream ofile(ofilename.c_str());

  if (!mfile)
  {
    std::cout << "Could not create file: " << mfilename << std::endl;
    std::exit(4);
  }
  if (!ofile)
  {
    std::cout << "Could not create file: " << ofilename << std::endl;
    std::exit(5);
  }

  const Affine3fVector motive_mats = parser.GetMotiveMats();
  const Affine3fVector oculus_mats = parser.GetOculusMats();

  Eigen::Affine3f prev_motive_mat = Eigen::Affine3f::Identity();

  uint64 size = std::min(motive_mats.size(), oculus_mats.size());
  for (uint64 i = 0; i < size; i++)
  {
    //std::cout << "Frame " << i << std::endl;
    const Eigen::Affine3f motive_mat = motive_mats[i];
    const Eigen::Affine3f oculus_mat = oculus_mats[i];

    if (motive_mat.matrix() == Eigen::Affine3f::Identity().matrix() ||
        oculus_mat.matrix() == Eigen::Affine3f::Identity().matrix())
      continue;
    if (!extract_lost_matrices && (motive_mat.matrix() == prev_motive_mat.matrix()))
      continue;
    prev_motive_mat = motive_mat;

    mfile << motive_mat.matrix() << "\n\n";
    ofile << oculus_mat.matrix() << "\n\n";
  }

  return 0;
}

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API