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/unlin/libbwabstraction
02 July 2024, 03:47:45 UTC
  • Code
  • Branches (3)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • refs/tags/v0.1
    • refs/tags/v0.2
    • 8c90648f07f68d37b9b0ad0581e44fa069aa758a
    No releases to show
  • e393547
  • /
  • tools
  • /
  • benchmark.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:41ed4406cb7ea1aad1fafa19e58401678599cb7a
origin badgedirectory badge
swh:1:dir:b0f341be1cfa8036033a8ce4da65d011ccfe04ec
origin badgerevision badge
swh:1:rev:8c90648f07f68d37b9b0ad0581e44fa069aa758a
origin badgesnapshot badge
swh:1:snp:cb883043adc01860813783e30023d60370b3e719

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
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: 8c90648f07f68d37b9b0ad0581e44fa069aa758a authored by unlin on 24 October 2019, 15:04:51 UTC
Update Readme.md.
Tip revision: 8c90648
benchmark.cpp
#include <bwabstraction.hpp>
#include <opencv2/opencv.hpp>
#include <glm/vec3.hpp> // glm::vec3
#include <glm/vec4.hpp> // glm::vec4
#include <glm/mat4x4.hpp> // glm::mat4
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/transform.hpp>
#include <cstdlib>
#include <boost/timer.hpp>
#include <iostream>

using namespace std;

void benchmark_one_model_one_render()
{
    boost::timer t;

    bwabstraction::Parameters param;
    bwabstraction::BWAbstraction bwa;
    bwabstraction::Result result;
    param.LoadMVPMatrixFromFile("camera/Chinese House.camera.txt");
    bwa.LoadModel("model/Chinese House.obj", param);
    
    bwa.Render(&result, param);

    cout << "benchmark_one_model_one_render: " << t.elapsed() << endl;
}

void benchmark_one_model_multiple_render()
{
    boost::timer t;

    bwabstraction::Parameters param;
    bwabstraction::BWAbstraction bwa;
    bwabstraction::Result result;
    param.LoadMVPMatrixFromFile("camera/Chinese House.camera.txt");
    bwa.LoadModel("model/Chinese House.obj", param);

    glm::mat4 mvp;
    for (int i = 0; i < 16; ++i) glm::value_ptr(mvp)[i] = param.mvpMatrix[i];
    glm::mat4 rotation = glm::rotate(30.0f, glm::vec3(0.0f, 0.0f, 1.0f));

    for (int i = 0; i < 10; ++i)
    {
        mvp = mvp * rotation;
        memcpy(param.mvpMatrix, glm::value_ptr(mvp), sizeof(float) * 16);
        bwa.Render(&result, param);

        //char name[50];
        //sprintf(name, "bench2-%d.png", i);
        //cv::imwrite(name, result.bwaImage);
    }

    cout << "benchmark_one_model_multiple_render: " << t.elapsed() << endl;
}

void benchmark_multiple_model_one_render()
{
    boost::timer t;

    std::string models[10] = {
        "model/Y4701_abacus.obj",
        "model/Y1704_PIANO.obj",
        "model/Y5709_Joystick.obj",
        "model/Y6379_Sparrow.obj",
        "model/Y9085_fax_machine.obj",
        "model/Y9336_microscope.obj",
        "model/Y60_bethoven.obj",
        "model/Y10399_White House.obj",
        "model/Y3664_gazebo.obj",
        "model/Y6002_OUTLET.obj",
    };

    std::string cameras[10] = {
        "camera/Y4701_abacus.camera.txt",
        "camera/Y1704_PIANO.camera.txt",
        "camera/Y5709_Joystick.camera.txt",
        "camera/Y6379_Sparrow.camera.txt",
        "camera/Y9085_fax_machine.camera.txt",
        "camera/Y9336_microscope.camera.txt",
        "camera/Y60_bethoven.camera.txt",
        "camera/Y10399_White House.camera.txt",
        "camera/Y3664_gazebo.camera.txt",
        "camera/Y6002_OUTLET.camera.txt",
    };

    bwabstraction::Parameters param;
    bwabstraction::BWAbstraction bwa;
    bwabstraction::Result result;

    for (int i = 0; i < 10; ++i)
    {
        param.LoadMVPMatrixFromFile(cameras[i]);
        bwa.LoadModel(models[i], param);
        bwa.Render(&result, param);
    }

    cout << "benchmark_multiple_model_one_render: " << t.elapsed() << endl;
}

void benchmark_multiple_model_multiple_render()
{
    boost::timer t;

    std::string models[10] = {
        "model/Y4701_abacus.obj",
        "model/Y1704_PIANO.obj",
        "model/Y5709_Joystick.obj",
        "model/Y6379_Sparrow.obj",
        "model/Y9085_fax_machine.obj",
        "model/Y9336_microscope.obj",
        "model/Y60_bethoven.obj",
        "model/Y10399_White House.obj",
        "model/Y3664_gazebo.obj",
        "model/Y6002_OUTLET.obj",
    };

    std::string cameras[10] = {
        "camera/Y4701_abacus.camera.txt",
        "camera/Y1704_PIANO.camera.txt",
        "camera/Y5709_Joystick.camera.txt",
        "camera/Y6379_Sparrow.camera.txt",
        "camera/Y9085_fax_machine.camera.txt",
        "camera/Y9336_microscope.camera.txt",
        "camera/Y60_bethoven.camera.txt",
        "camera/Y10399_White House.camera.txt",
        "camera/Y3664_gazebo.camera.txt",
        "camera/Y6002_OUTLET.camera.txt",
    };

    bwabstraction::Parameters param;
    bwabstraction::BWAbstraction bwa;
    bwabstraction::Result result;

    for (int i = 0; i < 10; ++i)
    {
        param.LoadMVPMatrixFromFile(cameras[i]);
        bwa.LoadModel(models[i], param);

        glm::mat4 mvp;
        for (int i = 0; i < 16; ++i) glm::value_ptr(mvp)[i] = param.mvpMatrix[i];
        glm::mat4 rotation = glm::rotate(30.0f, glm::vec3(0.0f, 0.0f, 1.0f));

        for (int j = 0; j < 10; ++j)
        {
            mvp = mvp * rotation;
            memcpy(param.mvpMatrix, glm::value_ptr(mvp), sizeof(float) * 16);
            bwa.Render(&result, param);

            //char name[50];
            //sprintf(name, "bench4-%d-%d.png", i, j);
            //cv::imwrite(name, result.bwaImage);
        }
        
    }

    cout << "benchmark_multiple_model_multiple_render: " << t.elapsed() << endl;
}

int main(void)
{
    benchmark_one_model_one_render();
    benchmark_one_model_multiple_render();
    benchmark_multiple_model_one_render();
    benchmark_multiple_model_multiple_render();

#ifdef _MSC_VER
    system("PAUSE");
#endif

    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