Scaling#
Camera Modules with Integrated ISP#
On dart camera modules with an integrated ISP (daA…mci cameras), the Scaling feature allows you to zoom in and out of your images.
To achieve this, the Scaling feature introduces a virtual sensor plane that can be scaled using the BslScalingFactor
parameter. The BslScaledSensorWidth
and BslScaledSensorHeight
parameters indicate the current size of the virtual sensor.
- A lower scaling factor increases the size of the virtual sensor.
- A higher scaling factor decreases the size of the virtual sensor.
Formula
Virtual sensor size = Physical sensor size / BslScalingFactor
Example: Assume your camera sensor has a resolution of 2592 x 1944 pixels. If you set the BslScalingFactor
parameter to 0.5, the virtual sensor will be twice the size of the physical sensor, i.e., 5184 x 3888 pixels.
Zooming In#
To zoom in, set the BslScalingFactor
parameter to a value lower than 1.0.
This increases the size of the virtual sensor while the image ROI size and position remain the same.
Example: In the example below, the BslScalingFactor
parameter is set to 0.5. The size of the virtual sensor doubles while the image ROI size and position remain the same.
As a result, image content will appear zoomed in and shifted to the upper left.
Zooming Out#
To zoom out, set the BslScalingFactor
parameter to a value higher than 1.0.
This decreases the size of the virtual sensor while the image ROI size and position remain the same.
Info
The virtual sensor can't be smaller than the image ROI.
Therefore, you may have to reduce the height and width of the image ROI before you can zoom out.
Example: In the example below, the BslScalingFactor
parameter is set to 2.0. The size of the virtual sensor doubles while the image ROI size and position remain the same.
As a result, image content will appear zoomed out and shifted to the lower right.
Camera Modules without Integrated ISP#
On dart camera modules without an integrated ISP (daA…mc cameras), the Scaling feature allows you to downscale images from sensor size to the size of the image ROI.
For example, assume your camera sensor has a resolution of 2592 x 1944 pixels. Also assume you set the image ROI to 640 x 480 pixels. Now, if you enable scaling, images will be downscaled from 2592 x 1944 to 640 x 480 pixels.
If the aspect ratio of the image ROI doesn't match the aspect ratio of the sensor, output images will be cropped to avoid distortion. For example, assume the aspect ratio of the sensor is 4:3 (e.g., 2592 x 1944 pixels). Also assume you set the image ROI to 500 x 300 pixels. Keeping an aspect ratio of 4:3 would require a resolution of 500 x 375. Therefore, to avoid distortion, the camera crops 75 pixels from the width.
To enable scaling, set the BslScalingEnable
parameter to true
.
Sample Code#
Cameras with Integrated ISP#
// 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);
/* 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);
Cameras without Integrated ISP#
// Enable scaling
camera.BslScalingEnable.SetValue(true);
INodeMap& nodemap = camera.GetNodeMap();
// Enable scaling
CBooleanParameter(nodemap, "BslScalingEnable").SetValue(true);
/* 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 */
/* Enable scaling */
errRes = PylonDeviceSetBooleanFeature(hdev, "BslScalingEnable", 1);
CHECK(errRes);
You can also use the pylon Viewer to easily set the parameters.