Commit 6ca1822f authored by Anatoly Baksheev's avatar Anatoly Baksheev

added comments with future work for VizImpl

added authors to license header
parent d6e2b657
set(BUILD_opencv_viz_INIT OFF)
############################################################################### ###############################################################################
# Find qvtk # Find qvtk
# This sets the following variables: # This sets the following variables:
...@@ -36,18 +39,21 @@ macro(find_vtk) ...@@ -36,18 +39,21 @@ macro(find_vtk)
endif() endif()
endmacro() endmacro()
find_vtk()
find_package(OpenGL)
if (OPENGL_FOUND) #find_package(OpenGL)
if(OPENGL_INCLUDE_DIR) #if (OPENGL_FOUND)
include_directories("${OPENGL_INCLUDE_DIR}") # if(OPENGL_INCLUDE_DIR)
endif() # include_directories("${OPENGL_INCLUDE_DIR}")
if(OPENGL_DEFINITIONS) # endif()
add_definitions("${OPENGL_DEFINITIONS}") # if(OPENGL_DEFINITIONS)
endif() # add_definitions("${OPENGL_DEFINITIONS}")
endif() # endif()
#endif()
find_vtk()
if(NOT HAVE_VTK) if(NOT HAVE_VTK)
...@@ -65,14 +71,13 @@ endif() ...@@ -65,14 +71,13 @@ endif()
add_definitions(-DHAVE_VTK) add_definitions(-DHAVE_VTK)
set(the_description "Viz")
set(BUILD_opencv_viz_INIT OFF) set(BUILD_opencv_viz_INIT OFF)
include_directories(src) include_directories(src)
set(the_description "Viz") ocv_define_module(viz opencv_core)
ocv_define_module(viz opencv_core opencv_calib3d)
#${PCL_LIBRARIES}
target_link_libraries(opencv_viz vtkCommon vtkWidgets vtkHybrid vtkCharts vtkFiltering vtkRendering ${OPENGL_LIBRARIES}) target_link_libraries(opencv_viz vtkCommon vtkWidgets vtkFiltering vtkRendering)
#${OPENGL_LIBRARIES})
if(APPLE) if(APPLE)
target_link_libraries(opencv_viz "-framework Cocoa") target_link_libraries(opencv_viz "-framework Cocoa")
......
...@@ -38,9 +38,12 @@ ...@@ -38,9 +38,12 @@
// or tort (including negligence or otherwise) arising in any way out of // 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. // the use of this software, even if advised of the possibility of such damage.
// //
// * Point Cloud Library (PCL) - www.pointclouds.org // Authors:
// During implementation if OpenCV Viz module, similar module // * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
// from PCL was used as reference implementation. // * Ozan Tonkal
//
// During implementation of OpenCV Viz module, similar module
// from PCL (www.pointclouds.org) was used as reference implementation.
// //
//M*/ //M*/
...@@ -60,9 +63,10 @@ namespace cv ...@@ -60,9 +63,10 @@ namespace cv
//! takes coordiante frame data and builds transfrom to global coordinate frame //! takes coordiante frame data and builds transfrom to global coordinate frame
CV_EXPORTS Affine3f makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& axis_y, const Vec3f& axis_z, const Vec3f& origin = Vec3f::all(0)); CV_EXPORTS Affine3f makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& axis_y, const Vec3f& axis_z, const Vec3f& origin = Vec3f::all(0));
//! constructs camera pose from posiont, focal_point and up_vector (see gluLookAt() for more infromation //! constructs camera pose from position, focal_point and up_vector (see gluLookAt() for more infromation
CV_EXPORTS Affine3f makeCameraPose(const Vec3f& position, const Vec3f& focal_point, const Vec3f& up_vector); CV_EXPORTS Affine3f makeCameraPose(const Vec3f& position, const Vec3f& focal_point, const Vec3f& up_vector);
//! checks float value for Nan //! checks float value for Nan
inline bool isNan(float x) inline bool isNan(float x)
{ {
......
#pragma once #pragma once
#include <string> #include <string>
#include <opencv2/core/cvdef.h>
#include <opencv2/core.hpp> #include <opencv2/core.hpp>
#include <opencv2/core/affine.hpp> #include <opencv2/core/affine.hpp>
......
...@@ -18,3 +18,22 @@ cv::Affine3f cv::viz::makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& ax ...@@ -18,3 +18,22 @@ cv::Affine3f cv::viz::makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& ax
return Affine3f(R, origin); return Affine3f(R, origin);
} }
vtkSmartPointer<vtkMatrix4x4> cv::viz::convertToVtkMatrix (const cv::Matx44f &m)
{
vtkSmartPointer<vtkMatrix4x4> vtk_matrix = vtkSmartPointer<vtkMatrix4x4>::New();
for (int i = 0; i < 4; i++)
for (int k = 0; k < 4; k++)
vtk_matrix->SetElement(i, k, m(i, k));
return vtk_matrix;
}
cv::Matx44f cv::viz::convertToMatx(const vtkSmartPointer<vtkMatrix4x4>& vtk_matrix)
{
cv::Matx44f m;
for (int i = 0; i < 4; i++)
for (int k = 0; k < 4; k++)
m(i, k) = vtk_matrix->GetElement (i, k);
return m;
}
...@@ -626,11 +626,9 @@ void cv::viz::Viz3d::VizImpl::resetCamera () ...@@ -626,11 +626,9 @@ void cv::viz::Viz3d::VizImpl::resetCamera ()
renderer_->ResetCamera (); renderer_->ResetCamera ();
} }
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
void cv::viz::Viz3d::VizImpl::setCameraPosition (const cv::Vec3d& pos, const cv::Vec3d& view, const cv::Vec3d& up) void cv::viz::Viz3d::VizImpl::setCameraPosition (const cv::Vec3d& pos, const cv::Vec3d& view, const cv::Vec3d& up)
{ {
vtkSmartPointer<vtkCamera> cam = renderer_->GetActiveCamera (); vtkSmartPointer<vtkCamera> cam = renderer_->GetActiveCamera ();
cam->SetPosition (pos[0], pos[1], pos[2]); cam->SetPosition (pos[0], pos[1], pos[2]);
cam->SetFocalPoint (view[0], view[1], view[2]); cam->SetFocalPoint (view[0], view[1], view[2]);
...@@ -642,13 +640,10 @@ void cv::viz::Viz3d::VizImpl::setCameraPosition (const cv::Vec3d& pos, const cv: ...@@ -642,13 +640,10 @@ void cv::viz::Viz3d::VizImpl::setCameraPosition (const cv::Vec3d& pos, const cv:
void cv::viz::Viz3d::VizImpl::setCameraPosition (double pos_x, double pos_y, double pos_z, double up_x, double up_y, double up_z) void cv::viz::Viz3d::VizImpl::setCameraPosition (double pos_x, double pos_y, double pos_z, double up_x, double up_y, double up_z)
{ {
//rens_->InitTraversal (); //rens_->InitTraversal ();
vtkSmartPointer<vtkCamera> cam = renderer_->GetActiveCamera (); vtkSmartPointer<vtkCamera> cam = renderer_->GetActiveCamera ();
cam->SetPosition (pos_x, pos_y, pos_z); cam->SetPosition (pos_x, pos_y, pos_z);
cam->SetViewUp (up_x, up_y, up_z); cam->SetViewUp (up_x, up_y, up_z);
renderer_->Render (); renderer_->Render ();
} }
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
...@@ -980,20 +975,13 @@ void cv::viz::Viz3d::VizImpl::updateCells (vtkSmartPointer<vtkIdTypeArray> &cell ...@@ -980,20 +975,13 @@ void cv::viz::Viz3d::VizImpl::updateCells (vtkSmartPointer<vtkIdTypeArray> &cell
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void cv::viz::Viz3d::VizImpl::allocVtkPolyData (vtkSmartPointer<vtkAppendPolyData> &polydata) void cv::viz::Viz3d::VizImpl::allocVtkPolyData (vtkSmartPointer<vtkAppendPolyData> &polydata)
{ {polydata = vtkSmartPointer<vtkAppendPolyData>::New (); }
polydata = vtkSmartPointer<vtkAppendPolyData>::New ();
}
//////////////////////////////////////////////////////////////////////////////////////////////
void cv::viz::Viz3d::VizImpl::allocVtkPolyData (vtkSmartPointer<vtkPolyData> &polydata) void cv::viz::Viz3d::VizImpl::allocVtkPolyData (vtkSmartPointer<vtkPolyData> &polydata)
{ { polydata = vtkSmartPointer<vtkPolyData>::New (); }
polydata = vtkSmartPointer<vtkPolyData>::New ();
}
//////////////////////////////////////////////////////////////////////////////////////////////
void cv::viz::Viz3d::VizImpl::allocVtkUnstructuredGrid (vtkSmartPointer<vtkUnstructuredGrid> &polydata)
{
polydata = vtkSmartPointer<vtkUnstructuredGrid>::New ();
}
void cv::viz::Viz3d::VizImpl::allocVtkUnstructuredGrid (vtkSmartPointer<vtkUnstructuredGrid> &polydata)
{ polydata = vtkSmartPointer<vtkUnstructuredGrid>::New (); }
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void cv::viz::convertToVtkMatrix (const Eigen::Vector4f &origin, const Eigen::Quaternion<float> &orientation, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix) void cv::viz::convertToVtkMatrix (const Eigen::Vector4f &origin, const Eigen::Quaternion<float> &orientation, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix)
...@@ -1011,23 +999,6 @@ void cv::viz::convertToVtkMatrix (const Eigen::Vector4f &origin, const Eigen::Qu ...@@ -1011,23 +999,6 @@ void cv::viz::convertToVtkMatrix (const Eigen::Vector4f &origin, const Eigen::Qu
vtk_matrix->SetElement (3, 3, 1.0f); vtk_matrix->SetElement (3, 3, 1.0f);
} }
vtkSmartPointer<vtkMatrix4x4> cv::viz::convertToVtkMatrix (const cv::Matx44f &m)
{
vtkSmartPointer<vtkMatrix4x4> vtk_matrix = vtkSmartPointer<vtkMatrix4x4>::New();
for (int i = 0; i < 4; i++)
for (int k = 0; k < 4; k++)
vtk_matrix->SetElement(i, k, m(i, k));
return vtk_matrix;
}
cv::Matx44f cv::viz::convertToMatx(const vtkSmartPointer<vtkMatrix4x4>& vtk_matrix)
{
cv::Matx44f m;
for (int i = 0; i < 4; i++)
for (int k = 0; k < 4; k++)
m(i, k) = vtk_matrix->GetElement (i, k);
return m;
}
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
...@@ -1043,8 +1014,8 @@ void cv::viz::Viz3d::VizImpl::setWindowName (const std::string &name) ...@@ -1043,8 +1014,8 @@ void cv::viz::Viz3d::VizImpl::setWindowName (const std::string &name)
window_->SetWindowName (name.c_str ()); window_->SetWindowName (name.c_str ());
} }
void cv::viz::Viz3d::VizImpl::setPosition (int x, int y) { window_->SetPosition (x, y); } void cv::viz::Viz3d::VizImpl::setWindowPosition (int x, int y) { window_->SetPosition (x, y); }
void cv::viz::Viz3d::VizImpl::setSize (int xw, int yw) { window_->SetSize (xw, yw); } void cv::viz::Viz3d::VizImpl::setWindowSize (int xw, int yw) { window_->SetSize (xw, yw); }
bool cv::viz::Viz3d::VizImpl::addPolygonMesh (const Mesh3d& mesh, const Mat& mask, const std::string &id) bool cv::viz::Viz3d::VizImpl::addPolygonMesh (const Mesh3d& mesh, const Mat& mask, const std::string &id)
{ {
......
This diff is collapsed.
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