-
Notifications
You must be signed in to change notification settings - Fork 5.8k
python binding for viz #2882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
python binding for viz #2882
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3777c0f
python binding for viz
LaurentBerger 9ba03b6
oops
LaurentBerger d3cf545
bug
LaurentBerger d10b638
comment but( this is not solved https://github.com/opencv/opencv_cont…
LaurentBerger f760047
review 2
LaurentBerger 0cec78e
oversight
LaurentBerger 5e5a2d4
oversight oops
LaurentBerger 8bf772c
viz: move out Py* classes from public C++ headers
alalek c6fdc38
viz: recover PyColor
alalek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#ifndef OPENCV_PYTHON_VIZ_IMPL_HPP | ||
#define OPENCV_PYTHON_VIZ_IMPL_HPP | ||
|
||
#include "python_viz.hpp" | ||
|
||
namespace cv { namespace viz { | ||
|
||
PyAffine3d makeTransformToGlobalPy(const Vec3d& axis_x, const Vec3d& axis_y, const Vec3d& axis_z, const Vec3d& origin) | ||
{ | ||
return makeTransformToGlobal(axis_x, axis_y, axis_z, origin); | ||
} | ||
|
||
PyAffine3d makeCameraPosePy(const Vec3d& position, const Vec3d& focal_point, const Vec3d& y_dir) | ||
{ | ||
return makeCameraPose(position, focal_point, y_dir); | ||
} | ||
|
||
#define WRAP_SHOW_WIDGET_1 return Viz3d::showWidget(id, *widget.widget.get()) | ||
#define WRAP_SHOW_WIDGET_2 return Viz3d::showWidget(id, *widget.widget.get(), pose) | ||
inline void PyViz3d::showWidget(const String &id, PyWLine &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWLine &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWSphere &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWSphere &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCameraPosition &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCameraPosition &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWArrow &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWArrow &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCircle &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCircle &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWPlane &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWPlane &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCone &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCone &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCube &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCube &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCylinder &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCylinder &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCoordinateSystem &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWPaintedCloud &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWPaintedCloud &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCloudCollection &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCloudCollection &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWGrid &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWGrid &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, const cv::Ptr<WMesh> &widget) { return Viz3d::showWidget(id, *widget.get()); } | ||
inline void PyViz3d::showWidget(const String &id, const cv::Ptr<WMesh> &widget, PyAffine3d &pose) { return Viz3d::showWidget(id, *widget.get(), pose); } | ||
inline void PyViz3d::showWidget(const String &id, PyWPolyLine &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWPolyLine &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCloud &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCloud &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWImage3D &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWImage3D &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWImageOverlay &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWImageOverlay &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWText &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWText &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWText3D &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWText3D &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCloudNormals &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWCloudNormals &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWTrajectory &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWTrajectory &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWTrajectorySpheres &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWTrajectorySpheres &widget) { WRAP_SHOW_WIDGET_1; } | ||
inline void PyViz3d::showWidget(const String &id, PyWTrajectoryFrustums &widget, PyAffine3d &pose) { WRAP_SHOW_WIDGET_2; } | ||
inline void PyViz3d::showWidget(const String &id, PyWTrajectoryFrustums &widget) { WRAP_SHOW_WIDGET_1; } | ||
#undef WRAP_SHOW_WIDGET_1 | ||
#undef WRAP_SHOW_WIDGET_2 | ||
|
||
|
||
PyWGrid::PyWGrid(InputArray cells, InputArray cells_spacing, const Color &color) | ||
{ | ||
if (cells.kind() == _InputArray::MAT && cells_spacing.kind() == _InputArray::MAT) | ||
{ | ||
Mat k = cells.getMat(); | ||
Mat l = cells_spacing.getMat(); | ||
if (k.total() == 2 && l.total() == 2 ) | ||
{ | ||
CV_Assert(k.type() == CV_64FC1 && k.type() == CV_64FC1); | ||
Vec2i c1(k.at<double>(0), k.at<double>(1)); | ||
Vec2d c2(l.at<double>(0), l.at<double>(1)); | ||
widget = cv::makePtr<WGrid>(c1, c2, color); | ||
} | ||
else | ||
CV_Error(cv::Error::StsVecLengthErr, "unknown size"); | ||
} | ||
else | ||
CV_Error(cv::Error::StsUnsupportedFormat, "unknown type"); | ||
} | ||
|
||
|
||
PyWTrajectoryFrustums::PyWTrajectoryFrustums(InputArray path, InputArray K, double scale, const Color &color) | ||
{ | ||
if (K.kind() == _InputArray::MAT) | ||
{ | ||
Mat k = K.getMat(); | ||
if (k.rows == 3 && k.cols == 3) | ||
{ | ||
Matx33d x = k; | ||
widget = cv::makePtr<WTrajectoryFrustums>(path, x, scale, color); | ||
|
||
} | ||
else if (k.total() == 2) | ||
widget = cv::makePtr<WTrajectoryFrustums>(path, Vec2d(k.at<double>(0), k.at<double>(1)), 1.0, color); | ||
else | ||
CV_Error(cv::Error::StsVecLengthErr, "unknown size"); | ||
} | ||
else | ||
CV_Error(cv::Error::StsVecLengthErr, "unknown size"); | ||
} | ||
|
||
|
||
}} // namespace | ||
#endif // OPENCV_PYTHON_VIZ_IMPL_HPP |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @mshabunin Perhaps we need some
CV_WRAP_WITHOUT_BASE
marker for bindings.