PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkPlusNVidiaDVPVideoSourceLinux.cxx
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2 Program: Plus
3 Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4 See License.txt for details.
5 =========================================================Plus=header=end*/
6 
7 /*=========================================================================
8 The following copyright notice is applicable to parts of this file:
9 Copyright (c) 2014, Robarts Research Institute, The University of Western Ontario, London, Ontario, Canada
10 All rights reserved.
11 Authors include:
12 * Adam Rankin (Robarts Research Institute and The University of Western Ontario)
13 =========================================================================*/
14 
15 // Plus includes
16 #include "PlusConfigure.h"
17 #include "vtkPlusNvidiaDVPVideoSource.h"
18 #include "vtkPlusDataSource.h"
19 
20 // VTK includes
21 #include <vtkObjectFactory.h>
22 
23 // NVidia DVP includes
24 #include <DVPAPI.h>
25 #include <dvpapi_gl.h>
26 
27 #include <NVCtrlLib.h>
28 #include <NVCtrl.h>
29 
30 
31 //----------------------------------------------------------------------------
32 
34 
35 //----------------------------------------------------------------------------
37  : FrameNumber( 0 )
38  , EnableGPUCPUCopy( false )
39 {
40  // No callback function provided by the device, so the data capture thread will be used to poll the hardware and add new items to the buffer
41  this->StartThreadForInternalUpdates = true;
42  this->AcquisitionRate = 30;
43 }
44 
45 //----------------------------------------------------------------------------
47 {
48  if ( this->Connected )
49  {
50  this->Disconnect();
51  }
52 }
53 
54 //----------------------------------------------------------------------------
55 void vtkPlusNvidiaDVPVideoSource::PrintSelf( ostream& os, vtkIndent indent )
56 {
57  this->Superclass::PrintSelf( os, indent );
58 }
59 
60 //----------------------------------------------------------------------------
62 {
63  LOG_TRACE( "vtkPlusPhilips3DProbeVideoSource::InternalConnect" );
64 
65  DVPStatus status = dvpInitGLContext();
66  return PLUS_SUCCESS;
67 }
68 
69 //----------------------------------------------------------------------------
71 {
72  LOG_TRACE( "vtkPlusNvidiaDVPVideoSource::InternalDisconnect" );
73 
74  return PLUS_SUCCESS;
75 }
76 
77 //-----------------------------------------------------------------------------
79 {
80  return PLUS_SUCCESS;
81 }
82 
83 //-----------------------------------------------------------------------------
84 PlusStatus vtkPlusNvidiaDVPVideoSource::ReadConfiguration( vtkXMLDataElement* rootConfigElement )
85 {
86  LOG_TRACE( "vtkPlusNvidiaDVPVideoSource::ReadConfiguration" );
87  XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_READING( deviceConfig, rootConfigElement );
88 
89  XML_READ_BOOL_ATTRIBUTE_OPTIONAL( EnableGPUCPUCopy, deviceConfig );
90 
91  return PLUS_SUCCESS;
92 }
93 
94 //-----------------------------------------------------------------------------
96 {
97  LOG_TRACE( "vtkPlusNvidiaDVPVideoSource::WriteConfiguration" );
98  XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_WRITING( deviceConfig, rootConfig );
99 
100  XML_WRITE_BOOL_ATTRIBUTE( EnableGPUCPUCopy, deviceConfig );
101 
102  return PLUS_SUCCESS;
103 }
104 
105 //-----------------------------------------------------------------------------
107 {
108  if ( this->OutputChannels.size() != 1 && this->EnableGPUCPUCopy ||
109  this->OutputChannels.size() > 0 && !this->EnableGPUCPUCopy )
110  {
111  LOG_ERROR( "Incorrect configuration. GPU/CPU copy and OutputChannel configuration are incompatible." );
112  this->SetCorrectlyConfigured( false );
113  return PLUS_FAIL;
114  }
115 
116  vtkPlusDataSource* videoSource( NULL );
117  if( this->EnableGPUCPUCopy && this->GetFirstVideoSource( videoSource ) != PLUS_SUCCESS )
118  {
119  LOG_ERROR( "Unable to find video source. Device needs a video buffer to put new frames into when copying frames from the GPU." );
120  this->SetCorrectlyConfigured( false );
121  return PLUS_FAIL;
122  }
123 
124  return PLUS_SUCCESS;
125 }
126 
127 //----------------------------------------------------------------------------
129 {
130  return false;
131 }
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
bool EnableGPUCPUCopy
Enable copying of frame data from GPU to CPU for broadcasting.
#define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_WRITING(deviceConfig, rootConfigElement)
igsioStatus PlusStatus
Definition: PlusCommon.h:40
vtkStandardNewMacro(vtkPlusNvidiaDVPVideoSource)
double AcquisitionRate
#define PLUS_FAIL
Definition: PlusCommon.h:43
PlusStatus GetFirstVideoSource(vtkPlusDataSource *&anImage)
virtual PlusStatus Disconnect()
virtual PlusStatus NotifyConfigured()
Perform any completion tasks once configured.
virtual void SetCorrectlyConfigured(bool)
DVPStatus
Definition: DVPAPI.h:83
#define PLUS_SUCCESS
Definition: PlusCommon.h:44
#define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_READING(deviceConfig, rootConfigElement)
bool StartThreadForInternalUpdates
virtual bool IsTracker() const
Respond to the query if this is a tracker or not.
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *config)
Read configuration from XML data.
ChannelContainer OutputChannels
DVPAPI_INTERFACE dvpInitGLContext(uint32_t flags)
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *config)
Write configuration to XML data.
Class for providing VTK video input interface from an NVidia digital video platform interface.
Interface to a 3D positioning tool, video source, or generalized data stream.