자료형 |
멤버변수 |
인라인 함수 이름 |
설명 |
CvPoint |
x,y |
cvPoint |
int형 2D 화소 위치 |
CvPoint2D32f |
x,y, |
cvPoint2D32f |
float형 2D 화소 위치 |
CvPoint2D65f |
x,y |
cvPoint2D64f |
double형 2D 화소 위치 |
CvScalar |
valp4[ |
cvScalar, cvRealScalar, cvScalarAll |
화소의 밝기 값 또는 컬러 값 표현 그레이 스케일 영상 : val[0] 컬러 영상: val[0]=B val[1]=G val[2]=R val[3]=alpha |
인라인 함수 설명
CV_INLINE CvPoint cvPoint(int x, int y)
{
CvPoint p;
p.x=x;
p.y=y;
return p;
}
CV_INLINE CvPoint2D32f cvPoint2D32f(double x, double y)
{
CvPoint2D32f p;
p.x = (float)x;
p.y = (float)y;
return p;
}
CV_INLINE CvPoint2D64f cvPoint2D32f(double x, double y)
{
CvPoint2D64f p;
p.x = (float)x;
p.y = (float)y;
return p;
}
CV_INLINE CvScalar cvScalar(double val0, double val1 CV_DEFAULT(0), double val2 CV_DEFAULT(0), double val3 CV_DEFAULT(0))
{
CvScalar scalar;
scalar.val[0]=val0; scalar.val[1]=val1;
scalar.val[2]=val2; scalar.val[3]=val3;
return scalar;
}
CV_INLINE CvScalar cvRealScalar(double val0)
{
CvScalar scalar;
scalar.val[0]=val0;
scalar.val[1]=scalar.val[2]=scalar.val[3]=0;
return scalar;
}
CV_INLINE Cvscalar cvScalarAll(double val0123)
{
CvScalar scalar;
scalar.val[0]=val0123;
scalar.val[1]=val0123;
scalar.val[2]=val0123;
scalar.val[3]=val0123;
}
ex1)
#include <iostream>
#include <opencv\cv.h>
#include <opencv\highgui.h>
int test01()
{
CvPoint pt0 = cvPoint(10,20);
CvPoint2D32f pt1 = cvPoint2D32f(30.0,40.0);
CvPoint2D64f pt2 = cvPoint2D64f(50.0,60.0);
printf("pt0 : %d, %d\n",pt0.x,pt0.y);
printf("pt1 : %f,%f\n",pt1.x,pt1.y);
printf("pt2 : %f, %f\n", pt2.x,pt2.y);
return 0;
}
int test02()
{
CvScalar color1 = cvScalar(255,255,255);
CvScalar color2 = cvScalar(255);
CvScalar color3 = cvRealScalar(255);
CvScalar color4 = cvScalarAll(255);
printf("color1.val: %f, %f, %f, %f\n", color1.val[0], color1.val[1], color1.val[2], color1.val[3]);
printf("color2.val: %f, %f, %f, %f\n", color2.val[0], color2.val[1], color2.val[2], color2.val[3]);
printf("color3.val: %f, %f, %f, %f\n", color3.val[0], color3.val[1], color3.val[2], color3.val[3]);
printf("color4.val: %f, %f, %f, %f\n", color4.val[0], color4.val[1], color4.val[2], color4.val[3]);
return0;
}
------------------------------------------------------------------------------------------------
typedef struct
{
int width;
int height;
}CvSize;
CV_INLINE CvSize cvSize(int width, int height)
{
CvSize s;
s.width = width;
s.height = height;
return s;
}
typedef struct CvRect
{
int x;
int y;
int width;
int height;
}CvRect;
CV_INLINE CvRect cvRect(int x, int y, int width, int height)
{
CvRect r;
r.x = x;
r.y = y
r.width = width;
r.height = height;
return r;
}
ex3)
int test03()
{
CvSize size = cvSize(720,480);
CvRect rect = cvRect(100,100,400,200);
CvPoint pt1,pt2;
printf("size : %d, %d\n", size.width, size.height);
pt1.x = rect.x;
pt1.y = rect.y;
pt2.x = rect.x + rect.width;
pt2.y = rect.y + rect.height;
printf(":Left Top Point(p1) : %d, %d\n", pt1.x, pt1.y);
printf("Right Bottom Point(p2) : %d, %d\n", pt2.x, pt2.y);
return 0;
}
...cvScalar는 가변인수함수?
함수, 변수 등의 형태를 잘 알고 사용하자!