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

オプティックコントロール#

Optic Control機能を使用すると、レンズなどの光学デバイスを制御できます。

この機能はSLPプロトコルに基づき、カメラ、照明デバイス、および光学デバイス(レンズなど)が互いに直接通信できるようにします。

情報

ILC非搭載のレガシーBasler製ライトおよび販売終了となったBasler Camera Lightsのマニュアルは、現在のBasler Product Documentationには含まれていません。これらの製品に関する情報が必要な場合は、こちらをクリックしてダウンロードできる、以前のリリースのオフラインドキュメントを参照してください。

情報

dart M camera modulesの場合、Optic Control機能は現在、Basler dart Mインターフェイスボード(⁠Interface Board ⁠dart M GigE RJ45 PoEまたは⁠Interface Board dart M GigE RJ45 AUX)を使用している場合にのみ利用可能です。

機能を使用する#

Optic Control機能を使用するには、以下が必要です。

  • オートフォーカス機能を備えたBaslerレンズ。
    適切なレンズに関する情報については、Partner Liquid LensトピックのOptotuneレンズ、またはPartner Motorized LensesトピックのComputar LensConnect Series with Variable Focal Lengthセクションを参照してください。
  • 光学レンズをカメラに接続するための適切なBasler Lens Sync Cable。同期ケーブルを使用すると、照明デバイスとレンズを接続し、カメラの単一のGPIOポートを介してそれらを制御できます。必要なBasler同期ケーブルは、操作する周辺機器によって異なります。
    利用可能なケーブルのバリエーションとサポートされているユースケースについては、Basler Sync Cablesを参照してください。
  • Peripheral Device Control機能を含むファームウェアを実行している互換性のあるカメラ。

オプティックデバイスの初期化#

光学デバイスを使用する前に、初期化する必要があります。

光学デバイスを初期化するには:

  1. Preparing Peripheral DevicesおよびChecking and Clearing Errorsに記載されている手順に従います。
  2. 制御する光学デバイスを選択します。
    最初の光学デバイスについては、次のように設定します。 OpticControllerSelector を Optic1.
  3. 実行します: OpticControllerInitialize 接続されたレンズを初期化するコマンド。
    レンズの種類によっては、内部モーターが動くのが確認できる場合があります。初期化時間もレンズの種類によって異なります。
  4. 次の項目を監視します: OpticControllerStatus パラメーター。初期化が完了すると、パラメーターの値は次のようになります。 Ready。そうならない場合は、以下を参照してください。 エラーのチェックとクリア 以下。

接続されているレンズに応じて、そのレンズがサポートするパラメーターのみを設定に使用できます。

下の表は、光学デバイス内のオプティックコントローラーが取りうるステータスの概要を示しています。

値 意味
Ready 光学デバイスを使用する準備が整っています。
Busy 光学デバイスは現在操作の処理中であり、新しいコマンドに対して一時的に利用できません。
NotConnected オプティックデバイスがカメラに接続されていないか、検出できません。
NotInitialized オプティックデバイスはまだ初期化されていません。デバイスを初期化するには、次を実行します。 OpticControllerInitializeコマンド。
エラー オプティックデバイスでエラーが発生しました。詳細については、Error Statusesテーブルを参照してください。
Initializing オプティックデバイスは現在初期化中です。このプロセス中は、デバイスを操作できない場合があります。

フォーカスの設定#

マニュアルフォーカス#

マニュアルフォーカスは、事前定義された設定を繰り返し切り替える必要がある場合に最適です。オートフォーカスとは異なり、複数の画像を解析する必要がないため、素早く動作します。速度はレンズのタイプによって異なります。

  • リキッドレンズは通常、約20ミリ秒で新しいフォーカスに切り替わります。
  • 電動レンズの場合、速度は変更の大きさに依存します。
    最も近いフォーカス位置から最も遠いフォーカス位置への移動には、中間位置間の切り替えよりも大幅に時間がかかります。

上記 機能を使用する に記載されているすべてのレンズは、 FocusStepper パラメータを使用したフォーカス制御をサポートしています。パラメータ値には直接的な物理的意味はありません。代わりに、レンズがサポートするフォーカス範囲が整数範囲にマッピングされ、 0 は最も近いフォーカス距離に、最大 FocusStepper は最も遠いフォーカス距離に対応します。

