아래 소스를 참고하세요.
//이미지정보확인
int ImageWidth = this.arImageViewer1.Image.Width;
int ImageHeight = this.arImageViewer1.Image.Height;
IntPtr ImagePtr = this.arImageViewer1.GetImagePtr();
//메인이미지설정
EImageBW8 imgBW8 = new EImageBW8();
imgBW8.SetImagePtr(ImageWidth, ImageHeight, ImagePtr); //기존이미지 포인터를 이용하여 생성
//ROI설정
EROIBW8 roi1 = new EROIBW8();
roi1.Attach(imgBW8); //ROI의 기준이미지 설정
roi1.SetPlacement(this.arImageViewer1.ROIS[0].X, this.arImageViewer1.ROIS[0].Y,
this.arImageViewer1.ROIS[0].Width, this.arImageViewer1.ROIS[0].Height); //ROI 위치 및 크기설정
//패턴매칭할 매처를 생성
EMatcher matcher = new EMatcher();
matcher.LearnPattern(roi1); //ROI에 해당하는 이미지를 찾을 것이므로 learnPattern 에 지정한다
matcher.Match(imgBW8); //매칭결과를 찾으며 원본이미지를 파라미터로 입력합니다.
//매칭이 성공했다면 NumPositions 에 매칭결과값이 추가됩니다.
if (matcher.NumPositions > 0)
{
//매칭결과값이 있는경우
for (int i = 0; i < matcher.NumPositions; i++)
Console.WriteLine(string.Format("Match Position {0} Score = {1}", i, matcher.GetPosition(i).Score));
}
else MessageBox.Show("매칭결과가 없습니다.");
'Programming > Computer Vision' 카테고리의 다른 글
| (euresys) 이미지 객체 생성 방법 및 ROI 생성 (0) | 2016.11.19 |
|---|