File util.h
Go to the documentation of this file
/*******************************************************
* Author: Intelligent Medical Systems
* License: see LICENSE.md file
*******************************************************/
#ifndef UTIL_H
#define UTIL_H
#include <b2nd.h>
#include <xiApi.h>
#include <QColor>
#include <QMap>
#include <QString>
#include <boost/log/trivial.hpp>
#include <msgpack.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <string>
#define HandleResult(res, place) \
if (res != XI_OK) \
{ \
std::stringstream errormsg; \
errormsg << "Error after " << place << " " << res << "\n"; \
throw std::runtime_error(errormsg.str()); \
}
#define HandleBLOSCResult(res, place) \
if (res != 0) \
{ \
std::stringstream errormsg; \
errormsg << "Error after " << place << " " << res << "\n"; \
throw std::runtime_error(errormsg.str()); \
}
class FileImage
{
public:
std::vector<int> m_exposureMetadata;
std::vector<int> m_acqNframeMetadata;
std::vector<std::string> m_colorFilterArray;
std::vector<std::string> m_timeStamp;
QMap<QString, std::vector<float>> m_additionalMetadata;
char *m_filePath;
b2nd_context_t *m_ctx;
b2nd_array_t *m_src; // New member to store array
FileImage(const char *filePath, unsigned int imageHeight, unsigned int imageWidth);
~FileImage();
void WriteImageData(XI_IMG image, QMap<QString, float> additionalMetadata);
void AppendMetadata();
static bool CheckFileMetadata(const b2nd_array_t *src);
};
void AppendBLOSCVLMetadata(b2nd_array_t *src, const char *key, msgpack::sbuffer &newData);
int GetBLOSCVLMetadataLength(const b2nd_array_t *src, const char *key);
template <typename T> void PackAndAppendMetadata(b2nd_array_t *src, const char *key, const std::vector<T> &metadata);
std::string ColorFilterToString(XI_COLOR_FILTER_ARRAY colorFilterArray);
void WaitMilliseconds(int milliseconds);
cv::Mat CreateLut(const QColor &saturationColor, const QColor &darkColor, int minValue, int maxValue);
struct CommandLineArguments
{
bool test_mode;
bool version;
};
void XIIMGtoMat(const XI_IMG &xi_img, cv::Mat &mat_img);
QString GetTimeStamp();
extern CommandLineArguments g_commandLineArguments;
#endif // UTIL_H