67 lines
1.6 KiB
C
Raw Normal View History

2022-11-10 17:07:39 +01:00
#pragma once
2022-11-03 09:23:30 +01:00
#include <iostream>
2022-11-10 14:41:27 +01:00
#include <future>
#include <thread>
2022-12-22 23:13:53 +01:00
#include <functional>
2022-11-10 14:41:27 +01:00
2022-11-03 09:23:30 +01:00
#include <opencv2/opencv.hpp>
2022-11-10 14:41:27 +01:00
2022-11-03 09:23:30 +01:00
#include <input.h>
#include <processing.h>
#include <control_module.h>
#include <interpreter.h>
#include <intersection_handler.h>
2022-11-10 14:41:27 +01:00
2022-11-03 09:23:30 +01:00
using namespace cv;
2022-12-22 23:13:53 +01:00
struct LFR_Result
{
cv::Mat rawImage;
cv::Mat processedImage;
FrameData data;
};
2022-11-03 09:23:30 +01:00
class LFR
{
2022-12-22 23:13:53 +01:00
public:
using ListenerKey = void const*;
using ExceptionCallback = std::function<bool(std::exception const &ex)>;
using ListenerCallback = std::function<void(LFR_Result)>;
private:
using ListenerPair = std::pair<ListenerKey, ListenerCallback>;
using ListenerVector = std::vector<ListenerPair>;
2022-11-03 09:23:30 +01:00
Input input;
Processing processing;
ControlModule controlModule;
Interpreter interpreter;
IntersectionHandler intersectionHandler;
2022-12-22 23:13:53 +01:00
int thresholdBinary;
int gaussKernelSize;
2022-12-22 23:13:53 +01:00
ListenerVector listeners;
ExceptionCallback cb;
bool stop;
std::unique_ptr<std::thread> thread;
mutable std::mutex mutex;
//void provideOutput(Mat originalImage, Mat processedImage, const FrameData& frameData, const Rect& roi);
void createThread();
void setStop(bool val);
2022-11-03 09:23:30 +01:00
public:
LFR() = delete;
2022-12-22 23:13:53 +01:00
LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSize, ExceptionCallback cb);
2022-11-03 09:23:30 +01:00
~LFR();
2022-11-10 14:41:27 +01:00
void startLoop();
2022-11-03 09:23:30 +01:00
void endLoop();
2022-12-22 23:13:53 +01:00
void addListener(ListenerCallback cv, ListenerKey key);
void removeListener(ListenerKey key);
void isStopped() const noexcept;
Mat provideOutput(Mat originalImage, Mat processedImage, const FrameData& frameData, const Rect& roi);
2022-11-03 09:23:30 +01:00
};