38 #include <QTextStream>
40 #include <vtkImageChangeInformation.h>
41 #include <vtkImageLuminance.h>
42 #include <vtkImageData.h>
43 #include "vtkImageAppend.h"
44 #include "vtkMetaImageWriter.h"
58 mSaveFolder(saveFolder),
61 mMutex(QMutex::Recursive),
64 mTimestampsFile(saveFolder+
"/"+prefix+
".fts"),
65 mCompressed(compressed),
66 mWriteColor(writeColor)
68 this->setObjectName(
"org.custusx.resource.videorecordersave");
82 data.
mImage = vtkImageDataPtr::New();
83 data.
mImage->DeepCopy(image);
87 QMutexLocker sentry(&
mMutex);
137 vtkSmartPointer<vtkImageLuminance> luminance = vtkSmartPointer<vtkImageLuminance>::New();
138 luminance->SetInputData(data.
mImage);
140 data.
mImage = luminance->GetOutput();
146 writer->SetInputData(data.
mImage);
172 QMutexLocker sentry(&
mMutex);
177 this->
write(current);
204 mImages->setDeleteFilesOnRelease(
true);
207 mSaveFolder = saveFolder;
209 mSaveThread->start();
214 mSaveThread->cancel();
228 void SavingVideoRecorder::newFrameSlot()
230 if (!mSource->validData())
234 TimeInfo timestamp = mSource->getAdvancedTimeInfo();
235 QString filename = mSaveThread->addData(timestamp, image);
237 mImages->append(filename);
238 mTimestamps.push_back(timestamp);
255 mSaveThread->cancel();
258 this->deleteFolder(mSaveFolder);
263 void SavingVideoRecorder::deleteFolder(QString folder)
266 filters <<
"*.fts" <<
"*.mhd" <<
"*.raw" <<
"*.zraw";
267 for (
int i=0; i<filters.size(); ++i)
268 filters[i] = mPrefix + filters[i];
271 QStringList files = dir.entryList(filters);
273 for (
int i=0; i<files.size(); ++i)
274 dir.remove(files[i]);
QString qstring_cast(const T &val)
virtual ~SavingVideoRecorder()
bool closeTimestampsFile()
std::vector< TimeInfo > getTimestamps()
void reportError(QString msg)
void writeTimeStampsFile(TimeInfo timeStamps)
cstring_cast_Placeholder cstring_cast(const T &val)
QString addData(TimeInfo timestamp, vtkImageDataPtr data)
virtual ~VideoRecorderSaveThread()
double getAcquisitionTime() const
VideoRecorderSaveThread(QObject *parent, QString saveFolder, QString prefix, bool compressed, bool writeColor)
virtual void stopRecord()
boost::shared_ptr< class VideoSource > VideoSourcePtr
vtkSmartPointer< class vtkMetaImageWriter > vtkMetaImageWriterPtr
SavingVideoRecorder(VideoSourcePtr source, QString saveFolder, QString prefix, bool compressed, bool writeColor)
void write(DataType data)
bool openTimestampsFile()
std::list< DataType > mPendingData
CachedImageDataContainerPtr getImageData()
boost::shared_ptr< class CachedImageDataContainer > CachedImageDataContainerPtr
void newFrame()
emitted when a new frame has arrived (getVtkImageData() returns something new). info/status/name/vali...
virtual void startRecord()
QMutex mMutex
protects the mPendingData