1 |
|
2 |
|
3 | #include <opencv2/highgui/highgui.hpp>
|
4 | #include <opencv2/imgproc/imgproc.hpp>
|
5 | #include <opencv2/core/core.hpp>
|
6 | #include <iostream>
|
7 |
|
8 | #include <opencv/cvaux.h>
|
9 | #include <opencv/highgui.h>
|
10 | #include <opencv/cxcore.h>
|
11 | #include <stdio.h>
|
12 | #include <stdio.h>
|
13 | #include <stdlib.h>
|
14 | #include <string.h>
|
15 | #include <assert.h>
|
16 | #include <math.h>
|
17 | #include <float.h>
|
18 | #include <limits.h>
|
19 | #include <time.h>
|
20 | #include <ctype.h>
|
21 |
|
22 |
|
23 | using namespace cv;
|
24 | using namespace std;
|
25 |
|
26 |
|
27 | int main( int argc, char** argv )
|
28 | {
|
29 | Mat Image;
|
30 | |
31 | Mat gray;
|
32 | Mat hsv;
|
33 | Mat thresholded_hsv;
|
34 | Mat thresholded_hsv_smoothed;
|
35 | Mat Image_circles;
|
36 | */
|
37 | char key = 0;
|
38 |
|
39 |
|
40 | VideoCapture capture(0);
|
41 |
|
42 |
|
43 | if (!capture.isOpened()) {
|
44 | printf("Failed to open a video device or video file!\n");
|
45 | return 1;
|
46 | }
|
47 |
|
48 |
|
49 | capture.set(CV_CAP_PROP_FRAME_WIDTH, 640);
|
50 | capture.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
|
51 |
|
52 |
|
53 | |
54 | Mat org;
|
55 | org = imread("/users/mmaraya/Dropbox/Programming/opencv/build/bugs/8/BackgroundComputerVision_2.jpg");
|
56 | if (org.empty())
|
57 | {
|
58 | cout << "Cannot load image!" << endl;
|
59 | return -1;
|
60 | }
|
61 | namedWindow("Background", CV_WINDOW_AUTOSIZE);
|
62 | imshow("Background", org);
|
63 | resizeWindow("Background",1134, 700);
|
64 | moveWindow("Background", 100, 1);
|
65 | */
|
66 |
|
67 |
|
68 | namedWindow("Original Camera Video", CV_WINDOW_AUTOSIZE);
|
69 | |
70 | namedWindow("Grayscale Video", CV_WINDOW_AUTOSIZE);
|
71 | namedWindow("HSV Video", CV_WINDOW_AUTOSIZE);
|
72 | namedWindow("HSV Thresholded Video", CV_WINDOW_AUTOSIZE);
|
73 | namedWindow("HSV Smoothed and Thresholded Video", CV_WINDOW_AUTOSIZE);
|
74 | namedWindow("Circles", CV_WINDOW_AUTOSIZE);
|
75 | */
|
76 |
|
77 | moveWindow("Original Camera Video", 150, 170);
|
78 | |
79 | moveWindow("Grayscale Video", 500, 170);
|
80 | moveWindow("HSV Video", 850, 170);
|
81 | moveWindow("HSV Thresholded Video", 150, 450);
|
82 | moveWindow("HSV Smoothed and Thresholded Video", 500, 450);
|
83 | moveWindow("Circles", 850, 450);
|
84 | */
|
85 |
|
86 |
|
87 |
|
88 | |
89 | Scalar hsv_min = Scalar(150, 84, 130, 0);
|
90 | Scalar hsv_max = Scalar(358, 256, 255, 0);
|
91 | */
|
92 |
|
93 | while( key != 'q')
|
94 | {
|
95 |
|
96 | capture >> Image;
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | |
116 | Image.copyTo(Image_circles);
|
117 |
|
118 | HoughCircles(thresholded_hsv_smoothed, circles, CV_HOUGH_GRADIENT, 2, 100, 100, 50, 10, 400 );
|
119 | for( size_t i = 0; i < circles.size(); i++ )
|
120 | {
|
121 | Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
|
122 | int radius = cvRound(circles[i][2]);
|
123 | // draw the circle center
|
124 | circle( Image_circles, center, 3, Scalar(0,255,0), -1, 8, 0 );
|
125 | // draw the circle outline
|
126 | circle( Image_circles, center, radius, Scalar(0,0,255), 3, 8, 0 );
|
127 | }
|
128 | */
|
129 |
|
130 |
|
131 |
|
132 | imshow("Original Camera Video",Image);
|
133 | |
134 | imshow("Grayscale Video", gray);
|
135 | imshow("HSV Video", hsv);
|
136 | imshow("HSV Thresholded Video", thresholded_hsv);
|
137 | imshow("HSV Smoothed and Thresholded Video", thresholded_hsv_smoothed);
|
138 | imshow("Circles", Image_circles);
|
139 | */
|
140 |
|
141 | resizeWindow("Original Camera Video",320, 240);
|
142 | |
143 | resizeWindow("Grayscale Video",320, 240);
|
144 | resizeWindow("HSV Video",320, 240);
|
145 | resizeWindow("HSV Thresholded Video",320, 240);
|
146 | resizeWindow("HSV Smoothed and Thresholded Video",320, 240);
|
147 | resizeWindow("Circles",320, 240);
|
148 | */
|
149 | key = waitKey(25);
|
150 | }
|
151 | return 0;
|
152 | }
|