我为自己的工作开发了QT校准工具。我已经有了相机的固有参数,并且可以使用棋盘检测外部参数。问题是,我的老板想增加一种可能性,即在检测到棋盘所在的桌子旁边显示3D模型。我使用OpenCV小部件进行流传输,但是我不知道如何在考虑外部性的同时将流与3D模型一起显示。
现在,我设法做到了:
void camCalibration::startVisualisationAR()
{
this->initializeVisualizers();
this->loadXraydevice();
//! Wait to get initial data
boost::posix_time::milliseconds waiting_for_data(100);
boost::this_thread::sleep(waiting_for_data);
int count=0;
while( m_ARVisuStarted )
{
//! Get color imgs from shared buffer and show it
for( int dIdx = 0; dIdx < m_numCameras; dIdx++)
{
//! Color current color
m_sharedDataMutexes[dIdx]->lock();
m_colorImagesLocal[ dIdx ] = m_imagesPerCamera[dIdx][0]->clone();
m_sharedDataMutexes[ dIdx ]->unlock();
if( m_colorImagesLocal[ dIdx ].rows != 0)
{
if( xaware_demo_utils::openCV2VTK( m_colorImagesLocal[ dIdx ], m_colorImagesData[ dIdx ] ))
{
m_colorImagesData[ dIdx ]->Modified();
m_colorImagesActor[ dIdx ]->SetInput( m_colorImagesData[ dIdx ] );
m_colorImagesActor[ dIdx ]->SetOpacity(1);
//m_virtualImagesActor[ dIdx ]->SetInput( m_virtualImagesData[ dIdx ] );
if(count < m_numCameras)
{
m_xRayDevice_renderers[ dIdx ]->AddActor( m_colorImagesActor[ dIdx ] );
m_xRayDevice_renderers[ dIdx ]->AddActor( m_xRayDevice_actor );
vtkSmartPointer<vtkCamera> camera = m_xRayDevice_renderers[ dIdx ]->GetActiveCamera();
m_xRayDevice_renderers[ dIdx ]->ResetCamera();
camera->Zoom(1.7);
m_xRayDevice_renderWindows[ dIdx ]->Render();
count++;
}
//! Get output AR image in CV format
vtkSmartPointer<vtkImageData> ar_output = vtkSmartPointer<vtkImageData>::New();
ar_output = xaware_demo_utils::vtkWindowToImage( m_xRayDevice_renderWindows[ dIdx ]);
m_outputARImages[ dIdx ] = xaware_demo_utils::vtkToOpenCV( ar_output );
//! Convert color channels
cv::cvtColor( m_outputARImages[ dIdx ], m_outputARImages[ dIdx ], CV_BGRA2RGBA );
cv::cvtColor( m_outputARImages[ dIdx ], m_outputARImages[ dIdx ], CV_RGBA2RGB );
//! Sent AR images to GUI
m_sharedOutputDataMutexes[ dIdx ]->lock();
*m_outputSharedImages[ dIdx ] = m_outputARImages[ dIdx ].clone();
m_sharedOutputDataMutexes[ dIdx ]->unlock();
}
}
}
}
//! Release memory
this->closeRenderWindows();
}
出于保密原因,我无法显示更多信息。
在进行校准时,这里是带有棋盘格的房间:
然后,我使用一个复选框激活AR可视化。现在,我可以在摄像机输入旁边显示3D模型(为避免任何问题,我用一个漂亮的鳄鱼雕像代替了X射线设备):
有什么想法可以将渲染器视图限制为视频演员,而不是两个演员?以及如何根据相机的参数设置图像的体积比例和位置?