Skip to main content

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("examples/cup1.obj")
mesh_2: trimesh.Trimesh = trimesh.load("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

Release files for light-field-distance 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for light-field-distance 0.0.9
File Size Uploaded
light-field-distance-0.0.9.tar.gz 354.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for light-field-distance 0.0.9
File Interpreter ABI Platform
light_field_distance-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 889.5 kB

Release files / light-field-distance-0.0.9.tar.gz

Download URL light-field-distance-0.0.9.tar.gz
Size 354.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e552d62c6d96f95be6352cf30748597dcdbdc17dd5e45a17d90e899c40a45d90
BLAKE2b-256 checksum
How to use checksums
9bcc8c3cab08dea9320a29a9501f1a09d451a550e221b83487c7e4c36652da7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2.post20191201 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3

Release files / light_field_distance-0.0.9-py3-none-any.whl

Download URL light_field_distance-0.0.9-py3-none-any.whl
Size 535.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ec3f4f086872a5ac2f4b1c1a8e6021fd823e69e1a0cf8feb8d146272759a7f5
BLAKE2b-256 checksum
How to use checksums
76ecbfc66203269b001b5bb42224c815135ad5f96aaf85add2ea31e85f1d358d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2.post20191201 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

1 release file

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page