一部の校正済みレンズは、 FocalPower パラメータを使用したフォーカス制御もサポートしています。このパラメータは、ディオプター単位のレンズの光学パワーを指定する浮動小数点値です。

オートフォーカス#

カメラはレンズのフォーカスを自動的に調整し、画像で最適なフォーカスを実現できます。カメラのイメージセンサーでキャプチャされた画像を使用します。

情報

オートフォーカス

  • オートフォーカスは画像ベースであり、ユーザー定義のROI(Region of Interest)内で動作します。オートフォーカスにはROI 3を使用する必要があります。
  • オートフォーカスROIにはサイズ制限があり(最大256 x 256ピクセル)、画像全体をカバーすることはできません。その結果、オートフォーカスは画像全体ではなく、構成された Auto Function ROI 内の画像データのみを評価します。
  • オートフォーカスプロセスでは、複数の画像の取り込みが必要です。そのため、フォーカス達成に必要な時間はカメラのフレームレートに大きく依存します。一般的に、フレームレートが高いほど、オートフォーカス動作は速くなります。

情報

オートフォーカスの画像要件

  • オートフォーカスが確実に動作するには、画像に十分なコントラストが必要です。
  • 均一なサーフェスや低コントラストのサーフェスでは、正確なフォーカスに必要な画像詳細が得られない場合があります。
  • エッジ、バーコード、テキスト、およびその他の明確な構造により、オートフォーカスのパフォーマンスと精度を大幅に向上させることができます。

オートフォーカスを使用するには:

  1. オートフォーカスのパラメータは、機能ツリーの Auto Function Control カテゴリにあります。
    このカテゴリを開いて調整します。
  2. カラーカメラでは、 BslAutoFocusColorSelect パラメータを使用してオートフォーカスに使用するカラーチャンネルを選択します。
    レンズの焦点距離は光の波長にも依存するため、最適なフォーカス設定は赤、緑、青の光でわずかに異なります。ほとんどのアプリケーションでは、デフォルト設定の Greenが良い選択肢となります。
  3. 使用 BslAutoFocusStepperLowerLimit および BslAutoFocusStepperUpperLimit で、カメラが検索するフォーカス範囲を制限します。
    オブジェクトが出現する距離範囲が分かっている場合は、両方の制限に対応する FocusStepper の値を設定します。これにより、オートフォーカスを大幅に高速化できます。
  4. 設定するピクセルのカラーコンポーネントを指定するには、 FocusAutoMode パラメータを使用して、カメラがフォーカスを自動制御する方法を選択します。
    • 名前が ImageBasedで始まるモードでは、カメラが画像データを分析して現在のシーンのフォーカスを評価します。 ImageBased はデフォルトのモードであり、ほとんどの状況に適しています。カメラはフォーカス位置を段階的に移動しながら画像をキャプチャし、最適値を見つけます。
    • ImageBasedFast はキャプチャする画像数を減らすためオートフォーカスが早く終了しますが、精度が低くなり、悪条件下では最適値を逃す可能性があります。
    • ImageBasedAccurate は、特に上限および下限のフォーカス制限と組み合わせて使用する場合に、精度を向上させることができます。
  5. Auto Function ROI機能を使用して、オートフォーカスに使用するROI 3を選択します。
    オートフォーカス用のROI 3の最大サイズは256 x 256ピクセルに制限されています。より小さな値にすることも可能です。
  6. 画像のグラブを開始します。
    オートフォーカスには画像取得が必要です。
  7. 設定 FocusAuto を Once でオートフォーカスを開始します。
    カメラは画像のグラブ中にフォーカスを調整します。操作が完了すると、 FocusStepper で見つかった最適値に設定され、 FocusAuto を Off.

情報

イメージ FocalPower パラメータは、接続されたレンズが校正済みの焦点パワー値を提供する場合のみ使用できます。このパラメータのサポートはレンズメーカーによって異なります。

オートフォーカス速度の向上#

