CameraPositionWidget: a workaround for setting frustum color in the presence of an image
This commit is contained in:
parent
ec756afe87
commit
b661d72252
@ -173,7 +173,7 @@ namespace cv
|
||||
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 Vec2f &fov, double scale = 1.0, const Color &color = Color::white());
|
||||
CameraPositionWidget(const Matx33f &K, const Mat &img, double scale = 1.0);
|
||||
CameraPositionWidget(const Matx33f &K, const Mat &img, double scale = 1.0, const Color &color = Color::white());
|
||||
|
||||
};
|
||||
|
||||
|
@ -1031,7 +1031,7 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(const Vec2f &fov, double sca
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
cv::viz::CameraPositionWidget::CameraPositionWidget(const Matx33f &K, const Mat &image, double scale)
|
||||
cv::viz::CameraPositionWidget::CameraPositionWidget(const Matx33f &K, const Mat &image, double scale, const Color &color)
|
||||
{
|
||||
CV_Assert(!image.empty() && image.depth() == CV_8U);
|
||||
|
||||
@ -1049,6 +1049,11 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(const Matx33f &K, const Mat
|
||||
vtkSmartPointer<vtkImageData> vtk_image = vtkSmartPointer<vtkImageData>::New();
|
||||
ConvertToVtkImage::convert(image, vtk_image);
|
||||
|
||||
// Adjust a pixel of the vtk_image
|
||||
vtk_image->SetScalarComponentFromDouble(0, image.rows-1, 0, 0, color[2]);
|
||||
vtk_image->SetScalarComponentFromDouble(0, image.rows-1, 0, 1, color[1]);
|
||||
vtk_image->SetScalarComponentFromDouble(0, image.rows-1, 0, 2, color[0]);
|
||||
|
||||
// Need to flip the image as the coordinates are different in OpenCV and VTK
|
||||
vtkSmartPointer<vtkImageFlip> flipFilter = vtkSmartPointer<vtkImageFlip>::New();
|
||||
flipFilter->SetFilteredAxis(1); // Vertical flip
|
||||
|
Loading…
x
Reference in New Issue
Block a user