NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
mitkOpenCVFileIOUtils.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef mitkOpenCVFileIOUtils_h
16 #define mitkOpenCVFileIOUtils_h
17 
18 #include "niftkOpenCVUtilsExports.h"
20 #include <mitkOpenCVPointTypes.h>
21 #include <highgui.h>
22 
27 namespace mitk {
28 
32 extern "C++" NIFTKOPENCVUTILS_EXPORT bool CheckIfDirectoryContainsTrackingMatrices(const std::string& directory);
33 
37 extern "C++" NIFTKOPENCVUTILS_EXPORT std::vector<std::string> FindTrackingMatrixDirectories(const std::string& directory);
38 
42 extern "C++" NIFTKOPENCVUTILS_EXPORT mitk::TimeStampsContainer FindTrackingTimeStamps(std::string directory);
43 
47 extern "C++" NIFTKOPENCVUTILS_EXPORT std::vector<std::string> FindVideoFrameMapFiles(const std::string directory);
48 
54 extern "C++" NIFTKOPENCVUTILS_EXPORT bool ReadTrackerMatrix(const std::string& filename, cv::Mat& outputMatrix);
55 
59 extern "C++" NIFTKOPENCVUTILS_EXPORT bool ReadTrackerMatrix(const std::string& filename, cv::Matx44d& outputMatrix);
60 
65 extern "C++" NIFTKOPENCVUTILS_EXPORT bool SaveTrackerMatrix(const std::string& filename, cv::Mat& outputMatrix);
66 
70 extern "C++" NIFTKOPENCVUTILS_EXPORT bool SaveTrackerMatrix(const std::string& filename, cv::Matx44d& outputMatrix);
71 
79 extern "C++" NIFTKOPENCVUTILS_EXPORT cv::VideoCapture* InitialiseVideoCapture(std::string filename, bool ignoreErrors = false);
80 
84 extern "C++" NIFTKOPENCVUTILS_EXPORT std::vector< std::pair<unsigned long long, cv::Point3d> > LoadTimeStampedPoints(const std::string& directory);
85 
89 extern "C++" NIFTKOPENCVUTILS_EXPORT void LoadTimeStampedPoints(std::vector< std::pair<unsigned long long, cv::Point3d> >& points,
90  std::vector <mitk::ProjectedPointPair >& screenPoints, const std::string& fileName);
91 
95 extern "C++" NIFTKOPENCVUTILS_EXPORT void LoadTimeStampedPoints(std::vector< std::pair<unsigned long long, cv::Point2d> >& points,
96  const std::string& fileName);
97 
101 extern "C++" NIFTKOPENCVUTILS_EXPORT void SaveTimeStampedPoints(const std::vector< std::pair<unsigned long long, cv::Point3d> >& points, const std::string& fileName);
102 
106 extern "C++" NIFTKOPENCVUTILS_EXPORT void SavePickedObjects ( const std::vector < mitk::PickedObject > & points, std::ostream& os );
107 
111 extern "C++" NIFTKOPENCVUTILS_EXPORT void LoadPickedObjects ( std::vector < mitk::PickedObject > & points, std::istream& is );
112 
117 extern "C++" NIFTKOPENCVUTILS_EXPORT std::vector<cv::Mat> LoadMatricesFromDirectory (const std::string& fullDirectoryName);
118 
119 
124 extern "C++" NIFTKOPENCVUTILS_EXPORT std::vector<cv::Mat> LoadOpenCVMatricesFromDirectory (const std::string& fullDirectoryName);
125 
126 
131 extern "C++" NIFTKOPENCVUTILS_EXPORT std::vector<cv::Mat> LoadMatricesFromExtrinsicFile (const std::string& fullFileName);
132 
133 
137 extern "C++" NIFTKOPENCVUTILS_EXPORT void LoadStereoCameraParametersFromDirectory (const std::string& directory,
138  cv::Mat* leftCameraIntrinsic, cv::Mat* leftCameraDistortion,
139  cv::Mat* rightCameraIntrinsic, cv::Mat* rightCameraDisortion,
140  cv::Mat* rightToLeftRotationMatrix, cv::Mat* rightToLeftTranslationVector,
141  cv::Mat* leftCameraToTracker);
142 
143 
151 extern "C++" NIFTKOPENCVUTILS_EXPORT void LoadCameraIntrinsicsFromPlainText ( const std::string& filename,
152  cv::Mat* cameraIntrinsic, cv::Mat* cameraDistortion);
153 
154 
160 extern "C++" NIFTKOPENCVUTILS_EXPORT void LoadStereoTransformsFromPlainText ( const std::string& filename,
161  cv::Mat* rightToLeftRotationMatrix, cv::Mat* rightToLeftTranslationVector);
162 
163 
168 extern "C++" NIFTKOPENCVUTILS_EXPORT void LoadHandeyeFromPlainText ( const std::string& filename,
169  cv::Mat* leftCameraToTracker);
170 
177 extern "C++" NIFTKOPENCVUTILS_EXPORT mitk::PickedPointList::Pointer LoadPickedPointListFromDirectory (
178  const std::string& directoryName ,
179  unsigned int frameNumber = 0 ,
180  unsigned long long timestamp = 0,
181  std::string channel = "world",
182  cv::Scalar scalar = cv::Scalar ( 255, 255, 255 ) );
183 
184 } // end namespace
185 
186 #endif
187 
188 
189 
void LoadHandeyeFromPlainText(const std::string &filename, cv::Mat *leftCameraToTracker)
Load the handeye matrix from a plain text file cv::Mat.
Definition: mitkOpenCVFileIOUtils.cxx:799
std::vector< std::pair< unsigned long long, cv::Point3d > > LoadTimeStampedPoints(const std::string &directory)
Loads points from a directory, where each point is in a separate file, and the filename is a timestam...
Definition: mitkOpenCVFileIOUtils.cxx:273
std::vector< std::string > FindVideoFrameMapFiles(const std::string directory)
Recursively hunts for all files that look like they are a video frame map file, (.+)(framemap.log).
Definition: mitkOpenCVFileIOUtils.cxx:100
void LoadStereoTransformsFromPlainText(const std::string &filename, cv::Mat *rightToLeftRotationMatrix, cv::Mat *rightToLeftTranslationVector)
Load stereo camera parameters from a plain text file cv::Mat.
Definition: mitkOpenCVFileIOUtils.cxx:773
void LoadStereoCameraParametersFromDirectory(const std::string &directory, cv::Mat *leftCameraIntrinsic, cv::Mat *leftCameraDistortion, cv::Mat *rightCameraIntrinsic, cv::Mat *rightCameraDistortion, cv::Mat *rightToLeftRotationMatrix, cv::Mat *rightToLeftTranslationVector, cv::Mat *leftCameraToTracker)
Load stereo camera parameters from a directory.
Definition: mitkOpenCVFileIOUtils.cxx:667
std::vector< cv::Mat > LoadMatricesFromDirectory(const std::string &fullDirectoryName)
Read a set of matrices, stored as plain text, 4x4 matrices from a directory and put them in a vector ...
Definition: mitkOpenCVFileIOUtils.cxx:544
void SaveTimeStampedPoints(const std::vector< std::pair< unsigned long long, cv::Point3d > > &points, const std::string &fileName)
Saves points to a flat text file.
Definition: mitkOpenCVFileIOUtils.cxx:442
Definition: ReceptorMemberCommandTest.cxx:25
cv::VideoCapture * InitialiseVideoCapture(std::string filename, bool ignoreErrors)
Attempts to open a video capture and checks for errors. see trac 3718. This attempts to avoid problem...
Definition: mitkOpenCVFileIOUtils.cxx:244
std::vector< cv::Mat > LoadMatricesFromExtrinsicFile(const std::string &fullFileName)
Load a set of matrices from a file describing the extrinsic parameters of a standard camera calibrati...
Definition: mitkOpenCVFileIOUtils.cxx:621
bool ReadTrackerMatrix(const std::string &filename, cv::Mat &outputMatrix)
Extracted from mitkVideoTrackerMatching, reads a 4x4 matrix into a cv::Mat, and if the matrix can't b...
Definition: mitkOpenCVFileIOUtils.cxx:124
Derived point types to contain data for projection and analysis.
void LoadPickedObjects(std::vector< mitk::PickedObject > &points, std::istream &is)
Loads a vector of picked objects.
Definition: mitkOpenCVFileIOUtils.cxx:503
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glew.h:3085
std::vector< std::string > FindTrackingMatrixDirectories(const std::string &directory)
Recursively hunts for all directories that look like they contain tracking matrices, .txt.
Definition: mitkOpenCVFileIOUtils.cxx:55
std::vector< cv::Mat > LoadOpenCVMatricesFromDirectory(const std::string &fullDirectoryName)
Read a set of matrices, stored in openCV xml matrix format from a directory and put them in a vector ...
Definition: mitkOpenCVFileIOUtils.cxx:581
void LoadCameraIntrinsicsFromPlainText(const std::string &filename, cv::Mat *CameraIntrinsic, cv::Mat *CameraDistortion)
Load camera intrinsics from a plain text file and return results as cv::Mat.
Definition: mitkOpenCVFileIOUtils.cxx:743
Helper class that contains a vector of timestamps, that are assumed to be strictly increasing...
Definition: mitkTimeStampsContainer.h:30
void SavePickedObjects(const std::vector< mitk::PickedObject > &points, std::ostream &os)
Saves a vector of picked objects.
Definition: mitkOpenCVFileIOUtils.cxx:465
bool CheckIfDirectoryContainsTrackingMatrices(const std::string &directory)
Iterates through a directory to see if it contains any files that have a timestamp as a name...
Definition: mitkOpenCVFileIOUtils.cxx:33
bool SaveTrackerMatrix(const std::string &filename, cv::Mat &outputMatrix)
Saves a 4x4 matrix;.
Definition: mitkOpenCVFileIOUtils.cxx:189
mitk::PickedPointList::Pointer LoadPickedPointListFromDirectory(const std::string &directory, unsigned int frameNumber, unsigned long long timestamp, std::string channel, cv::Scalar scalar)
Create an mitk::PickedPointList object from a directory of mitk point files directory contains files ...
Definition: mitkOpenCVFileIOUtils.cxx:814
GLsizei const GLcharARB ** string
Definition: glew.h:5194
mitk::TimeStampsContainer FindTrackingTimeStamps(std::string directory)
Returns an mitk::TimeStampsContainer containing all the timestamps of tracking matrices.
Definition: mitkOpenCVFileIOUtils.cxx:76