parent
0b13d89080
commit
2d9b15e493
17 changed files with 338 additions and 249 deletions
@ -0,0 +1,30 @@ |
|||||||
|
#include "sink.hpp" |
||||||
|
|
||||||
|
namespace kb { |
||||||
|
namespace viz2d { |
||||||
|
|
||||||
|
Sink::Sink(std::function<bool(const cv::UMat&)> consumer) : consumer_(consumer) { |
||||||
|
} |
||||||
|
|
||||||
|
Sink::Sink() { |
||||||
|
|
||||||
|
} |
||||||
|
Sink::~Sink() { |
||||||
|
} |
||||||
|
|
||||||
|
bool Sink::isReady() { |
||||||
|
if(consumer_) |
||||||
|
return true; |
||||||
|
else |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
bool Sink::isOpen() { |
||||||
|
return open_; |
||||||
|
} |
||||||
|
|
||||||
|
void Sink::operator()(const cv::UMat& frame) { |
||||||
|
open_ = consumer_(frame); |
||||||
|
} |
||||||
|
} /* namespace viz2d */ |
||||||
|
} /* namespace kb */ |
@ -0,0 +1,25 @@ |
|||||||
|
#ifndef SRC_COMMON_SINK_HPP_ |
||||||
|
#define SRC_COMMON_SINK_HPP_ |
||||||
|
|
||||||
|
#include <functional> |
||||||
|
#include <opencv2/opencv.hpp> |
||||||
|
|
||||||
|
namespace kb { |
||||||
|
namespace viz2d { |
||||||
|
|
||||||
|
class Sink { |
||||||
|
bool open_ = true; |
||||||
|
std::function<bool(const cv::UMat&)> consumer_; |
||||||
|
public: |
||||||
|
Sink(std::function<bool(const cv::UMat&)> consumer); |
||||||
|
Sink(); |
||||||
|
virtual ~Sink(); |
||||||
|
bool isReady(); |
||||||
|
bool isOpen(); |
||||||
|
void operator()(const cv::UMat& frame); |
||||||
|
}; |
||||||
|
|
||||||
|
} /* namespace viz2d */ |
||||||
|
} /* namespace kb */ |
||||||
|
|
||||||
|
#endif /* SRC_COMMON_SINK_HPP_ */ |
@ -0,0 +1,35 @@ |
|||||||
|
#include "source.hpp" |
||||||
|
|
||||||
|
namespace kb { |
||||||
|
namespace viz2d { |
||||||
|
|
||||||
|
Source::Source(std::function<bool(cv::UMat&)> generator, float fps) : generator_(generator), fps_(fps) { |
||||||
|
} |
||||||
|
|
||||||
|
Source::Source() : fps_(0) { |
||||||
|
} |
||||||
|
|
||||||
|
Source::~Source() { |
||||||
|
} |
||||||
|
|
||||||
|
bool Source::isReady() { |
||||||
|
if(generator_) |
||||||
|
return true; |
||||||
|
else |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
bool Source::isOpen() { |
||||||
|
return open_; |
||||||
|
} |
||||||
|
|
||||||
|
float Source::fps() { |
||||||
|
return fps_; |
||||||
|
} |
||||||
|
|
||||||
|
std::pair<uint64_t, cv::UMat&> Source::operator()() { |
||||||
|
open_ = generator_(frame_); |
||||||
|
return {count_++, frame_}; |
||||||
|
} |
||||||
|
} /* namespace viz2d */ |
||||||
|
} /* namespace kb */ |
@ -0,0 +1,29 @@ |
|||||||
|
#ifndef SRC_COMMON_SOURCE_HPP_ |
||||||
|
#define SRC_COMMON_SOURCE_HPP_ |
||||||
|
|
||||||
|
#include <functional> |
||||||
|
#include <opencv2/opencv.hpp> |
||||||
|
|
||||||
|
namespace kb { |
||||||
|
namespace viz2d { |
||||||
|
|
||||||
|
class Source { |
||||||
|
bool open_ = true; |
||||||
|
std::function<bool(cv::UMat&)> generator_; |
||||||
|
cv::UMat frame_; |
||||||
|
uint64_t count_ = 0; |
||||||
|
float fps_; |
||||||
|
public: |
||||||
|
Source(std::function<bool(cv::UMat&)> generator, float fps); |
||||||
|
Source(); |
||||||
|
virtual ~Source(); |
||||||
|
bool isReady(); |
||||||
|
bool isOpen(); |
||||||
|
float fps(); |
||||||
|
std::pair<uint64_t, cv::UMat&> operator()(); |
||||||
|
}; |
||||||
|
|
||||||
|
} /* namespace viz2d */ |
||||||
|
} /* namespace kb */ |
||||||
|
|
||||||
|
#endif /* SRC_COMMON_SOURCE_HPP_ */ |
Loading…
Reference in new issue