コンテンツにスキップ
ステージングサーバー
開発サーバー

Scaling#

Scalingカメラ機能を使用すると、画像を拡大/縮小できます。

機能を使用する#

仕組み#

Scaling機能により、以下のパラメータを使用してスケーリングできる仮想センサープレーンが導入されます。 BslScalingFactor パラメータ。以下のパラメータ BslScaledSensorWidth および BslScaledSensorHeight パラメータは、仮想センサーの現在のサイズを示します。

  • スケーリング係数を小さくすると、仮想センサーのサイズが大きくなります。
  • スケーリング係数を大きくすると、仮想センサーのサイズが小さくなります。

式

仮想センサーサイズ = 物理センサーサイズ / BslScalingFactor

例: カメラセンサーの解像度が 2592 x 1944 ピクセルであると仮定します。もし BslScalingFactor パラメータを 0.5 に設定すると、仮想センサーのサイズは物理センサーの 2 倍、つまり 5184 x 3888 ピクセルになります。

拡大#

拡大するには、 BslScalingFactor パラメータを次の値に設定します。 より低い 1.0 より大きい。

これにより仮想センサーのサイズが大きくなりますが、画像ROIのサイズと位置は同じです。

例: 以下の例では、 BslScalingFactor パラメータが 0.5 に設定されています。Image ROI のサイズと位置は変わらないまま、仮想センサーのサイズが半分になります。

その結果、画像コンテンツが拡大表示され、左上に移動します。

例:拡大

縮小#

縮小するには、 BslScalingFactor パラメータを次の値に設定します。 より高い 1.0 より大きい。

これにより仮想センサーのサイズが小さくなりますが、画像ROIのサイズと位置は同じです。

情報

仮想センサーは画像ROIより小さくできません。

そのため、縮小する前に、画像ROIの高さと幅を縮小しなければならない場合があります。

例: 以下の例では、 BslScalingFactor パラメータが 2.0 に設定されています。Image ROI のサイズと位置は変わらないまま、仮想センサーのサイズが 2 倍になります。

その結果、画像コンテンツが縮小表示され、右下に移動します。

例:縮小

サンプルコード#

// 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

pylon Viewer を使用してパラメータを簡単に設定することもできます。