Comments (9)
I have been spent some spare time for upgrading pybind.
I fixed many issues by referring upgrade to pybind 2.2 except the error below.
/Users/jaesikpa/Research/Open3D/src/Python/py3d_eigen.cpp:90:10: error: no matching constructor for initialization of 'py::buffer_info'
return py::buffer_info(
^
/Users/jaesikpa/Research/Open3D/src/Python/py3d_eigen.cpp:176:2: note: in instantiation of function template specialization '(anonymous
namespace)::pybind_eigen_vector_of_vector<Eigen::Matrix<double, 3, 1, 0, 3, 1> >' requested here
pybind_eigen_vector_of_vector<Eigen::Vector3d>(m, "Vector3dVector",
^
/Users/jaesikpa/Research/Open3D/src/External/pybind11/include/pybind11/buffer_info.h:28:5: note: candidate constructor not viable: cannot
convert initializer list argument to 'detail::any_container<ssize_t>' (aka 'any_container<long>')
buffer_info(void *ptr, ssize_t itemsize, const std::string &format, ssize_t ndim,
^
/Users/jaesikpa/Research/Open3D/src/External/pybind11/include/pybind11/buffer_info.h:39:5: note: candidate constructor template not viable:
requires 3 arguments, but 6 were provided
buffer_info(T *ptr, detail::any_container<ssize_t> shape_in, detail::any_container<ssize_t> strides_in)
^
/Users/jaesikpa/Research/Open3D/src/External/pybind11/include/pybind11/buffer_info.h:46:5: note: candidate constructor template not viable:
requires 2 arguments, but 6 were provided
buffer_info(T *ptr, ssize_t size)
^
/Users/jaesikpa/Research/Open3D/src/External/pybind11/include/pybind11/buffer_info.h:83:5: note: candidate constructor not viable: requires 7
arguments, but 6 were provided
buffer_info(private_ctr_tag, void *ptr, ssize_t itemsize, const std::string &format, ssize_t ndim,
^
/Users/jaesikpa/Research/Open3D/src/External/pybind11/include/pybind11/buffer_info.h:42:5: note: candidate constructor not viable: requires 4
arguments, but 6 were provided
buffer_info(void *ptr, ssize_t itemsize, const std::string &format, ssize_t size)
^
/Users/jaesikpa/Research/Open3D/src/External/pybind11/include/pybind11/buffer_info.h:49:14: note: candidate constructor not viable: requires at
most 2 arguments, but 6 were provided
explicit buffer_info(Py_buffer *view, bool ownview = true)
^
/Users/jaesikpa/Research/Open3D/src/External/pybind11/include/pybind11/buffer_info.h:56:5: note: candidate constructor not viable: requires 1
argument, but 6 were provided
buffer_info(const buffer_info &) = delete;
^
/Users/jaesikpa/Research/Open3D/src/External/pybind11/include/pybind11/buffer_info.h:59:5: note: candidate constructor not viable: requires
single argument 'other', but 6 arguments were provided
buffer_info(buffer_info &&other) {
^
/Users/jaesikpa/Research/Open3D/src/External/pybind11/include/pybind11/buffer_info.h:26:5: note: candidate constructor not viable: requires 0
arguments, but 6 were provided
buffer_info() { }
^
:
The compile error comes from the following lines in src/Python/py3d_eigen.cpp:
auto vec = py::bind_vector_without_repr<std::vector<EigenVector>>(
m, bind_name, py::buffer_protocol());
vec.def_buffer([](std::vector<EigenVector> &v) -> py::buffer_info {
return py::buffer_info(
v.data(), sizeof(Scalar),
py::format_descriptor<Scalar>::format(),
2, {v.size(), EigenVector::RowsAtCompileTime},
{sizeof(EigenVector), sizeof(Scalar)});
});
FYI, the following lines are safe:
auto vec = py::bind_vector<std::vector<Scalar>>(m, bind_name,
py::buffer_protocol());
vec.def_buffer([](std::vector<Scalar> &v) -> py::buffer_info {
return py::buffer_info(
v.data(), sizeof(Scalar),
py::format_descriptor<Scalar>::format(),
1, {v.size()}, {sizeof(Scalar)});
});
The only difference is to use py::bind_vector_without_repr()
instead of py::bind_vector()
made by @qianyizh. @qianyizh: Can you tell me how to resolve this issue?
from open3d.
Ah, I remember.
I hated the bind_vector function from pybind11, because its __repr__
prints the complete list of all elements. For example, when you call print(pcd.points)
it prints the whole list which can be extremely long.
This is not the behavior I wanted, so I copied the pybind11 convenient function bind_vector
but removed the __repr__
part, and called that function bind_vector_without_repr
.
Can you check:
- If pybind11 still have the long list printing
__repr__
behavior? If it is fixed, then we just replace allbind_vector_without_repr
withbind_vector
. The__repr__
part should also be removed frompybind_eigen_vector_of_vector
andpybind_eigen_vector_of_matrix
. - If it is not fixed. Then copy out the body of the new
bind_vector
function, paste them intobind_vector_without_repr
but remove the__repr__
part.
This should resolve the issue.
from open3d.
Good. I am working on this issue.
from open3d.
I decided to keep bind_vector_without_repr
. Actually the error comes from converting
{v.size(), EigenVector::RowsAtCompileTime}
into detail::any_container<ssize_t>
. It is because pybind2.2 has strict compile time error-check.
This fixes the error:
auto vec = py::bind_vector_without_repr<std::vector<EigenVector>>(
m, bind_name, py::buffer_protocol());
vec.def_buffer([](std::vector<EigenVector> &v) -> py::buffer_info {
size_t rows = EigenVector::RowsAtCompileTime;
return py::buffer_info(
v.data(), sizeof(Scalar),
py::format_descriptor<Scalar>::format(),
2, {v.size(), rows,
{sizeof(EigenVector), sizeof(Scalar)});
});
Now everything works fine. I tested pybind2.2 with the tutorial scripts.
from open3d.
The remaining job is to replace ___init___
for classes. It is not critical issue, but highly recommended by pybind2.2 to avoid runtime warnings.
For example, (from pybind upgrade guide)
// old -- deprecated (runtime warning shown only in debug mode)
py::class<Foo>(m, "Foo")
.def("__init__", [](Foo &self, ...) {
new (&self) Foo(...); // uses placement-new
});
// new
py::class<Foo>(m, "Foo")
.def(py::init([](...) { // Note: no `self` argument
return new Foo(...); // return by raw pointer
// or: return std::make_unique<Foo>(...); // return by holder
// or: return Foo(...); // return by value (move constructor)
}));
Now I am trying to replace
pinhole_intr.def("__init__", [](PinholeCameraIntrinsic &c, int w, int h,
double fx, double fy, double cx, double cy) {
new (&c)PinholeCameraIntrinsic(w, h, fx, fy, cx, cy);
}, "width"_a, "height"_a, "fx"_a, "fy"_a, "cx"_a, "cy"_a);
with
pinhole_intr.def(py::init([](int w, int h,
double fx, double fy, double cx, double cy) {
return new PinholeCameraIntrinsic(w, h, fx, fy, cx, cy);
}, "width"_a, "height"_a, "fx"_a, "fy"_a, "cx"_a, "cy"_a));
but this makes compile error. It is because of keyword arguments. I can compile it without keyword arguments. @qianyizh do you have any suggestion for this issue?
from open3d.
What is a keyword argument?
from open3d.
It is "width"_a, "height"_a, "fx"_a, "fy"_a, "cx"_a, "cy"_a
. If I remove this line, it complies.
from open3d.
I think they are the decorations to the function, i.e., when you type help(xxx.__init__)
, these decorations will pop out as the argument names.
from open3d.
Addressed in #127
from open3d.
Related Issues (20)
- How to make the export image background become transparency.
- fstring error in summary.py
- The open3d library is linked with the system GLIB_C, which causes several issues with installation. I understand the choice is made for a particular reason, however, this makes the library highly system version dependent.
- `stdgpu` target fails the CMake configure step with CUDA 12.4 due to changes in Thrust version header
- GUI/WebRTC/`ext_civetweb` error on latest MSVC (2022): `invalid numeric argument '/Wextra'`
- Is it possible to access additional vertex properties from ply file?
- v0.18.0 Build failure: fatal errors: multiple defined symbols in 'zlib.dll' & Cannot open include file: 'unzip.h' HOT 1
- How to use Open3D in QT Widget
- Cannot import Open3D0.18 on Windows 11 64 HOT 2
- 'double free or corruption (!prev)' when using .extract_voxel_grid() HOT 1
- Multiple errors related to **tgeometry_kernel** when compiling with CUDA 12.4 HOT 1
- Connected Component Clustering with Octree
- Does open3d have a confirm dialog in gui ?
- PointCloud.points has no elements and read only HOT 3
- open3d initialization failed Prompt:UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 4-5: invalid continuation byte HOT 1
- Segmentation fault when importing first PyTorch 2.2.2 and then Open3D 0.18.0 HOT 1
- Cannot compile on Windows 10 with MinGW-w64 HOT 2
- Why is the human point cloud generated by my icp algorithm noisy
- How to get a colored ointcloud from RGBD images?
- open3d.visualization.Visualizer.get_render_option() return NoneType Object
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from open3d.