Commit 30860958 authored by Anatoly Baksheev's avatar Anatoly Baksheev

improved background gradient

parent b0ca93b2
......@@ -100,6 +100,7 @@ namespace cv
void setFullScreen(bool mode = true);
void setBackgroundColor(const Color& color = Color::black());
void setBackgroundTexture(InputArray image = noArray());
void setBackgroundGradient(const Color& up, const Color& down);
void setBackgroundMeshLab();
void spin();
......
......@@ -137,6 +137,7 @@ void cv::viz::Viz3d::saveScreenshot(const String &file) { impl_->saveScreenshot(
void cv::viz::Viz3d::setWindowPosition(const Point& window_position) { impl_->setWindowPosition(window_position); }
void cv::viz::Viz3d::setFullScreen(bool mode) { impl_->setFullScreen(mode); }
void cv::viz::Viz3d::setBackgroundColor(const Color& color) { impl_->setBackgroundColor(color); }
void cv::viz::Viz3d::setBackgroundGradient(const Color& up, const Color& down) { impl_->setBackgroundGradient(up, down); }
void cv::viz::Viz3d::setBackgroundTexture(InputArray image) { impl_->setBackgroundTexture(image); }
void cv::viz::Viz3d::setBackgroundMeshLab() {impl_->setBackgroundMeshLab(); }
......
......@@ -302,6 +302,21 @@ void cv::viz::Viz3d::VizImpl::setBackgroundColor(const Color& color)
{
Color c = vtkcolor(color);
renderer_->SetBackground(c.val);
renderer_->GradientBackgroundOff();
}
void cv::viz::Viz3d::VizImpl::setBackgroundGradient(const Color& up, const Color& down)
{
Color vtkup = vtkcolor(up), vtkdown = vtkcolor(down);
renderer_->SetBackground(vtkdown.val);
renderer_->SetBackground2(vtkup.val);
renderer_->GradientBackgroundOn();
}
//////////////////////////////////////////////////////////////////////////////////////////////
void cv::viz::Viz3d::VizImpl::setBackgroundMeshLab()
{
setBackgroundGradient(Color(2, 1, 1), Color(240, 120, 120));
}
//////////////////////////////////////////////////////////////////////////////////////////////
......@@ -329,30 +344,6 @@ void cv::viz::Viz3d::VizImpl::setBackgroundTexture(InputArray image)
renderer_->TexturedBackgroundOn();
}
//////////////////////////////////////////////////////////////////////////////////////////////
void cv::viz::Viz3d::VizImpl::setBackgroundMeshLab()
{
static Color up(2, 1, 1), down(240, 120, 120);
static Mat meshlab_texture;
if (meshlab_texture.empty())
{
meshlab_texture.create(2048, 2048, CV_8UC4);
for (int y = 0; y < meshlab_texture.rows; ++y)
{
double alpha = (y+1)/(double)meshlab_texture.rows;
Vec4b color = up * (1 - alpha) + down * alpha;
Vec4b *row = meshlab_texture.ptr<Vec4b>(y);
for(int x = 0; x < meshlab_texture.cols; ++x)
row[x] = color;
}
}
setBackgroundTexture(meshlab_texture);
}
/////////////////////////////////////////////////////////////////////////////////////////////
void cv::viz::Viz3d::VizImpl::setCamera(const Camera &camera)
{
......
......@@ -110,7 +110,7 @@ public:
void setFullScreen(bool mode);
String getWindowName() const;
void setBackgroundColor(const Color& color);
void setBackgroundGradient(const Color& up, const Color& down);
void setBackgroundTexture(InputArray image);
void setBackgroundMeshLab();
......
......@@ -51,8 +51,9 @@ TEST(Viz_viz3d, develop)
//theRNG().fill(mesh.colors, RNG::UNIFORM, 0, 255);
cv::viz::Viz3d viz("abc");
viz.setBackgroundColor(cv::viz::Color::mlab());
viz.setBackgroundMeshLab();
viz.showWidget("coo", cv::viz::WCoordinateSystem(1));
viz.showWidget("cloud", cv::viz::WCloud(cloud));
//viz.showWidget("h", cv::viz::Widget::fromPlyFile("d:/horse-red.ply"));
//viz.showWidget("a", cv::viz::WArrow(cv::Point3f(0,0,0), cv::Point3f(1,1,1)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment