개정판 16231f58
issue #0000 imagecompare 수정
- rect을 opencv에서 그려 이미지로 출력
Change-Id: I241d6b62eb8dd88ae4a970c4e531d079bbaa3602
ImageComparer/Markus.ImageComparer/ImageCompareBase.cs | ||
---|---|---|
62 | 62 |
Cv2.CvtColor(OriginalImageData, OriginalImageData, ColorConversionCodes.BGR2GRAY); |
63 | 63 |
Cv2.CvtColor(TargatImageData, TargatImageData, ColorConversionCodes.BGR2GRAY); |
64 | 64 |
|
65 |
Mat outputData = new Mat(TargatImageData.Size(), MatType.CV_8UC1); |
|
65 |
//Cv2.EqualizeHist(OriginalImageData, OriginalImageData); |
|
66 |
//Cv2.EqualizeHist(TargatImageData, TargatImageData); |
|
67 |
|
|
68 |
//Cv2.GaussianBlur(OriginalImageData, OriginalImageData, new OpenCvSharp.Size(5, 5), 0); |
|
69 |
//Cv2.GaussianBlur(TargatImageData, TargatImageData, new OpenCvSharp.Size(5, 5), 0); |
|
70 |
// Canny 엣지 검출 적용 |
|
66 | 71 |
|
72 |
Mat outputData = new Mat(TargatImageData.Size(), MatType.CV_8UC1); |
|
67 | 73 |
Cv2.Absdiff(OriginalImageData, TargatImageData, outputData); |
68 | 74 |
|
69 | 75 |
// 틀린부분을 반환 |
... | ... | |
146 | 152 |
return results; |
147 | 153 |
} |
148 | 154 |
|
155 |
protected System.Drawing.Bitmap GetContoursImage(Mat data,Size resultSize,Color RectColor) |
|
156 |
{ |
|
157 |
System.Drawing.Bitmap result = null; |
|
158 |
|
|
159 |
try |
|
160 |
{ |
|
161 |
OpenCvSharp.Mat transparentImage = new OpenCvSharp.Mat(new OpenCvSharp.Size(resultSize.Width, resultSize.Height), OpenCvSharp.MatType.CV_8UC4, new OpenCvSharp.Scalar(0, 0, 0, 0)); |
|
162 |
|
|
163 |
// 컨투어를 찾기 위한 변수 선언 |
|
164 |
OpenCvSharp.HierarchyIndex[] hierarchy; |
|
165 |
OpenCvSharp.Point[][] contours; |
|
166 |
OpenCvSharp.Point testpoint = new OpenCvSharp.Point(); |
|
167 |
|
|
168 |
OpenCvSharp.Cv2.Threshold(data, data, 50, 255, OpenCvSharp.ThresholdTypes.BinaryInv); |
|
169 |
// 이진화된 이미지에서 컨투어 찾기 |
|
170 |
OpenCvSharp.Cv2.FindContours(data, out contours, out hierarchy, OpenCvSharp.RetrievalModes.List, OpenCvSharp.ContourApproximationModes.ApproxNone, testpoint); |
|
171 |
|
|
172 |
|
|
173 |
// OpenCvSharp.Scalar(B,G,R,A) |
|
174 |
// 컨투어 그리기 |
|
175 |
OpenCvSharp.Cv2.DrawContours(transparentImage, contours, -1, new OpenCvSharp.Scalar(RectColor.B, RectColor.G, RectColor.R, RectColor.A), 10); |
|
176 |
|
|
177 |
// Mat을 Bitmap으로 변환 |
|
178 |
result = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(transparentImage); |
|
179 |
} |
|
180 |
catch (Exception ex) |
|
181 |
{ |
|
182 |
throw new Exception("GetContoursImage Error.",ex); |
|
183 |
} |
|
184 |
finally |
|
185 |
{ |
|
186 |
|
|
187 |
} |
|
188 |
|
|
189 |
return result; |
|
190 |
} |
|
191 |
|
|
149 | 192 |
private List<System.Windows.Rect> GetRectList(OpenCvSharp.Point[] points,Size block) |
150 | 193 |
{ |
151 | 194 |
List<System.Windows.Rect> result = new List<System.Windows.Rect>(); |
내보내기 Unified diff