프로젝트

일반

사용자정보

개정판 253c9730

ID253c973011a7e37766669ce83d920cd6a70e855c
상위 16231f58
하위 206eb77c

김태성이(가) 4달 전에 추가함

issue #00000 compare 속도 및 메모리 최적화
- page 변셩시 이미지 안 보이는 문제 수정

Change-Id: I0efcd3d93178807d9bead96c38e81377ca6730fd

차이점 보기:

KCOM/KCOM.csproj
58 58
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
59 59
    <DebugSymbols>true</DebugSymbols>
60 60
    <OutputPath>bin\x64\Debug\</OutputPath>
61
    <DefineConstants>TRACE;DEBUG;_CUSTOM_BINDING;BASIC_BINDING</DefineConstants>
61
    <DefineConstants>TRACE;DEBUG;CUSTOM_BINDING;_BASIC_BINDING</DefineConstants>
62 62
    <DebugType>full</DebugType>
63 63
    <PlatformTarget>x64</PlatformTarget>
64 64
    <ErrorReport>prompt</ErrorReport>
......
362 362
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_Default|x64'">
363 363
    <DebugSymbols>true</DebugSymbols>
364 364
    <OutputPath>bin\x64\Release_Default\</OutputPath>
365
    <DefineConstants>TRACE;DEBUG;CUSTOM_BINDING;_BASIC_BINDING</DefineConstants>
365
    <DefineConstants>TRACE;DEBUG;_CUSTOM_BINDING;BASIC_BINDING</DefineConstants>
366 366
    <WarningLevel>3</WarningLevel>
367 367
    <DebugType>full</DebugType>
368 368
    <PlatformTarget>x64</PlatformTarget>
......
1558 1558
 cd $(SolutionDir)
1559 1559
 call "PublishSign.bat"
1560 1560
 rem call "appCast_Daelim.bat" "@(VersionNumber)"
1561
 call "appCast_DIG.bat" "@(VersionNumber)"
1562
 call "appCast_ETECH.bat" "@(VersionNumber)"
1561
call rem call "appCast_DIG.bat" "@(VersionNumber)"
1562
rem call "appCast_ETECH.bat" "@(VersionNumber)"
1563 1563
 rem call "appCast_DIG_DEBUG.bat" "@(VersionNumber)"
1564
 rem call "appCast_SNI_SDMS.bat" "@(VersionNumber)"
1565
 rem call "appCast_SNI_XICNA.bat" "@(VersionNumber)"
1564
rem call "appCast_SNI_SDMS.bat" "@(VersionNumber)"
1565
rem call "appCast_SNI_XICNA.bat" "@(VersionNumber)"
1566 1566
 rem call "appCast_doftech.bat" "@(VersionNumber)"
1567 1567
 rem call "appCast_HS.bat" "@(VersionNumber)"
1568 1568
 rem "appCast_bseng.bat" "@(VersionNumber)"
KCOM/Views/MainMenu.xaml.cs
5417 5417

  
5418 5418
                    System.Drawing.Size imageSize = new System.Drawing.Size((int)ViewerDataModel.Instance.ImageViewWidth_C, (int)ViewerDataModel.Instance.ImageViewHeight_C);
5419 5419

  
5420
                    System.Drawing.Size recSize = new System.Drawing.Size(2,2);
5420
                    //System.Drawing.Size recSize = new System.Drawing.Size(2,2);
5421 5421

  
5422
                    if(ViewerDataModel.Instance.ImageViewWidth_C > 1000 && ViewerDataModel.Instance.ImageViewHeight_C > 1000)
5423
                    {
5424
                        recSize = new System.Drawing.Size((int)(ViewerDataModel.Instance.ImageViewWidth_C /1000),(int)(ViewerDataModel.Instance.ImageViewHeight_C/ 1000));
5425
                    }
5422
                    //if(ViewerDataModel.Instance.ImageViewWidth_C > 1000 && ViewerDataModel.Instance.ImageViewHeight_C > 1000)
5423
                    //{
5424
                    //    recSize = new System.Drawing.Size((int)(ViewerDataModel.Instance.ImageViewWidth_C /1000),(int)(ViewerDataModel.Instance.ImageViewHeight_C/ 1000));
5425
                    //}
5426 5426

  
5427 5427
                    var rectColor = System.Drawing.Color.FromArgb(255, 244, 15, 100);
5428
                    var result = imageCompare.CompareReturnDrawContours(ViewerDataModel.Instance.ImageViewPath, ViewerDataModel.Instance.ImageViewPath_C, rectColor, imageSize);
5429 5428

  
5429
                    var result = imageCompare.CompareReturnDrawContours(ViewerDataModel.Instance.ImageViewPath, ViewerDataModel.Instance.ImageViewPath_C, rectColor, imageSize);
5430 5430
                    //borderComprareWait.Visibility = Visibility.Collapsed;
5431 5431

  
5432 5432
                    CompareDisplay(result);
......
5472 5472
                // 애니메이션 설정
5473 5473
                DoubleAnimation animation = new DoubleAnimation