オートフォーカスに必要な時間を短縮するには、以下の推奨事項を考慮してください:

  • フォーカス制限を設定する(BslAutoFocusStepperLowerLimit および BslAutoFocusStepperUpperLimit) を使用して、オートフォーカスが最適なフォーカス位置を検索する範囲を制限します。
  • オートフォーカス動作中に Image ROI を縮小することで、達成可能なフレームレートを最大化し、オートフォーカスをより早く完了させることができます。
  • 素早いフォーカス調整に対応した高速なレンズを使用します。

絞りの設定#

レンズが絞り制御に対応している場合は、 ApertureStepper パラメータを使用して絞りを開閉できます。パラメータ値は物理的な絞り (F値) を表すものではありません。そうではなく、レンズがサポートする絞り範囲を整数範囲にマッピングするものであり、値 0 は最大の絞り開放に対応し、最大 ApertureStepper の値は最小の絞りに対応します。

焦点距離の設定#

レンズが焦点距離制御に対応している場合は、 FocalLengthStepper パラメータを使用して焦点距離 (つまりズーム) を調整します。パラメータ値には直接的な物理的意味はありません。そうではなく、レンズがサポートする焦点距離範囲を整数範囲にマッピングするものであり、0 は最短の焦点距離に対応し、最大 FocalLengthStepper の値はレンズがサポートする最長の焦点距離に対応します。

焦点距離を変更した後にフォーカス位置がずれることがあるため、フォーカスの再調整が必要になる場合があります。

エラーのチェックとクリア#

エラーステータス#

イメージ BslPeripheralDeviceErrorStatus パラメータには以下の値を設定できます:

値 意味
Communication Error 光学デバイスとカメラ間のデータ伝送に不具合がある場合、通信エラーが発生します。これは、長すぎるケーブルの使用や、ライン上の過剰なノイズが原因で発生する可能性があります。
接続ロスト 以前接続されていた光学デバイスとの接続が失われました。これは、たとえばケーブルが緩んだ場合などに発生する可能性があります。
No Error エラーは検出されませんでした。
未接続 光学デバイスがカメラに接続されていないか、まだ列挙されていません。次を実行します: BslPeripheralEnumerateDevices コマンドを実行してください。
サポートされていない器具のバージョン 光学デバイスは現在のカメラと互換性がありません。サポートにお問い合わせいただき、ファームウェアアップデートが利用可能かどうかをご確認ください。

サンプルコード#

情報

コードサンプルは、ファームウェアに Peripheral Devices Control 機能が含まれている ace 2、boost R、および dart M カメラにのみ適用されます。

ace 2、boost R、dart M カメラ#
// Select and initialize the optic controller.
camera.OpticControllerSelector.SetValue(OpticControllerSelector_Optic1);
camera.OpticControllerInitialize.Execute();

// Set focus position manually using stepper (0 = nearest focus position).
camera.FocusStepper.SetValue(1000);

// Set focus position manually using focal power (0 = nearest focus position).
camera.FocalPower.SetValue(1.0);

// Set aperture (0 = maximum aperture opening).
camera.ApertureStepper.SetValue(50);

// Set focal length (0 = shortest focal length).
camera.FocalLengthStepper.SetValue(200);

// Configure the autofocus ROI.
camera.AutoFunctionROISelector.SetValue(AutoFunctionROISelector_ROI3);
camera.AutoFunctionROIUseFocus.SetValue(true);
camera.AutoFunctionROIWidth.SetValue(128);
camera.AutoFunctionROIHeight.SetValue(128);
camera.AutoFunctionROIOffsetX.SetValue(840);
camera.AutoFunctionROIOffsetY.SetValue(480);

// Use the green color channel for focus evaluation.
camera.BslAutoFocusColorSelect.SetValue(BslAutoFocusColorSelect_Green);

// Restrict the autofocus search range.
// Limiting the range speeds up the focusing process.
camera.BslAutoFocusStepperLowerLimit.SetValue(800);
camera.BslAutoFocusStepperUpperLimit.SetValue(1200);

// Configure autofocus behavior.
camera.FocusAutoMode.SetValue(FocusAutoMode_ImageBased);

