1
/*=========================================================================
3
Program: Image Guided Surgery Software Toolkit
4
Module: $RCSfile: igstkFrameTest.cxx,v $
6
Date: $Date: 2009-06-19 22:01:18 $
7
Version: $Revision: 1.2 $
9
Copyright (c) ISC Insight Software Consortium. All rights reserved.
10
See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
12
This software is distributed WITHOUT ANY WARRANTY; without even
13
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14
PURPOSE. See the above copyright notices for more information.
16
=========================================================================*/
19
// Warning about: identifier was truncated to '255' characters
20
// in the debug information (MVC6.0 Debug)
21
#pragma warning( disable : 4786 )
25
#include "igstkLandmark3DRegistration.h"
26
#include "igstkLogger.h"
27
#include "itkStdStreamLogOutput.h"
28
#include "itkObject.h"
29
#include "itkCommand.h"
31
#include "igstkEvents.h"
32
#include "igstkVideoImager.h"
40
class VideoImagerTool;
41
class DummyVideoImager;
42
class DummyVideoImagerTool;
44
class DummyVideoImagerTool : public igstk::VideoImagerTool
48
igstkFriendClassMacro( DummyVideoImager );
50
/** Macro with standard traits declarations. */
51
igstkStandardClassTraitsMacro( DummyVideoImagerTool, igstk::VideoImagerTool )
53
void RequestAttachToVideoImager(DummyVideoImager* imager );
55
DummyVideoImagerTool::Pointer DummyVideoImagerToolPointer;
58
DummyVideoImagerTool(): m_StateMachine(this) {};
59
~DummyVideoImagerTool()
62
/** Check if the tracker tool is configured or not. This method should
63
* be implemented in the derived classes*/
64
virtual bool CheckIfVideoImagerToolIsConfigured( ) const { return true; }
68
class DummyVideoImager : public igstk::VideoImager
72
igstkFriendClassMacro( DummyVideoImagerTool );
74
double GetImagerValidityTime()
76
return this->GetValidityTime();
79
/** Typedef for internal boolean return type. */
80
typedef VideoImager::ResultType ResultType;
82
/** Open communication with the imaging device. */
83
virtual ResultType InternalOpen( void ) { return SUCCESS; };
85
/** Close communication with the imaging device. */
86
virtual ResultType InternalClose( void ){ return SUCCESS; };
88
/** Put the imaging device into imaging mode. */
89
virtual ResultType InternalStartImaging( void ){ return SUCCESS; };
91
/** Take the imaging device out of imaging mode. */
92
virtual ResultType InternalStopImaging( void ){ return SUCCESS; };
94
/** Update the status and the transforms for all VideoImagerTools. */
95
virtual ResultType InternalUpdateStatus( void ){ return SUCCESS; };
97
/** Update the status and the frames.
98
This function is called by a separate thread. */
99
virtual ResultType InternalThreadedUpdateStatus( void ){ return SUCCESS; };
101
/** Reset the imaging device to put it back to its original state. */
102
virtual ResultType InternalReset( void ){ return SUCCESS; };
104
/** Verify imager tool information */
105
virtual ResultType VerifyVideoImagerToolInformation(
106
const VideoImagerToolType * ){ return SUCCESS; };
108
/** The "ValidateSpecifiedFrequency" method checks if the specified
109
* frequency is valid for the imaging device that is being used. */
110
virtual ResultType ValidateSpecifiedFrequency( double frequencyInHz ){ return SUCCESS; };
112
/** Print object information */
113
virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const{ return; };
115
/** Remove imager tool entry from internal containers */
116
virtual ResultType RemoveVideoImagerToolFromInternalDataContainers( const
117
VideoImagerToolType * imagerTool ){ return SUCCESS; };
119
/** Add imager tool entry to internal containers */
120
virtual ResultType AddVideoImagerToolToInternalDataContainers( const
121
VideoImagerToolType * imagerTool ){ return SUCCESS; };
123
DummyVideoImager::Pointer DummyVideoImagerPointer;
124
//typedef ::itk::SmartPointer< Self > Pointer;
126
/** Macro with standard traits declarations. */
127
igstkStandardClassTraitsMacro( DummyVideoImager, igstk::VideoImager )
130
DummyVideoImager( void ): m_StateMachine(this) {};
131
~DummyVideoImager( void ) {};
135
/** The "RequestAttachToVideoImager" method attaches
136
* the imager tool to a imager. */
137
void DummyVideoImagerTool::RequestAttachToVideoImager(DummyVideoImager* imager )
139
this->VideoImagerTool::RequestAttachToVideoImager( imager );
145
int igstkFrameTest( int argv, char * argc[] )
147
typedef igstk::FrameTest::DummyVideoImager VideoImagerType;
148
typedef igstk::FrameTest::DummyVideoImagerTool VideoImagerToolType;
150
VideoImagerType::Pointer videoImager= VideoImagerType::New();
152
videoImager->RequestOpen();
154
double defaultValidityTime = videoImager->GetImagerValidityTime();
155
std::cout << "Default validity time: " << defaultValidityTime << std::endl;
157
double videoImagerFrequency = 1;
158
double validityTimeShouldBe = (1000.0/videoImagerFrequency) + 10;
160
videoImager->RequestSetFrequency( videoImagerFrequency );
162
double validityTimeReturned = videoImager->GetImagerValidityTime();
164
if( fabs( validityTimeShouldBe - validityTimeReturned ) > 1e-5 )
166
std::cerr << "Error in RequestSetFrequency()/GetImagerValidityTime() "<<std::endl;
170
videoImager->RequestSetFrequency( 30 );
172
VideoImagerToolType::Pointer videoImagerTool =
173
VideoImagerToolType::New();
174
VideoImagerToolType::Pointer videoImagerToolCopy =
175
VideoImagerToolType::New();
177
videoImagerTool->RequestConfigure();
178
videoImagerTool->RequestAttachToVideoImager( videoImager );
179
unsigned int dims[3]= {256,256,1};
182
videoImagerTool->SetFrameDimensions(dims);
183
igstk::Frame* frame1 = videoImagerTool->GetFrameFromBuffer(0);
184
igstk::Frame* frame2 = videoImagerTool->GetTemporalCalibratedFrame();
185
igstk::Frame* frame3(const_cast<igstk::Frame*> (frame2));
186
frame1->GetStartTime();
187
frame2->GetExpirationTime();
188
frame3->SetTimeToExpiration(1000);
189
frame3->IsValidAtTime(500);
190
frame3->IsValidNow();
191
frame3->Print(std::cout, 0);