The Camera Emulation feature allows you to test basic camera features and create test images without having a physical camera device attached to your computer.
The camera emulation devices can be accessed using the pylon API and the pylon Viewer.
In addition to camera transport layers like GigE Vision or USB3 Vision, pylon offers a transport layer that can create simple camera emulation devices. This allows you to develop applications without the need for a physical camera. It is also useful if you want to develop a multi-camera application and don't have enough cameras at hand.
You can create up to 256 camera emulation devices.
Besides emulating image acquisition and standard camera features, camera emulation devices also offer features that a physical camera does not offer:
If you are using pylon for Linux, camera emulation support is installed by default.
If you are using pylon for Windows and have installed pylon via the runtime redistributable package, camera emulation support is installed by default.
If you are using pylon for Windows and have installed pylon via the pylon Software Suite installer:
If you chose the Camera User or Developer profile during installation, camera emulation support is installed by default.
If you chose the Custom profile during installation, camera emulation support is only installed if you selected the Camera Emulation Support option. If you haven't done that, run the installer again and select that option.
Make sure that camera emulation support is installed.
In the Tools menu of the pylon Viewer, click Options.
In the Options dialog, click Camera Emulation.
On the Camera Emulation page, enter the desired number of camera emulation devices and click OK. The emulation devices will be visible in the Devices pane after a short wait. They can be accessed using the pylon Viewer. If you also want to access the devices in the pylon API, follow the instructions below.
Info
If the number of camera emulation devices is set to 0, the Camera Emulation node will not be shown in the Devices pane.
Make sure that camera emulation support is installed.
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.
Info
If PYLON_CAMEMU is not set or set to 0, no emulation devices will be available.
In addition to displaying standard test images, camera emulation allows you to display custom test images that are loaded from disk.
Info
On Windows, the following image file formats can be loaded: BMP, JPG, PNG, and TIF.
On Linux, the following image file formats can be loaded: PNG and TIF.
To display a custom test image:
Set the TestImageSelector parameter to Off. This disables the use of standard test images.
Set the ImageFileMode parameter to On. This enables the use of custom test images.
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
If you want to display multiple test images:
Place all test images to be displayed in a single directory. The directory must not contain any subdirectories.
Provide the full path of the directory containing the files in the ImageFilename parameter. Example: c:\images\
Acquire at least one image to display the test image(s). If you want to display the image(s) in the pylon Viewer, click the single or continuous shot button on the toolbar.
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.
If the custom test image is displayed in monochrome, switch to a color pixel format (BGR/BGRA/RGB).
If the custom test image isn't displayed in full size, adjust the image ROI parameters (Width, Height, OffsetX, and OffsetY).
The Force Failed Buffer feature allows you to simulate a bad camera connection by generating failed buffers. This can be useful, e.g., to test your exception handling routines.
To generate failed buffers:
Start image acquisition.
Set the ForceFailedBufferCount parameter to the number of failed buffers you want to generate.
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 imagescamera.TestImageSelector.SetValue(TestImageSelector_Off);// Enable custom test imagescamera.ImageFileMode.SetValue(ImageFileMode_On);// Load custom test image from diskcamera.ImageFilename.SetValue("c:\\images\\image1.png");// ** Force Failed Buffer **// Set the number of failed buffers to generate to 40camera.ForceFailedBufferCount.SetValue(40);// Generate 40 failed bufferscamera.ForceFailedBuffer.Execute();
INodeMap&nodemap=camera.GetNodeMap();// ** Custom Test Images **// Disable standard test imagesCEnumParameter(nodemap,"TestImageSelector").SetValue("Off");// Enable custom test imagesCEnumParameter(nodemap,"ImageFileMode").SetValue("On");// Load custom test image from diskCStringParameter(nodemap,"ImageFilename").SetValue("c:\\images\\image1.png");// ** Force Failed Buffer **// Set the number of failed buffers to generate to 40CIntegerParameter(nodemap,"ForceFailedBufferCount").SetValue(40);// Generate 40 failed buffersCCommandParameter(nodemap,"ForceFailedBuffer").Execute();
// ** Custom Test Images **// Disable standard test imagescamera.Parameters[PLCamera.TestImageSelector].SetValue(PLCamera.TestImageSelector.Off);// Enable custom test imagescamera.Parameters[PLCamera.ImageFileMode].SetValue(PLCamera.ImageFileMode.On);// Load custom test image from diskcamera.Parameters[PLCamera.ImageFilename].SetValue("c:\\images\\image1.png");// ** Force Failed Buffer **// Set the number of failed buffers to generate to 40camera.Parameters[PLCamera.ForceFailedBufferCount].SetValue(40);// Generate 40 failed bufferscamera.Parameters[PLCamera.ForceFailedBuffer].Execute();
/* Macro to check for errors */#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)GENAPIC_RESULTerrRes=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 imagescamera.TestImageSelector.Value="Off"# Enable custom test imagescamera.ImageFileMode.Value="On"# Load custom test image from diskcamera.ImageFilename.Value="c:\\images\\image1.png"# ** Force Failed Buffer **# Set the number of failed buffers to generate to 40camera.ForceFailedBufferCount.Value=40# Generate 40 failed bufferscamera.ForceFailedBuffer.Execute()