more tests
This commit is contained in:
parent
e7791e1590
commit
f610c295f2
@ -234,9 +234,9 @@ namespace cv
|
||||
{
|
||||
public:
|
||||
//! Creates grid at the origin
|
||||
WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white());
|
||||
WGrid(const Vec2i &dimensions, const Vec2f &spacing, const Color &color = Color::white());
|
||||
//! Creates grid based on the plane equation
|
||||
WGrid(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color = Color::white());
|
||||
WGrid(const Vec4f &coeffs, const Vec2i &dimensions, const Vec2f &spacing, const Color &color = Color::white());
|
||||
};
|
||||
|
||||
class CV_EXPORTS WCameraPosition : public Widget3D
|
||||
|
@ -63,12 +63,6 @@ cv::viz::WCloud::WCloud(InputArray _cloud, InputArray _colors)
|
||||
Mat cloud = _cloud.getMat();
|
||||
Mat colors = _colors.getMat();
|
||||
|
||||
if (cloud.isContinuous() && colors.isContinuous())
|
||||
{
|
||||
cloud = cloud.reshape(cloud.channels(), 1);
|
||||
colors = colors.reshape(colors.channels(), 1);
|
||||
}
|
||||
|
||||
vtkSmartPointer<vtkCloudMatSource> cloud_source = vtkSmartPointer<vtkCloudMatSource>::New();
|
||||
cloud_source->SetColorCloud(cloud, colors);
|
||||
|
||||
@ -268,12 +262,6 @@ void cv::viz::WCloudCollection::addCloud(InputArray _cloud, InputArray _colors,
|
||||
CV_Assert(cloud.type() == CV_32FC3 || cloud.type() == CV_64FC3 || cloud.type() == CV_32FC4 || cloud.type() == CV_64FC4);
|
||||
CV_Assert(colors.depth() == CV_8U && cloud.size() == colors.size());
|
||||
|
||||
if (cloud.isContinuous() && colors.isContinuous())
|
||||
{
|
||||
cloud = cloud.reshape(cloud.channels(), 1);
|
||||
colors = colors.reshape(colors.channels(), 1);
|
||||
}
|
||||
|
||||
vtkIdType nr_points;
|
||||
vtkSmartPointer<vtkPolyData> polydata = CloudCollectionUtils::create(cloud, nr_points);
|
||||
|
||||
|
@ -474,7 +474,7 @@ namespace cv { namespace viz { namespace
|
||||
{
|
||||
struct GridUtils
|
||||
{
|
||||
static vtkSmartPointer<vtkPolyData> createGrid(const Vec2i &dimensions, const Vec2d &spacing)
|
||||
static vtkSmartPointer<vtkPolyData> createGrid(const Vec2i &dimensions, const Vec2f &spacing)
|
||||
{
|
||||
// Create the grid using image data
|
||||
vtkSmartPointer<vtkImageData> grid = vtkSmartPointer<vtkImageData>::New();
|
||||
@ -500,7 +500,7 @@ namespace cv { namespace viz { namespace
|
||||
};
|
||||
}}}
|
||||
|
||||
cv::viz::WGrid::WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color &color)
|
||||
cv::viz::WGrid::WGrid(const Vec2i &dimensions, const Vec2f &spacing, const Color &color)
|
||||
{
|
||||
vtkSmartPointer<vtkPolyData> grid = GridUtils::createGrid(dimensions, spacing);
|
||||
|
||||
@ -518,7 +518,7 @@ cv::viz::WGrid::WGrid(const Vec2i &dimensions, const Vec2d &spacing, const Color
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
cv::viz::WGrid::WGrid(const Vec4f &coefs, const Vec2i &dimensions, const Vec2d &spacing, const Color &color)
|
||||
cv::viz::WGrid::WGrid(const Vec4f &coefs, const Vec2i &dimensions, const Vec2f &spacing, const Color &color)
|
||||
{
|
||||
vtkSmartPointer<vtkPolyData> grid = GridUtils::createGrid(dimensions, spacing);
|
||||
|
||||
@ -1224,11 +1224,11 @@ cv::viz::WTrajectory::WTrajectory(const std::vector<Affine3f> &path, int display
|
||||
vtkIdType nr_points = path.size();
|
||||
|
||||
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
|
||||
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
|
||||
vtkSmartPointer<vtkPolyLine> polyLine = vtkSmartPointer<vtkPolyLine>::New();
|
||||
|
||||
points->SetDataTypeToFloat();
|
||||
points->SetNumberOfPoints(nr_points);
|
||||
|
||||
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
|
||||
vtkSmartPointer<vtkPolyLine> polyLine = vtkSmartPointer<vtkPolyLine>::New();
|
||||
polyLine->GetPointIds()->SetNumberOfIds(nr_points);
|
||||
|
||||
Vec3f *data_beg = vtkpoints_data<float>(points);
|
||||
|
@ -1 +1,24 @@
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
cv::String cv::Path::combine(const String& item1, const String& item2)
|
||||
{
|
||||
if (item1.empty())
|
||||
return item2;
|
||||
|
||||
if (item2.empty())
|
||||
return item1;
|
||||
|
||||
char last = item1[item1.size()-1];
|
||||
|
||||
bool need_append = last != '/' && last != '\\';
|
||||
return item1 + (need_append ? "/" : "") + item2;
|
||||
}
|
||||
|
||||
cv::String cv::Path::combine(const String& item1, const String& item2, const String& item3)
|
||||
{ return combine(combine(item1, item2), item3); }
|
||||
|
||||
cv::String cv::Path::change_extension(const String& file, const String& ext)
|
||||
{
|
||||
String::size_type pos = file.find_last_of('.');
|
||||
return pos == String::npos ? file : file.substr(0, pos+1) + ext;
|
||||
}
|
||||
|
@ -63,5 +63,21 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <limits>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
struct Path
|
||||
{
|
||||
static String combine(const String& item1, const String& item2);
|
||||
static String combine(const String& item1, const String& item2, const String& item3);
|
||||
static String change_extension(const String& file, const String& ext);
|
||||
};
|
||||
|
||||
inline cv::String get_dragon_ply_file_path()
|
||||
{
|
||||
return Path::combine(cvtest::TS::ptr()->get_data_path(), "dragon.ply");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -48,7 +48,7 @@ void tutorial2()
|
||||
}
|
||||
|
||||
|
||||
TEST(Viz_viz3d, DISABLED_tutorial2_pose_of_widget)
|
||||
TEST(Viz, DISABLED_tutorial2_pose_of_widget)
|
||||
{
|
||||
tutorial2();
|
||||
}
|
||||
|
@ -15,21 +15,21 @@ void tutorial3(bool camera_pov)
|
||||
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
||||
|
||||
/// Let's assume camera has the following properties
|
||||
Point3f cam_pos(3.0f,3.0f,3.0f), cam_focal_point(3.0f,3.0f,2.0f), cam_y_dir(-1.0f,0.0f,0.0f);
|
||||
Point3f cam_pos(3.f, 3.f, 3.f), cam_focal_point(3.f, 3.f, 2.f), cam_y_dir(-1.f, 0.f, 0.f);
|
||||
|
||||
/// We can get the pose of the cam using makeCameraPose
|
||||
Affine3f cam_pose = viz::makeCameraPose(cam_pos, cam_focal_point, cam_y_dir);
|
||||
|
||||
/// We can get the transformation matrix from camera coordinate system to global using
|
||||
/// - makeTransformToGlobal. We need the axes of the camera
|
||||
Affine3f transform = viz::makeTransformToGlobal(Vec3f(0.0f,-1.0f,0.0f), Vec3f(-1.0f,0.0f,0.0f), Vec3f(0.0f,0.0f,-1.0f), cam_pos);
|
||||
Affine3f transform = viz::makeTransformToGlobal(Vec3f(0.f, -1.f, 0.f), Vec3f(-1.f, 0.f, 0.f), Vec3f(0.f, 0.f, -1.f), cam_pos);
|
||||
|
||||
/// Create a cloud widget.
|
||||
Mat bunny_cloud = viz::readCloud("d:/cloud_dragon.ply");
|
||||
viz::WCloud cloud_widget(bunny_cloud, viz::Color::green());
|
||||
Mat dragon_cloud = viz::readCloud(get_dragon_ply_file_path());
|
||||
viz::WCloud cloud_widget(dragon_cloud, viz::Color::green());
|
||||
|
||||
/// Pose of the widget in camera frame
|
||||
Affine3f cloud_pose = Affine3f().translate(Vec3f(0.0f,0.0f,3.0f));
|
||||
Affine3f cloud_pose = Affine3f().translate(Vec3f(0.f, 0.f, 3.f));
|
||||
/// Pose of the widget in global frame
|
||||
Affine3f cloud_pose_global = transform * cloud_pose;
|
||||
|
||||
@ -37,7 +37,7 @@ void tutorial3(bool camera_pov)
|
||||
if (!camera_pov)
|
||||
{
|
||||
viz::WCameraPosition cpw(0.5); // Coordinate axes
|
||||
viz::WCameraPosition cpw_frustum(Vec2f(0.889484, 0.523599)); // Camera frustum
|
||||
viz::WCameraPosition cpw_frustum(Vec2f(0.889484f, 0.523599f)); // Camera frustum
|
||||
myWindow.showWidget("CPW", cpw, cam_pose);
|
||||
myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose);
|
||||
}
|
||||
@ -53,12 +53,12 @@ void tutorial3(bool camera_pov)
|
||||
myWindow.spin();
|
||||
}
|
||||
|
||||
TEST(Viz_viz3d, DISABLED_tutorial3_global_view)
|
||||
TEST(Viz, DISABLED_tutorial3_global_view)
|
||||
{
|
||||
tutorial3(false);
|
||||
}
|
||||
|
||||
TEST(Viz_viz3d, DISABLED_tutorial3_camera_view)
|
||||
TEST(Viz, DISABLED_tutorial3_camera_view)
|
||||
{
|
||||
tutorial3(true);
|
||||
}
|
||||
|
87
modules/viz/test/tests_simple.cpp
Normal file
87
modules/viz/test/tests_simple.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and / or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv::viz;
|
||||
|
||||
TEST(Viz, DISABLED_show_cloud_bluberry)
|
||||
{
|
||||
Mat dragon_cloud = readCloud(get_dragon_ply_file_path());
|
||||
|
||||
Viz3d viz("show_cloud_bluberry");
|
||||
viz.setBackgroundColor();
|
||||
viz.showWidget("coosys", WCoordinateSystem());
|
||||
viz.showWidget("dragon", WCloud(dragon_cloud, Color::bluberry()));
|
||||
viz.spin();
|
||||
}
|
||||
|
||||
TEST(Viz, DISABLED_show_cloud_random_color)
|
||||
{
|
||||
Mat dragon_cloud = readCloud(get_dragon_ply_file_path());
|
||||
|
||||
Mat colors(dragon_cloud.size(), CV_8UC3);
|
||||
theRNG().fill(colors, RNG::UNIFORM, 0, 255);
|
||||
|
||||
Viz3d viz("show_cloud_random_color");
|
||||
viz.setBackgroundColor();
|
||||
viz.showWidget("coosys", WCoordinateSystem());
|
||||
viz.showWidget("dragon", WCloud(dragon_cloud, colors));
|
||||
viz.spin();
|
||||
}
|
||||
|
||||
TEST(Viz, DISABLED_show_cloud_masked)
|
||||
{
|
||||
Mat dragon_cloud = readCloud(get_dragon_ply_file_path());
|
||||
|
||||
Vec3f qnan = Vec3f::all(std::numeric_limits<float>::quiet_NaN());
|
||||
for(size_t i = 0; i < dragon_cloud.total(); ++i)
|
||||
if (i % 15 != 0)
|
||||
dragon_cloud.at<Vec3f>(i) = qnan;
|
||||
|
||||
Viz3d viz("show_cloud_masked");
|
||||
viz.setBackgroundColor();
|
||||
viz.showWidget("coosys", WCoordinateSystem());
|
||||
viz.showWidget("dragon", WCloud(dragon_cloud));
|
||||
viz.spin();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user