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)
- C++ Types in Python Documentation HOT 1
- Open3D development wheels are unavailable HOT 2
- Animation camera trajectory json creation
- Open3D on WSL2 unable to visualize. Error: GLFW Error: Wayland: The platform does not support setting the window position, Failed to initialize GLEW., [DrawGeometries] Failed creating OpenGL window. HOT 1
- how to set VerbosityContextManager in c++ HOT 2
- multiview registration without odometry edge.
- Hidden point removal crashes silently HOT 5
- Silent Failure when assigning color to point cloud points, and/or creating coordinate frame triangle mesh. HOT 2
- generalizedICP get nan value.
- generalizedICP get nan value.
- issue in building open3d in jetson orin
- ICP registration crashes in visualization/draw
- Crash on construction of `o3d.visualization.VisualizerWithEditing` HOT 1
- Why is my computer reporting this error "Process finished with exit code -1073741819(0xC0000005)" HOT 4
- Bilateral Filters in PointClouds
- Not able to copy/paste from system clipboard into gui.TextEdit
- Unable to set background image of O3DVisualizer HOT 2
- How can I apply a transformation only once in open3D HOT 2
- Request to customize origin and size in octree.convert_from_point_cloud() HOT 1
- [Vuln for dependency] Please release new .whl files by using newest curl HOT 2
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.