개정판 253c9730
issue #00000 compare 속도 및 메모리 최적화
- page 변셩시 이미지 안 보이는 문제 수정
Change-Id: I0efcd3d93178807d9bead96c38e81377ca6730fd
Markus.ImageComparer/ImageCompare.cs | ||
---|---|---|
190 | 190 |
{ |
191 | 191 |
Originalbitmap.Dispose(); |
192 | 192 |
TargatBitmap.Dispose(); |
193 |
|
|
194 |
GC.Collect(2); |
|
195 |
GC.Collect(2); |
|
193 | 196 |
} |
194 | 197 |
|
195 | 198 |
return result; |
... | ... | |
461 | 464 |
} |
462 | 465 |
finally |
463 | 466 |
{ |
467 |
GC.Collect(2); |
|
468 |
GC.Collect(2); |
|
464 | 469 |
} |
465 | 470 |
|
466 | 471 |
return result; |
... | ... | |
470 | 475 |
{ |
471 | 476 |
System.Windows.Media.Imaging.BitmapSource result = null; |
472 | 477 |
|
473 |
Bitmap Originalbitmap = null; |
|
474 |
Bitmap TargatBitmap = null; |
|
475 |
|
|
476 | 478 |
try |
477 | 479 |
{ |
478 | 480 |
|
479 |
Originalbitmap = Converter.ConvertBitmapFrameToBitmap(OriginalbitmapFrame); |
|
480 |
TargatBitmap = Converter.ConvertBitmapFrameToBitmap(TargatBitmapFrame); |
|
481 |
using (OpenCvSharp.Mat Originalbitmap = Converter.ConvertBitmapFrameToMat(OriginalbitmapFrame)) |
|
481 | 482 |
|
482 |
var bitmap = CompareReturnDrawContours(Originalbitmap, TargatBitmap, rectColor, ResultImageSize); |
|
483 |
|
|
484 |
result = CreateBitmapSourceFromBitmap(bitmap); |
|
483 |
using (OpenCvSharp.Mat TargatBitmap = Converter.ConvertBitmapFrameToMat(TargatBitmapFrame)) |
|
484 |
{ |
|
485 |
var bitmap = CompareReturnDrawContours(Originalbitmap, TargatBitmap, rectColor, ResultImageSize); |
|
486 |
result = CreateBitmapSourceFromBitmap(bitmap); |
|
487 |
} |
|
485 | 488 |
} |
486 | 489 |
catch (Exception) |
487 | 490 |
{ |
... | ... | |
489 | 492 |
} |
490 | 493 |
finally |
491 | 494 |
{ |
492 |
Originalbitmap.Dispose();
|
|
493 |
TargatBitmap.Dispose();
|
|
495 |
GC.Collect(2);
|
|
496 |
GC.Collect(2);
|
|
494 | 497 |
} |
495 | 498 |
|
496 | 499 |
return result; |
497 | 500 |
} |
498 | 501 |
|
499 |
public System.Drawing.Bitmap CompareReturnDrawContours(System.Drawing.Bitmap Originalbitmap, System.Drawing.Bitmap TargatBitmap, Color rectColor, Size? ResultImageSize = null)
|
|
502 |
private System.Drawing.Bitmap CompareReturnDrawContours(OpenCvSharp.Mat OriginalData, OpenCvSharp.Mat TargatData, Color rectColor, Size? ResultImageSize = null)
|
|
500 | 503 |
{ |
501 | 504 |
System.Drawing.Bitmap result = null; |
502 | 505 |
|
503 | 506 |
try |
504 | 507 |
{ |
505 |
Size resultImageSize = Originalbitmap.Size; |
|
508 |
var originalSize = OriginalData.Size(); |
|
509 |
|
|
510 |
Size resultImageSize = new Size(originalSize.Width, originalSize.Height); |
|
506 | 511 |
|
507 | 512 |
if (ResultImageSize.HasValue) |
508 | 513 |
{ |
509 | 514 |
resultImageSize = ResultImageSize.Value; |
510 | 515 |
} |
511 | 516 |
|
512 |
var data = MathchesImageData(Originalbitmap, TargatBitmap, resultImageSize);
|
|
517 |
var data = MathchesImageData(OriginalData, TargatData, resultImageSize);
|
|
513 | 518 |
result = GetContoursImage(data, resultImageSize, rectColor); |
514 | 519 |
} |
515 | 520 |
catch (Exception ex) |
... | ... | |
518 | 523 |
} |
519 | 524 |
finally |
520 | 525 |
{ |
526 |
GC.Collect(2); |
|
527 |
GC.Collect(2); |
|
521 | 528 |
} |
522 | 529 |
|
523 | 530 |
return result; |
내보내기 Unified diff