6 #include <vtkVersion.h> 7 #include <vtkFrustumSource.h> 8 #include <vtkPolyData.h> 9 #include <vtkPointData.h> 10 #include <vtkSmartPointer.h> 11 #include <vtkCamera.h> 12 #include <vtkPlanes.h> 13 #include <vtkMapper.h> 15 #include <vtkRenderWindow.h> 16 #include <vtkRenderer.h> 17 #include <vtkRenderWindowInteractor.h> 18 #include <vtkPolyDataMapper.h> 19 #include <vtkTriangle.h> 20 #include <vtkCellArray.h> 21 #include <vtkMatrix4x4.h> 22 #include <vtkTransform.h> 31 std::shared_ptr<ScanDataManager> sdm,
33 vtkSmartPointer<vtkRenderer> renderer,
35 QTreeWidgetItem *parent
68 m_pose.
r = pose[3] * 57.295779513;
69 m_pose.
t = pose[4] * 57.295779513;
70 m_pose.
p = pose[5] * 57.295779513;
84 setCheckState(0, Qt::Unchecked );
94 if(checkState(0) && visible)
96 std::cout <<
"ADD ACTOR" << std::endl;
106 QTreeWidgetItem* parent_it = parent();
108 while(parent_it !=
NULL)
111 auto transform_obj =
dynamic_cast< Transformable*
>(parent_it);
116 parent_it = parent_it->parent();
127 cam->GetPosition(x,y,z);
134 Vector3d cam_origin(0.0, 0.0, -1.0);
136 Vector3d focal_point(0.0, 0.0, 0.0);
143 cam->SetPosition(cam_origin.x(), cam_origin.y(), cam_origin.z());
144 cam->SetFocalPoint(focal_point.x(), focal_point.y(), focal_point.z());
145 cam->SetViewUp(view_up.x(), view_up.y(), view_up.z());
157 std::vector<Vector3d > cv_pixels;
161 Intrinsicsd intrisics_corrected = Intrinsicsd::Identity();
168 int u_max = intrisics_corrected(0, 2) * 2;
169 int v_max = intrisics_corrected(1, 2) * 2;
171 Intrinsicsd cam_mat_inv = intrisics_corrected.inverse();
174 std::cout <<
"u,v max: "<< u_max <<
"," << v_max << std::endl;
179 cv_pixels.push_back({0.0, 0.0, 1.0});
181 cv_pixels.push_back({0.0, double(v_max), 1.0});
183 cv_pixels.push_back({double(u_max), double(v_max), 1.0});
185 cv_pixels.push_back({double(u_max), 0.0, 1.0});
189 std::vector<Vector3d > lvr_points;
193 lvr_points.push_back({0.0, 0.0, 0.0});
195 std::cout <<
"cam space: " << std::endl;
196 for(
int i=0; i<cv_pixels.size(); i++)
208 std::cout << tmp.transpose() << std::endl;
211 lvr_points.push_back(tmp);
214 std::cout <<
"world space:" << std::endl;
216 for(
int i=0; i<lvr_points.size(); i++)
219 std::cout << lvr_points[i].transpose() << std::endl;
232 vtkSmartPointer<vtkPoints> points =
233 vtkSmartPointer<vtkPoints>::New();
236 points->SetNumberOfPoints(lvr_points.size());
238 for(
int i=0; i<lvr_points.size(); i++)
240 auto p = lvr_points[i];
241 points->SetPoint(i,
p.x(),
p.y(),
p.z());
245 unsigned char white[3] = {255, 255, 255};
246 unsigned char red[3] = {255, 0, 0};
247 unsigned char green[3] = {0, 255, 0};
248 unsigned char blue[3] = {0, 0, 255};
249 unsigned char yellow[3] = {255, 255, 0};
252 vtkSmartPointer<vtkUnsignedCharArray>
colors =
253 vtkSmartPointer<vtkUnsignedCharArray>::New();
254 colors->SetNumberOfComponents(3);
255 colors->SetNumberOfTuples(lvr_points.size());
256 colors->SetName(
"Colors");
258 #if VTK_MAJOR_VERSION < 7 259 colors->SetTupleValue(0, white);
260 colors->SetTupleValue(1, red);
261 colors->SetTupleValue(2, green);
262 colors->SetTupleValue(3, blue);
263 colors->SetTupleValue(4, yellow);
265 colors->SetTypedTuple(0, white);
266 colors->SetTypedTuple(1, red);
267 colors->SetTypedTuple(2, green);
268 colors->SetTypedTuple(3, blue);
269 colors->SetTypedTuple(4, yellow);
273 vtkSmartPointer<vtkCellArray> triangles =
274 vtkSmartPointer<vtkCellArray>::New();
277 vtkSmartPointer<vtkTriangle> triangle =
278 vtkSmartPointer<vtkTriangle>::New();
282 triangle->GetPointIds()->SetId(0, 0);
283 triangle->GetPointIds()->SetId(1, 1);
284 triangle->GetPointIds()->SetId(2, 2);
286 triangles->InsertNextCell(triangle);
289 triangle->GetPointIds()->SetId(0, 0);
290 triangle->GetPointIds()->SetId(1, 2);
291 triangle->GetPointIds()->SetId(2, 3);
293 triangles->InsertNextCell(triangle);
296 triangle->GetPointIds()->SetId(0, 0);
297 triangle->GetPointIds()->SetId(1, 3);
298 triangle->GetPointIds()->SetId(2, 4);
300 triangles->InsertNextCell(triangle);
303 triangle->GetPointIds()->SetId(0, 0);
304 triangle->GetPointIds()->SetId(1, 4);
305 triangle->GetPointIds()->SetId(2, 1);
307 triangles->InsertNextCell(triangle);
310 vtkSmartPointer<vtkPolyData> polydata =
311 vtkSmartPointer<vtkPolyData>::New();
312 polydata->SetPoints(points);
313 polydata->SetPolys(triangles);
314 polydata->GetPointData()->SetScalars(colors);
317 vtkSmartPointer<vtkPolyDataMapper> mapper =
318 vtkSmartPointer<vtkPolyDataMapper>::New();
319 #if VTK_MAJOR_VERSION <= 5 320 mapper->SetInputConnection(polydata->GetProducerPort());
322 mapper->SetInputData(polydata);
324 vtkSmartPointer<vtkActor> actor =
325 vtkSmartPointer<vtkActor>::New();
326 actor->SetMapper(mapper);
std::vector< Vector3d > genFrustrumLVR(float scale=1.0)
void reload(vtkSmartPointer< vtkRenderer > renderer)
vtkSmartPointer< vtkActor > m_frustrum_actor
vtkSmartPointer< vtkActor > genFrustrum(float scale=1.0)
Eigen::Vector3d Vector3d
Eigen 3D vector, double precision.
Main class for conversion of LVR model instances to vtk actors. This class parses the internal model ...
Transform< double > Transformd
4x4 double precision transformation matrix
boost::shared_ptr< LVRModelBridge > ModelBridgePtr
Intrinsics< double > Intrinsicsd
4x4 extrinsic calibration (double precision)
Vector3< T > multiply(const Transform< T > &transform, const Vector3< T > &p)
static Vector3< T > openCvToLvr(const Vector3< T > &in)
OpenCV to Lvr coordinate change: Point.
void setVisibility(bool visible)
std::shared_ptr< ScanDataManager > m_sdm
void setPose(const Pose &pose)
std::shared_ptr< Model > ModelPtr
Transformd getGlobalTransform()
Get Transformation from Camera frame to Global. QTree used as TF tree, lvr2::Transformable types are ...
LVRCvImageItem * m_cvItem
vtkSmartPointer< vtkRenderer > m_renderer
LVRCamDataItem(ScanImage &data, std::shared_ptr< ScanDataManager > sdm, size_t cam_id, vtkSmartPointer< vtkRenderer > renderer, QString name="", QTreeWidgetItem *parent=NULL)
Extrinsicsd extrinsics
Extrinsics.