コンテンツにスキップ

カメラのエミュレーション#

カメラエミュレーション機能を使用すると、物理的なカメラデバイスをコンピューターに接続しなくても、基本的なカメラ機能をテストしたり、テスト画像を作成したりできます。

カメラエミュレーションデバイスには、pylon APIやpylon Viewerを使用してアクセスできます。

概要#

GigE VisionやUSB3 Visionのようなカメラトランスポート層に加えて、pylonはシンプルなカメラエミュレーションデバイスを作成できるトランスポート層を提供してします。これにより、物理的なカメラを必要とせずにアプリケーションを開発できます。また、マルチカメラアプリケーションを開発したい場合や、手元に十分なカメラがない場合にも便利です。

最大256個のカメラエミュレーションデバイスを作成できます。

カメラエミュレーションデバイスには、画像取得と標準カメラ機能のエミュレーションに加え、次のような物理的なカメラにはない機能もあります。

カメラエミュレーションの有効化#

カメラエミュレーションは、pylon Viewer、pylon APIの、またはその両方で有効にできます。

カメラエミュレーションサポートのインストール#

  • pylon for Linuxを使用している場合、カメラエミュレーションサポートはデフォルトでインストールされます。
  • pylon for Windowsを使用していて、ランタイム再頒布可能パッケージを介してpylonをインストールした場合、カメラエミュレーションサポートはデフォルトでインストールされます。
  • pylon for Windowsを使用しており、pylon Camera Software Suiteインストーラーを介してpylonをインストールした場合は、次のとおりになります。
    • インストール時にCamera UserまたはDeveloperプロファイルを選択した場合、カメラエミュレーションサポートはデフォルトでインストールされます。
    • インストール時にCustomプロファイルを選択した場合、カメラエミュレーションサポートはCamera Emulation Supportオプションを選択した場合にのみインストールされます。選択しなかった場合は、インストーラーを再度実行して、そのオプションを選択してください。

pylon Viewerでカメラエミュレーションを有効にする#

pylon Viewerでカメラエミュレーションを有効にするには:

  1. カメラエミュレーションサポートがインストールされていることを確認します。
  2. pylon ViewerのToolsメニューで、Optionsをクリックします。
  3. Optionsダイアログで、Camera Emulationをクリックします。
  4. Camera Emulationページで、必要なカメラエミュレーションデバイスの数を入力し、OKをクリックします。
    少し待つと、エミュレーションデバイスがDevicesペインに表示されます。
    pylon Viewerを使用してアクセスできます。pylon API内のデバイスにもアクセスする場合は、以下の手順に従います。

情報

カメラエミュレーションデバイスの数が0に設定されている場合、Camera EmulationノードはDevicesペインに表示されません。

pylon APIでカメラエミュレーションを有効にする#

pylon APIでカメラエミュレーションを有効にするには:

  1. カメラエミュレーションサポートがインストールされていることを確認します。
  2. Add a system environment variable named PYLON_CAMEMU and set its value to the desired number of emulation devices.
    Example: PYLON_CAMEMU=2
    This will provide two emulation devices.
    They can be accessed using the pylon API. If you also want to access the devices in the pylon Viewer, follow the instructions above.

情報

If PYLON_CAMEMU is not set or set to 0, no emulation devices will be available.

標準的なカメラ機能#

カメラエミュレーションデバイスは、次の標準カメラ機能をエミュレートできます。

追加機能#

次の機能は、カメラエミュレーションデバイスのみで使用でき、物理的なBaslerカメラでは使用できません

カスタムTest Imagesの表示#

標準の試験画像の表示に加えて、カメラエミュレーションでは、ディスクからロードされたカスタム試験画像を表示できます。

情報

  • Windowsでは、BMP、JPG、PNG、TIFの画像ファイル形式をロードできます。
  • Linuxでは、PNGおよびTIFの画像ファイル形式をロードできます。

カスタム試験画像を表示するには:

  1. Set the TestImageSelector parameter to Off.
    This disables the use of standard test images.
  2. Set the ImageFileMode parameter to On.
    This enables the use of custom test images.
  3. If you want to display a single test image, provide the image file name, including the full path, in the ImageFilename parameter.
    Example: c:\images\my-test-image.png
  4. 複数の試験画像を表示する場合は、次の手順に従います。

    1. すべての試験画像が1つのディレクトリーに表示されるように配置します。
      ディレクトリーにサブディレクトリーを入れないでください。
    2. Provide the full path of the directory containing the files in the ImageFilename parameter.
      Example: c:\images\
  5. 1つ以上の画像を取得して、試験画像を表示します。pylon Viewerに画像を表示する場合は、ツールバーのシングル撮影ボタンまたは連続撮影ボタンをクリックします。

