Scaling#
该功能的使用#
运作原理#
Scaling 功能引入了一个可以使用 BslScalingFactor
参数进行缩放的虚拟传感器平面。BslScaledSensorWidth
和 BslScaledSensorHeight
参数指示虚拟传感器的当前大小。
- 较低的缩放系数会增加虚拟传感器的大小。
- 较高的缩放系数会降低虚拟传感器的大小。
公式
虚拟传感器大小 = 物理传感器大小/BslScalingFactor
示例:假设您的相机传感器的分辨率为 2592 x 1944 像素。如果将 BslScalingFactor
参数设置为 0.5,则虚拟传感器将是物理传感器大小的两倍,即 5184 x 3888 像素。
放大#
如要放大,请将 BslScalingFactor
参数设置为低于 1.0 的值。
这增加了虚拟传感器的大小,而 Image ROI 大小和位置保持不变。
Example: In the example below, the BslScalingFactor
parameter is set to 0.5. The size of the virtual sensor halves while the image ROI size and position remain the same.
因此,图像内容将放大显示并移动到左上角。
缩小#
如要缩小,请将 BslScalingFactor
参数设置为高于 1.0 的值。
这降低了虚拟传感器的大小,而 Image ROI 大小和位置保持不变。
信息
虚拟传感器不能小于 Image ROI。
因此,您可能必须先减小 Image ROI 的高度和宽度,然后才能缩小。
示例:在下面的示例中,BslScalingFactor
参数设置为 2.0。虚拟传感器的大小会加倍,而图像 ROI 大小和位置保持不变。
因此,图像内容将缩小显示并移动到左上角。
示例代码#
// Set scaling to 0.5, i.e., set the size of the
// virtual sensor to 2x the size of the physical sensor
camera.BslScalingFactor.SetValue(0.5);
// Get the size of the virtual sensor
double scaledWidth = camera.BslScaledSensorWidth.GetValue();
double scaledHeight = camera.BslScaledSensorHeight.GetValue();
// Disable scaling
camera.BslScalingFactor.SetValue(1.0);
INodeMap& nodemap = camera.GetNodeMap();
// Set scaling to 0.5, i.e., set the size of the
// virtual sensor to 2x the size of the physical sensor
CFloatParameter(nodemap, "BslScalingFactor").SetValue(0.5);
// Get the size of the virtual sensor
double scaledWidth = CFloatParameter(nodemap, "BslScaledSensorWidth").GetValue();
double scaledHeight = CFloatParameter(nodemap, "BslScaledSensorHeight").GetValue();
// Disable scaling
CFloatParameter(nodemap, "BslScalingFactor").SetValue(1.0);
// Set scaling to 0.5, i.e., set the size of the
// virtual sensor to 2x the size of the physical sensor
camera.Parameters[PLCamera.BslScalingFactor].SetValue(0.5);
// Get the size of the virtual sensor
double scaledWidth = camera.Parameters[PLCamera.BslScaledSensorWidth].GetValue();
double scaledHeight = camera.Parameters[PLCamera.BslScaledSensorHeight].GetValue();
// Disable scaling
camera.Parameters[PLCamera.BslScalingFactor].SetValue(1.0);
/* 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 scaledWidth = 0;
double scaledHeight = 0;
/* Set scaling to 0.5, i.e., set the size of the */
/* virtual sensor to 2x the size of the physical sensor */
errRes = PylonDeviceSetFloatFeature(hdev, "BslScalingFactor", 0.5);
CHECK(errRes);
/* Get the size of the virtual sensor */
errRes = PylonDeviceGetFloatFeature(hdev, "BslScaledSensorWidth", &scaledWidth);
CHECK(errRes);
errRes = PylonDeviceGetFloatFeature(hdev, "BslScaledSensorHeight", &scaledHeight);
CHECK(errRes);
/* Disable scaling */
errRes = PylonDeviceSetFloatFeature(hdev, "BslScalingFactor", 1.0);
CHECK(errRes);
# Set scaling to 0.5, i.e., set the size of the
# virtual sensor to 2x the size of the physical sensor
camera.BslScalingFactor.Value = 0.5
# Get the size of the virtual sensor
scaledWidth = camera.BslScaledSensorWidth.Value
scaledHeight = camera.BslScaledSensorHeight.Value
# Disable scaling
camera.BslScalingFactor.Value = 1.0
You can also use the pylon Viewer to easily set the parameters.