36 #include <boost/array.hpp>
39 #include <vtkImageData.h>
40 #include <vtkImageImport.h>
41 #include <vtkPNGReader.h>
50 : mImageWidth(width), mImageHeight(height), mImageColorDepth(depth), mImageImport(
vtkImageImportPtr::New())
52 mImportInitialized =
false;
53 mStartWhenConnected =
false;
55 mImageImport->SetDataScalarTypeToUnsignedChar();
56 mImageImport->SetNumberOfScalarComponents(3);
61 mPollTimer =
new QTimer(
this);
62 mPollTimer->setInterval(40);
66 mImageData = mImageImport->GetOutput();
87 return mImageImport->GetOutput();
92 return (
double) mSource.
timestamp().toMSecsSinceEpoch();
98 return "NOT YET IMPLEMENTED";
104 return QString(
"%1 and %2").arg(
isConnected() ?
"Connected" :
"Not connected").arg(
isStreaming() ?
"streaming" :
"not streaming");;
111 mStartWhenConnected =
true;
114 mStartWhenConnected =
false;
127 mStartWhenConnected =
false;
161 unsigned char* buffer = (
unsigned char*) mSource.
isNew();
165 mTimeStamp = mSource.
timestamp().currentMSecsSinceEpoch();
168 Q_UNUSED(numChannels);
171 mImageImport->SetDataExtentToWholeExtent();
173 mImageImport->SetImportVoidPointer(buffer);
174 mImageImport->Update();
175 mImportInitialized =
true;
186 mConnected = mSource.
attach(key);
190 connect(mPollTimer, SIGNAL(timeout()),
this, SLOT(serverPollSlot()));
193 if (mStartWhenConnected)
209 disconnect(mPollTimer, SIGNAL(timeout()),
this, SLOT(serverPollSlot()));
220 void VideoSourceSHM::serverPollSlot()
227 mImageImport->SetDataSpacing(resolution, resolution, 1);
virtual ~VideoSourceSHM()
virtual QString getInfoString() const
Returns a short info message.
void release()
Release our read buffer.
void streaming(bool on)
emitted when streaming started/stopped
virtual double getTimestamp()
virtual void start()
start streaming
virtual vtkImageDataPtr getVtkImageData()
const void * isNew()
Return new buffer only if new is available, otherwise return NULL.
virtual QString getName()
virtual bool isConnected() const
return true when a connection to the data source is established.
void connectServer(const QString &key)
virtual QString getStatusString() const
Returns a short status message.
vtkSmartPointer< class vtkImageImport > vtkImageImportPtr
virtual bool isStreaming() const
return true when the source is streaming data.
VideoSourceSHM(int width=0, int height=0, int depth=24)
bool attach(const QString &key)
virtual void stop()
stop streaming
void newFrame()
emitted when a new frame has arrived (getVtkImageData() returns something new). info/status/name/vali...
virtual bool validData() const
return true is data stream is ok to display. This is a heuristic based on the data rate...
virtual void setResolution(double resolution)