• Getting Started
  • Development Guide
  • API Reference
  • Release Notes
Search Results for

    Show / Hide Table of Contents
    • Saige.Infrastructure
      • GpuDetectedEventArgs
      • IGpuService
      • NvGpuService
      • PhysicalGpu
    • SaigeVision.Core
      • AugmentationParams
      • ClassInfo
      • DetTrainingOptions
      • Ellipse
      • EngineAlgorithm
      • EngineMetadata
      • IEnumerableExtensions
      • Label
      • Label<T>
      • LabeledImage<T>
      • NetworkDepthOption
      • NetworkParams
      • Range
      • SaigeVisionApp
      • SegTrainingOptions
      • SrImage
      • SrImageDataHandle
      • StringExtensions
      • TrainingOptions
    • SaigeVision.Core.Inference
      • ClassificationEngine
      • ClassificationReport
      • ClsInspectionOptions
      • ContourInspectionOptions
      • CropLargePatchMode
      • DetectedBox
      • DetectionEngine
      • DetectionReport
      • DetInspectionOptions
      • EngineInfoSerializer
      • EngineLoader
      • InspectException
      • InspectionOptions
      • ISegmentationResult
      • OcrEngine
      • OcrOptions
      • OcrReport
      • OcrResultStringInfo
      • ScoreValues<T>
      • SegContourResult
      • SegInspectionOptions
      • SegmentationEngine
      • SegmentationExtensions
      • SegmentationReport<T>
      • SegmentationReport<T1, T2>
      • SegScoremapResult
      • SizeCalculationType
    • SaigeVision.Core.Shapes
      • Box
      • Contour
      • Shape<T>

    Class SrImage

    SaigeVision.Core를 위한 이미지 클래스입니다.

    Inheritance
    object
    SrImage
    Implements
    IDisposable
    ISerializable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: SaigeVision.Core
    Assembly: SaigeVision.Core.dll
    Syntax
    [Serializable]
    public class SrImage : IDisposable, ISerializable
    Remarks

    SrImage는 다양한 방법으로 이미지를 로드하고 핸들링할 수 있는 기능을 제공합니다.

    8bit 그레이 스케일과 24bit RGB 형식만을 지원합니다. 생성자를 통해 인스턴스를 생성할때, 지정된 이미지가 언급된 형식외의 사양을 가졌다면 강제로 변환합니다. (예. ARGB).

    일반적으로 이미지를 위한 클래스들은 많은 리소스를 사용합니다. System.IDisposable을 지원하니, 해당 이미지를 사용하지 않는다면 System.IDisposable.Dispose()를 통해 메모리를 해제해주세요. Using block을 사용하는건 매우 좋은 선택입니다.

    Examples

    파일 경로를 통해 생성하는 경우입니다.

    SrImage image = new SrImage("c:/Image.jpg");

    스트림을 통해 생성하는 경우입니다.

    Stream stream = new FileStream("c:/Image.jpg");
    SrImage image = new SrImage(stream);

    Constructors

    View Source

    SrImage(Bitmap, Uri)

    Declaration
    public SrImage(Bitmap bitmap, Uri uri = null)
    Parameters
    Type Name Description
    Bitmap bitmap
    Uri uri
    See Also
    SrImageDataHandle
    View Source

    SrImage(int, int, int, int, byte[])

    Initializes a new instance of the SrImage class.

    Declaration
    public SrImage(int width, int height, int stride, int channelSize, byte[] data)
    Parameters
    Type Name Description
    int width

    이미지 가로 길.

    int height

    이미지 세로 길.

    int stride

    직렬화된 데이터의 스트라이드.

    int channelSize

    채널 수.

    byte[] data

    데이터 배열.

    Remarks

    width와 height는 지정된 data의 실제 Width, Height가 지정되어야 합니다.

    stride는 이미지 데이터를 Matrix 구조로 생각했을때, 하나의 row 가 갖추는 수평 길이입니다. 일반적으로 이미지의 Width * ChannelSize 라고 볼 수 있지만, Width를 알 수 없을때 행의 끝을 알기 위한 Right padding이 주어질 수 있습니다. 이런 경우 Stride는 Width * ChannelSize보다 더 큽니다. 또한 stride가 양수이면 하향식 데이터이며, 음수이면 상향식 데이터입니다.

    data는 ChnnelSize가 1일때 Gray scale로 갖추어진 배열 데이터의 포인터를 지정받습니다. ChannelSize 가 3이라면 RGB 순으로 정렬된 시퀀스 데이터의 포인터를 지정해야합니다.

    SrImage는 gray scale과 RGB 스케일만을 지원합니다. 그러한 이유로 channelSize에 1과 3이 아닌 값을 지정하면 강제로 스케일을 RGB로 변환하여 보유합니다. (예, ARGB는 RGB로 강제 변환됩니다.)

    data는 내부적으로 Unmanaged memory 영역에 복사됩니다. 인스턴스 생성 후 해당 배열 데이터는 직접 관리해야 합니다. 이말은 즉슨, SrImage 인스턴스의 생명은 해당 배열과 관련없는것을 의미합니다.

    See Also
    SrImageDataHandle
    View Source

    SrImage(int, int, int, int, IntPtr)

    생성자입니다.

    Declaration
    public SrImage(int width, int height, int stride, int channelSize, IntPtr data)
    Parameters
    Type Name Description
    int width

    이미지 가로 길이.

    int height

    이미지 세로 길이.

    int stride

    직렬화된 데이터의 스트라이드.

    int channelSize

    채널 수.

    IntPtr data

    데이터 포인트.

    Remarks

    width와 height는 지정된 data의 실제 Width, Height가 지정되어야 합니다.

    stride는 이미지 데이터를 Matrix 구조로 생각했을때, 하나의 row 가 갖추는 수평 길이입니다. 일반적으로 이미지의 Width * ChannelSize 라고 볼 수 있지만, Width를 알 수 없을때 행의 끝을 알기 위한 Right padding이 주어질 수 있습니다. 이런 경우 Stride는 Width * ChannelSize보다 더 큽니다. 또한 stride가 양수이면 하향식 데이터이며, 음수이면 상향식 데이터입니다.

    data는 ChnnelSize가 1일때 Gray scale로 갖추어진 배열 데이터의 포인터를 지정받습니다. ChannelSize 가 3이라면 BGR 순으로 정렬된 시퀀스 데이터의 포인터를 지정해야합니다.

    SrImage는 gray scale과 RGB 스케일만을 지원합니다. 그러한 이유로 channelSize에 1과 3이 아닌 값을 지정하면 강제로 스케일을 RGB로 변환하여 보유합니다. (예, ARGB는 RGB로 강제 변환됩니다.)

    해당 생성자의 파라메터에서 가장 주목해야 할 놈은 data입니다. 주입된 data는 사용자에 의해 관리되어야 합니다. 이말은 즉슨, SrImage 인스턴스를 사용하는 동안에 외부에서 data의 메모리를 해제해서는 안됩니다. 생성된 인스턴스의 생명과 관련이 깊음을 의미합니다.

    Examples

    다음 예제는 System.Drawing.Bitmap을 통해 인스턴스를 생성하여, 파일로 Save 하는 예제로 해당 생성자를 설명합니다.

    Bitmap oldImage = new Bitmap(@"c:\Hello.jpg");
    Rectangle oldImageBounds = new Rectangle(default, oldImage.Size);
    BitmapData oldBitData = oldImage.LockBits(oldImageBounds, ImageLockMode.ReadOnly, oldImage.PixelFormat;
    
    int channelSize = 0;
    //이외 방법으로 채널 사이즈를 지정해도 됩니다.
    if (oldImage.PixelFormat == PixelFormat.Format24bppRgb)
        channelSize = 3;
    else if (oldImage.PixelFormat == PixelFormat.Format8bppIndexed)
        channelSize = 1;
    else throw new NotSupportedException();
    
    using (SrImage newImage = new SrImage(oldImage.Width, oldImage.Height, oldBitData.Stride, channelSize, oldBitData.Scan0))
    {
        newImage.Save(@"c:\new_hello.png", ImageFormat.Png);
    }
    oldImage.UnlockBits(oldBitData);
    See Also
    SrImageDataHandle
    View Source

    SrImage(Stream)

    생성자입니다.

    Declaration
    public SrImage(Stream stream)
    Parameters
    Type Name Description
    Stream stream

    이미지 데이터를 담은 스트림.

    Remarks

    stream은 생성된 인스턴스의 SaigeVision.Core.SrImage.Dispose(System.Boolean)가 호출되지 전까지 연결을 유지해야합니다.

    See Also
    SrImageDataHandle
    View Source

    SrImage(string)

    생성자입니다.

    Declaration
    public SrImage(string filePath)
    Parameters
    Type Name Description
    string filePath

    이미지 파일 경로.

    Examples

    가능하다면 아래와 같이 Using 블럭을 사용하세요. SrImage는 System.IDisposable을 상속합니다.

    using(SrImage image = new SrImage("c:\Image.jpg"))
    {
        image.Save("c:\NewImage.jpg", ImageFormat.Jpeg);
    }
    See Also
    SrImageDataHandle

    Properties

    View Source

    Channel

    채널 수.

    Declaration
    public int Channel { get; }
    Property Value
    Type Description
    int
    Remarks

    1 == Gray scale, 3 == RGB scale.

    See Also
    SrImageDataHandle
    View Source

    Height

    세로 길이.

    Declaration
    public int Height { get; }
    Property Value
    Type Description
    int
    See Also
    SrImageDataHandle
    View Source

    Uri

    원본 이미지의 Uri.

    Declaration
    public Uri Uri { get; }
    Property Value
    Type Description
    Uri
    Remarks

    File path를 통한 생성자를 통해 생성된 인스턴스만 값을 가질 수 있으며, 그외 생성자는 해당 값을 null로 표현합니다.

    See Also
    SrImageDataHandle
    View Source

    Width

    가로 길이.

    Declaration
    public int Width { get; }
    Property Value
    Type Description
    int
    See Also
    SrImageDataHandle

    Methods

    View Source

    Dispose()

    Declaration
    public void Dispose()
    See Also
    SrImageDataHandle
    View Source

    ~SrImage()

    Declaration
    protected ~SrImage()
    See Also
    SrImageDataHandle
    View Source

    GetData(bool)

    이미지의 byte[] 형 데이터에 접근할 수 있는 핸들을 리턴합니다.

    Declaration
    public SrImageDataHandle GetData(bool isReadOnly = true)
    Parameters
    Type Name Description
    bool isReadOnly

    읽기 전용 설정.

    Returns
    Type Description
    SrImageDataHandle

    데이터 접근 핸들.

    See Also
    SrImageDataHandle
    View Source

    Save(Stream, ImageFormat)

    이미지를 저장합니다.

    Declaration
    public void Save(Stream stream, ImageFormat format)
    Parameters
    Type Name Description
    Stream stream

    저장할 스트림.

    ImageFormat format

    저장에 사용할 이미지 포맷.

    See Also
    SrImageDataHandle
    View Source

    Save(string, ImageFormat)

    이미지를 저장합니다.

    Declaration
    public void Save(string path, ImageFormat format)
    Parameters
    Type Name Description
    string path

    저장할 파일 경로.

    ImageFormat format

    저장에 사용할 이미지 포맷.

    See Also
    SrImageDataHandle
    View Source

    ToBitmap()

    Declaration
    public Bitmap ToBitmap()
    Returns
    Type Description
    Bitmap
    See Also
    SrImageDataHandle

    Operators

    View Source

    implicit operator Bitmap(SrImage)

    Declaration
    public static implicit operator Bitmap(SrImage image)
    Parameters
    Type Name Description
    SrImage image
    Returns
    Type Description
    Bitmap
    See Also
    SrImageDataHandle

    Implements

    System.IDisposable
    System.Runtime.Serialization.ISerializable

    See Also

    SrImageDataHandle
    • View Source
    In This Article
    Back to top Generated by DocFX