トラブルシューティング#

  • If the custom test image isn't displayed, i.e., the image displayed is completely black, then pylon couldn't load the file. Check the file name or path provided in the ImageFilename parameter. If you provided a directory name, make sure that the directory doesn't contain any subdirectories.
  • カスタム試験画像がモノクロで表示されている場合は、カラーピクセルフォーマット(BGR/BGRA/RGB)に切り替えます。
  • If the custom test image isn't displayed in full size, adjust the image ROI parameters (Width, Height, OffsetX, and OffsetY).

失敗したバッファーの生成#

バッファーの強制失敗機能を使用すると、障害が発生したバッファーを生成して、不良なカメラ接続をシミュレートできます。これは、例外処理ルーチンをテストする場合などに便利です。

失敗したバッファーを生成するには:

  1. 画像取得を開始します。
  2. Set the ForceFailedBufferCount parameter to the number of failed buffers you want to generate.
  3. Execute the ForceFailedBuffer command.
    The camera emulation device will now generate corrupt images. The number of corrupt images depends on the value of the ForceFailedBufferCount parameter.

サンプルコード#

// ** Custom Test Images **
// Disable standard test images
camera.TestImageSelector.SetValue(TestImageSelector_Off);
// Enable custom test images
camera.ImageFileMode.SetValue(ImageFileMode_On);
// Load custom test image from disk
camera.ImageFilename.SetValue("c:\\images\\image1.png");
// ** Force Failed Buffer **
// Set the number of failed buffers to generate to 40
camera.ForceFailedBufferCount.SetValue(40);
// Generate 40 failed buffers
camera.ForceFailedBuffer.Execute();
INodeMap& nodemap = camera.GetNodeMap();
// ** Custom Test Images **
// Disable standard test images
CEnumParameter(nodemap, "TestImageSelector").SetValue("Off");
// Enable custom test images
CEnumParameter(nodemap, "ImageFileMode").SetValue("On");
// Load custom test image from disk
CStringParameter(nodemap, "ImageFilename").SetValue("c:\\images\\image1.png");
// ** Force Failed Buffer **
// Set the number of failed buffers to generate to 40
CIntegerParameter(nodemap, "ForceFailedBufferCount").SetValue(40);
// Generate 40 failed buffers
CCommandParameter(nodemap, "ForceFailedBuffer").Execute();
// ** Custom Test Images **
// Disable standard test images
camera.Parameters[PLCamera.TestImageSelector].SetValue(PLCamera.TestImageSelector.Off);
// Enable custom test images
camera.Parameters[PLCamera.ImageFileMode].SetValue(PLCamera.ImageFileMode.On);
// Load custom test image from disk
camera.Parameters[PLCamera.ImageFilename].SetValue("c:\\images\\image1.png");
// ** Force Failed Buffer **
// Set the number of failed buffers to generate to 40
camera.Parameters[PLCamera.ForceFailedBufferCount].SetValue(40);
// Generate 40 failed buffers
camera.Parameters[PLCamera.ForceFailedBuffer].Execute();
/* 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 */
/* ** Custom Test Images ** */
/* Disable standard test images */
errRes = PylonDeviceFeatureFromString(hdev, "TestImageSelector", "Off");
CHECK(errRes);
/* Enable custom test images */
errRes = PylonDeviceFeatureFromString(hdev, "ImageFileMode", "On");
CHECK(errRes);
/* Load custom test image from disk */
errRes = PylonDeviceFeatureFromString(hdev, "ImageFilename", "c:\\images\\image1.png");
CHECK(errRes);
/* ** Force Failed Buffer ** */
/* Set the number of failed buffers to generate to 40 */
errRes = PylonDeviceSetIntegerFeature(hdev, "ForceFailedBufferCount", 40);
CHECK(errRes);
/* Generate 40 failed buffers */
errRes = PylonDeviceExecuteCommandFeature(hdev, "ForceFailedBuffer");
CHECK(errRes);
# ** Custom Test Images **
# Disable standard test images
camera.TestImageSelector.Value = "Off"
# Enable custom test images
camera.ImageFileMode.Value = "On"
# Load custom test image from disk
camera.ImageFilename.Value = "c:\\images\\image1.png"
# ** Force Failed Buffer **
# Set the number of failed buffers to generate to 40
camera.ForceFailedBufferCount.Value = 40
# Generate 40 failed buffers
camera.ForceFailedBuffer.Execute()

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