CameraPositionWidget: constructor with Vec2f fov (tentative)
This commit is contained in:
parent
2294eb82c9
commit
0a3691d6ac
@ -170,6 +170,7 @@ namespace cv
|
|||||||
CameraPositionWidget(double scale = 1.0);
|
CameraPositionWidget(double scale = 1.0);
|
||||||
CameraPositionWidget(const Vec3f &position, const Vec3f &look_at, const Vec3f &up_vector, double scale = 1.0);
|
CameraPositionWidget(const Vec3f &position, const Vec3f &look_at, const Vec3f &up_vector, double scale = 1.0);
|
||||||
CameraPositionWidget(const Matx33f &K, double scale = 1.0, const Color &color = Color::white());
|
CameraPositionWidget(const Matx33f &K, double scale = 1.0, const Color &color = Color::white());
|
||||||
|
CameraPositionWidget(const Vec2f &fov, double scale = 1.0, const Color &color = Color::white());
|
||||||
};
|
};
|
||||||
|
|
||||||
class CV_EXPORTS CloudWidget : public Widget3D
|
class CV_EXPORTS CloudWidget : public Widget3D
|
||||||
|
@ -895,7 +895,7 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(const Matx33f &K, double sca
|
|||||||
camera->SetPosition(0.0,0.0,0.0);
|
camera->SetPosition(0.0,0.0,0.0);
|
||||||
camera->SetViewUp(0.0,1.0,0.0);
|
camera->SetViewUp(0.0,1.0,0.0);
|
||||||
camera->SetFocalPoint(0.0,0.0,1.0);
|
camera->SetFocalPoint(0.0,0.0,1.0);
|
||||||
camera->SetClippingRange(0.01, scale * f_y * 0.001);
|
camera->SetClippingRange(0.01, scale);
|
||||||
|
|
||||||
double planesArray[24];
|
double planesArray[24];
|
||||||
camera->GetFrustumPlanes(aspect_ratio, planesArray);
|
camera->GetFrustumPlanes(aspect_ratio, planesArray);
|
||||||
@ -922,3 +922,41 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(const Matx33f &K, double sca
|
|||||||
WidgetAccessor::setProp(*this, actor);
|
WidgetAccessor::setProp(*this, actor);
|
||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cv::viz::CameraPositionWidget::CameraPositionWidget(const Vec2f &fov, double scale, const Color &color)
|
||||||
|
{
|
||||||
|
vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
|
||||||
|
|
||||||
|
camera->SetViewAngle(fov[1] * 180 / CV_PI); // Vertical field of view
|
||||||
|
camera->SetPosition(0.0,0.0,0.0);
|
||||||
|
camera->SetViewUp(0.0,1.0,0.0);
|
||||||
|
camera->SetFocalPoint(0.0,0.0,1.0);
|
||||||
|
camera->SetClippingRange(0.01, scale);
|
||||||
|
|
||||||
|
double planesArray[24];
|
||||||
|
// Default aspect ratio = 1.0? fovx/fovy?
|
||||||
|
camera->GetFrustumPlanes(1.0, planesArray);
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkPlanes> planes = vtkSmartPointer<vtkPlanes>::New();
|
||||||
|
planes->SetFrustumPlanes(planesArray);
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkFrustumSource> frustumSource =
|
||||||
|
vtkSmartPointer<vtkFrustumSource>::New();
|
||||||
|
frustumSource->SetPlanes(planes);
|
||||||
|
frustumSource->Update();
|
||||||
|
|
||||||
|
// Extract the edges so we have the grid
|
||||||
|
vtkSmartPointer<vtkExtractEdges> filter = vtkSmartPointer<vtkExtractEdges>::New();
|
||||||
|
filter->SetInput(frustumSource->GetOutput());
|
||||||
|
filter->Update();
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
|
mapper->SetInput(filter->GetOutput());
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
||||||
|
actor->SetMapper(mapper);
|
||||||
|
|
||||||
|
WidgetAccessor::setProp(*this, actor);
|
||||||
|
setColor(color);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user