5474 5474
                {
5475
                    From =0.39,
5475
                    From =0.50,
5476 5476
                    To = 0.1,
5477 5477
                    Duration = new Duration(TimeSpan.FromSeconds(2)),
5478 5478
                    AutoReverse = true
......
5567 5567
                            ViewerDataModel.Instance.SyncPageAngle = findPage.PAGE_ANGLE;
5568 5568
                        }
5569 5569

  
5570
                        ViewerDataModel.Instance.SyncPageNumber = syncCurrentPageNo;
5571

  
5570 5572
                        ComparePageLoad(CurrentRev.DOCUMENT_ID, syncCurrentPageNo, OriginalSizeMode.IsChecked);
5571 5573

  
5572 5574
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
Markus.ImageComparer/Converter.cs
25 25
                }
26 26
            }
27 27
        }
28

  
29
        public static OpenCvSharp.Mat ConvertBitmapFrameToMat(BitmapSource bitmapSource)
30
        {
31
            using (MemoryStream outStream = new MemoryStream())
32
            {
33
                BitmapEncoder enc = new BmpBitmapEncoder();
34
                enc.Frames.Add(BitmapFrame.Create(bitmapSource, null, null, null));
35
                enc.Save(outStream);
36
                
37
                return OpenCvSharp.Mat.FromImageData(outStream.ToArray(), OpenCvSharp.ImreadModes.Color);
38
            }
39
        }
28 40
    }
29 41
}
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;
Markus.ImageComparer/ImageCompareBase.cs
45 45
            try
46 46
            {
47 47
                SetStatus("Image Load", 0, CompareStatus.Loading);
48
                OpenCvSharp.Size rSize = new OpenCvSharp.Size(resultSize.Width, resultSize.Height);
48 49

  
49
                Originalbitmap = ChangeBitmapFormatAndSize(Originalbitmap, resultSize, PixelFormat.Format24bppRgb);
50
                TargatBitmap = ChangeBitmapFormatAndSize(TargatBitmap, resultSize, PixelFormat.Format24bppRgb);
50
                //Originalbitmap = ChangeBitmapFormatAndSize(Originalbitmap, resultSize, PixelFormat.Format24bppRgb);
51
                //TargatBitmap = ChangeBitmapFormatAndSize(TargatBitmap, resultSize, PixelFormat.Format24bppRgb);
51 52

  
52 53
                // 원본이미지의 크키와 Format24bppRgb로 타켓 이미지를 변경
53 54
                // 크기가 틀린 경우 비교시 바이트배열 오류 발생
......
55 56
                {
56 57
                    using (Mat TargatImageData = OpenCvSharp.Extensions.BitmapConverter.ToMat(TargatBitmap))
57 58
                    {
58
                        if (OriginalImageData.Size() != TargatImageData.Size())
59
                        if (OriginalImageData.Size() != rSize)
59 60
                        {
60
                            Cv2.Resize(TargatImageData, TargatImageData, OriginalImageData.Size());
61
                            Cv2.Resize(OriginalImageData, OriginalImageData, rSize);
62
                        }
63

  
64
                        if (TargatImageData.Size() != rSize)
65
                        {
66
                            Cv2.Resize(TargatImageData, TargatImageData, rSize);
61 67
                        }
62 68

  
63 69
                        Cv2.CvtColor(OriginalImageData, OriginalImageData, ColorConversionCodes.BGR2GRAY);
......
83 89
            return result;
84 90
        }
85 91

  
92
        protected Mat MathchesImageData(Mat OriginalImageData, Mat TargatImageData, Size resultSize)
93
        {
94
            Mat result = new Mat();
95

  
96
            try
97
            {
98
                SetStatus("Image Load", 0, CompareStatus.Loading);
99
                OpenCvSharp.Size rSize = new OpenCvSharp.Size(resultSize.Width, resultSize.Height);
100

  
101
                // 크기가 틀린 경우 비교시 바이트배열 오류 발생
102
         
103
                if (OriginalImageData.Size() != rSize)
104
                {
105
                    Cv2.Resize(OriginalImageData, OriginalImageData, rSize);
106
                }
107

  
108
                if (TargatImageData.Size() != rSize)
109
                {
110
                    Cv2.Resize(TargatImageData, TargatImageData, rSize);
111
                }
112

  
113
                Cv2.CvtColor(OriginalImageData, OriginalImageData, ColorConversionCodes.BGR2GRAY);
114
                Cv2.CvtColor(TargatImageData, TargatImageData, ColorConversionCodes.BGR2GRAY);
115

  
116
                using (Mat outputData = new Mat(new OpenCvSharp.Size(resultSize.Width, resultSize.Height), MatType.CV_8UC1))
117
                {
118
                    Cv2.Absdiff(OriginalImageData, TargatImageData, outputData);
119
                    // 틀린부분을 반환
120
                    Cv2.BitwiseNot(outputData, result);
121
                }
122
            }
123
            catch (Exception ex)
124
            {
125
                throw ex;
126
            }
127
            finally
128
            {
129
            }
130

  
131
            return result;
132
        }
133

  
86 134

  
87 135
        /// <summary>
88 136
        /// Image<TColor, TDepth>의 틀린 부분을 Rect로 반환

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)