diff --git a/modules/viz/include/opencv2/viz.hpp b/modules/viz/include/opencv2/viz.hpp index f6dc882c3..5c2fe03d9 100644 --- a/modules/viz/include/opencv2/viz.hpp +++ b/modules/viz/include/opencv2/viz.hpp @@ -108,10 +108,9 @@ namespace cv void remove(const String &window_name); static VizAccessor * instance_; - static bool is_instantiated_; struct VizAccessorImpl; - static VizAccessorImpl * impl_; + VizAccessorImpl * impl_; friend class Viz3d; }; diff --git a/modules/viz/src/interactor_style.cpp b/modules/viz/src/interactor_style.cpp index c740b248e..ccf188ded 100644 --- a/modules/viz/src/interactor_style.cpp +++ b/modules/viz/src/interactor_style.cpp @@ -48,9 +48,6 @@ #include "precomp.hpp" - -using namespace cv; - ////////////////////////////////////////////////////////////////////////////////////////////// void cv::viz::InteractorStyle::Initialize() { @@ -78,11 +75,11 @@ void cv::viz::InteractorStyle::Initialize() } ////////////////////////////////////////////////////////////////////////////////////////////// -void cv::viz::InteractorStyle::saveScreenshot(const std::string &file) +void cv::viz::InteractorStyle::saveScreenshot(const String &file) { FindPokedRenderer(Interactor->GetEventPosition()[0], Interactor->GetEventPosition()[1]); wif_->SetInput(Interactor->GetRenderWindow()); - wif_->Modified(); // Update the WindowToImageFilter + wif_->Modified(); // Update the WindowToImageFilter snapshot_writer_->Modified(); snapshot_writer_->SetFileName(file.c_str()); snapshot_writer_->Write(); @@ -117,30 +114,19 @@ void cv::viz::InteractorStyle::OnChar() FindPokedRenderer(Interactor->GetEventPosition()[0], Interactor->GetEventPosition()[1]); if (Interactor->GetKeyCode() >= '0' && Interactor->GetKeyCode() <= '9') return; - std::string key(Interactor->GetKeySym()); - if (key.find("XF86ZoomIn") != std::string::npos) + + String key(Interactor->GetKeySym()); + if (key.find("XF86ZoomIn") != String::npos) zoomIn(); - else if (key.find("XF86ZoomOut") != std::string::npos) + else if (key.find("XF86ZoomOut") != String::npos) zoomOut(); int keymod = false; switch (modifier_) { - case KB_MOD_ALT: - { - keymod = Interactor->GetAltKey(); - break; - } - case KB_MOD_CTRL: - { - keymod = Interactor->GetControlKey(); - break; - } - case KB_MOD_SHIFT: - { - keymod = Interactor->GetShiftKey(); - break; - } + case KB_MOD_ALT: keymod = Interactor->GetAltKey(); break; + case KB_MOD_CTRL: keymod = Interactor->GetControlKey(); break; + case KB_MOD_SHIFT: keymod = Interactor->GetShiftKey(); break; } switch (Interactor->GetKeyCode()) @@ -202,7 +188,6 @@ bool cv::viz::InteractorStyle::getControlKey() { return Interactor->GetControlKe void cv::viz::InteractorStyle::OnKeyDown() { - CV_Assert("Interactor style not initialized. Please call Initialize() before continuing" && init_); CV_Assert("No renderer given! Use SetRendererCollection() before continuing." && renderer_); @@ -274,42 +259,40 @@ cv::viz::InteractorStyle::OnKeyDown() vtkSmartPointer ac = CurrentRenderer->GetActors(); vtkCollectionSimpleIterator ait; for (ac->InitTraversal(ait); vtkActor* actor = ac->GetNextActor(ait); ) - { for (actor->InitPathTraversal(); vtkAssemblyPath* path = actor->GetNextPath(); ) { vtkActor* apart = reinterpret_cast (path->GetLastNode()->GetViewProp()); apart->GetProperty()->SetRepresentationToPoints(); } - } break; } // Save a PNG snapshot with the current screen case 'j': case 'J': { - char cam_fn[80], snapshot_fn[80]; - unsigned t = static_cast(time(0)); - sprintf(snapshot_fn, "screenshot-%d.png" , t); - saveScreenshot(snapshot_fn); + unsigned int t = static_cast(time(0)); + String png_file = cv::format("screenshot-%d.png", t); + String cam_file = cv::format("screenshot-%d.cam", t); - sprintf(cam_fn, "screenshot-%d.cam", t); - ofstream ofs_cam; - ofs_cam.open(cam_fn); vtkSmartPointer cam = Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera(); - double clip[2], focal[3], pos[3], view[3]; - cam->GetClippingRange(clip); - cam->GetFocalPoint(focal); - cam->GetPosition(pos); - cam->GetViewUp(view); + Vec2d clip; + Vec3d focal, pos, view; + cam->GetClippingRange(clip.val); + cam->GetFocalPoint(focal.val); + cam->GetPosition(pos.val); + cam->GetViewUp(view.val); + Vec2i win_pos(Interactor->GetRenderWindow()->GetPosition()); + Vec2i win_size(Interactor->GetRenderWindow()->GetSize()); + double angle = cam->GetViewAngle() / 180.0 * CV_PI; - int *win_pos = Interactor->GetRenderWindow()->GetPosition(); - int *win_size = Interactor->GetRenderWindow()->GetSize(); - ofs_cam << clip[0] << "," << clip[1] << "/" << focal[0] << "," << focal[1] << "," << focal[2] << "/" << - pos[0] << "," << pos[1] << "," << pos[2] << "/" << view[0] << "," << view[1] << "," << view[2] << "/" << - cam->GetViewAngle() / 180.0 * CV_PI << "/" << win_size[0] << "," << win_size[1] << "/" << win_pos[0] << "," << win_pos[1] - << endl; + String data = cv::format("%f,%f/%f,%f,%f/%f,%f,%f/%f,%f,%f/%f/%d,%d/%d,%d", clip[0],clip[1], focal[0],focal[1],focal[2], + pos[0],pos[1],pos[2], view[0],view[1], view[2], angle , win_size[0],win_size[1], win_pos[0], win_pos[1]); + + saveScreenshot(png_file); + ofstream ofs_cam(cam_file.c_str()); + ofs_cam << data.c_str() << endl; ofs_cam.close(); - std::cout << "Screenshot (" << snapshot_fn << ") and camera information (" << cam_fn << ") successfully captured." << std::endl; + cout << "Screenshot (" << png_file.c_str() << ") and camera information (" << cam_file.c_str() << ") successfully captured." << endl; break; } // display current camera settings/parameters @@ -354,7 +337,6 @@ cv::viz::InteractorStyle::OnKeyDown() vtkSmartPointer ac = CurrentRenderer->GetActors(); vtkCollectionSimpleIterator ait; for (ac->InitTraversal(ait); vtkActor* actor = ac->GetNextActor(ait); ) - { for (actor->InitPathTraversal(); vtkAssemblyPath* path = actor->GetNextPath(); ) { vtkActor* apart = reinterpret_cast (path->GetLastNode()->GetViewProp()); @@ -362,7 +344,6 @@ cv::viz::InteractorStyle::OnKeyDown() if (psize < 63.0f) apart->GetProperty()->SetPointSize(psize + 1.0f); } - } } break; } @@ -375,7 +356,6 @@ cv::viz::InteractorStyle::OnKeyDown() vtkSmartPointer ac = CurrentRenderer->GetActors(); vtkCollectionSimpleIterator ait; for (ac->InitTraversal(ait); vtkActor* actor = ac->GetNextActor(ait); ) - { for (actor->InitPathTraversal(); vtkAssemblyPath* path = actor->GetNextPath(); ) { vtkActor* apart = static_cast(path->GetLastNode()->GetViewProp()); @@ -383,7 +363,6 @@ cv::viz::InteractorStyle::OnKeyDown() if (psize > 1.0f) apart->GetProperty()->SetPointSize(psize - 1.0f); } - } } break; } @@ -460,9 +439,7 @@ cv::viz::InteractorStyle::OnKeyDown() case 'o': case 'O': { vtkSmartPointer cam = CurrentRenderer->GetActiveCamera(); - int flag = cam->GetParallelProjection(); - cam->SetParallelProjection(!flag); - + cam->SetParallelProjection(!cam->GetParallelProjection()); CurrentRenderer->SetActiveCamera(cam); CurrentRenderer->Render(); break; @@ -499,18 +476,14 @@ cv::viz::InteractorStyle::OnKeyDown() // if a valid transformation was found, use it otherwise fall back to default view point. if (found_transformation) { - vtkProp3D * actor = vtkProp3D::SafeDownCast(it->second); - cam->SetPosition(actor->GetUserMatrix()->GetElement(0, 3), - actor->GetUserMatrix()->GetElement(1, 3), - actor->GetUserMatrix()->GetElement(2, 3)); + const vtkMatrix4x4* m = vtkProp3D::SafeDownCast(it->second)->GetUserMatrix(); - cam->SetFocalPoint(actor->GetUserMatrix()->GetElement(0, 3) - actor->GetUserMatrix()->GetElement(0, 2), - actor->GetUserMatrix()->GetElement(1, 3) - actor->GetUserMatrix()->GetElement(1, 2), - actor->GetUserMatrix()->GetElement(2, 3) - actor->GetUserMatrix()->GetElement(2, 2)); + cam->SetFocalPoint(m->GetElement(0, 3) - m->GetElement(0, 2), + m->GetElement(1, 3) - m->GetElement(1, 2), + m->GetElement(2, 3) - m->GetElement(2, 2)); - cam->SetViewUp(actor->GetUserMatrix()->GetElement(0, 1), - actor->GetUserMatrix()->GetElement(1, 1), - actor->GetUserMatrix()->GetElement(2, 1)); + cam->SetViewUp (m->GetElement(0, 1), m->GetElement(1, 1), m->GetElement(2, 1)); + cam->SetPosition(m->GetElement(0, 3), m->GetElement(1, 3), m->GetElement(2, 3)); } else { @@ -712,11 +685,8 @@ void cv::viz::InteractorStyle::OnTimer() Interactor->Render(); } -namespace cv +namespace cv { namespace viz { - namespace viz - { - //Standard VTK macro for *New() - vtkStandardNewMacro(InteractorStyle) - } -} + //Standard VTK macro for *New() + vtkStandardNewMacro(InteractorStyle) +}} diff --git a/modules/viz/src/interactor_style.h b/modules/viz/src/interactor_style.h index ed3f4dfbd..3af13fcc4 100644 --- a/modules/viz/src/interactor_style.h +++ b/modules/viz/src/interactor_style.h @@ -57,16 +57,9 @@ namespace cv { public: - enum KeyboardModifier - { - KB_MOD_ALT, - KB_MOD_CTRL, - KB_MOD_SHIFT - }; + enum KeyboardModifier { KB_MOD_ALT, KB_MOD_CTRL, KB_MOD_SHIFT }; static InteractorStyle *New(); - - InteractorStyle() {} virtual ~InteractorStyle() {} // this macro defines Superclass, the isA functionality and the safe downcast method @@ -75,32 +68,24 @@ namespace cv /** \brief Initialization routine. Must be called before anything else. */ virtual void Initialize(); - inline void setWidgetActorMap(const Ptr& actors) { widget_actor_map_ = actors; } + void setWidgetActorMap(const Ptr& actors) { widget_actor_map_ = actors; } void setRenderer(vtkSmartPointer& ren) { renderer_ = ren; } void registerMouseCallback(void (*callback)(const MouseEvent&, void*), void* cookie = 0); void registerKeyboardCallback(void (*callback)(const KeyboardEvent&, void*), void * cookie = 0); - void saveScreenshot(const std::string &file); + void saveScreenshot(const String &file); /** \brief Change the default keyboard modified from ALT to a different special key.*/ inline void setKeyboardModifier(const KeyboardModifier &modifier) { modifier_ = modifier; } - protected: + private: /** \brief Set to true after initialization is complete. */ bool init_; - /** \brief Collection of vtkRenderers stored internally. */ vtkSmartPointer renderer_; + Ptr widget_actor_map_; - /** \brief Actor map stored internally. */ - cv::Ptr widget_actor_map_; - - /** \brief The current window width/height. */ Vec2i win_size_; - - /** \brief The current window position x/y. */ Vec2i win_pos_; - - /** \brief The maximum resizeable window width/height. */ Vec2i max_win_size_; /** \brief A PNG writer for screenshot captures. */ diff --git a/modules/viz/src/precomp.hpp b/modules/viz/src/precomp.hpp index beb7c5c04..6df03e4f6 100644 --- a/modules/viz/src/precomp.hpp +++ b/modules/viz/src/precomp.hpp @@ -128,6 +128,7 @@ #include #include #include +#include namespace cv { diff --git a/modules/viz/src/viz.cpp b/modules/viz/src/viz.cpp index 2517d138a..747c8de34 100644 --- a/modules/viz/src/viz.cpp +++ b/modules/viz/src/viz.cpp @@ -50,18 +50,9 @@ cv::Affine3f cv::viz::makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& axis_y, const Vec3f& axis_z, const Vec3f& origin) { - Affine3f::Mat3 R; - R.val[0] = axis_x.val[0]; - R.val[3] = axis_x.val[1]; - R.val[6] = axis_x.val[2]; - - R.val[1] = axis_y.val[0]; - R.val[4] = axis_y.val[1]; - R.val[7] = axis_y.val[2]; - - R.val[2] = axis_z.val[0]; - R.val[5] = axis_z.val[1]; - R.val[8] = axis_z.val[2]; + Affine3f::Mat3 R(axis_x[0], axis_y[0], axis_z[0], + axis_x[1], axis_y[1], axis_z[1], + axis_x[2], axis_y[2], axis_z[2]); return Affine3f(R, origin); } @@ -73,22 +64,7 @@ cv::Affine3f cv::viz::makeCameraPose(const Vec3f& position, const Vec3f& focal_p Vec3f u = normalize(y_dir.cross(n)); Vec3f v = n.cross(u); - Matx44f pose_mat = Matx44f::zeros(); - pose_mat(0,0) = u[0]; - pose_mat(0,1) = u[1]; - pose_mat(0,2) = u[2]; - pose_mat(1,0) = v[0]; - pose_mat(1,1) = v[1]; - pose_mat(1,2) = v[2]; - pose_mat(2,0) = n[0]; - pose_mat(2,1) = n[1]; - pose_mat(2,2) = n[2]; - pose_mat(3,0) = position[0]; - pose_mat(3,1) = position[1]; - pose_mat(3,2) = position[2]; - pose_mat(3,3) = 1.0f; - pose_mat = pose_mat.t(); - return pose_mat; + return makeTransformToGlobal(u, v, n, position); } vtkSmartPointer cv::viz::convertToVtkMatrix(const cv::Matx44f &m) @@ -109,36 +85,31 @@ cv::Matx44f cv::viz::convertToMatx(const vtkSmartPointer& vtk_matr return m; } -namespace cv +namespace cv { namespace viz { - namespace viz + template Vec<_Tp, 3>* vtkpoints_data(vtkSmartPointer& points); + + template<> Vec3f* vtkpoints_data(vtkSmartPointer& points) { - template Vec<_Tp, 3>* vtkpoints_data(vtkSmartPointer& points); - - template<> Vec3f* vtkpoints_data(vtkSmartPointer& points) - { - CV_Assert(points->GetDataType() == VTK_FLOAT); - vtkDataArray *data = points->GetData(); - float *pointer = static_cast(data)->GetPointer(0); - return reinterpret_cast(pointer); - } - - template<> Vec3d* vtkpoints_data(vtkSmartPointer& points) - { - CV_Assert(points->GetDataType() == VTK_DOUBLE); - vtkDataArray *data = points->GetData(); - double *pointer = static_cast(data)->GetPointer(0); - return reinterpret_cast(pointer); - } + CV_Assert(points->GetDataType() == VTK_FLOAT); + vtkDataArray *data = points->GetData(); + float *pointer = static_cast(data)->GetPointer(0); + return reinterpret_cast(pointer); } -} + + template<> Vec3d* vtkpoints_data(vtkSmartPointer& points) + { + CV_Assert(points->GetDataType() == VTK_DOUBLE); + vtkDataArray *data = points->GetData(); + double *pointer = static_cast(data)->GetPointer(0); + return reinterpret_cast(pointer); + } +}} /////////////////////////////////////////////////////////////////////////////////////////////// /// Viz accessor implementation cv::viz::VizAccessor * cv::viz::VizAccessor::instance_ = 0; -bool cv::viz::VizAccessor::is_instantiated_ = false; -cv::viz::VizAccessor::VizAccessorImpl * cv::viz::VizAccessor::impl_ = 0; struct cv::viz::VizAccessor::VizAccessorImpl { @@ -146,33 +117,22 @@ struct cv::viz::VizAccessor::VizAccessorImpl }; cv::viz::VizAccessor::VizAccessor() { impl_ = new cv::viz::VizAccessor::VizAccessorImpl;} - -cv::viz::VizAccessor::~VizAccessor() -{ - if(impl_) - { - delete impl_; - impl_ = 0; - } -} +cv::viz::VizAccessor::~VizAccessor() { delete impl_; } cv::viz::VizAccessor & cv::viz::VizAccessor::getInstance() { - if (!is_instantiated_) - { + if (!instance_) instance_ = new VizAccessor(); - is_instantiated_ = true; - } + return *instance_; } void cv::viz::VizAccessor::release() { - if (is_instantiated_) + if (instance_) { delete instance_; instance_ = 0; - is_instantiated_ = false; } } @@ -183,18 +143,15 @@ cv::viz::Viz3d cv::viz::VizAccessor::get(const String & window_name) generateWindowName(window_name, name); VizMap::iterator vm_itr = impl_->viz_map.find(name); - bool exists = vm_itr != impl_->viz_map.end(); - if (exists) return vm_itr->second; - else return Viz3d(window_name); + return vm_itr != impl_->viz_map.end() ? vm_itr->second : Viz3d(window_name); } void cv::viz::VizAccessor::add(Viz3d window) { String window_name = window.getWindowName(); VizMap::iterator vm_itr = impl_->viz_map.find(window_name); - bool exists = vm_itr != impl_->viz_map.end(); - if (exists) return ; - impl_->viz_map.insert(VizPair(window_name, window)); + if (vm_itr == impl_->viz_map.end()) + impl_->viz_map.insert(VizPair(window_name, window)); } void cv::viz::VizAccessor::remove(const String &window_name) @@ -204,21 +161,24 @@ void cv::viz::VizAccessor::remove(const String &window_name) generateWindowName(window_name, name); VizMap::iterator vm_itr = impl_->viz_map.find(name); - bool exists = vm_itr != impl_->viz_map.end(); - if (!exists) return ; - impl_->viz_map.erase(vm_itr); + if (vm_itr != impl_->viz_map.end()) + impl_->viz_map.erase(vm_itr); } void cv::viz::VizAccessor::generateWindowName(const String &window_name, String &output) { output = "Viz"; // Already is Viz - if (window_name == output) return; + if (window_name == output) + return; String prefixed = output + " - "; - if (window_name.substr(0, prefixed.length()) == prefixed) output = window_name; // Already has "Viz - " - else if (window_name.substr(0, output.length()) == output) output = prefixed + window_name; // Doesn't have prefix - else output = (window_name == "" ? output : prefixed + window_name); + if (window_name.substr(0, prefixed.length()) == prefixed) + output = window_name; // Already has "Viz - " + else if (window_name.substr(0, output.length()) == output) + output = prefixed + window_name; // Doesn't have prefix + else + output = (window_name == "" ? output : prefixed + window_name); } cv::viz::Viz3d cv::viz::get(const String &window_name) diff --git a/modules/viz/src/viz3d_impl.cpp b/modules/viz/src/viz3d_impl.cpp index d01437242..ae8fc150c 100644 --- a/modules/viz/src/viz3d_impl.cpp +++ b/modules/viz/src/viz3d_impl.cpp @@ -47,9 +47,6 @@ //M*/ #include "precomp.hpp" -#include "opencv2/core/utility.hpp" - -#include #if 1 || !defined __APPLE__ vtkRenderWindowInteractor* vtkRenderWindowInteractorFixNew() @@ -60,9 +57,7 @@ vtkRenderWindowInteractor* vtkRenderWindowInteractorFixNew() ///////////////////////////////////////////////////////////////////////////////////////////// cv::viz::Viz3d::VizImpl::VizImpl(const String &name) - : style_(vtkSmartPointer::New()) - , widget_actor_map_(new WidgetActorMap) - , s_lastDone_(0.0) + : style_(vtkSmartPointer::New()) , widget_actor_map_(new WidgetActorMap), s_lastDone_(0.0) { renderer_ = vtkSmartPointer::New(); @@ -127,7 +122,8 @@ cv::viz::Viz3d::VizImpl::~VizImpl() { if (interactor_) interactor_->DestroyTimer(timer_id_); - if (renderer_) renderer_->Clear(); + if (renderer_) + renderer_->Clear(); } ///////////////////////////////////////////////////////////////////////////////////////////// @@ -394,7 +390,7 @@ cv::viz::Camera cv::viz::Viz3d::VizImpl::getCamera() const Size window_size(renderer_->GetRenderWindow()->GetSize()[0], renderer_->GetRenderWindow()->GetSize()[1]); - double aspect_ratio = static_cast(window_size.width) / static_cast(window_size.height); + double aspect_ratio = window_size.width / (double)window_size.height; Matx44f proj_matrix = convertToMatx(active_camera.GetProjectionTransformMatrix(aspect_ratio, -1.0f, 1.0f)); Camera camera(proj_matrix, window_size); diff --git a/modules/viz/src/viz3d_impl.hpp b/modules/viz/src/viz3d_impl.hpp index 50d642e71..88f8424bf 100644 --- a/modules/viz/src/viz3d_impl.hpp +++ b/modules/viz/src/viz3d_impl.hpp @@ -124,10 +124,7 @@ private: struct ExitMainLoopTimerCallback : public vtkCommand { - static ExitMainLoopTimerCallback* New() - { - return new ExitMainLoopTimerCallback; - } + static ExitMainLoopTimerCallback* New() { return new ExitMainLoopTimerCallback; } virtual void Execute(vtkObject* vtkNotUsed(caller), unsigned long event_id, void* call_data) { if (event_id != vtkCommand::TimerEvent) @@ -146,10 +143,7 @@ private: struct ExitCallback : public vtkCommand { - static ExitCallback* New() - { - return new ExitCallback; - } + static ExitCallback* New() { return new ExitCallback; } virtual void Execute(vtkObject*, unsigned long event_id, void*) { if (event_id == vtkCommand::ExitEvent) @@ -188,21 +182,7 @@ private: bool removeActorFromRenderer(const vtkSmartPointer &actor); - /** \brief Internal method. Creates a vtk actor from a vtk polydata object. - * \param[in] data the vtk polydata object to create an actor for - * \param[out] actor the resultant vtk actor object - * \param[in] use_scalars set scalar properties to the mapper if it exists in the data. Default: true. - */ void createActorFromVTKDataSet(const vtkSmartPointer &data, vtkSmartPointer &actor, bool use_scalars = true); - - /** \brief Updates a set of cells (vtkIdTypeArray) if the number of points in a cloud changes - * \param[out] cells the vtkIdTypeArray object (set of cells) to update - * \param[out] initcells a previously saved set of cells. If the number of points in the current cloud is - * higher than the number of cells in \a cells, and initcells contains enough data, then a copy from it - * will be made instead of regenerating the entire array. - * \param[in] nr_points the number of points in the new cloud. This dictates how many cells we need to - * generate - */ void updateCells(vtkSmartPointer &cells, vtkSmartPointer &initcells, vtkIdType nr_points); }; diff --git a/modules/viz/test/test_tutorial3.cpp b/modules/viz/test/test_tutorial3.cpp index 27544a9a2..6c63763df 100644 --- a/modules/viz/test/test_tutorial3.cpp +++ b/modules/viz/test/test_tutorial3.cpp @@ -75,12 +75,12 @@ void tutorial3(bool camera_pov) myWindow.spin(); } -TEST(Viz_viz3d, tutorial3_global_view) +TEST(Viz_viz3d, DISABLED_tutorial3_global_view) { tutorial3(false); } -TEST(Viz_viz3d, tutorial3_camera_view) +TEST(Viz_viz3d, DISABLED_tutorial3_camera_view) { tutorial3(true); } diff --git a/modules/viz/test/test_viz3d.cpp b/modules/viz/test/test_viz3d.cpp index 2acb5a3c3..98811165a 100644 --- a/modules/viz/test/test_viz3d.cpp +++ b/modules/viz/test/test_viz3d.cpp @@ -96,18 +96,18 @@ TEST(Viz_viz3d, develop) cv::viz::WMesh bunny_widget(bunny_mesh); bunny_widget.setColor(cv::viz::Color::cyan()); - cam_1 = cv::viz::WCameraPosition(cv::Vec2f(0.6, 0.4), 0.2, cv::viz::Color::green()); + cam_1 = cv::viz::WCameraPosition(cv::Vec2f(0.6f, 0.4f), 0.2, cv::viz::Color::green()); cam_coordinates = cv::viz::WCameraPosition(0.2); viz.showWidget("bunny", bunny_widget); - viz.showWidget("cam_1", cam_1, viz::makeCameraPose(Point3f(1.0,0.0,0.0), Point3f(0.0,0.0,0.0), Point3f(0.0,1.0,0.0))); - viz.showWidget("cam_coordinate", cam_coordinates, viz::makeCameraPose(Point3f(1.0,0.0,0.0), Point3f(0.0,0.0,0.0), Point3f(0.0,1.0,0.0))); + viz.showWidget("cam_1", cam_1, viz::makeCameraPose(Point3f(1.f,0.f,0.f), Point3f(0.f,0.f,0.f), Point3f(0.f,1.f,0.f))); + viz.showWidget("cam_coordinate", cam_coordinates, viz::makeCameraPose(Point3f(1.f,0.f,0.f), Point3f(0.f,0.f,0.f), Point3f(0.f,1.f,0.f))); std::vector cam_path; for (int i = 0, j = 0; i <= 360; ++i, j+=5) { - cam_path.push_back(viz::makeCameraPose(Vec3d(0.5*cos(double(i)*CV_PI/180.0), 0.5*sin(double(j)*CV_PI/180.0), 0.5*sin(double(i)*CV_PI/180.0)), Vec3f(0.f, 0.f, 0.f), Vec3f(0.f, 1.f, 0.f))); + cam_path.push_back(viz::makeCameraPose(Vec3d(0.5*cos(i*CV_PI/180.0), 0.5*sin(j*CV_PI/180.0), 0.5*sin(i*CV_PI/180.0)), Vec3f(0.f, 0.f, 0.f), Vec3f(0.f, 1.f, 0.f))); } int path_counter = 0;