Repository navigation
Expand file tree
/
Copy pathunderwater_hsv_lab.cpp
More file actions
138 lines (91 loc) · 3.27 KB
/
Copy pathunderwater_hsv_lab.cpp
File metadata and controls
138 lines (91 loc) · 3.27 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include <stdio.h>
#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include <opencv2/opencv.hpp>
#include<opencv2/photo/photo.hpp>
#include<omp.h>
using namespace std;
using namespace cv;
// -------------------Global Variable------------------------
int front_cam1=1,front_cam2=2,down_cam=3;
VideoCapture cap("/home/shaggy/line_auv/GOPR0033.MP4");
VideoCapture cam1(front_cam1);
VideoCapture cam2(front_cam2);
//-----------------------------------------------------------------
Mat clahe_conversion(Mat input)
{
vector<Mat> RGB; // Use the STL’s vector structure to store multiple Mat objects
split(input, RGB); // split the image into separate color planes (R G B)
//// Enhance Local Contrast (CLAHE)
Ptr<CLAHE> clahe = createCLAHE();
clahe->setClipLimit(4);
Mat RGB_eq;
//whiteBalance()
//// Equalizes the histogram of a one channel image (8UC1) using Contrast Limited Adaptive Histogram Equalization.
clahe->apply(RGB[0],RGB[0]);
clahe->apply(RGB[1],RGB[1]);
clahe->apply(RGB[2],RGB[2]);
merge(RGB,RGB_eq); // now merge the results back
return RGB_eq;
}
int main(){
Mat image ;//= imread("/home/shaggy/line_auv/rippleJPG");
namedWindow("White Balance", CV_WINDOW_NORMAL);
//namedWindow("filter_image", CV_WINDOW_NORMAL);
namedWindow("input", CV_WINDOW_NORMAL);
namedWindow("h", CV_WINDOW_NORMAL);
//namedWindow("CLAHE", CV_WINDOW_NORMAL);
//namedWindow("hue", CV_WINDOW_NORMAL);
namedWindow("path", CV_WINDOW_NORMAL);
namedWindow("red buoy", CV_WINDOW_NORMAL);
namedWindow("green buoy", CV_WINDOW_NORMAL);
if(!cap.isOpened())
{
cout<<"Check Video"<<"\n";
return 0;
}
while(1)
{
if(!cap.read(image))
{
continue;
}
Mat image_hsv;
//Mat image_baln=balance_white(image.clone());
Mat image_CLAHE = clahe_conversion(image.clone());
cvtColor(image_CLAHE, image_hsv, COLOR_BGR2HSV);
vector<Mat>hsv;
split(image_hsv, hsv);
Mat hsv_image = hsv[0];
#pragma omp parallel for collapse(2)
for(int y=0; y<hsv_image.cols; y++){
for(int x=0; x<hsv_image.rows; x++){
if(hsv_image.at<uchar>(x,y) >=0 && hsv_image.at<uchar>(x,y) <10 )//|| hsv_image.at<uchar>(x,y) >160 && hsv_image.at<uchar>(x,y)<180){
{
hsv_image.at<uchar>(x,y) = 255;
}
else
hsv_image.at<uchar>(x,y) = 0;
}
}
/* #pragma omp parallel
{
cout<<"hgfh"<<endl;
}*/
//----------All imshow here----------------------------------------------
imshow("path",hsv_image);
//imshow("hsv",image_hsv);
imshow("input", image);
imshow("h",hsv[0]);
//imshow("saturation", hsv[1]);
// waitKey(0);
imshow("White Balance",image_CLAHE);
//-----------------------------------------------------------------------------
if(waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
{
cout << "esc key is pressed by user" << endl;
break;
}
}
return 0;
}