버그 픽스하기
This commit is contained in:
@@ -1,11 +1,49 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <array>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cmath>
|
|
||||||
#include "opencv2/opencv.hpp"
|
#include "opencv2/opencv.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
|
Mat src;
|
||||||
|
Point2f srcQuad[4], dstQuad[4];
|
||||||
|
|
||||||
|
void on_mouse(int event, int x, int y, int flags, void* userdata);
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
Mat src = imread("../../resources/images/card.bmp");
|
||||||
|
|
||||||
|
namedWindow("src");
|
||||||
|
setMouseCallback("src", on_mouse);
|
||||||
|
|
||||||
|
imshow("src", src);
|
||||||
|
waitKey(0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_mouse(int event, int x, int y, int flags, void* userdata) {
|
||||||
|
static int cnt = 0;
|
||||||
|
|
||||||
|
if (event == EVENT_LBUTTONDOWN) {
|
||||||
|
srcQuad[cnt++ % 4] = Point2f(x, y);
|
||||||
|
|
||||||
|
circle(src, Point(x, y), 5, Scalar(0, 0, 255), -1);
|
||||||
|
imshow("src", src);
|
||||||
|
|
||||||
|
if (cnt % 4 == 0) {
|
||||||
|
int w = 200, h = 300;
|
||||||
|
|
||||||
|
dstQuad[0] = Point2f(0, 0);
|
||||||
|
dstQuad[1] = Point2f(w - 1, 0);
|
||||||
|
dstQuad[2] = Point2f(w - 1, h - 1);
|
||||||
|
dstQuad[3] = Point2f(0, h - 1);
|
||||||
|
|
||||||
|
Mat pers = getPerspectiveTransform(srcQuad, dstQuad);
|
||||||
|
|
||||||
|
Mat dst;
|
||||||
|
warpPerspective(src, dst, pers, Size(w, h));
|
||||||
|
|
||||||
|
imshow("dst", dst);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -133,6 +133,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="..\..\resources\images\card.bmp" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|||||||
@@ -19,4 +19,9 @@
|
|||||||
<Filter>소스 파일</Filter>
|
<Filter>소스 파일</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="..\..\resources\images\card.bmp">
|
||||||
|
<Filter>리소스 파일</Filter>
|
||||||
|
</Image>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user