// Start autofocus.
camera.FocusAuto.SetValue(FocusAuto_Once);
INodeMap& nodemap = camera.GetNodeMap();
// Select and initialize the optic controller.
CEnumParameter(nodemap, "OpticControllerSelector").SetValue("Optic1");
CCommandParameter(nodemap, "OpticControllerInitialize").Execute();

// Set focus position manually using stepper (0 = nearest focus position).
CIntegerParameter(nodemap, "FocusStepper").SetValue(1000);

// Set focus position manually using focal power (0 = nearest focus position).
CFloatParameter(nodemap, "FocalPower").SetValue(1.0);

// Set aperture (0 = maximum aperture opening).
CIntegerParameter(nodemap, "ApertureStepper").SetValue(50);

// Set focal length (0 = shortest focal length).
CIntegerParameter(nodemap, "FocalLengthStepper").SetValue(200);

// Configure autofocus ROI.
CEnumParameter(nodemap, "AutoFunctionROISelector").SetValue("ROI3");
CBooleanParameter(nodemap, "AutoFunctionROIUseFocus").SetValue(true);
CIntegerParameter(nodemap, "AutoFunctionROIWidth").SetValue(128);
CIntegerParameter(nodemap, "AutoFunctionROIHeight").SetValue(128);
CIntegerParameter(nodemap, "AutoFunctionROIOffsetX").SetValue(840);
CIntegerParameter(nodemap, "AutoFunctionROIOffsetY").SetValue(480);

// Use the green color channel for focus evaluation.
CEnumParameter(nodemap, "BslAutoFocusColorSelect").SetValue("Green");

// Restrict the autofocus search range.
// Limiting the range speeds up the focusing process.
CIntegerParameter(nodemap, "BslAutoFocusStepperLowerLimit").SetValue(800);
CIntegerParameter(nodemap, "BslAutoFocusStepperUpperLimit").SetValue(1200);

// Configure autofocus behavior.
CEnumParameter(nodemap, "FocusAutoMode").SetValue("ImageBased");

// Start autofocus.
CEnumParameter(nodemap, "FocusAuto").SetValue("Once");
// Select and initialize the optic controller.
camera.Parameters[PLCamera.OpticControllerSelector].SetValue(PLCamera.OpticControllerSelector.Optic1);
camera.Parameters[PLCamera.OpticControllerInitialize].Execute();

// Set focus position manually using stepper (0 = nearest focus position).
camera.Parameters[PLCamera.FocusStepper].SetValue(1000);

// Set focus position manually using focal power (0 = nearest focus position).
camera.Parameters[PLCamera.FocalPower].SetValue(1.0);

// Set aperture (0 = maximum aperture opening).
camera.Parameters[PLCamera.ApertureStepper].SetValue(50);

// Set focal length (0 = shortest focal length).
camera.Parameters[PLCamera.FocalLengthStepper].SetValue(200);

// Configure autofocus ROI.
camera.Parameters[PLCamera.AutoFunctionROISelector].SetValue(PLCamera.AutoFunctionROISelector.ROI3);
camera.Parameters[PLCamera.AutoFunctionROIUseFocus].SetValue(true);
camera.Parameters[PLCamera.AutoFunctionROIWidth].SetValue(128);
camera.Parameters[PLCamera.AutoFunctionROIHeight].SetValue(128);
camera.Parameters[PLCamera.AutoFunctionROIOffsetX].SetValue(840);
camera.Parameters[PLCamera.AutoFunctionROIOffsetY].SetValue(480);

// Use the green color channel for focus evaluation.
camera.Parameters[PLCamera.BslAutoFocusColorSelect].SetValue(PLCamera.BslAutoFocusColorSelect.Green);

// Restrict the autofocus search range.
// Limiting the range speeds up the focusing process.
camera.Parameters[PLCamera.BslAutoFocusStepperLowerLimit].SetValue(800);
camera.Parameters[PLCamera.BslAutoFocusStepperUpperLimit].SetValue(1200);

// Configure autofocus behavior.
camera.Parameters[PLCamera.FocusAutoMode].SetValue(PLCamera.FocusAutoMode.ImageBased);

