Coder Social home page Coder Social logo

chenyuyi94 / light-field-distance Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kacperkan/light-field-distance

0.0 1.0 0.0 1.73 MB

Program basing on https://github.com/Sunwinds/ShapeDescriptor that calculates distance for Wavefront OBJ objets.

License: BSD 2-Clause "Simplified" License

Shell 0.01% Python 0.40% C 99.53% Makefile 0.04% Dockerfile 0.02%

light-field-distance's Introduction

Light Field Distance metric

Original repo: link

Note

The code was converted to be able to use LFD metric (distance between two descriptors) that will compare visual appearance between ground truth mesh and retrieved mesh.

This fork

The original repository was adapted partially to run on Linux. Only LightField was changed so it can be used through docker without any dependency. Underneath, the container uses OSMesa for headless rendering.

Requirements

  • pip install trimesh

Installation

pip install light-field-distance

or

python setup.py install

No need to explicitly install anything.

Usage

from lfd import LightFieldDistance
import trimesh

# rest of code
mesh_1: trimesh.Trimesh = ...
mesh_2: trimesh.Trimesh = ...

lfd_value: float = LightFieldDistance(verbose=True).get_distance(
    mesh_1.vertices, mesh_1.faces,
    mesh_2.vertices, mesh_2.faces
)

The script will calculate light field distances [1] between two shapes. Example usage:

from lfd import LightFieldDistance
import trimesh

# rest of code
mesh_1: trimesh.Trimesh = trimesh.load("lfd/examples/cup1.obj")
mesh_2: trimesh.Trimesh = trimesh.load("lfd/examples/airplane.obj")

lfd_value: float = LightFieldDistance(verbose=True).get_distance(
    mesh_1.vertices, mesh_1.faces,
    mesh_2.vertices, mesh_2.faces
)

The lower the metric's value, the more similar shapes are in terms of the visual appearance

How does it work

The lfd.py is a proxy for the container that install all the dependency necessary to run a C code. The code performs calculation of Zernike moments and other coefficients that are necessary to calculate the distance (3DAlignment program). Then, these coefficients are saved and run by the Distance program that calculated the Light Field Distance. It prints out the result and the stdout from the printing is handled by the python script.

If an image for the C code is not found, it builds one. The operation is performed once and it takes a while to finish it. After that, the script runs the necessary computations transparently.

Contribution

For anyone interested in having a contribution, these are things to be done. Due to the time constraints, I'm not able to do these on my own:

  • retrieve calculating coefficients from renders to be returned by a method
  • bind C code with pybind11 to allow direct computation from the python code without any Docker dependency

How am I sure that it works as supposed?

I checked descriptor artifacts from the original implementation and compared with results in the docker through md5sum

light-field-distance's People

Contributors

kacperkan avatar sunwinds avatar

Watchers

 avatar

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.