Compression Beyond#
이미지 데이터를 압축하면 카메라의 대역폭 사용량이 줄어들거나, 프레임 레이트가 높아지거나, 또는 둘 다 향상될 수 있습니다.
자세한 내용은 Basler 웹사이트의 기능 설명을 참조하세요.
기능 사용법#
작동 원리#
압축은 다음과 같은 상황에서 자동으로 수행됩니다. ImageCompressionMode 로 설정된 경우 BaslerCompressionBeyond.
이 기능을 활성화하면 항상 가능한 한 최대 크기로 이미지를 압축합니다. 이를 통해 카메라가 출력하는 데이터 양("페이로드"), 즉 대역폭 사용량이 줄어듭니다. 이는 멀티 카메라 환경에서 Basler GigE 카메라를 사용할 때 특히 유용합니다.
카메라가 프레임 레이트까지 최적화하도록 하려면 추가적인 구성이 필요합니다. 카메라는 노출이 시작되기 전에 이미지가 얼마나 압축될지 "알 수" 없기 때문입니다.
이를 해결하려면 카메라에 압축 한계를 지정해야 합니다. 최소한 이미지를 압축할 수 있습니다. 압축률을 지정하여 수행합니다(BslImageCompressionRatio parameter)보다 높아야 합니다.
예를 들어, 다음을 설정합니다 BslImageCompressionRatio 파라미터를 90으로 설정하면, 카메라가 모든 이미지를 원래 크기의 최소 90%까지 압축할 수 있음을 카메라에 알립니다. 이 정보를 바탕으로 카메라는 프레임 레이트를 최대 10%까지 높일 수 있습니다.
그러나 값을 너무 낮게 설정하면, 즉 카메라가 예상된 압축률을 달성하지 못하면 프레임이 건너뛰어집니다. 이 경우 다음을 변경할 수 있습니다 ImageCompressionRateOption 파라미터를 다음에서 Lossless (으)로 FixRatio. 이를 통해 더 낮은 압축률을 사용할 수 있지만 이미지 Quality는 저하됩니다.
정보
- 이미지 취득 중에는 다음을 읽어 마지막으로 취득한 이미지의 페이로드 크기와 압축률을 확인할 수 있습니다.
BslImageCompressionLastRatio및BslImageCompressionLastSize파라미터 값입니다. -
Compression Beyond가 활성화되면 pylon Viewer의 이미지 표시 영역 상태 표시줄에 해당 기능에 대한 정보가 표시됩니다.

-
나만의 이미지 그래빙 루틴을 구현할 때는 CImageDecompressor 클래스를 사용하여 그래브된 이미지의 압축을 해제해야 합니다. 자세한 내용은 pylon API Documentation의 Image Decompression을 참조하세요.
Compression Beyond 구성#
Compression Beyond를 구성하는 방법은 요구 사항에 따라 다릅니다.
대역폭 최적화#
카메라가 다음 작업을 수행하도록 하려는 경우를 가정해 보겠습니다.
- 대역폭 사용량 줄이기
- 프레임 레이트 높이기
- 최적의 이미지 Quality 유지하기
이를 달성하려면:
- 카메라가 대기 상태(유휴 상태)인지, 즉 이미지를 캡처하고 있지 않은지 확인하세요.
- 다음 값 중 하나로
ImageCompressionMode매개변수:BaslerCompressionBeyond. - 다음 값 중 하나로
ImageCompressionRateOption매개변수:Lossless. - 다음 값 중 하나로
BslImageCompressionRatio파라미터를 100으로 설정합니다.
이 설정을 사용하면 카메라가 image Quality 저하를 최소화하면서 이미지를 최대한 압축합니다.
무손실 압축을 통한 대역폭 및 프레임 레이트 최적화#
카메라가 다음 작업을 수행하도록 하려는 경우를 가정해 보겠습니다.
- 대역폭 사용량 줄이기
- 프레임 레이트 높이기
- 최적의 이미지 Quality 유지하기
이를 달성하려면:
- 카메라가 대기 상태(유휴 상태)인지, 즉 이미지를 캡처하고 있지 않은지 확인하세요.
- 다음 값 중 하나로
ImageCompressionMode매개변수:BaslerCompressionBeyond. - 다음 값 중 하나로
ImageCompressionRateOption매개변수:Lossless. - 다음 값 중 하나로
BslImageCompressionRatioparameter 값을 100보다 낮은 값(예: 90)으로 설정합니다. - 다음의 값을 가져옵니다:
BslResultingAcquisitionFrameRateparameter를 사용하여 예상 프레임 레이트를 확인합니다. - 애플리케이션에 필요한 프레임 레이트가 충분히 나오지 않으면, 더 낮은 값으로 4단계와 5단계를 반복합니다.
BslImageCompressionRatio파라미터 값입니다. - 이미지 취득을 시작합니다. 카메라가 프레임 누락 없이 이미지를 취득할 수 없는 경우, 원하는 프레임 레이트를 달성할 수 없습니다. 다음 방법을 시도해 보세요.
- 더 낮은 프레임 레이트가 허용되는 경우,
BslImageCompressionRatioparameter 값을 높여 카메라가 지속적으로 이미지를 취득할 수 있도록 합니다. - 더 낮은 image Quality가 허용되는 경우, 아래의 절차를 수행합니다.
- 더 낮은 프레임 레이트가 허용되는 경우,
손실 압축을 통한 대역폭 및 프레임 레이트 최적화#
정보
항상 lossless compression을 먼저 시도하세요. lossless compression으로 원하는 결과를 얻을 수 없는 경우에만 lossy compression을 사용하세요.
카메라가 다음 작업을 수행하도록 하려는 경우를 가정해 보겠습니다.
- 대역폭 사용량 줄이기
- 프레임 레이트 높이기
- 최적의 이미지 Quality 유지하기
이를 달성하려면:
- 카메라가 대기 상태(유휴 상태)인지, 즉 이미지를 캡처하고 있지 않은지 확인하세요.
- 다음 값 중 하나로
ImageCompressionMode매개변수:BaslerCompressionBeyond. - 다음 값 중 하나로
ImageCompressionRateOption매개변수:FixRatio. - 다음 값 중 하나로
BslImageCompressionRatio매개변수:100. - 최소 하나 이상의 이미지를 취득합니다.
- 다음의 값을 가져옵니다:
BslImageCompressionLastRatio파라미터.
이 값은 lossless 및 lossy 이미지 취득 간의 임계값을 나타냅니다. - 다음 값 중 하나로
BslImageCompressionRatioparameter 값을 다음 값보다 낮게 설정합니다.BslImageCompressionLastRatio파라미터.
parameter 값이 낮을수록 image Quality가 떨어집니다. - 이미지 취득을 시작합니다. 카메라가 프레임 누락 없이 이미지를 취득할 수 없는 경우,
BslImageCompressionRatioparameter 값을 높여 카메라가 이미지를 정상적으로 취득할 수 있도록 합니다.
이 설정을 사용하면 lossless compression에 비해 대역폭 사용량을 줄이고 더 높은 프레임 레이트를 달성할 수 있습니다. 단, 이 경우 image 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를 사용하여 파라미터를 손쉽게 설정할 수 있습니다.