File displayFunctional.h
File List > src > displayFunctional.h
Go to the documentation of this file
/*******************************************************
* Author: Intelligent Medical Systems
* License: see LICENSE.md file
*******************************************************/
#ifndef DISPLAYFUNCTIONAL_H
#define DISPLAYFUNCTIONAL_H
#include <xiApi.h>
#include <boost/thread.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc.hpp>
#include "constants.h"
#include "display.h"
#include "mainwindow.h"
#include "util.h"
class MainWindow;
class DisplayerFunctional : public Displayer
{
Q_OBJECT
public:
explicit DisplayerFunctional(MainWindow *mainWindow);
explicit DisplayerFunctional()
{
}
~DisplayerFunctional() override;
void SetCameraProperties(QString cameraModel) override;
static void DownsampleImageIfNecessary(cv::Mat &image);
void UpdateLut(int minValue, int maxValue, const QColor &darkColor, const QColor &saturatedColor) override;
void UpdateBGRChannels(const std::vector<int> &bgrChannels) override;
QString m_cameraType = CAMERA_TYPE_SPECTRAL;
QString m_cameraModel;
std::vector<int> m_mosaicShape;
cv::Mat m_lut = CreateLut(DEFAULT_SATURATION_COLOR, DEFAULT_DARK_COLOR, UNDEREXPOSURE_PIXEL_BOUNDARY_VALUE,
OVEREXPOSURE_PIXEL_BOUNDARY_VALUE);
protected:
MainWindow *m_mainWindow{};
public slots:
void Display(XI_IMG &image) override;
void OnDisplayTimeout();
private:
boost::thread m_displayThread;
bool m_hasPendingImage = false;
QTimer m_displayTimer;
int m_displayIntervalMilliseconds = 40;
XI_IMG m_nextImage{};
int m_scaling_factor = 4;
boost::mutex m_mutexImageDisplay;
cv::Ptr<cv::CLAHE> m_clahe = cv::createCLAHE();
std::vector<int> m_bgrChannels;
void ProcessImage(XI_IMG &image);
[[noreturn]] void ProcessImageOnThread();
void PrepareRawImage(cv::Mat &raw_image, bool equalize_hist) const;
void NormalizeBGRImage(cv::Mat &bgr_image) const;
void GetBand(cv::Mat &image, cv::Mat &band_image, unsigned int band_nr) const;
void GetBGRImage(cv::Mat &image, cv::Mat &bgr_image) const;
cv::Mat InitializeBandImage(const cv::Mat &image) const;
mutable std::mutex m_LutMutex;
};
void PrepareBGRImage(cv::Mat &bgr_image, int bgr_norm);
QImage GetQImageFromMatrix(const cv::Mat &image, QImage::Format format);
std::pair<double, double> GetSaturationPercentages(const cv::Mat &image, int minValue, int maxValue);
#endif // DISPLAYFUNCTIONAL_H