Commit ade55607696baa64b4bfa07529aec389b996e6e5
1 parent
7b815975
Added heatmap
Showing
1 changed file
with
39 additions
and
0 deletions
openbr/plugins/imgproc/heatmap.cpp
0 → 100644
| 1 | +#include "openbr/plugins/openbr_internal.h" | |
| 2 | +#include "openbr/core/opencvutils.h" | |
| 3 | + | |
| 4 | +#include <opencv2/ml/ml.hpp> | |
| 5 | +#include <opencv2/contrib/contrib.hpp> | |
| 6 | + | |
| 7 | +using namespace cv; | |
| 8 | + | |
| 9 | +namespace br | |
| 10 | +{ | |
| 11 | + | |
| 12 | +class HeatmapTransform : public UntrainableTransform | |
| 13 | +{ | |
| 14 | + Q_OBJECT | |
| 15 | + | |
| 16 | + Q_PROPERTY(float alpha READ get_alpha WRITE set_alpha RESET reset_alpha STORED false) | |
| 17 | + BR_PROPERTY(float, alpha, .5) | |
| 18 | + | |
| 19 | + void project(const Template &src, Template &dst) const | |
| 20 | + { | |
| 21 | + dst = src; | |
| 22 | + | |
| 23 | + const float beta = 1-alpha; | |
| 24 | + | |
| 25 | + Mat buffer; | |
| 26 | + applyColorMap(src,buffer,COLORMAP_JET); | |
| 27 | + | |
| 28 | + Mat colored; | |
| 29 | + cvtColor(src, colored, CV_GRAY2BGR); | |
| 30 | + | |
| 31 | + addWeighted(colored,alpha,buffer,beta,0.0,dst); | |
| 32 | + } | |
| 33 | +}; | |
| 34 | + | |
| 35 | +BR_REGISTER(Transform, HeatmapTransform) | |
| 36 | + | |
| 37 | +} // namespace br | |
| 38 | + | |
| 39 | +#include "imgproc/heatmap.moc" | ... | ... |