Commit 05c7c932 authored by siddharth's avatar siddharth

cloning_gui.cpp updated

parent 75b76554
...@@ -190,7 +190,6 @@ void source(int event, int x, int y, int, void*) ...@@ -190,7 +190,6 @@ void source(int event, int x, int y, int, void*)
void destination(int event, int x, int y, int, void*) void destination(int event, int x, int y, int, void*)
{ {
Mat im1; Mat im1;
minxd = INT_MAX; minyd = INT_MAX; maxxd = INT_MIN; maxyd = INT_MIN; minxd = INT_MAX; minyd = INT_MAX; maxxd = INT_MIN; maxyd = INT_MIN;
im1 = img2.clone(); im1 = img2.clone();
...@@ -250,7 +249,6 @@ void destination(int event, int x, int y, int, void*) ...@@ -250,7 +249,6 @@ void destination(int event, int x, int y, int, void*)
} }
} }
const Point* pts6[1] = {&pts2[0]}; const Point* pts6[1] = {&pts2[0]};
fillPoly(res, pts6, &numpts, 1, Scalar(255, 255, 255), 8, 0); fillPoly(res, pts6, &numpts, 1, Scalar(255, 255, 255), 8, 0);
...@@ -274,40 +272,6 @@ void destination(int event, int x, int y, int, void*) ...@@ -274,40 +272,6 @@ void destination(int event, int x, int y, int, void*)
im1.release(); im1.release();
} }
void checkfile(char *file)
{
while(1)
{
printf("Enter %s Image: ",file);
if(!strcmp(file,"Source"))
{
cin >> src;
if(access( src, F_OK ) != -1 )
{
break;
}
else
{
printf("Image doesn't exist\n");
}
}
else if(!strcmp(file,"Destination"))
{
cin >> dest;
if(access( dest, F_OK ) != -1 )
{
break;
}
else
{
printf("Image doesn't exist\n");
}
}
}
}
int main() int main()
{ {
cout << endl; cout << endl;
...@@ -348,13 +312,28 @@ int main() ...@@ -348,13 +312,28 @@ int main()
if(num == 1 || num == 2 || num == 3) if(num == 1 || num == 2 || num == 3)
{ {
checkfile(s); string src,dest;
checkfile(d); cout << "Enter Source Image: ";
cin >> src;
cout << "Enter Destination Image: ";
cin >> dest;
img0 = imread(src); img0 = imread(src);
img2 = imread(dest); img2 = imread(dest);
if(!img0.data)
{
cout << "Source Image does not exist" << endl;
exit(0);
}
if(!img2.data)
{
cout << "Destination Image does not exist" << endl;
exit(0);
}
channel = img0.channels(); channel = img0.channels();
res = Mat::zeros(img2.size(),CV_8UC1); res = Mat::zeros(img2.size(),CV_8UC1);
...@@ -376,8 +355,10 @@ int main() ...@@ -376,8 +355,10 @@ int main()
} }
else if(num == 4) else if(num == 4)
{ {
checkfile(s); string src;
cout << "Enter Source Image: ";
cin >> src;
cout << "Enter RGB values: " << endl; cout << "Enter RGB values: " << endl;
cout << "Red: "; cout << "Red: ";
cin >> red; cin >> red;
...@@ -390,6 +371,12 @@ int main() ...@@ -390,6 +371,12 @@ int main()
img0 = imread(src); img0 = imread(src);
if(!img0.data)
{
cout << "Source Image does not exist" << endl;
exit(0);
}
res1 = Mat::zeros(img0.size(),CV_8UC1); res1 = Mat::zeros(img0.size(),CV_8UC1);
final = Mat::zeros(img0.size(),CV_8UC3); final = Mat::zeros(img0.size(),CV_8UC3);
...@@ -402,7 +389,9 @@ int main() ...@@ -402,7 +389,9 @@ int main()
} }
else if(num == 5) else if(num == 5)
{ {
checkfile(s); string src;
cout << "Enter Source Image: ";
cin >> src;
cout << "alpha: "; cout << "alpha: ";
cin >> alpha; cin >> alpha;
...@@ -412,6 +401,12 @@ int main() ...@@ -412,6 +401,12 @@ int main()
img0 = imread(src); img0 = imread(src);
if(!img0.data)
{
cout << "Source Image does not exist" << endl;
exit(0);
}
res1 = Mat::zeros(img0.size(),CV_8UC1); res1 = Mat::zeros(img0.size(),CV_8UC1);
final = Mat::zeros(img0.size(),CV_8UC3); final = Mat::zeros(img0.size(),CV_8UC3);
...@@ -424,7 +419,9 @@ int main() ...@@ -424,7 +419,9 @@ int main()
} }
else if(num == 6) else if(num == 6)
{ {
checkfile(s); string src;
cout << "Enter Source Image: ";
cin >> src;
cout << "low_threshold: "; cout << "low_threshold: ";
cin >> low_t; cin >> low_t;
...@@ -437,6 +434,12 @@ int main() ...@@ -437,6 +434,12 @@ int main()
img0 = imread(src); img0 = imread(src);
if(!img0.data)
{
cout << "Source Image does not exist" << endl;
exit(0);
}
res1 = Mat::zeros(img0.size(),CV_8UC1); res1 = Mat::zeros(img0.size(),CV_8UC1);
final = Mat::zeros(img0.size(),CV_8UC3); final = Mat::zeros(img0.size(),CV_8UC3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment