콘텐츠로 바로 가기
STAGING SERVER
DEVELOPMENT SERVER

Compression Beyond#

Compression Beyond camera feature를 사용하면 카메라가 출력하는 이미지 데이터를 압축할 수 있습니다.

이미지 데이터를 압축하면 카메라의 대역폭 사용량이 줄어들거나 프레임 속도가 높아지거나 둘 다 가능합니다.

자세한 내용은 Basler 웹사이트의 기능 설명을 참조하십시오.

기능 사용#

작동 방식#

압축은 다음과 같은 경우에 자동으로 수행됩니다. ImageCompressionMode 파라미터가 다음으로 설정된 경우에만 Light Control 기능과 함께 사용할 수 있음을 명시했습니다. BaslerCompressionBeyond.

이 기능을 활성화하면 항상 가능한 한 많이 이미지를 압축합니다. 이를 통해 카메라가 출력하는 데이터("페이로드")의 양, 즉 대역폭 사용량이 줄어듭니다. 이는 특히 다중 카메라 설정의 Basler GigE 카메라에 매우 유용합니다.

카메라가 프레임 속도도 최적화하게 하려면 추가 설정이 필요합니다. 노출이 시작되기 전에 카메라가 이미지를 얼마나 압축할 수 있는지 "알 수" 없기 때문입니다.

