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

Revision 2b5968f8c7e02ec9e04bd9ed159d6677f40b44f7 authored by Hung-Kuo Chu on 27 October 2019, 06:41:49 UTC, committed by GitHub on 27 October 2019, 06:41:49 UTC
Update README.md
1 parent 8c90648
  • Files
  • Changes
  • aad9c77
  • /
  • examples
  • /
  • 01_basic.cpp
Raw File Download

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.

  • revision
  • directory
  • content
revision badge
swh:1:rev:2b5968f8c7e02ec9e04bd9ed159d6677f40b44f7
directory badge
swh:1:dir:dff328e068346ece3b9c6d02be7067bc0eae6d09
content badge
swh:1:cnt:a493b5b18def3f2f1bf5da9eca5ff44560dd438c

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.

  • revision
  • directory
  • content
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
01_basic.cpp
// Example code for basic usage.

// include the library
#include <bwabstraction.hpp>
// for cv::imwrite()
#include <opencv2/opencv.hpp>

int main(void)
{
    // create a parameter object. use it to control the behavior of the algorithm.
    bwabstraction::Parameters param;

    // we show here all available options to the algorithm.
    param.scale = 1.0f;
    param.contrastWeight = 0.0f;
    param.inclusionWeight = 1.5f;
    param.backgroundWeight = 250.0f;
    param.neighbourWeight = 50.0f;
    param.consistencyWeight = 50.0f;
    param.featureWeight = 1000.0f;
    param.congruentThreshold = 0.005f;
    param.patchSizeThreshold = 30;
    param.verbose = true;
    param.renderWidth = 1600;
    param.renderHeight = 1200;
    param.resultImage = bwabstraction::ResultImage::ALL;
    param.backgroundColor[0] = param.backgroundColor[1] = param.backgroundColor[2] = 1.0f; // white background

    // LoadMVPMatrixFromFile() is a helper function that fills param.mvpMatrix
    // with a text file of 16 real numbers. you can populate param.mvpMatrix any way you like.
    param.LoadMVPMatrixFromFile("camera/Chinese house.camera.txt");

    // create an algorithm object. use it to perform computation.
    bwabstraction::BWAbstraction bwa;

    // load 3D model with parameter object.
    if(!bwa.LoadModel("model/Chinese House.obj", param))
    {
        // load model failed. two possible reasons:
        // 1, cannot open file. 2, mesh quality is bad (face normal not aligned, duplicated vertices, etc...)
        exit(1);
    }

    // create an result object that holds results.
    bwabstraction::Result result;

    // start rendering with result object and parameter object.
    bwa.Render(&result, param);

    // save images returned.
    cv::imwrite("patches.png", result.patchImage); // type: CV_8UC3
    cv::imwrite("depthcritical.png", result.depthCriticalLineImage); // type: CV_8UC3
    cv::imwrite("sharpedge.png", result.sharpEdgeLineImage); // type: CV_8UC3
    cv::imwrite("boundaries.png", result.boundaryImage); // type: CV_8UC3
    cv::imwrite("featureline.png", result.featureLineImage); // type: CV_8UC3
    cv::imwrite("disttransform.png", result.distanceTransformImage); // type: CV_8UC3
    cv::imwrite("consistency.png", result.consistencyImage); // type: CV_8UC3
    cv::imwrite("components.png", result.componentImage); // type: CV_8UC3
    cv::imwrite("inclusions.png", result.inclusionImage); // type: CV_8UC3
    cv::imwrite("bwaResult.png", result.bwaImage); // type: CV_8UC1, different!

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

    return 0;
}
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

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