17 #include <QTextStream> 19 #include <vtkImageChangeInformation.h> 20 #include <vtkImageLuminance.h> 21 #include <vtkImageData.h> 22 #include "vtkImageAppend.h" 23 #include "vtkMetaImageWriter.h" 37 mSaveFolder(saveFolder),
40 mMutex(QMutex::Recursive),
43 mTimestampsFile(saveFolder+
"/"+prefix+
".fts"),
44 mCompressed(compressed),
45 mWriteColor(writeColor)
47 this->setObjectName(
"org.custusx.resource.videorecordersave");
61 data.
mImage = vtkImageDataPtr::New();
62 data.
mImage->DeepCopy(image);
66 QMutexLocker sentry(&
mMutex);
116 vtkSmartPointer<vtkImageLuminance> luminance = vtkSmartPointer<vtkImageLuminance>::New();
117 luminance->SetInputData(data.
mImage);
119 data.
mImage = luminance->GetOutput();
125 writer->SetInputData(data.
mImage);
151 QMutexLocker sentry(&
mMutex);
156 this->
write(current);
183 mImages->setDeleteFilesOnRelease(
true);
186 mSaveFolder = saveFolder;
188 mSaveThread->start();
193 mSaveThread->cancel();
207 void SavingVideoRecorder::newFrameSlot()
209 if (!mSource->validData())
213 TimeInfo timestamp = mSource->getAdvancedTimeInfo();
214 QString filename = mSaveThread->addData(timestamp, image);
216 mImages->append(filename);
217 mTimestamps.push_back(timestamp);
234 mSaveThread->cancel();
237 this->deleteFolder(mSaveFolder);
242 void SavingVideoRecorder::deleteFolder(QString folder)
245 filters <<
"*.fts" <<
"*.mhd" <<
"*.raw" <<
"*.zraw";
246 for (
int i=0; i<filters.size(); ++i)
247 filters[i] = mPrefix + filters[i];
250 QStringList files = dir.entryList(filters);
252 for (
int i=0; i<files.size(); ++i)
253 dir.remove(files[i]);
QString qstring_cast(const T &val)
virtual ~SavingVideoRecorder()
bool closeTimestampsFile()
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
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)
SavingVideoRecorder(VideoSourcePtr source, QString saveFolder, QString prefix, bool compressed, bool writeColor, FileManagerServicePtr filemanagerservice)
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
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
Namespace for all CustusX production code.