-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.cpp
More file actions
60 lines (47 loc) · 1.13 KB
/
Copy pathcamera.cpp
File metadata and controls
60 lines (47 loc) · 1.13 KB
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
#include <bits/stdc++.h>
#include "opencv2/opencv.hpp"
#define HMAX 180
#define SMAX 255
#define VMAX 255
using namespace cv;
int hslider;
int sslider;
int vslider;
int main()
{
VideoCapture cap(1);
if(!cap.isOpened())
{
return -1;
}
Mat edges;
namedWindow("camera",1);
namedWindow("original",1);
char hbarname[50];
char sbarname[50];
char vbarname[50];
sprintf(hbarname,"H: x %d",hslider);
sprintf(sbarname,"S: x %d",sslider);
sprintf(vbarname,"V: x %d",vslider);
createTrackbar( hbarname, "camera", &hslider, HMAX, NULL);
createTrackbar( sbarname, "camera", &sslider, SMAX, NULL);
createTrackbar( vbarname, "camera", &vslider, VMAX, NULL);
while(true)
{
Mat frame;
cap>>frame;
cvtColor(frame,edges,CV_BGR2HSV);
GaussianBlur(edges,edges,Size(7,7),1.5,1.5);
Mat threshold;
//inRange(edges, Scalar(40,50,60), Scalar(45,90,100), threshold );
inRange(edges, Scalar(hslider-10,sslider-30,vslider-30), Scalar(hslider+30,sslider+30,vslider+30), threshold );
//Canny(edges,edges,0,30,3);
imshow("camera",threshold);
imshow("original",edges);
if(waitKey(30)>=30)
{
break;
}
}
return 0;
}