13 #include <vtkImageImport.h> 14 #include <vtkImageData.h> 32 mImageImport = vtkImageImportPtr::New();
34 mImageTimer =
new QTimer(
this);
35 connect(mImageTimer, SIGNAL(timeout()),
this, SLOT(processBuffer()));
36 mBuffer = (uint8_t*)malloc(width * height * 3);
38 mImageImport->SetDataScalarTypeToUnsignedChar();
39 mImageImport->SetNumberOfScalarComponents(3);
40 mImageImport->SetWholeExtent(0, mWidth - 1, 0, mHeight - 1, 0, 0);
41 mImageImport->SetDataExtentToWholeExtent();
52 mResolution = resolution;
53 mImageImport->SetDataSpacing(mResolution, mResolution, 1);
58 return mImageImport->GetOutput();
72 mImageTimer->start(40);
81 static void TestImage(
int width,
int height,
int frames, uint8_t *image,
double mmPerPixel)
83 for (
int x = 0; x < width; ++x)
85 for (
int y = 0; y < height; ++y)
87 uint8_t *pix = &image[(y*width + x) * 3];
88 pix[0] = (x*255/width)+frames;
89 pix[1] = (y*255/height)+frames;
91 double mmPerPixel = 0.1;
92 if ( (
int)(x * mmPerPixel) % 10 == 0)
94 uint8_t *pix = &image[(y*width + x) * 3];
103 void TestVideoSource::processBuffer()
105 TestImage(mWidth, mHeight, mFrames, mBuffer, mResolution);
107 mImageImport->SetImportVoidPointer(mBuffer);
108 mImageImport->Update();
109 mImageImport->Modified();
116 return (
double) mImageImport->GetOutput()->GetMTime();
virtual bool isConnected() const
return true when a connection to the data source is established.
virtual void setConnected(bool state)
virtual TimeInfo getAdvancedTimeInfo()
virtual void stop()
stop streaming
virtual ~TestVideoSource()
virtual double getTimestamp()
virtual void start()
start streaming
virtual vtkImageDataPtr getVtkImageData()
QDateTime mAcquisitionTime
Possibly modified time stamp.
TestVideoSource(QString uid, QString name, int width, int height)
void newFrame()
emitted when a new frame has arrived (getVtkImageData() returns something new). info/status/name/vali...
virtual void setResolution(double resolution)
Namespace for all CustusX production code.