mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 13:47:32 +08:00
text3dwidget offers now users to decide whether it should face the camera or not
This commit is contained in:
parent
286f81f305
commit
2170559bed
@ -62,7 +62,7 @@ namespace cv
|
||||
void setRenderingProperty(const String &id, int property, double value);
|
||||
double getRenderingProperty(const String &id, int property);
|
||||
|
||||
void setDesiredUpdateRate(double time);
|
||||
void setDesiredUpdateRate(double rate);
|
||||
double getDesiredUpdateRate();
|
||||
|
||||
void setRepresentation(int representation);
|
||||
|
@ -14,7 +14,6 @@ namespace cv
|
||||
OPACITY,
|
||||
LINE_WIDTH,
|
||||
FONT_SIZE,
|
||||
COLOR,
|
||||
REPRESENTATION,
|
||||
IMMEDIATE_RENDERING,
|
||||
SHADING
|
||||
@ -162,7 +161,7 @@ namespace cv
|
||||
class CV_EXPORTS Text3DWidget : public Widget3D
|
||||
{
|
||||
public:
|
||||
Text3DWidget(const String &text, const Point3f &position, double text_scale = 1.0, const Color &color = Color::white());
|
||||
Text3DWidget(const String &text, const Point3f &position, double text_scale = 1.0, bool face_camera = true, const Color &color = Color::white());
|
||||
|
||||
void setText(const String &text);
|
||||
String getText() const;
|
||||
|
@ -521,21 +521,32 @@ template<> cv::viz::GridWidget cv::viz::Widget::cast<cv::viz::GridWidget>()
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// text3D widget implementation
|
||||
|
||||
cv::viz::Text3DWidget::Text3DWidget(const String &text, const Point3f &position, double text_scale, const Color &color)
|
||||
cv::viz::Text3DWidget::Text3DWidget(const String &text, const Point3f &position, double text_scale, bool face_camera, const Color &color)
|
||||
{
|
||||
vtkSmartPointer<vtkVectorText> textSource = vtkSmartPointer<vtkVectorText>::New ();
|
||||
textSource->SetText (text.c_str());
|
||||
textSource->Update ();
|
||||
vtkSmartPointer<vtkVectorText> textSource = vtkSmartPointer<vtkVectorText>::New();
|
||||
textSource->SetText(text.c_str());
|
||||
textSource->Update();
|
||||
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New ();
|
||||
mapper->SetInputConnection (textSource->GetOutputPort ());
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mapper->SetInputConnection (textSource->GetOutputPort());
|
||||
|
||||
vtkSmartPointer<vtkFollower> actor = vtkSmartPointer<vtkFollower>::New ();
|
||||
actor->SetMapper (mapper);
|
||||
actor->SetPosition (position.x, position.y, position.z);
|
||||
actor->SetScale (text_scale);
|
||||
if (face_camera)
|
||||
{
|
||||
vtkSmartPointer<vtkFollower> actor = vtkSmartPointer<vtkFollower>::New();
|
||||
actor->SetMapper(mapper);
|
||||
actor->SetPosition(position.x, position.y, position.z);
|
||||
actor->SetScale(text_scale);
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
actor->SetPosition(position.x, position.y, position.z);
|
||||
actor->SetScale(text_scale);
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
}
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ void cv::viz::Viz3d::setBackgroundColor(const Color& color) { impl_->setBackgrou
|
||||
void cv::viz::Viz3d::setRenderingProperty(const String &id, int property, double value) { getWidget(id).setRenderingProperty(property, value); }
|
||||
double cv::viz::Viz3d::getRenderingProperty(const String &id, int property) { return getWidget(id).getRenderingProperty(property); }
|
||||
|
||||
void cv::viz::Viz3d::setDesiredUpdateRate(double time) { impl_->setDesiredUpdateRate(time); }
|
||||
void cv::viz::Viz3d::setDesiredUpdateRate(double rate) { impl_->setDesiredUpdateRate(rate); }
|
||||
double cv::viz::Viz3d::getDesiredUpdateRate() { return impl_->getDesiredUpdateRate(); }
|
||||
|
||||
void cv::viz::Viz3d::setRepresentation(int representation) { impl_->setRepresentation(representation); }
|
||||
|
@ -189,10 +189,10 @@ cv::Affine3f cv::viz::Viz3d::VizImpl::getWidgetPose(const String &id) const
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void cv::viz::Viz3d::VizImpl::setDesiredUpdateRate(double time)
|
||||
void cv::viz::Viz3d::VizImpl::setDesiredUpdateRate(double rate)
|
||||
{
|
||||
if (interactor_)
|
||||
interactor_->SetDesiredUpdateRate(time);
|
||||
interactor_->SetDesiredUpdateRate(rate);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
void updateWidgetPose(const String &id, const Affine3f &pose);
|
||||
Affine3f getWidgetPose(const String &id) const;
|
||||
|
||||
void setDesiredUpdateRate(double time);
|
||||
void setDesiredUpdateRate(double rate);
|
||||
double getDesiredUpdateRate();
|
||||
|
||||
/** \brief Returns true when the user tried to close the window */
|
||||
|
Loading…
Reference in New Issue
Block a user