[vtkusers] VTK Stereo Rendering
mailagentrus
mailagentrus at mail.ru
Tue Jul 9 01:09:00 EDT 2013
Hi! I want to add a stereo mode to my program. Program wil be show pairs of
images image in stereo mode (with Nvidia 3d vision). I set up NVidia Qudro
410 and saw stereo mode with Polydata object with using Paraview.
But, when I try to make own program i see inly the firs pair images in
stereo mode, after that image in right eye does not update... Updates inly
the left eye image.
Help me, please!
Code:
#include <vtkPolyDataReader.h>
#include <vtkSmartPointer.h>
#include <vtkDataSetMapper.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCamera.h>
#include "vtkCommand.h"
#include "vtkImageData.h"
#include <vtkBMPReader.h>
#include <vtkImageViewer2.h>
#include <vtkImageActor.h>
vtkSmartPointer<vtkBMPReader> readerR;
vtkSmartPointer<vtkBMPReader> readerL;
vtkSmartPointer<vtkImageViewer2> imageViewer;
class vtkTimerCallback : public vtkCommand
{
public:
static vtkTimerCallback *New()
{
vtkTimerCallback *cb = new vtkTimerCallback;
cb->TimerCount = 0;
return cb;
}
virtual void Execute(vtkObject *vtkNotUsed(caller), unsigned long
eventId,
void *vtkNotUsed(callData))
{
if (vtkCommand::TimerEvent == eventId)
{
// for example name for left eye image is
readerL->SetFileName ( "D:/1234/-40.bmp");
readerL->Update();
// for example name for right eye image is
readerR->SetFileName ( "D:/1234/40.bmp");
readerR->Update();
imageViewer->SetInput(readerL->GetOutput());
imageViewer->GetRenderWindow()->SetStereoTypeToLeft();
imageViewer->GetRenderWindow()->Render();
imageViewer->GetRenderer()->ResetCamera();
imageViewer->GetRenderWindow()->Render();
imageViewer->GetRenderWindow()->StereoUpdate();
imageViewer->SetInput(readerL->GetOutput());
imageViewer->GetRenderWindow()->SetStereoTypeToRight();
imageViewer->GetRenderWindow()->Render();
imageViewer->GetRenderer()->ResetCamera();
imageViewer->GetRenderWindow()->Render();
imageViewer->GetRenderWindow()->StereoUpdate();
++this->TimerCount;
}
cout << this->TimerCount << endl;
}
private:
int TimerCount;
};
int main ( int argc, char *argv[] )
{
//Read the image
readerL =
vtkSmartPointer<vtkBMPReader>::New();
readerL->SetFileName ( "D:/1234/-5.bmp");
readerL->Update();
readerR =
vtkSmartPointer<vtkBMPReader>::New();
readerR->SetFileName ( "D:/1234/5.bmp");
readerR->Update();
// Visualize
imageViewer =
vtkSmartPointer<vtkImageViewer2>::New();
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
imageViewer->SetupInteractor(renderWindowInteractor);
imageViewer->GetRenderWindow()->SetSize( 800, 600 );
imageViewer->GetRenderWindow()->StereoCapableWindowOn();
imageViewer->GetRenderWindow()->SetStereoTypeToCrystalEyes();
imageViewer->GetRenderWindow()->SetStereoRender(1);
imageViewer->GetRenderWindow()->StereoUpdate();
renderWindowInteractor->Initialize();
imageViewer->SetInput(readerBase->GetOutput());
imageViewer->GetRenderWindow()->Render();
imageViewer->GetRenderer()->ResetCamera();
imageViewer->GetRenderWindow()->Render();
// Sign up to receive TimerEvent
vtkSmartPointer<vtkTimerCallback> cb =
vtkSmartPointer<vtkTimerCallback>::New();
renderWindowInteractor->AddObserver(vtkCommand::TimerEvent, cb);
int timerId = renderWindowInteractor->CreateRepeatingTimer(100);
std::cout << "timerId: " << timerId << std::endl;
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}
--
View this message in context: http://vtk.1045678.n5.nabble.com/VTK-Stereo-Rendering-tp5721833.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list