The camera emulation devices can be accessed using the pylon API and the pylon Viewer.
In this topic Hide
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:
You can enable camera emulation in the pylon Viewer, in the pylon API, or both.
To enable camera emulation in the pylon Viewer:
If the number of camera emulation devices is set to 0, the Camera Emulation node will not be shown in the Devices pane.
To enable camera emulation in the pylon API:
If PYLON_CAMEMU is not set or set to 0, no emulation devices will be available.
Camera emulation devices can emulate the following standard camera features:
The following features are only available on camera emulation devices and not on physical Basler cameras.
In addition to displaying standard test images, camera emulation allows you to display custom test images that are loaded from disk.
To display a custom test image:
Troubleshooting
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:
/* Custom Test Images*/
// Disable standard test images
camera.TestImageSelector.SetValue(TestImageSelector_Off);
// Enable custom test images
camera.ImageFileMode.SetValue(ImageFileMode_Off);
// 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*/
CEnumerationPtr(nodemap.GetNode("TestImageSelector"))->FromString("Off");
// Enable custom test images
CEnumerationPtr(nodemap.GetNode("ImageFileMode"))->FromString("Off");
// Load custom test image from disk
CStringPtr(nodemap.GetNode("ImageFilename"))->SetValue("c:\images\image1.png");
/*Force Failed Buffer*/
CIntegerPtr(nodemap.GetNode("ForceFailedBufferCount"))->SetValue(40);
// Generate 40 failed buffers
CCommandPtr(nodemap.GetNode("ForceFailedBuffer"))->Execute();
/*Custom Test Images*/
camera.Parameters[PLCamera.TestImageSelector].SetValue(PLCamera.TestImageSelector.Off);
// Enable custom test images
camera.Parameters[PLCamera.ImageFileMode].SetValue(PLCamera.ImageFileMode.Off);
// Load custom test image from disk
camera.Parameters[PLCamera.ImageFilename].SetValue("c:\images\image1.png");
/*Force Failed Buffer*/
camera.Parameters[PLCamera.ForceFailedBufferCount].SetValue(40);
// Generate 40 failed buffers
camera.Parameters[PLCamera.ForceFailedBuffer].Execute();
/*Custom Test Images*/
Pylon.DeviceFeatureFromString(hdev, "TestImageSelector", "Off");
// Enable custom test images
Pylon.DeviceFeatureFromString(hdev, "ImageFileMode", "Off");
// Load custom test image from disk
Pylon.DeviceFeatureFromString(hdev, "ImageFilename", "c:\images\image1.png");
/*Force Failed Buffer*/
Pylon.DeviceSetIntegerFeature(hdev, "ForceFailedBufferCount", 40);
// Generate 40 failed buffers
Pylon.DeviceExecuteCommandFeature(hdev, "ForceFailedBuffer");
/* 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*/
errRes = PylonDeviceFeatureFromString(hdev, "TestImageSelector", "Off");
CHECK(errRes);
/* Enable custom test images */
errRes = PylonDeviceFeatureFromString(hdev, "ImageFileMode", "Off");
CHECK(errRes);
/* Load custom test image from disk */
errRes = PylonDeviceFeatureFromString(hdev, "ImageFilename", "c:\images\image1.png");
CHECK(errRes);
/*Force Failed Buffer*/
errRes = PylonDeviceSetIntegerFeature(hdev, "ForceFailedBufferCount", 40);
CHECK(errRes);
/* Generate 40 failed buffers */
errRes = PylonDeviceExecuteCommandFeature(hdev, "ForceFailedBuffer");
CHECK(errRes);
You can also use the pylon Viewer to easily set the parameters.