implemented showImage
This commit is contained in:
@@ -613,15 +613,16 @@ cv::String cv::viz::WText::getText() const
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// image overlay widget implementation
|
||||
|
||||
cv::viz::WImageOverlay::WImageOverlay(const Mat &image, const Rect &rect)
|
||||
cv::viz::WImageOverlay::WImageOverlay(InputArray image, const Rect &rect)
|
||||
{
|
||||
CV_Assert(!image.empty() && image.depth() == CV_8U);
|
||||
vtkSmartPointer<vtkImageMatSource> source = vtkSmartPointer<vtkImageMatSource>::New();
|
||||
source->SetImage(image);
|
||||
Size sz = image.size();
|
||||
|
||||
// Scale the image based on the Rect, and flip to match y-ais orientation
|
||||
vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
|
||||
transform->Scale(image.cols/(double)rect.width, image.rows/(double)rect.height, 1.0);
|
||||
transform->Scale(sz.width/(double)rect.width, sz.height/(double)rect.height, 1.0);
|
||||
transform->RotateX(180);
|
||||
|
||||
vtkSmartPointer<vtkImageReslice> image_reslice = vtkSmartPointer<vtkImageReslice>::New();
|
||||
@@ -640,11 +641,12 @@ cv::viz::WImageOverlay::WImageOverlay(const Mat &image, const Rect &rect)
|
||||
vtkSmartPointer<vtkActor2D> actor = vtkSmartPointer<vtkActor2D>::New();
|
||||
actor->SetMapper(image_mapper);
|
||||
actor->SetPosition(rect.x, rect.y);
|
||||
actor->GetProperty()->SetDisplayLocationToForeground();
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
}
|
||||
|
||||
void cv::viz::WImageOverlay::setImage(const Mat &image)
|
||||
void cv::viz::WImageOverlay::setImage(InputArray image)
|
||||
{
|
||||
CV_Assert(!image.empty() && image.depth() == CV_8U);
|
||||
|
||||
@@ -661,10 +663,11 @@ void cv::viz::WImageOverlay::setImage(const Mat &image)
|
||||
// Create the vtk image and set its parameters based on input image
|
||||
vtkSmartPointer<vtkImageMatSource> source = vtkSmartPointer<vtkImageMatSource>::New();
|
||||
source->SetImage(image);
|
||||
Size sz = image.size();
|
||||
|
||||
// Scale the image based on the Rect, and flip to match y-ais orientation
|
||||
vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
|
||||
transform->Scale(image.cols/(double)size.width, image.rows/(double)size.height, 1.0);
|
||||
transform->Scale(sz.width/(double)size.width, sz.height/(double)size.height, 1.0);
|
||||
transform->RotateX(180);
|
||||
|
||||
vtkSmartPointer<vtkImageReslice> image_reslice = vtkSmartPointer<vtkImageReslice>::New();
|
||||
@@ -687,7 +690,7 @@ template<> cv::viz::WImageOverlay cv::viz::Widget::cast<cv::viz::WImageOverlay>(
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// image 3D widget implementation
|
||||
|
||||
cv::viz::WImage3D::WImage3D(const Mat &image, const Size2d &size)
|
||||
cv::viz::WImage3D::WImage3D(InputArray image, const Size2d &size)
|
||||
{
|
||||
CV_Assert(!image.empty() && image.depth() == CV_8U);
|
||||
|
||||
@@ -717,7 +720,7 @@ cv::viz::WImage3D::WImage3D(const Mat &image, const Size2d &size)
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
}
|
||||
|
||||
cv::viz::WImage3D::WImage3D(const Mat &image, const Size2d &size, const Vec3d ¢er, const Vec3d &normal, const Vec3d &up_vector)
|
||||
cv::viz::WImage3D::WImage3D(InputArray image, const Size2d &size, const Vec3d ¢er, const Vec3d &normal, const Vec3d &up_vector)
|
||||
{
|
||||
CV_Assert(!image.empty() && image.depth() == CV_8U);
|
||||
|
||||
@@ -732,7 +735,7 @@ cv::viz::WImage3D::WImage3D(const Mat &image, const Size2d &size, const Vec3d &c
|
||||
*this = image3d;
|
||||
}
|
||||
|
||||
void cv::viz::WImage3D::setImage(const Mat &image)
|
||||
void cv::viz::WImage3D::setImage(InputArray image)
|
||||
{
|
||||
CV_Assert(!image.empty() && image.depth() == CV_8U);
|
||||
|
||||
|
@@ -112,6 +112,17 @@ void cv::viz::Viz3d::showWidget(const String &id, const Widget &widget, const Af
|
||||
void cv::viz::Viz3d::removeWidget(const String &id) { impl_->removeWidget(id); }
|
||||
cv::viz::Widget cv::viz::Viz3d::getWidget(const String &id) const { return impl_->getWidget(id); }
|
||||
void cv::viz::Viz3d::removeAllWidgets() { impl_->removeAllWidgets(); }
|
||||
|
||||
|
||||
void cv::viz::Viz3d::showImage(InputArray image, const Size& window_size)
|
||||
{
|
||||
removeAllWidgets();
|
||||
if (window_size.width > 0 && window_size.height > 0)
|
||||
setWindowSize(window_size);
|
||||
|
||||
showWidget("showImage", WImageOverlay(image, Rect(Point(0,0), getWindowSize())));
|
||||
}
|
||||
|
||||
void cv::viz::Viz3d::setWidgetPose(const String &id, const Affine3d &pose) { impl_->setWidgetPose(id, pose); }
|
||||
void cv::viz::Viz3d::updateWidgetPose(const String &id, const Affine3d &pose) { impl_->updateWidgetPose(id, pose); }
|
||||
cv::Affine3d cv::viz::Viz3d::getWidgetPose(const String &id) const { return impl_->getWidgetPose(id); }
|
||||
|
@@ -122,6 +122,13 @@ cv::String cv::viz::VizStorage::generateWindowName(const String &window_name)
|
||||
cv::viz::Viz3d cv::viz::getWindowByName(const String &window_name) { return Viz3d (window_name); }
|
||||
void cv::viz::unregisterAllWindows() { VizStorage::unregisterAll(); }
|
||||
|
||||
cv::viz::Viz3d cv::viz::imshow(const String& window_name, InputArray image, const Size& window_size)
|
||||
{
|
||||
Viz3d viz = getWindowByName(window_name);
|
||||
viz.showImage(image, window_size);
|
||||
return viz;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Read/write clouds. Supported formats: ply, stl, xyz, obj
|
||||
|
||||
|
Reference in New Issue
Block a user