Skip to content
Snippets Groups Projects
Commit 031fe9be authored by Roh min do's avatar Roh min do
Browse files

erase

parent 6f76138a
Branches
No related tags found
No related merge requests found
...@@ -40,6 +40,18 @@ Mat3b img = imread("C:\\Users\\RMD\\desktop\\1233.png"); ...@@ -40,6 +40,18 @@ Mat3b img = imread("C:\\Users\\RMD\\desktop\\1233.png");
Mat3b templ = imread("C:\\Users\\RMD\\desktop\\t1.png"); Mat3b templ = imread("C:\\Users\\RMD\\desktop\\t1.png");
Mat3b templ2 = imread("C:\\Users\\RMD\\desktop\\t2.png"); Mat3b templ2 = imread("C:\\Users\\RMD\\desktop\\t2.png");
Mat final = imread("C:\\Users\\RMD\\desktop\\123456.png"); Mat final = imread("C:\\Users\\RMD\\desktop\\123456.png");
#include "opencv2/features2d.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/features2d/hal/interface.h"
struct rectanglesave {
int xpos;
int ypos;
int rowsize;
int colsize;
};
rectanglesave save[500] = { NULL };
using namespace cv;
using namespace std;
bool check = true; bool check = true;
int startx = 0, starty = 0; int startx = 0, starty = 0;
bool check2 = true; bool check2 = true;
...@@ -47,12 +59,36 @@ bool check3 = true; ...@@ -47,12 +59,36 @@ bool check3 = true;
Mat tempo; Mat tempo;
using namespace cv; using namespace cv;
using namespace std; using namespace std;
#include <cstdlib>
#include <cmath>
void on_mouse(int event, int x, int y, int flags, void*) void on_mouse(int event, int x, int y, int flags, void*)
{ {
double min = 100;
int index;
int i = 0;
switch (event) { switch (event) {
case EVENT_LBUTTONDOWN:
case EVENT_MBUTTONUP:
cout << "EVENT_DBDBBUTTONUP: " << x << ", " << y << endl;
while (save[i].xpos!=0) {
double distance = sqrt(pow(x - save[i].xpos, 2) + pow(y - save[i].ypos, 2));
if (distance < min) {
min = distance;
index = i;
}
i++;
}
printf("xpos: %d, ypos: %d, col: %d, cols: %d\n", save[index].xpos, save[index].ypos, save[index].colsize, save[index].rowsize);
rectangle(img, Rect(save[index].xpos, save[index].ypos, save[index].colsize, save[index].rowsize), Scalar(0, 0,255), 1);
rectangle(final, Rect(save[index].xpos, save[index].ypos, save[index].colsize-4, save[index].rowsize-4), Scalar(0, 0, 0), 1);
imshow("final", img);
imshow("final2", final);
i = 0;
break;
case EVENT_LBUTTONUP:
if (check == true) if (check == true)
check = false; check = false;
else else
...@@ -71,9 +107,6 @@ void on_mouse(int event, int x, int y, int flags, void*) ...@@ -71,9 +107,6 @@ void on_mouse(int event, int x, int y, int flags, void*)
} }
//cout << "EVENT_LBUTTONDOWN: " << x << ", " << y << endl; //cout << "EVENT_LBUTTONDOWN: " << x << ", " << y << endl;
break; break;
case EVENT_LBUTTONUP:
//cout << "EVENT_LBUTTONUP: " << x << ", " << y << endl;
break;
case EVENT_RBUTTONDOWN: case EVENT_RBUTTONDOWN:
if (check2 == true) if (check2 == true)
check2 = false; check2 = false;
...@@ -106,6 +139,7 @@ void on_mouse(int event, int x, int y, int flags, void*) ...@@ -106,6 +139,7 @@ void on_mouse(int event, int x, int y, int flags, void*)
break; break;
} }
} }
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
#include <cmath> #include <cmath>
...@@ -128,10 +162,10 @@ int main() ...@@ -128,10 +162,10 @@ int main()
namedWindow("final"); namedWindow("final");
setTrackbarPos("low threshold", "final", 50); setTrackbarPos("low threshold", "final", 50);
int count = 0;
imshow("final", img); imshow("final", img);
imshow("final2", final); imshow("final2", final);
resizeWindow("final", 1024, 1024);
int test1[500] = { NULL }; int test1[500] = { NULL };
int test2[500] = { NULL }; int test2[500] = { NULL };
double thresh = 0.545; double thresh = 0.545;
...@@ -201,17 +235,19 @@ int main() ...@@ -201,17 +235,19 @@ int main()
} }
if (ch == true) { if (ch == true) {
printf("x: %d, y: %d\n", max_point.x, max_point.y); //printf("x: %d, y: %d\n", max_point.x, max_point.y);
if (templ.cols < templ.rows) { if (templ.cols < templ.rows) {
//max_point.x = (int)(check-4 *(floor((double)max_point.x / (double)(check-4)+ 0.5))); //max_point.x = (int)(check-4 *(floor((double)max_point.x / (double)(check-4)+ 0.5)));
max_point.y = (int)((templ.rows + 2) *(floor((double)max_point.y / (double)(templ.rows + 2) + 0.5))); max_point.y = (int)((templ.rows + 2) *(floor((double)max_point.y / (double)(templ.rows + 2) + 0.5)));
} }
else else
max_point.x = (int)((templ.cols + 2) *(floor((double)max_point.x / (double)(templ.cols + 2) + 0.5))); max_point.x = (int)((templ.cols + 2) *(floor((double)max_point.x / (double)(templ.cols + 2) + 0.5)));
save[count].xpos = max_point.x, save[count].ypos=max_point.y, save[count].colsize = templ.cols , save[count].rowsize=templ.rows;
count++;
rectangle(final, Rect(max_point.x, max_point.y, templ.cols - 4, templ.rows - 4), Scalar(100, 100, 100), 1); rectangle(final, Rect(max_point.x, max_point.y, templ.cols - 4, templ.rows - 4), Scalar(100, 100, 100), 1);
rectangle(img, Rect(max_point.x, max_point.y, templ.cols, templ.rows), Scalar(0, 255, 0), 1); rectangle(img, Rect(max_point.x, max_point.y, templ.cols, templ.rows), Scalar(0, 255, 0), 1);
}
}
num111 = num1; num111 = num1;
...@@ -260,7 +296,8 @@ int main() ...@@ -260,7 +296,8 @@ int main()
} }
else else
max_point.x = (int)(templ2.cols *(floor((double)max_point.x / (double)(templ2.cols) + 0.5))); max_point.x = (int)(templ2.cols *(floor((double)max_point.x / (double)(templ2.cols) + 0.5)));
save[count].xpos = max_point.x, save[count].ypos = max_point.y, save[count].colsize = templ2.cols, save[count].rowsize = templ2.rows;
count++;
rectangle(final, Rect(max_point.x, max_point.y, templ2.cols - 4, templ2.rows - 4), Scalar(100, 100, 100), 1); rectangle(final, Rect(max_point.x, max_point.y, templ2.cols - 4, templ2.rows - 4), Scalar(100, 100, 100), 1);
rectangle(img, Rect(max_point.x, max_point.y, templ2.cols, templ2.rows), Scalar(0, 255, 0), 1); rectangle(img, Rect(max_point.x, max_point.y, templ2.cols, templ2.rows), Scalar(0, 255, 0), 1);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment