-
Notifications
You must be signed in to change notification settings - Fork 0
/
clrfrmprcs.h
54 lines (42 loc) · 1.31 KB
/
clrfrmprcs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#if !defined FTRACKER
#define FTRACKER
#include <string>
#include <vector>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/video/tracking.hpp>
#include "videoprocessor.h"
using namespace cv;
class carto : public FrameProcessor {
public:
void colorred(cv::Mat img,cv::Mat &image, int div){
cv::Mat lookup(1,256,CV_8U);
for (int i=0; i<180; i++) {
lookup.at<uchar>(i)= i/div*div + div/2;
}
cv::LUT(img,lookup,image);
}
void process(cv:: Mat &img, cv:: Mat &output) {
Mat image,hsv;
std::vector <Mat> channels;
cvtColor(img,img,cv::COLOR_BGR2HSV);
split(img,channels);
colorred(channels[0],hsv,30);
cvtColor(img,img,cv::COLOR_HSV2BGR);
channels[0]=hsv;
merge(channels,image);
cvtColor(image,image,cv::COLOR_HSV2BGR);
img=image;
Mat col;
bilateralFilter(img,col,9,100,100);
//namedWindow("bil");
//imshow("bil",col);
cvtColor(img,img,COLOR_BGR2GRAY);
medianBlur(img,img,5);
adaptiveThreshold(img,img,255,cv::ADAPTIVE_THRESH_MEAN_C,cv::THRESH_BINARY,9,5);
bitwise_and(col,col,output,img);
}
};
#endif