// Start autofocus.
camera.Parameters[PLCamera.FocusAuto].SetValue(PLCamera.FocusAuto.Once);
/* 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 */
/* Select and initialize the optic controller. */
errRes = PylonDeviceFeatureFromString(hdev, "OpticControllerSelector", "Optic1");
CHECK(errRes);
errRes = PylonDeviceExecuteCommandFeature(hdev, "OpticControllerInitialize");
CHECK(errRes);

/* Set focus position manually using stepper (0 = nearest focus position). */
errRes = PylonDeviceSetIntegerFeature(hdev, "FocusStepper", 1000);
CHECK(errRes);

/* Set focus position manually using focal power (0 = nearest focus position). */
errRes = PylonDeviceSetFloatFeature(hdev, "FocalPower", 1.0);
CHECK(errRes);

/* Set aperture (0 = maximum aperture opening). */
errRes = PylonDeviceSetIntegerFeature(hdev, "ApertureStepper", 50);
CHECK(errRes);

/* Set focal length (0 = shortest focal length). */
errRes = PylonDeviceSetIntegerFeature(hdev, "FocalLengthStepper", 200);
CHECK(errRes);

/* Configure autofocus ROI. */
errRes = PylonDeviceFeatureFromString(hdev, "AutoFunctionROISelector", "ROI3");
CHECK(errRes);
errRes = PylonDeviceSetBooleanFeature(hdev, "AutoFunctionROIUseFocus", 1);
CHECK(errRes);
errRes = PylonDeviceSetIntegerFeature(hdev, "AutoFunctionROIWidth", 128);
CHECK(errRes);
errRes = PylonDeviceSetIntegerFeature(hdev, "AutoFunctionROIHeight", 128);
CHECK(errRes);
errRes = PylonDeviceSetIntegerFeature(hdev, "AutoFunctionROIOffsetX", 840);
CHECK(errRes);
errRes = PylonDeviceSetIntegerFeature(hdev, "AutoFunctionROIOffsetY", 480);
CHECK(errRes);

/* Use the green color channel for focus evaluation. */
errRes = PylonDeviceFeatureFromString(hdev, "BslAutoFocusColorSelect", "Green");
CHECK(errRes);

/* Restrict the autofocus search range. */
/* Limiting the range speeds up the focusing process. */
errRes = PylonDeviceSetIntegerFeature(hdev, "BslAutoFocusStepperLowerLimit", 800);
CHECK(errRes);
errRes = PylonDeviceSetIntegerFeature(hdev, "BslAutoFocusStepperUpperLimit", 1200);
CHECK(errRes);

/* Configure autofocus behavior. */
errRes = PylonDeviceFeatureFromString(hdev, "FocusAutoMode", "ImageBased");
CHECK(errRes);

/* Start autofocus. */
errRes = PylonDeviceFeatureFromString(hdev, "FocusAuto", "Once");
CHECK(errRes);
# Select and initialize the optic controller.
camera.OpticControllerSelector.Value = "Optic1"
camera.OpticControllerInitialize.Execute()

# Set focus position manually using stepper (0 = nearest focus position).
camera.FocusStepper.Value = 1000

# Set focus position manually using focal power (0 = nearest focus position).
camera.FocalPower.Value = 1.0

# Set aperture (0 = maximum aperture opening).
camera.ApertureStepper.Value = 50

# Set focal length (0 = shortest focal length).
camera.FocalLengthStepper.Value = 200

# Configure autofocus ROI.
camera.AutoFunctionROISelector.Value = "ROI3"
camera.AutoFunctionROIUseFocus.Value = True
camera.AutoFunctionROIWidth.Value = 128
camera.AutoFunctionROIHeight.Value = 128
camera.AutoFunctionROIOffsetX.Value = 840
camera.AutoFunctionROIOffsetY.Value = 480

# Use the green color channel for focus evaluation.
camera.BslAutoFocusColorSelect.Value = "Green"

# Restrict the autofocus search range.
# Limiting the range speeds up the focusing process.
camera.BslAutoFocusStepperLowerLimit.Value = 800
camera.BslAutoFocusStepperUpperLimit.Value = 1200

# Configure autofocus behavior.
camera.FocusAutoMode.Value = "ImageBased"

# Start autofocus.
camera.FocusAuto.Value = "Once"

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