-
Notifications
You must be signed in to change notification settings - Fork 0
/
img2.cpp
65 lines (51 loc) · 1.63 KB
/
img2.cpp
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
55
56
57
58
59
60
61
62
63
64
65
#pragma package <opencv>
#include <iostream>
#include <unistd.h>
#include <time.h>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <opencv2/opencv.hpp>
#include<opencv2/core/core.hpp>
#include<opencv2/ml/ml.hpp>
#include<vector>
#include"segmentation.cpp"
using namespace cv;
using namespace std;
struct hsvRange {
int LowH; int HighH;
int LowS; int HighS;
int LowV; int HighV;
};
//colours
const int RESIZED_IMAGE_WIDTH = 20;
const int RESIZED_IMAGE_HEIGHT = 30;
struct hsvRange blue={0,100,0,100,0,100};
Mat thresH(char *file,char *mode)
{
int start, end,diff,l=0;
const int MIN_CONTOUR_AREA = 5;
Mat imgOriginal=imread( file, CV_LOAD_IMAGE_GRAYSCALE ),imgOrig,matBlurred, imgThresholded,tmp,t2;
Mat imgHSV;
namedWindow("imgOriginal", CV_WINDOW_AUTOSIZE);
namedWindow("imgThresh", CV_WINDOW_AUTOSIZE);
imshow("imgOriginal",imgOriginal);
cv::GaussianBlur(imgOriginal, // input image
matBlurred, // output image
cv::Size(1,1), // smoothing window width and height in pixels
0); // sigma value, determines how much the image will be blurred, zero makes function choose the sigma value
imwrite("GausianBlur.png",matBlurred);
imshow("BlurredImg",matBlurred);
waitKey(0);
threshold (matBlurred,imgThresholded,0,255,CV_THRESH_BINARY_INV|CV_THRESH_OTSU);
imwrite("thresh.png",imgThresholded);
imshow("imgThresh",imgThresholded);
waitKey(0);
segment(imgThresholded,imgOriginal,mode);
return imgThresholded;
}
int main( int argc, char** argv )
{
Point p[20];int k=0;
Mat detect;
detect=thresH(argv[1],argv[2]);
}