이를 해결하려면 카메라에 다음 사항을 알려주어야 합니다. 최소한 이미지를 압축할 수 있습니다. 압축률을 지정하여 수행합니다(BslImageCompressionRatio 파라미터가 감소합니다.

예를 들어, 설정하면 BslImageCompressionRatio 파라미터를 90으로 설정하면, 카메라가 모든 이미지를 원래 크기의 최소 90%까지 압축할 수 있음을 카메라에 알립니다. 이 정보를 통해 카메라는 프레임 속도를 최대 10%까지 높일 수 있습니다.

그러나 값을 너무 낮게 설정하면, 즉 카메라가 예상된 압축률을 달성할 수 없으면 프레임이 건너뛰어집니다. 이 경우 다음을 변경할 수 있습니다. ImageCompressionRateOption 파라미터 변경: Lossless 에서 FixRatio. 이를 통해 더 낮은 압축률을 사용할 수 있지만 이미지 Quality은 떨어집니다.

정보

  • 이미지 취득 중에는 다음을 읽어 마지막으로 취득한 이미지의 페이로드 크기와 압축률을 확인할 수 있습니다. BslImageCompressionLastRatio 및 BslImageCompressionLastSize 파라미터 값.
  • Compression Beyond가 활성화되면 pylon Viewer는 이미지 표시 영역의 상태 표시줄에 해당 기능에 대한 정보를 표시합니다.

    Compression Beyond 상태 표시줄

  • 자체 이미지 그랩 루틴을 구현할 때는 CImageDecompressor 클래스를 사용하여 그랩한 이미지의 압축을 해제해야 합니다. 자세한 내용은 pylon API Documentation의 Image Decompression을 참조하십시오.

Compression Beyond 구성하기#

Compression Beyond를 구성하는 방법은 요구 사항에 따라 다릅니다.

대역폭 최적화#

카메라가 다음 작업을 수행하도록 하려는 경우를 가정해 보겠습니다.

  • 대역폭 사용량 감소
  • 프레임 속도 증가
  • 최적의 이미지 Quality 유지

이를 달성하려면:

  1. 카메라가 대기 상태이며 이미지를 캡처하고 있지 않은지 확인하십시오.
  2. 파라미터를 원하는 ImageCompressionMode 파라메터 BaslerCompressionBeyond.
  3. 파라미터를 원하는 ImageCompressionRateOption 파라메터 Lossless.
  4. 파라미터를 원하는 BslImageCompressionRatio 파라미터를 100으로 설정합니다.

이러한 설정을 사용하면 카메라는 이미지 Quality를 희생하지 않고 가능한 한 많이 이미지를 압축합니다.

무손실 압축을 통한 대역폭 및 프레임 속도 최적화#

카메라가 다음 작업을 수행하도록 하려는 경우를 가정해 보겠습니다.

  • 대역폭 사용량 감소
  • 프레임 속도 증가
  • 최적의 이미지 Quality 유지

이를 달성하려면:

  1. 카메라가 대기 상태이며 이미지를 캡처하고 있지 않은지 확인하십시오.
  2. 파라미터를 원하는 ImageCompressionMode 파라메터 BaslerCompressionBeyond.
  3. 파라미터를 원하는 ImageCompressionRateOption 파라메터 Lossless.
  4. 파라미터를 원하는 BslImageCompressionRatio parameter 값을 100보다 낮은 값(예: 90)으로 설정합니다.
  5. 다음의 값을 가져옵니다. BslResultingAcquisitionFrameRate parameter로 예상 프레임 레이트를 결정합니다.
  6. 애플리케이션에 필요한 프레임 레이트가 충족되지 않는 경우, 더 낮은 값으로 4단계와 5단계를 반복합니다. BslImageCompressionRatio 매개변수 값.
  7. 이미지 취득을 시작합니다. 프레임 누락 없이 이미지를 취득할 수 없는 경우, 원하는 프레임 레이트를 달성할 수 없습니다. 다음 방법을 시도해 보세요.
    • 낮은 프레임 레이트가 허용되는 경우, BslImageCompressionRatio parameter 값을 높여 카메라가 연속으로 이미지를 취득할 수 있도록 합니다.
    • 낮은 Quality가 허용되는 경우, 아래에 자세히 설명된 절차를 수행합니다.

손실 압축을 통한 대역폭 및 프레임 속도 최적화#

정보

항상 lossless compression을 먼저 시도하십시오. lossless compression으로 필요한 결과를 얻을 수 없는 경우에만 lossy compression을 사용하십시오.

카메라가 다음 작업을 수행하도록 하려는 경우를 가정해 보겠습니다.

  • 대역폭 사용량 감소
  • 프레임 속도 증가
  • 최적의 이미지 Quality 유지

이를 달성하려면:

  1. 카메라가 대기 상태이며 이미지를 캡처하고 있지 않은지 확인하십시오.
  2. 파라미터를 원하는 ImageCompressionMode 파라메터 BaslerCompressionBeyond.
  3. 파라미터를 원하는 ImageCompressionRateOption 파라메터 FixRatio.
  4. 파라미터를 원하는 BslImageCompressionRatio 파라메터 100.
  5. 적어도 하나의 이미지를 취득합니다.
  6. 다음의 값을 가져옵니다. BslImageCompressionLastRatio 파라미터에 HTML 로그 파일(*.html)의 경로와 이름을 지정할 수 있습니다.
    이 값은 lossless 및 lossy 이미지 취득 간의 임계값을 나타냅니다.
  7. 파라미터를 원하는 BslImageCompressionRatio parameter 값을 BslImageCompressionLastRatio 파라미터에 HTML 로그 파일(*.html)의 경로와 이름을 지정할 수 있습니다.
    parameter 값이 낮을수록 Quality도 낮아집니다.
  8. 이미지 취득을 시작합니다. 프레임 누락 없이 이미지를 취득할 수 없는 경우, BslImageCompressionRatio parameter 값을 높여 카메라가 이미지를 취득할 수 있도록 합니다.

이러한 설정을 사용하면 lossless compression에 비해 대역폭 사용량을 줄이고 프레임 레이트를 높일 수 있습니다. 단, 이 경우 Quality가 저하됩니다.

샘플 코드#

// Enable Compression Beyond with lossless compression
camera.ImageCompressionMode.SetValue(ImageCompressionMode_BaslerCompressionBeyond);
camera.ImageCompressionRateOption.SetValue(ImageCompressionRateOption_Lossless);
// To increase the frame rate, tell the camera that it will be able
// to compress any image to at least 70 % of its original size
camera.BslImageCompressionRatio.SetValue(70);
// Get the resulting acquisition frame rate
double resultingFrameRate = camera.BslResultingAcquisitionFrameRate.GetValue();
if (resultingFrameRate < desiredFrameRate) {
    // Frame rate isn't high enough for the application.
    // Therefore, enable lossy compression. This allows even
    // lower compression rates, but reduces image quality.
    camera.ImageCompressionRateOption.SetValue(ImageCompressionRateOption_FixRatio);
    camera.BslImageCompressionRatio.SetValue(50);
}
// Start image acquisition
// ...
// (Implement your own image grabbing routine here.
// For example, the InstantCamera class provides the StartGrabbing() method.
// Note that you must decompress grabbed images using the CImageDecompressor class.)
// ...
// Determine the compression ratio of the last acquired image
double lastRatio = camera.BslImageCompressionLastRatio.GetValue();
// Determine the payload size of the last acquired image in bytes
int64_t lastSize = camera.BslImageCompressionLastSize.GetValue();
INodeMap& nodemap = camera.GetNodeMap();
// Enable Compression Beyond with lossless compression
CEnumParameter(nodemap, "ImageCompressionMode").SetValue("BaslerCompressionBeyond");
CEnumParameter(nodemap, "ImageCompressionRateOption").SetValue("Lossless");
// To increase the frame rate, tell the camera that it will be able
// to compress any image to at least 70 % of its original size
CIntegerParameter(nodemap, "BslImageCompressionRatio").SetValue(70);
// Get the resulting acquisition frame rate
double resultingFrameRate = CFloatParameter(nodemap, "BslResultingAcquisitionFrameRate").GetValue();
if(resultingFrameRate < desiredFrameRate){    
    // Frame rate isn't high enough for the application.
    // Therefore, enable lossy compression. This allows even
    // lower compression rates, but reduces image quality.
    CEnumParameter(nodemap, "ImageCompressionRateOption").SetValue("FixRatio");
    CIntegerParameter(nodemap, "BslImageCompressionRatio").SetValue(50);
}
// Start image acquisition
// ...
// (Implement your own image grabbing routine here.
// For example, the InstantCamera class provides the StartGrabbing() method.
// Note that you must decompress grabbed images using the CImageDecompressor class.)
// ...
// Determine the compression ratio of the last acquired image
double lastRatio = CFloatParameter(nodemap, "BslImageCompressionLastRatio").GetValue();
// Determine the payload size of the last acquired image in bytes
int64_t lastSize = CIntegerParameter(nodemap, "BslImageCompressionLastSize").GetValue();
// Enable Compression Beyond with lossless compression
camera.Parameters[PLCamera.ImageCompressionMode].SetValue(PLCamera.ImageCompressionMode.BaslerCompressionBeyond);
camera.Parameters[PLCamera.ImageCompressionRateOption].SetValue(PLCamera.ImageCompressionRateOption.Lossless);
// To increase the frame rate, tell the camera that it will be able
// to compress any image to at least 70 % of its original size
camera.Parameters[PLCamera.BslImageCompressionRatio].SetValue(70);
// Get the resulting acquisition frame rate
double resultingFrameRate = camera.Parameters[PLCamera.BslResultingAcquisitionFrameRate].GetValue();
if(resultingFrameRate < desiredFrameRate){    
    // Frame rate isn't high enough for the application.
    // Therefore, enable lossy compression. This allows even
    // lower compression rates, but reduces image quality.
    camera.Parameters[PLCamera.ImageCompressionRateOption].SetValue(PLCamera.ImageCompressionRateOption.FixRatio);
    camera.Parameters[PLCamera.BslImageCompressionRatio].SetValue(50);
}
// Start image acquisition
// ...
// (Implement your own image grabbing routine here.
// For example, the InstantCamera class provides the StartGrabbing() method.
// Note that you must decompress grabbed images using the CImageDecompressor class.)
// ...
// Determine the compression ratio of the last acquired image
double lastRatio = camera.Parameters[PLCamera.BslImageCompressionLastRatio].GetValue();
// Determine the payload size of the last acquired image in bytes
Int64 lastSize = camera.Parameters[PLCamera.BslImageCompressionLastSize].GetValue();
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK;  /* Return value of pylon methods */
double resultingFrameRate = 0;
double lastRatio = 0;
int64_t lastSize = 0;
/* Enable Compression Beyond with lossless compression */
errRes = PylonDeviceFeatureFromString(hdev, "ImageCompressionMode", "BaslerCompressionBeyond");
CHECK(errRes);
errRes = PylonDeviceFeatureFromString(hdev, "ImageCompressionRateOption", "Lossless");
CHECK(errRes);
/* To increase the frame rate, tell the camera that it will be able */
/* to compress any image to at least 70 % of its original size */
errRes = PylonDeviceSetIntegerFeature(hdev, "BslImageCompressionRatio", 70);
CHECK(errRes);
/* Get the resulting acquisition frame rate */
errRes = PylonDeviceGetFloatFeature(hdev, "BslResultingAcquisitionFrameRate", &resultingFrameRate);
CHECK(errRes);
if(resultingFrameRate < desiredFrameRate){    
    /* Frame rate isn't high enough for the application. */
    /* Therefore, enable lossy compression. This allows even */
    /* lower compression rates, but reduces image quality. */
    errRes = PylonDeviceFeatureFromString(hdev, "ImageCompressionRateOption", "FixRatio");
    CHECK(errRes);
    errRes = PylonDeviceSetIntegerFeature(hdev, "BslImageCompressionRatio", 50);
    CHECK(errRes);
}
/* Start image acquisition */
/* ... */
/* (Implement your own image grabbing routine here. */
/* For example, the InstantCamera class provides the StartGrabbing() method. */
/* Note that you must decompress grabbed images using the CImageDecompressor class.) */
/* ... */
/* Determine the compression ratio of the last acquired image */
errRes = PylonDeviceGetFloatFeature(hdev, "BslImageCompressionLastRatio", &lastRatio);
CHECK(errRes);
/* Determine the payload size of the last acquired image in bytes */
errRes = PylonDeviceGetIntegerFeature(hdev, "BslImageCompressionLastSize", &lastSize);
CHECK(errRes);
# Enable Compression Beyond with lossless compression
camera.ImageCompressionMode.Value = "BaslerCompressionBeyond"
camera.ImageCompressionRateOption.Value = "Lossless"
# To increase the frame rate, tell the camera that it will be able
# to compress any image to at least 70 % of its original size
camera.BslImageCompressionRatio.Value = 70
# Get the resulting acquisition frame rate
resultingFrameRate = camera.BslResultingAcquisitionFrameRate.Value
if resultingFrameRate < desiredFrameRate:
    # Frame rate isn't high enough for the application.
    # Therefore, enable lossy compression. This allows even
    # lower compression rates, but reduces image quality.
    camera.ImageCompressionRateOption.Value = "FixRatio"
    camera.BslImageCompressionRatio.Value = 50
# Start image acquisition
# ...
# (Implement your own image grabbing routine here.
# For example, the InstantCamera class provides the StartGrabbing() method.
# Note that you must decompress grabbed images using the CImageDecompressor class.)
# ...
# Determine the compression ratio of the last acquired image
lastRatio = camera.BslImageCompressionLastRatio.Value
# Determine the payload size of the last acquired image in bytes
lastSize = camera.BslImageCompressionLastSize.Value

pylon Viewer를 사용하여 파라미터를 손쉽게 설정할 수도 있습니다.