참고서적
생능출판사
OpenCV로 배우는 영상 처리 및 응용
OpenCV 4.1 설치 하기, 비주얼스튜디오 15에 적용시키기
https://webnautes.tistory.com/1132
Visual Studio 2017에서 OpenCV 4.1.0을 사용하는 방법
안녕하세요 : ) Visual Studio 2017에서 OpenCV 4.1.0을 사용하는 방법을 소개합니다. 기존 글로 적는 방식도 복구시켰습니다. 영상 아래쪽에 있습니다. 영상과 글 중 편한 방식으로 선택해서 진행하세요 : ) 마지..
webnautes.tistory.com
기본 예제. 맛보기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
void main()
{
cv::Mat image(300, 400, CV_8UC1, cv::Scalar(200));
cv::imshow("영상보기", image);
cv::waitKey(0);
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
point
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
|
int main()
{
// Point_ 객체 선언 방식
cv::Point_<int> pt1(100, 200);
cv::Point_<float> pt2(92.3f, 125.23f);
cv::Point_<double> pt3(100.2, 300.9);
// Point_ 객체 간결 선언 방식
cv::Point2i pt4(120, 69);
cv::Point2f pt5(0.3f, 0.f), pt6(0.f, 0.4f);
cv::Point2d pt7(0.25, 0.6);
// Point_ 객체 연산
cv::Point pt8 = pt1 + (cv::Point) pt2;
cv::Point2f pt9 = pt6 * 3.14f;
cv::Point2d pt10 = (pt3 + (cv::Point2d) pt6) * 10;
std::cout << "pt8 = " << pt8.x << " , " << pt8.y << std::endl;
std::cout << "[pt9] = " << pt9 << std::endl;
std::cout << (pt2 == pt6) << std::endl;
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
size
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
|
using namespace cv;
using namespace std;
int main()
{
// Size_ 객체 기본 선언 방식
Size_<int> sz1(100, 200);
Size_<float> sz2(192.3f, 25.3f);
Size_<double> sz3(100.2, 30.9);
// Size 객체 간결 선언 방식
Size sz4(120, 69);
Size2f sz5(0.3f, 0.f);
Size2d sz6(0.25, 0.6);
Point2d pt1(0.25, 0.6);
Size2i sz7 = sz1 + (Size2i)sz2;
Size2d sz8 = sz3 - (Size2d)sz4;
Size2d sz9 = sz5 + (Size2f)pt1;
cout << "[sz7] = " << sz7 << endl;
cout << "[sz8] = " << sz8 << endl;
cout << "[sz9] = " << sz9 << endl;
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
rect
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
|
using namespace cv;
using namespace std;
int main()
{
Size2d sz(100.5, 60.6);
Point2f pt1(20.f, 30.f), pt2(100.f, 200.f);
// Rect_ 객체 기본 선언 방식
Rect_<int> rect1(10, 10, 30, 50);
Rect_<float> rect2(pt1, pt2);
Rect_<double> rect3(Point2d(20.5, 10), sz);
// 간결 선언 방식 & 연산 적용
Rect rect4 = rect1 + (Point)pt1;
Rect2f rect5 = rect2 + (Size2f)sz;
Rect2d rect6 = rect1 & (Rect)rect2;
// 결과 출력
cout << "rect3 = " << rect3.x << "," << rect3.y << ", ";
cout << "[rect6] = " << rect6 << endl;
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
vec
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
|
using namespace cv;
using namespace std;
int main()
{
// 기본 선언 및 간렬 방식
Vec <int, 2> v1(5, 12);
Vec <double, 3> v2(40, 130.7, 125.6);
Vec2b v3(10, 10);
Vec6f v4(40.f, 230.25f, 525.6f);
Vec3i v5(200, 230, 250);
// 객체 연산 및 형변환
Vec3d v6 = v2 + (Vec3d)v5;
Vec2b v7 = (Vec2b)v1 + v3;
Vec6f v8 = v4 * 20.0f;
Point pt1 = v1 + (Vec2i)v7;
Point3_<int> pt2 = v2;
// 콘솔창 출력
cout << "[v3] = " << v3 << endl;
cout << "[v7] = " << v7 << endl;
cout << "v8[0] = " << v8[0] << endl;
cout << "v8[1] = " << v8[1] << endl;
cout << "v8[2] = " << v8[2] << endl;
cout << "[v2] = " << v2 << endl;
cout << "[pt2] = " << pt2 << endl;
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
scalar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
using namespace cv;
using namespace std;
int main()
{
Scalar_<uchar> red(0, 0, 255);
Scalar_<int> blue(255, 0, 0);
Scalar_<double> color1(500);
Scalar_<float> color2(100.f, 200.f, 125.9f);
Vec3d green(0, 0, 300.5);
Scalar green1 = color1 + (Scalar)green;
Scalar green2 = color2 + (Scalar_<float>)green;
cout << "blue = " << blue[0] << ", " << blue[1];
cout << ", " << blue[1] << ", " << blue[2] << endl;
cout << "red = " << red << endl;
cout << "green = " << green << endl << endl;
cout << "green1 = " << green1 << endl;
cout << "green2 = " << green2 << endl;
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
회전사각형
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
|
using namespace cv;
using namespace std;
int main()
{
Mat image(300, 500, CV_8UC1, Scalar(255));
Point2f center(250, 150), pts[4];
Size2f size(300, 100);
RotatedRect rot_rect(center, size, 20);
Rect bound_rect = rot_rect.boundingRect();
rectangle(image, bound_rect, Scalar(0), 1);
for (int i = 0; i < 4; i++)
{
circle(image, pts[i], 4, Scalar(0), 1);
line(image, pts[i], pts[(i + 1) % 4], Scalar(0), 2);
}
imshow("회전사각형", image);
waitKey(0);
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
mat
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
|
using namespace cv;
using namespace std;
int main()
{
float data[] = {
1.2f, 2.3f, 3.2f,
4.5f, 5.f, 6.5f,
};
// Mat 객체 선언 방법
Mat m1(2, 3, CV_8U);
Mat m2(2, 3, CV_8U, Scalar(300));
Mat m3(2, 3, CV_16S, Scalar(300));
Mat m4(2, 3, CV_32F, data);
// Size 객체로 Mat 객체 선언 방법
Size sz(2, 3);
Mat m5(Size(2, 3), CV_64F);
Mat m6(sz, CV_32F, data);
cout << "[m1] =" << endl << m1 << endl;
cout << "[m2] =" << endl << m2 << endl;
cout << "[m3] =" << endl << m3 << endl;
cout << "[m4] =" << endl << m4 << endl << endl;
cout << "[m5] =" << endl << m5 << endl;
cout << "[m6] =" << endl << m6 << endl;
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
mat 클래스를 이용한 초기화
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
using namespace cv;
using namespace std;
int main()
{
double a = 32.12345678, b = 2.7;
short c = 400;
float d = 10.f, e = 11.f, f = 13.f;
Mat_<int> m1(2, 4);
Mat_<uchar> m2(3, 4, 100);
Mat_<short> m3(4, 5, c);
m1 << 1, 2, 3, 4, 5, 6;
Mat m4 = (Mat_<double>(2, 3) << 1, 2, 3, 4, 5, 6);
Mat m5 = (Mat_<float>(2, 3) << a, b, c, d, e, f);
cout << "[m1]=" << endl << m1 << endl;
cout << "[m2]=" << endl << m2 << endl << endl;
cout << "[m3]=" << endl << m3 << endl << endl;
cout << "[m4]=" << endl << m4 << endl;
cout << "[m5]=" << endl << m5 << endl;
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
'딥러닝 기반 영상인식 개발 전문가 과정 > 임베디드, ARM' 카테고리의 다른 글
7월8일 OpenCV 설치, YOLO 설치 (0) | 2019.07.08 |
---|---|
7월5일 이미지, 비디오, 채널 처리 (0) | 2019.07.05 |
7월3일 임베디드 ARM 총 정리 (0) | 2019.07.03 |
7월2일 ARM 64bit Architecture (0) | 2019.07.02 |
7월1일 ARM 소개 (0) | 2019.07.01 |