Giter Site home page Giter Site logo

Comments (5)

nachovizzo avatar nachovizzo commented on September 3, 2024 1

@amwfarid Could you please try the solution from here?

from make_it_dense.

nachovizzo avatar nachovizzo commented on September 3, 2024

Hello, sorry for the late reply!

This is because vdbfusion was not compiled with pyopenvdb support enabled. The way I check this on the build system is qutie dirty, and couldn't find a better solution:
https://github.com/PRBonn/vdbfusion/blob/8d01832419050aed1105e666040c4e5d3a14c96c/src/vdbfusion/pybind/CMakeLists.txt#L5

You can debug this problem yourself by firing up a python shell and try to import the library import pyopenvdb. Is this fails, then the rest fails. Probably something went wrong while building OpenVDB from source.

from make_it_dense.

amwfarid avatar amwfarid commented on September 3, 2024

@nachovizzo Thank you very much for the response and help!

I managed to get rid of the attribute error (but then got another error with FloatGrid). The issue you linked to gave some good hints. Here's what I did:

I made sure I uninstalled the vdbfusion on my venv
pip uninstall vdbfusion

I reinstalled OpenVDB in the way prescribed here (conda approach):

git clone --depth 1 https://github.com/nachovizzo/openvdb.git -b nacho/vdbfusion \
    && cd openvdb \
    && mkdir build && cd build \
    && cmake \
    -DOPENVDB_BUILD_PYTHON_MODULE=ON \
    -DUSE_NUMPY=ON \
    -DPYOPENVDB_INSTALL_DIRECTORY="/home/farid/projects/make_it_dense/venv/lib/python3.8/dist-packages" \
    -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
    -DUSE_ZLIB=OFF \
    ..\
    && make -j$(nproc) all install \
    && cd ../.. \
    && rm -rf openvdb

However importantly, I set DPYOPENVDB_INSTALL_DIRECTORY to point to my venv python install directory instead.

Afterwards, I went to the root of vdbfusion and did make install

The attribute error went away, but now I get this:

./apps/test_scan.py --cuda  data/kitti-odometry/dataset/sequences/00/velodyne/000000.bin
INFO - 2022-11-04 16:40:02,816 - instantiator - Created a temporary directory at /tmp/tmpcyqo1ika
INFO - 2022-11-04 16:40:02,816 - instantiator - Writing /tmp/tmpcyqo1ika/_remote_module_non_scriptable.py
Traceback (most recent call last):

  File "./apps/test_scan.py", line 54, in <module>
    typer.run(test)

  File "./apps/test_scan.py", line 36, in test
    out_grid, in_grid = run_completion_pipeline(

  File "/home/farid/projects/make_it_dense/venv/lib/python3.8/site-packages/make_it_dense/evaluation/scan_complete.py", line 58, in run_completion_pipeline
    tsdf_volume, coords_xyz = run_tsdf(scan, voxel_size, voxel_size * voxel_trunc)

  File "/home/farid/projects/make_it_dense/venv/lib/python3.8/site-packages/make_it_dense/evaluation/scan_complete.py", line 18, in run_tsdf
    target_coords_ijk_a, _ = LeafNodeGrid(base_volume.tsdf).numpy()

  File "/home/farid/projects/make_it_dense/venv/lib/python3.8/site-packages/vdb_to_numpy/grid_wrappers/leaf_node_grid.py", line 22, in __init__
    self.leaf_nodes = vdb_pybind.extract_leaf_nodes(self.vdb_grid)

ValueError: GridType: <class 'pyopenvdb.FloatGrid'> not supported

I recognize that we are using your fork of OpenVDB because of a wrong value issue related to FloatGrid, but this one says outright that the class is not supported. might there be a version mismatch somewhere?

from make_it_dense.

nachovizzo avatar nachovizzo commented on September 3, 2024

Almost there, could you paste the output of this command: python3 -c "import pyopenvdb; print(dir(pyopenvdb))" | tr ',' '\n' | grep Grid. In my case the output is:

'BoolGrid'
 'FloatGrid'
 'GridClass'
 'GridTypes'
 'Vec3SGrid'
 'readAllGridMetadata'
 'readGridMetadata'

The reason behind all this madness is to provide a way to pass a Python object back and forth without having to re-convert or to even think about the C++ native type. The code for this is:

https://github.com/PRBonn/vdbfusion/blob/a0ca08e46c8082e11b757689b3384818b646e4fc/src/vdbfusion/pybind/pyopenvdb.h#L28

template <>
struct type_caster<openvdb::FloatGrid::Ptr> {
public:
    /// Converts Python to C++
    bool load(handle src, bool /*unused*/) {
        PyObject* source = src.ptr();
        boost::python::extract<typename openvdb::FloatGrid::Ptr> grid_ptr(source);
        if (!grid_ptr.check()) return false;
        value = grid_ptr();
        return (value && (PyErr_Occurred() == nullptr));
    }

    /// Converts from C++ to Python
    static handle cast(openvdb::FloatGrid::Ptr src, return_value_policy, handle) {
        if (!src) return none().inc_ref();
        py::module::import("pyopenvdb").attr("FloatGrid");
        boost::python::object obj = boost::python::object(src);
        auto out = reinterpret_borrow<py::object>(obj.ptr());
        return out.release();
    }

    PYBIND11_TYPE_CASTER(openvdb::FloatGrid::Ptr, _("pyopenvdb.FloatGrid"));
};

from make_it_dense.

amwfarid avatar amwfarid commented on September 3, 2024

@nachovizzo I'm terribly sorry for responding late! I couldn't access the server to test the fix.

It finally worked! Indeed, the "-I" managed to fix the issue and now I can run the code. Thank you very much!

from make_it_dense.

Related Issues (7)

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.