Scaling#
ISP内蔵カメラモジュール#
ISPを内蔵したdartカメラモジュール(daA...mciカメラ)では、Scaling機能を使用して、画像を拡大および縮小できます。
これを実現するために、Scaling機能では、BslScalingFactor
パラメーターを使用してスケーリングできる仮想センサー平面を導入しています。BslScaledSensorWidth
およびBslScaledSensorHeight
パラメーターは、仮想センサーの現在のサイズを示します。
- スケーリング係数を小さくすると、仮想センサーのサイズが大きくなります。
- スケーリング係数を大きくすると、仮想センサーのサイズが小さくなります。
式
仮想センサーサイズ = 物理センサーサイズ/BslScalingFactor
例:カメラセンサーの解像度が2592 x 1944ピクセルであるとします。BslScalingFactor
パラメーターを0.5に設定すると、仮想センサーは物理センサーの2倍のサイズ(5184 x 3888ピクセル)になります。
拡大#
拡大するには、BslScalingFactor
パラメーターを1.0未満の値に設定します。
これにより仮想センサーのサイズが大きくなりますが、画像ROIのサイズと位置は同じです。
例:次の例では、BslScalingFactor
パラメーターは0.5に設定されています。仮想センサーのサイズは2倍になりますが、画像ROIのサイズと位置は同じままです。
その結果、画像コンテンツが拡大表示され、左上に移動します。
縮小#
縮小するには、BslScalingFactor
パラメーターを1.0より大きい値に設定します。
これにより仮想センサーのサイズが小さくなりますが、画像ROIのサイズと位置は同じです。
情報
仮想センサーは画像ROIより小さくできません。
そのため、縮小する前に、画像ROIの高さと幅を縮小しなければならない場合があります。
例:次の例では、BslScalingFactor
パラメーターは2.0に設定されています。仮想センサーのサイズは2倍になりますが、画像ROIのサイズと位置は同じままです。
その結果、画像コンテンツが縮小表示され、右下に移動します。
内蔵ISPなしのカメラモジュール#
ISPを内蔵していないdartカメラモジュール(daA...mcカメラ)では、Scaling機能を使用して、センサーのサイズから画像ROIのサイズに、画像をダウンスケールできます。
例えば、カメラセンサーの解像度が2592 x 1944画素であるとします。また、画像ROIを640 x 480画素に設定したとします。ここで、スケーリングを有効にすると、画像は2592 x 1944から640 x 480画素に縮小されます。
画像ROIの縦横比がセンサーの縦横比と一致しない場合は、歪みを避けるために出力画像がクロップされます。例えば、センサーのアスペクト比が4:3(2592 x 1944画素など)であるとします。また、画像ROIを500 x 300画素に設定したと仮定します。アスペクト比4:3を維持するには、500 x 375の解像度が必要です。したがって、ゆがみを避けるために、カメラは幅から75画素をクロップします。
スケーリングを有効にするにBslScalingEnable
パラメーターをtrue
に設定します。
サンプルコード#
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);
内蔵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);
pylonViewerアを使用して、パラメーターを簡単に設定することもできます。