plane widget size

pull/1453/head
ozantonkal 12 years ago
parent 030400d50f
commit eafcdc004d
  1. 4
      modules/viz/include/opencv2/viz/widgets.hpp
  2. 12
      modules/viz/src/simple_widgets.cpp
  3. 6
      modules/viz/test/test_viz3d.cpp

@ -46,8 +46,8 @@ namespace temp_viz
class CV_EXPORTS PlaneWidget : public Widget class CV_EXPORTS PlaneWidget : public Widget
{ {
public: public:
PlaneWidget(const Vec4f& coefs, const Color &color = Color::white()); PlaneWidget(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white());
PlaneWidget(const Vec4f& coefs, const Point3f& pt, const Color &color = Color::white()); PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white());
}; };
class CV_EXPORTS SphereWidget : public Widget class CV_EXPORTS SphereWidget : public Widget

@ -33,23 +33,24 @@ float temp_viz::LineWidget::getLineWidth()
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/// plane widget implementation /// plane widget implementation
temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Color &color) temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, double size, const Color &color)
{ {
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New (); vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New ();
plane->SetNormal (coefs[0], coefs[1], coefs[2]); plane->SetNormal (coefs[0], coefs[1], coefs[2]);
double norm = cv::norm(cv::Vec3f(coefs.val)); double norm = cv::norm(cv::Vec3f(coefs.val));
plane->Push (-coefs[3] / norm); plane->Push (-coefs[3] / norm);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New (); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
mapper->SetInput(plane->GetOutput ()); mapper->SetInput(plane->GetOutput ());
vtkSmartPointer<vtkLODActor> actor = WidgetAccessor::getActor(*this); vtkSmartPointer<vtkLODActor> actor = WidgetAccessor::getActor(*this);
actor->SetMapper(mapper); actor->SetMapper(mapper);
actor->SetScale(size);
setColor(color); setColor(color);
} }
temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, const Color &color) temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size, const Color &color)
{ {
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New (); vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New ();
cv::Point3f coefs3(coefs[0], coefs[1], coefs[2]); cv::Point3f coefs3(coefs[0], coefs[1], coefs[2]);
@ -65,6 +66,7 @@ temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, const
vtkSmartPointer<vtkLODActor> actor = WidgetAccessor::getActor(*this); vtkSmartPointer<vtkLODActor> actor = WidgetAccessor::getActor(*this);
actor->SetMapper(mapper); actor->SetMapper(mapper);
actor->SetScale(size);
setColor(color); setColor(color);
} }

@ -91,7 +91,7 @@ TEST(Viz_viz3d, accuracy)
int col_red = 0; int col_red = 0;
temp_viz::LineWidget lw(cv::Point3f(0.0,0.0,0.0), cv::Point3f(4.0,4.0,4.0), temp_viz::Color(0,255,0)); temp_viz::LineWidget lw(cv::Point3f(0.0,0.0,0.0), cv::Point3f(4.0,4.0,4.0), temp_viz::Color(0,255,0));
temp_viz::PlaneWidget pw(cv::Vec4f(0.0,1.0,2.0,3.0)); temp_viz::PlaneWidget pw(cv::Vec4f(0.0,1.0,2.0,3.0), 5.0);
temp_viz::SphereWidget sw(cv::Point3f(0,0,0), 0.5); temp_viz::SphereWidget sw(cv::Point3f(0,0,0), 0.5);
temp_viz::ArrowWidget aw(cv::Point3f(0,0,0), cv::Point3f(1,1,1), temp_viz::Color(255,0,0)); temp_viz::ArrowWidget aw(cv::Point3f(0,0,0), cv::Point3f(1,1,1), temp_viz::Color(255,0,0));
temp_viz::CircleWidget cw(cv::Point3f(0,0,0), 0.5, 0.01, temp_viz::Color(0,255,0)); temp_viz::CircleWidget cw(cv::Point3f(0,0,0), 0.5, 0.01, temp_viz::Color(0,255,0));
@ -100,10 +100,10 @@ TEST(Viz_viz3d, accuracy)
temp_viz::CoordinateSystemWidget csw(1.0f, cv::Affine3f::Identity()); temp_viz::CoordinateSystemWidget csw(1.0f, cv::Affine3f::Identity());
// v.showWidget("line", lw); // v.showWidget("line", lw);
// v.showWidget("plane", pw); v.showWidget("plane", pw);
// v.showWidget("sphere", sw); // v.showWidget("sphere", sw);
// v.showWidget("arrow", aw); // v.showWidget("arrow", aw);
v.showWidget("circle", cw); // v.showWidget("circle", cw);
// v.showWidget("cylinder", cyw); // v.showWidget("cylinder", cyw);
// v.showWidget("cube", cuw); // v.showWidget("cube", cuw);
v.showWidget("coordinateSystem", csw); v.showWidget("coordinateSystem", csw);

Loading…
Cancel
Save