-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrab.cpp
More file actions
65 lines (46 loc) · 1.1 KB
/
Copy pathgrab.cpp
File metadata and controls
65 lines (46 loc) · 1.1 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
61
62
63
64
65
#include <opencv2/opencv.hpp>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <unistd.h>
cv::Mat manageImg(cv::Mat image)
{
cv::Mat image2=image.clone();
cv::Mat element = getStructuringElement(cv::MORPH_RECT, cv::Size(10,10), cv::Point(0,0));
morphologyEx( image, image2, cv::MORPH_BLACKHAT, element);
return(image2);
}
int main() {
int fps;
cv::VideoCapture cam(0);
if(!cam.isOpened())
{
std::cout << "Error de Camara" << std::endl;
return -1;
}
fps = cam.get(CV_CAP_PROP_FPS);
cv::Size size(cam.get(CV_CAP_PROP_FRAME_WIDTH), cam.get(CV_CAP_PROP_FRAME_HEIGHT));
cv::VideoWriter graba("video.avi", CV_FOURCC('F','M','P','4'), fps, size);
if(!graba.isOpened())
{
std::cout << "Error de Grabación" << std::endl;
return -1;
}
while (true)
{
cv::Mat frame;
cv::Mat gray;
cam.read(frame);
//cv::cvtColor(frame, gray, CV_BGR2GRAY);
//cv::equalizeHist(gray,gray);
gray = manageImg(frame);
graba.write(frame);
cv::imshow("CAM", gray);
if (cv::waitKey(30) >= 0)
break;
}
graba.release();
cam.release();
return 0;
}