### Example: Install pylon Runtime with Exclusions Source: https://docs.baslerweb.com/knowledge/redistributable-pylon-runtime-installation-options Example command to install the pylon Runtime with all features except GigE drivers, DirectShow, and Twain. ```bash pylon_Runtime_.exe /exclude=DirectShow;Twain;GigE_Runtime_GigE_Performance_Driver;GigE_Filter_Driver ``` -------------------------------- ### Implementation of Start Acquisition Source: https://docs.baslerweb.com/frame-grabbers/siso_genicam Example showing the internal logic for starting acquisition using a command. ```c int Sgc_startAcquisition(SgcCameraHandle * camera, unsigned int start) { int result = SGC_OK; if (start) { result = Sgc_executeCommand(camera, "AcquisitionStart"); } return result; } ``` -------------------------------- ### Get Framegrabber SDK Installer Help Source: https://docs.baslerweb.com/frame-grabbers/installing-the-framegrabber-sdk.html Use this command to display all available installation parameters for the Framegrabber SDK installer script, along with their default values. ```bash sudo ./[NameOfFramegrabberSDKInstallerFile]-h ``` -------------------------------- ### Run Triton Inference Server Setup Script Source: https://docs.baslerweb.com/getting-started-with-pylon-ai Makes the setup script executable and then runs it with root permissions to install the Triton Inference Server. ```bash sudo chmod +x setup-pylon-ai-triton-inference-server.sh && sudo ./setup-pylon-ai-triton-inference-server.sh ``` -------------------------------- ### Example: Get Link Configuration Source: https://docs.baslerweb.com/frame-grabbers/siso_genicam Example demonstrating how to retrieve the number of links and the link speed using Sgc_getCameraPropertyWithType. ```APIDOC ## Example: Get Link Configuration ### Description This example demonstrates how to retrieve the number of links and the link speed of a camera using the `Sgc_getCameraPropertyWithType` function. ### Method C Function Call ### Endpoint N/A ### Parameters N/A ### Request Example ```c unsigned int numberOfLinks = 0; unsigned int linkSpeed = 0; int type = SGC_PROPERTY_TYPE_UINT; int result = Sgc_getCameraPropertyWithType(camera, CAM_PROP_NROFLINKS, &linkSpeed, &type, nullptr); if (result == SGC_OK) { result = Sgc_getCameraPropertyWithType(camera, CAM_PROP_LINKSPEED, &numberOfLinks, &type, nullptr); } if (result == SGC_OK) { std::cout << "Link configuration: " << numberOfLinks << " x " << (1e-3 * linkSpeed) << " Gbit/s" << std::endl; } ``` ### Response #### Success Response Prints the link configuration to standard output if successful. #### Response Example ``` Link configuration: 2 x 10 Gbit/s ``` ### Error Handling Checks the return value of `Sgc_getCameraPropertyWithType` for `SGC_OK` before proceeding. ``` -------------------------------- ### Install Camera Enablement Package Source: https://docs.baslerweb.com/gmsl-adapter-kit-for-nvidia-jetson-orin-nano Extracts and executes the setup script for the Basler Camera Enablement Package. ```bash tar -xf basler_cep_basler_nvidia_devkit_4ch_4.4.0.tar.gz cd basler_cep_basler_nvidia_devkit_4ch_4.4.0 sudo ./setup.sh ``` -------------------------------- ### Install NumPy Example Source: https://docs.baslerweb.com/visualapplets/new-features-in-visualapplets-3-6-0 Example command to install the numpy module using pip. This is run from the Windows Command Prompt after navigating to the python313 folder. ```bash python -m pip install numpy ``` -------------------------------- ### Initialize GrabTwoCameras Sample Environment Source: https://docs.baslerweb.com/pylonapi/c/samples Setup and include directives for the multi-camera acquisition sample. ```c #ifndef _WIN32_WINNT # define _WIN32_WINNT 0x0400 #endif #include #include #include #include #include #ifdef GENAPIC_LINUX_BUILD # include # include # include ``` -------------------------------- ### Create Display Window Example Source: https://docs.baslerweb.com/frame-grabbers/display_lib Example demonstrating how to retrieve image dimensions and pixel format, then create a display window matching these properties. Error handling is included for parameter retrieval and display creation. ```c // get image dimensions and pixel format from applet int result = FG_INVALID_PARAMETER; int width = 0, height = 0, fgFormat = 0; int widthId = Fg_getParameterIdByName(fg, "FG_WIDTH"); int heightId = Fg_getParameterIdByName(fg, "FG_HEIGHT"); int fgFormatId = Fg_getParameterIdByName(fg, "FG_FORMAT"); if (widthId > 0 && heightId > 0 && fgFormatId > 0) { result = Fg_getParameterWithType(fg, widthId, &width, dma); if (result == FG_OK) { result = Fg_getParameterWithType(fg, heightId, &height, dma); } if (result == FG_OK) { result = Fg_getParameterWithType(fg, fgFormatId, &fgFormat, dma); } } // get number of bits per pixel for the format int bitsPerPixel = FG_INVALID_VALUE; if (result == FG_OK) { bitsPerPixel = Fg_getBitsPerPixel(fgFormat); } if (bitsPerPixel <= 0) { result = FG_INVALID_VALUE; } // create a display int display = FG_INVALID_HANDLE; if (result == FG_OK) { display = CreateDisplay(bitsPerPixel, width, height); } if (display >= 0) { // use display ... CloseDisplay(display); } ``` -------------------------------- ### Display Help Information Source: https://docs.baslerweb.com/knowledge/redistributable-pylon-runtime-installation-options Use /help or /? to display help information about the installation options. This is useful for understanding available commands. ```bash /help or /? ``` -------------------------------- ### Get Exposure Start Delay Value Source: https://docs.baslerweb.com/exposure-start-delay Retrieves the current exposure start delay setting from the camera object. ```python d = camera.BslExposureStartDelay.Value ``` -------------------------------- ### Connect and Configure Camera Source: https://docs.baslerweb.com/frame-grabbers/siso_genicam Example demonstrating how to connect to a camera and set image dimensions. ```c int result = Sgc_connectCamera(camera); if (result == SGC_OK) { result = Sgc_setIntegerValue(camera, "Width", 1920); } if (result == SGC_OK) { result = Sgc_setIntegerValue(camera, "Height", 1080); } ``` -------------------------------- ### Initialize and Connect Node Map Source: https://docs.baslerweb.com/frame-grabbers/siso_genicam Example demonstrating how to download camera XML, initialize the node map, and set camera parameters like width and height. ```cpp try { // download camera XML int result = Sgc_loadCameraXml(camera); if (result != SGC_OK) throw std::runtime_error("Failed to download camera XML"); // get size of XML unsigned int size = 0; unsigned int propertyType = SGC_PROPERTY_TYPE_STRING; result = Sgc_getCameraPropertyWithType(camera, CAM_PROP_XML_DATA, nullptr, &propertyType, &size); if (result != SGC_OK || size == 0) throw std::runtime_error("Failed to determine size of camera XML"); // create buffer and extract camera XML std::unique_ptr xml(new char[size]); result = Sgc_getCameraPropertyWithType(camera, CAM_PROP_XML_DATA, xml.get(), &propertyType, &size); if (result != SGC_OK) throw std::runtime_error("Failed to extract camera XML"); // create device port and node map DevicePort port(camera); GENAPI_NAMESPACE::CNodeMapRef nodeMap; // initialize and connect node map nodeMap._LoadXMLFromString(xml.get()); if (!nodeMap._Connect(&port, "Device")) throw std::runtime_error("Failed to connect node map to device port"); // use node map to access camera features ... // set width GENAPI_NAMESPACE::CIntegerPtr width = nodeMap._GetNode("Width"); if (width != nullptr) { width->SetValue(1920); } // set height GENAPI_NAMESPACE::CIntegerPtr height = nodeMap._GetNode("Height"); if (height != nullptr) { height->SetValue(1080); } } catch (GENICAM_NAMESPACE::GenericException & x) { // handle GenICam exceptions ... } catch (std::exception & x) { // handle C++ standard exceptions ... } ``` -------------------------------- ### CPylonDataComponent GetOffsetY Source: https://docs.baslerweb.com/pylonapi/cpp/class_pylon_1_1_c_pylon_data_component Gets the starting row. ```APIDOC ## GetOffsetY# ### Description Gets the starting row. ### Method GetOffsetY ### Return Returns the starting row. ### Error Safety Does not throw C++ exceptions. ### Thread Safety This class is not thread-safe. If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. ``` -------------------------------- ### CPylonDataComponent GetOffsetX Source: https://docs.baslerweb.com/pylonapi/cpp/class_pylon_1_1_c_pylon_data_component Gets the starting column. ```APIDOC ## GetOffsetX# ### Description Gets the starting column. ### Method GetOffsetX ### Return Returns the starting column. ### Error Safety Does not throw C++ exceptions. ### Thread Safety This class is not thread-safe. If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. ``` -------------------------------- ### Initialize Action Command Sample Source: https://docs.baslerweb.com/pylonapi/cpp/sample_code Includes necessary headers and provides setup notes for using GigE Vision action commands with multiple cameras. ```cpp // Grab_UsingActionCommand.cpp /* Note: Before getting started, Basler recommends reading the "Programmer's Guide" topic in the pylon C++ API documentation delivered with pylon. If you are upgrading to a higher major version of pylon, Basler also strongly recommends reading the "Migrating from Previous Versions" topic in the pylon C++ API documentation. This sample shows how to issue a GigE Vision ACTION_CMD to multiple cameras. By using an action command multiple cameras can be triggered at the same time compared to software triggering, which must be triggered individually. To make the configuration of multiple cameras easier this sample uses the CInstantCameraArray class. It also uses a CActionTriggerConfiguration to set up the basic action command features. */ #include // for time #include // for rand & srand // Include files to use the pylon API. #include #ifdef PYLON_WIN_BUILD ``` -------------------------------- ### Run pylon GigE Configurator commands Source: https://docs.baslerweb.com/pylon-gige-configurator-%28cli-version%29 Basic examples for listing adapters, viewing help, and configuring IP addresses with specific network classes. ```bash PylonGigEConfigurator list PylonGigEConfigurator auto-all -h PylonGigEConfigurator auto-ip -a "Ethernet 2" --class C ``` -------------------------------- ### Camera Acquisition Setup Source: https://docs.baslerweb.com/pylonapi/net/Samples Demonstrates initializing a camera, registering event handlers, and switching between continuous and software-triggered acquisition modes. ```csharp internal static void Main() { // The exit code of the sample application. int exitCode = 0; try { // Create a camera object that selects the first camera device found. // More constructors are available for selecting a specific camera device. using (Camera camera = new Camera()) { IGrabResult result; // Print the model name of the camera. Console.WriteLine( "Using device: {0}", camera.CameraInfo[CameraInfoKey.ModelName] ); Console.WriteLine(); // Print the device type String deviceType = camera.CameraInfo[CameraInfoKey.DeviceType]; Console.WriteLine( "Testing {0} Camera Params:", deviceType ); Console.WriteLine( "==============================" ); //Register handler for acquired images camera.StreamGrabber.ImageGrabbed += OnImageGrabbed; Console.WriteLine( "Grab using continuous acquisition:" ); // Register the standard configuration event handler for setting up the camera for continuous acquisition. camera.CameraOpened += Configuration.AcquireContinuous; // The camera's Open() method calls the configuration handler's method that // applies the required parameter modifications. camera.Open(); // Grab some images for demonstration. camera.StreamGrabber.Start( countOfImagesToGrab ); while (camera.StreamGrabber.IsGrabbing) { result = camera.StreamGrabber.RetrieveResult( 5000, TimeoutHandling.ThrowException ); } // Close the camera camera.Close(); //------------------------------------------------------------- Console.WriteLine( "Grab using software trigger mode:" ); // Register the standard configuration event handler for setting up the camera for software // triggering. camera.CameraOpened += Configuration.SoftwareTrigger; // The camera's Open() method calls the configuration handler's method that // applies the required parameter modifications. camera.Open(); // Check if camera supports waiting for trigger ready if (camera.CanWaitForFrameTriggerReady) { // StartGrabbing() calls the camera's Open() automatically if the camera is not open yet. // The Open method calls the configuration handler's OnOpened() method that // sets the required parameters for enabling software triggering. // Grab some images for demonstration. ``` -------------------------------- ### Determine Exposure Start Delay in C# Source: https://docs.baslerweb.com/exposure-start-delay Access the BslExposureStartDelay feature in C# to get the exposure start delay in microseconds. This method uses the Parameters collection. ```csharp // Determine the exposure start delay at the current settings double d = camera.Parameters[PLCamera.BslExposureStartDelay].GetValue(); ``` -------------------------------- ### Initialize Pylon Multicast Sample Source: https://docs.baslerweb.com/pylonapi/cpp/sample_code Includes necessary headers and setup for the Grab_MultiCast sample, which allows multiple instances to monitor a GigE camera stream. ```cpp // Grab_MultiCast.cpp /* Note: Before getting started, Basler recommends reading the "Programmer's Guide" topic in the pylon C++ API documentation delivered with pylon. If you are upgrading to a higher major version of pylon, Basler also strongly recommends reading the "Migrating from Previous Versions" topic in the pylon C++ API documentation. This sample demonstrates how to open a camera in multicast mode and how to receive a multicast stream. Two instances of this application must be started simultaneously on different computers. The first application started on computer A acts as the controlling application and has full access to the GigE camera. The second instance started on computer B opens the camera in monitor mode. This instance is not able to control the camera but can receive multicast streams. To get the sample running, start this application first on computer A in control mode. After computer A has begun to receive frames, start the second instance of this application on computer B in monitor mode. */ // Include files to use the pylon API. #include #ifdef PYLON_WIN_BUILD # include #endif // Include file to use pylon universal instant camera parameters. #include // Include files used by samples. #include "../include/ConfigurationEventPrinter.h" #include "../include/ImageEventPrinter.h" // Include file for _kbhit #if defined(PYLON_WIN_BUILD) #include #elif defined(PYLON_UNIX_BUILD) ``` -------------------------------- ### Example: Uninstall Features Silently Source: https://docs.baslerweb.com/knowledge/redistributable-pylon-runtime-installation-options Example command to silently uninstall Camera Emulator, USB Runtime, and USB GenTL producer from an existing pylon Runtime installation. ```bash pylon_Runtime_.exe /quiet /uninstall=CamEmu_Support;USB_Runtime;GenTL_Producer_USB ``` -------------------------------- ### Compile and Install Driver Sources Source: https://docs.baslerweb.com/frame-grabbers/installing-the-framegrabber-sdk.html Navigate to the linux directory and execute the build and install commands. ```bash cd linux make && sudo make install ``` -------------------------------- ### Determine Exposure Start Delay in Python Source: https://docs.baslerweb.com/exposure-start-delay Retrieve the exposure start delay in microseconds using the Python API. This example assumes a 'camera' object is already initialized. ```python # Determine the exposure start delay at the current settings d = camera.BslExposureStartDelay.GetValue() ``` -------------------------------- ### Register Definition File Example Source: https://docs.baslerweb.com/visualapplets/files/manuals/content/embedding_and_simulating_ip_core.html This example demonstrates how to configure write and read registers, including setting initial values, connecting registers, waiting for clock cycles, and setting register values. Comments explain each step. ```vhdl REM ************************************************************ REM Command formats: DEF REM                  CON REM                  WCK REM                  SET REM ************************************************************ DEF 0006 10 1 00000000 #define write reg with width 0x10 at address 0x6 CON 0006 0006          #create read reg with addr 0x6 connected to REM                     write register with address 0x6 DEF 0007 20 1 00000000 #define write reg with width 0x20 at address 0x7 DEF 0007 10 0 00000000 #define read register at address 0x7 WCK 0010               #wait for 16 clock cycles SET 0007 0000000C      #set read register value ``` -------------------------------- ### Get EventFrameBurstStart Identifier Source: https://docs.baslerweb.com/pylonapi/cpp/class_basler___universal_camera_params_1_1_c_universal_camera_params___params__v10__0__0 Retrieve the unique identifier for the Frame Burst Start event. Use this parameter to get notified when the event occurs. Applies to ace USB models. ```cpp Pylon::IIntegerEx & EventFrameBurstStart; ``` -------------------------------- ### Minimal CMake Project Setup (Windows) Source: https://docs.baslerweb.com/cpp-prog-guide-%28stereo-mini%29 A basic CMakeLists.txt file for a Stereo mini application on Windows, including pylon setup. ```cmake cmake_minimum_required(VERSION 3.21) project(stereo_mini_app LANGUAGES CXX) # Locate pylon on Windows list(APPEND CMAKE_PREFIX_PATH $ENV{PYLON_DEV_DIR}) find_package(pylon 10.0 REQUIRED) add_executable(stereo_mini_app main.cpp) target_link_libraries(stereo_mini_app PRIVATE pylon::pylon) ``` -------------------------------- ### Get and Set Shutter Mode in Python Source: https://docs.baslerweb.com/?rhcsh=1&rhmapid=SensorShutterMode Control the camera's shutter mode using Python. This example shows how to get and set the 'Value' attribute of the ShutterMode property. ```python # Determine the current shutter mode shutterMode = camera.ShutterMode.Value # Set the shutter mode to rolling camera.ShutterMode.Value = "Rolling" # Set the shutter mode to global reset release camera.ShutterMode.Value = "GlobalResetRelease" ``` -------------------------------- ### Initialize Board Handle Example Source: https://docs.baslerweb.com/frame-grabbers/siso_genicam Demonstrates the lifecycle of initializing a board handle and cleaning up after use. ```cpp SgcBoardHandle * board = nullptr; int result = Sgc_initBoard(fg, 0, &board); if (result != SGC_OK) { // handle error ... } // use board, start discovery ... Sgc_freeBoard(board); ``` -------------------------------- ### Get Resulting Frame Rate (C Generic API) Source: https://docs.baslerweb.com/?rhcsh=1&rhmapid=BslResultingAcquisitionFrameRate This C-style API example shows how to get the frame rate using pylon functions and includes error checking. ```c /* 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 d = 0; /* Get the resulting acquisition frame rate */ errRes = PylonDeviceGetFloatFeature(hdev, "ResultingFrameRate", &d); CHECK(errRes); ``` -------------------------------- ### Implement Grab Strategies in C++ Source: https://docs.baslerweb.com/pylonapi/cpp/sample_code Demonstrates initializing the Pylon runtime, configuring an instant camera, and using the GrabStrategy_OneByOne strategy with software triggering. ```cpp // Grab_Strategies.cpp /* Note: Before getting started, Basler recommends reading the "Programmer's Guide" topic in the pylon C++ API documentation delivered with pylon. If you are upgrading to a higher major version of pylon, Basler also strongly recommends reading the "Migrating from Previous Versions" topic in the pylon C++ API documentation. This sample shows the use of the different grab strategies. There are different strategies to grab images with the Instant Camera grab engine: * One By One: This strategy is the default grab strategy. Acquisitioned images are processed in their arrival order. * Latest Image Only: Differs from the One By One strategy by a single image output queue. Therefore, only the latest image is kept in the output output queue, all other grabbed images are skipped. * Latest Images: Extends the above strategies by adjusting the size of output queue. If the output queue has a size of 1, it is equal to the Latest Image Only strategy. Consequently, setting the output queue size to CInstantCamera::MaxNumBuffer is equal to One by One. * Upcoming Image Grab: Ensures that the image grabbed is the next image received from the camera. When retrieving an image, a buffer is queued into the input queue and then the call waits for the upcoming image. Subsequently, image data is grabbed into the buffer and returned. Note: This strategy can't be used together with USB camera devices. */ // Include files to use the pylon API. #include // Include files used by samples. #include "../include/ConfigurationEventPrinter.h" #include "../include/ImageEventPrinter.h" // Namespace for using pylon objects. using namespace Pylon; // Namespace for using cout. using namespace std; int main( int /*argc*/, char* /*argv*/[] ) { // The exit code of the sample application. int exitCode = 0; // Before using any pylon methods, the pylon runtime must be initialized. PylonInitialize(); try { // This smart pointer will receive the grab result data. CGrabResultPtr ptrGrabResult; // Create an instant camera object for the camera device found first. CInstantCamera camera( CTlFactory::GetInstance().CreateFirstDevice() ); // Register the standard configuration event handler for enabling software triggering. // The software trigger configuration handler replaces the default configuration // as all currently registered configuration handlers are removed by setting the registration mode to RegistrationMode_ReplaceAll. camera.RegisterConfiguration( new CSoftwareTriggerConfiguration, RegistrationMode_ReplaceAll, Cleanup_Delete ); // For demonstration purposes only, registers an event handler configuration to print out information about camera use. // The event handler configuration is appended to the registered software trigger configuration handler by setting // registration mode to RegistrationMode_Append. camera.RegisterConfiguration( new CConfigurationEventPrinter, RegistrationMode_Append, Cleanup_Delete ); camera.RegisterImageEventHandler( new CImageEventPrinter, RegistrationMode_Append, Cleanup_Delete ); // Print the model name of the camera. cout << "Using device: " << camera.GetDeviceInfo().GetModelName() << endl << endl; // The MaxNumBuffer parameter can be used to control the count of buffers // allocated for grabbing. The default value of this parameter is 10. camera.MaxNumBuffer = 15; // Open the camera. camera.Open(); // Can the camera device be queried whether it is ready to accept the next frame trigger? if (camera.CanWaitForFrameTriggerReady()) { cout << "Grab using the GrabStrategy_OneByOne default strategy:" << endl << endl; // The GrabStrategy_OneByOne strategy is used. The images are processed // in the order of their arrival. camera.StartGrabbing( GrabStrategy_OneByOne ); // In the background, the grab engine thread retrieves the // image data and queues the buffers into the internal output queue. // Issue software triggers. For each call, wait up to 1000 ms until the camera is ready for triggering the next image. for (int i = 0; i < 3; ++i) { if (camera.WaitForFrameTriggerReady( 1000, TimeoutHandling_ThrowException )) { camera.ExecuteSoftwareTrigger(); } } // For demonstration purposes, wait for the last image to appear in the output queue. WaitObject::Sleep( 3 * 1000 ); // Check that grab results are waiting. ``` -------------------------------- ### Get Line Overload Status in C# Source: https://docs.baslerweb.com/?rhcsh=1&rhmapid=BslLineOverloadStatus Retrieve the overload status of camera I/O lines using the C# API. This example demonstrates setting a line and getting its status. ```csharp // Select a line camera.Parameters[PLCamera.LineSelector].SetValue(PLCamera.LineSelector.Line1); // Determine the status of the selected line bool status = camera.Parameters[PLCamera.LineOverloadStatus].GetValue(); // Get the line overload status of all I/O lines // Because the GenICam interface does not support // 32-bit words, the line status is reported as a 64-bit value Int64 lineOverloadStatusAll = camera.Parameters[PLCamera.LineOverloadStatusAll].GetValue(); ``` -------------------------------- ### Get EventFrameBurstStartOvertrigger Identifier Source: https://docs.baslerweb.com/pylonapi/cpp/class_basler___universal_camera_params_1_1_c_universal_camera_params___params__v10__0__0 Retrieve the unique identifier for the Frame Burst Start Overtrigger event. Use this parameter to get notified when the event occurs. Applies to ace USB models. ```cpp Pylon::IIntegerEx & EventFrameBurstStartOvertrigger; ``` -------------------------------- ### Initialize Pylon C Event Sample Source: https://docs.baslerweb.com/pylonapi/c/samples Setup of necessary handles and buffers for managing device streams and event grabbers. ```c #include #include #include #include #define CHECK( errc ) if ( GENAPI_E_OK != errc ) printErrorAndExit( errc ) /* This function can be used to wait for user input at the end of the sample program. */ void pressEnterToExit( void ); /* This method demonstrates how to retrieve the error message for the last failed function call. */ void printErrorAndExit( GENAPIC_RESULT errc ); /* Calculates the minimum and maximum gray value. */ void getMinMax( const unsigned char* pImg, int32_t width, int32_t height, unsigned char* pMin, unsigned char* pMax ); /* The function to be fired when an end of exposure event has been received. */ void GENAPIC_CC endOfExposureCallback( NODE_HANDLE hNode ); #define NUM_GRABS 100 /* Number of images to grab. */ #define NUM_IMAGE_BUFFERS 5 /* Number of buffers used for grabbing. */ #define NUM_EVENT_BUFFERS 20 /* Number of buffers used for grabbing. */ int main( void ) { GENAPIC_RESULT res; /* Return value of pylon methods. */ size_t numDevices; /* Number of available devices. */ PYLON_DEVICE_HANDLE hDev; /* Handle for the pylon device. */ PYLON_STREAMGRABBER_HANDLE hStreamGrabber; /* Handle for the pylon stream grabber. */ PYLON_EVENTGRABBER_HANDLE hEventGrabber; /* Handle for the event grabber used for receiving events. */ PYLON_EVENTADAPTER_HANDLE hEventAdapter; /* Handle for the event adapter used for dispatching events. */ PYLON_WAITOBJECT_HANDLE hWaitStream; /* Handle used for waiting for a grab to be finished. */ PYLON_WAITOBJECT_HANDLE hWaitEvent; /* Handle used for waiting for an event message. */ PYLON_WAITOBJECTS_HANDLE hWaitObjects; /* Container allowing waiting for multiple wait objects. */ NODEMAP_HANDLE hNodeMap; /* Handle for the node map containing the camera parameters. */ NODE_CALLBACK_HANDLE hCallback; /* Used for deregistering a callback function. */ NODE_HANDLE hNode; /* Handle for a camera parameter. */ size_t payloadSize; /* Size of an image in bytes. */ unsigned char* buffers[NUM_IMAGE_BUFFERS]; /* Buffers used for grabbing. */ PYLON_STREAMBUFFER_HANDLE bufHandles[NUM_IMAGE_BUFFERS]; /* Handles for the buffers. */ PylonGrabResult_t grabResult; /* Stores the result of a grab operation. */ int nGrabs; /* Counts the number of buffers grabbed. */ ``` -------------------------------- ### Initialize and Run Camera Acquisition Source: https://docs.baslerweb.com/pylonapi/net/Samples Main entry point for setting up the camera, starting the stream, and processing grab results. ```csharp internal static void Main() { // The exit code of the sample application. int exitCode = 0; try { // Create a camera object that selects the first camera device found. // More constructors are available for selecting a specific camera device. using (Camera camera = new Camera()) { // Print the model name of the camera. Console.WriteLine( "Using device: {0}", camera.CameraInfo[CameraInfoKey.ModelName] ); Console.WriteLine(); if (camera.CameraInfo[CameraInfoKey.ModelName].StartsWith( "a2A" )) { Console.WriteLine( "Note: This sample may not work as expected when used with ace 2 cameras." ); Console.WriteLine( " Please see note at the beginnging of the sample for details." ); } // Configure the camera. Configure( camera ); // Start grabbing of countOfImagesToGrab images. // The camera device is operated in a default configuration that // sets up free-running continuous acquisition. camera.StreamGrabber.Start( countOfImagesToGrab ); IGrabResult result; while (camera.StreamGrabber.IsGrabbing) { // Retrieve grab results and notify the camera event and image event handlers. result = camera.StreamGrabber.RetrieveResult( 5000, TimeoutHandling.ThrowException ); using (result) { // Nothing to do here with the grab result. The grab results are handled by the registered event handlers. } } // Disable events. Disable( camera ); // Print the recorded log showing the timing of events and images. PrintLog(); // Close the camera. camera.Close(); } } catch (Exception e) { // Error handling. Console.Error.WriteLine( "Exception: {0}", e.Message ); exitCode = 1; } finally { // Comment the following two lines to disable waiting on exit. Console.Error.WriteLine( "\nPress enter to exit." ); Console.ReadLine(); } Environment.Exit( exitCode ); } ``` -------------------------------- ### Get Parameter Array Source: https://docs.baslerweb.com/visualapplets/files/manuals/content/eVA_runtime.html Retrieves elements of a field parameter as an array, starting from a specified index. ```APIDOC ## Get Parameter Array ### Description Query field parameter of applet by parameter ID filling an array of data elements. The data is communicated via the data structure given by parameter 4. ### Function Signature `int vaRt_GetParamArray (va_hap_handle handle, int paramID, va_data* values, size_t startIndex, size_t elementCount)` ### Parameters - **handle** (va_hap_handle) - Hap handle from `vaRt_OpenHap()`. - **paramID** (int) - Parameter ID. - **values** (va_data*) - Pointer to the data structure which will be used for communication. The associated data elements will be overwritten by the acquired values. - **startIndex** (size_t) - Start index within the parameter field. - **elementCount** (size_t) - Number of elements which shall be queried. ### Return Value - 0: OK. - <0 : Error querying the array. ``` -------------------------------- ### GET BslExposureStartDelay Source: https://docs.baslerweb.com/exposure-start-delay Retrieves the current exposure start delay value in microseconds for the connected camera. ```APIDOC ## GET BslExposureStartDelay ### Description Retrieves the current exposure start delay value, which is the time period between the detection of a trigger signal and the actual start of the exposure. ### Method GET ### Endpoint BslExposureStartDelay ### Response #### Success Response (200) - **value** (double) - The exposure start delay in microseconds. ### Response Example { "BslExposureStartDelay": 15.5 } ``` -------------------------------- ### Initialize and Open a blaze Camera Source: https://docs.baslerweb.com/cpp-prog-guide Demonstrates the complete workflow of initializing the pylon runtime, creating a camera instance, registering the default configuration, and opening the connection. ```cpp #include using namespace Pylon; // .... // Before using any pylon methods, the pylon runtime must be initialized. PylonInitialize(); try { // 1: Create a camera object for the first available blaze camera. CBlazeInstantCamera camera(CTlFactory::GetInstance().CreateFirstDevice( CDeviceInfo().SetDeviceClass(BaslerGenTlBlazeDeviceClass)) ); // 2. Register the default configuration. camera.RegisterConfiguration( new CBlazeDefaultConfiguration, RegistrationMode_ReplaceAll, Cleanup_Delete); // 3. Open the camera, i.e., establish a connection to the camera device. camera.Open(); // Use the camera. std::cout << "Connected to camera " << camera.GetDeviceInfo().GetFriendlyName() << std::endl; // ..... // Close the connection. camera.Close(); } catch (const GenICam::GenericException& e) { std::cerr << "Exception occurred: " << std::endl << e.GetDescription() << std::endl; } // Releases all pylon resources. PylonTerminate(); ``` -------------------------------- ### Get EventFrameBurstStartTimestamp Source: https://docs.baslerweb.com/pylonapi/cpp/class_basler___universal_camera_params_1_1_c_universal_camera_params___params__v10__0__0 Retrieve the timestamp for the Frame Burst Start event. Applies to ace USB models. ```cpp Pylon::IIntegerEx & EventFrameBurstStartTimestamp; ``` -------------------------------- ### GUI_Sample Source: https://docs.baslerweb.com/pylonapi/pylon-sdk-samples-manual Demonstrates the use of an MFC GUI with the pylon C++ API for camera enumeration, configuration, grabbing, and image display/storage, including GUI controls for parameter modification. ```APIDOC ## GUI_Sample ### Description This sample demonstrates the use of a MFC GUI together with the pylon C++ API to enumerate attached cameras, to configure a camera, to start and stop the grab and to display and store grabbed images. It also shows you how to use GUI controls to display and modify camera parameters. ``` -------------------------------- ### Running the example program on Windows Source: https://docs.baslerweb.com/stereovisard/tutorials/rc_visard_general/opencv_example Command to run the `rc_visard_show_streams` executable on Windows, including options and the camera ID. Ensure the PATH environment variable is set correctly. ```cmd rc_visard_show_streams.exe [options] ``` -------------------------------- ### Get Build Number Source: https://docs.baslerweb.com/pylonapi/cpp/class_pylon_1_1_version_info Returns the build number. For example, in version 2.1.3.1234, this would return 1234. ```cpp inline unsigned int getBuild() const ``` -------------------------------- ### Example Project File Configuration Source: https://docs.baslerweb.com/dot-net-prog-guide This is an example of how your Visual Studio project file might look after adding the necessary assembly references and the property group to suppress architecture mismatch warnings. ```xml None .... .. .. .. .. .. .. Program Files\Basler\pylon\Development\Assemblies\Basler.Pylon\x64\Basler.Pylon.dll .. .. .. .. .. .. Program Files\Basler\pylon\Development\Assemblies\Basler.Pylon.Blaze\AnyCpu\Basler.Pylon.Blaze.dll .... ``` -------------------------------- ### Get Resulting Acquisition Frame Rate (Other Cameras) Source: https://docs.baslerweb.com/resulting-acquisition-frame-rate Examples for retrieving the acquisition frame rate for other camera models. ```APIDOC ## Get Resulting Acquisition Frame Rate (Other Cameras) ### Description Retrieves the acquisition frame rate from other camera models. ### Method Not applicable. ### Endpoint Not applicable. ### Parameters None ### Request Example ```json { "example": "// C++ (Native)\ndouble d = camera.BslResultingAcquisitionFrameRate.GetValue();" } ``` ### Response #### Success Response (200) Not applicable. #### Response Example ```json { "example": "// C++ (Generic)\nINodeMap& nodemap = camera.GetNodeMap();\ndouble d = CFloatParameter(nodemap, \"BslResultingAcquisitionFrameRate\").GetValue();" } ``` ``` ```APIDOC ## Get Resulting Acquisition Frame Rate (Other Cameras) - Parameters ### Description Retrieves the acquisition frame rate from other camera models using specific parameter access. ### Method Not applicable. ### Endpoint Not applicable. ### Parameters None ### Request Example ```json { "example": "// C++ (Native)\ndouble d = camera.Parameters[PLCamera.BslResultingAcquisitionFrameRate].GetValue();" } ``` ### Response #### Success Response (200) Not applicable. #### Response Example ```json { "example": "// C (Generic)\n#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)\nGENAPIC_RESULT errRes = GENAPI_E_OK; /* Return value of pylon methods */\ndouble d = 0;\n/* Get the resulting acquisition frame rate */\nerrRes = PylonDeviceGetFloatFeature(hdev, \"BslResultingAcquisitionFrameRate\", &d);\nCHECK(errRes);" } ``` ``` ```APIDOC ## Get Resulting Acquisition Frame Rate (Other Cameras) - Python ### Description Retrieves the acquisition frame rate from other camera models in Python. ### Method Not applicable. ### Endpoint Not applicable. ### Parameters None ### Request Example ```json { "example": "# Get the resulting acquisition frame rate\nd = camera.BslResultingAcquisitionFrameRate.Value" } ``` ### Response #### Success Response (200) Not applicable. #### Response Example ```json { "example": "# Get the resulting acquisition frame rate\nd = camera.BslResultingAcquisitionFrameRate.Value" } ``` ``` -------------------------------- ### Navigate to Setup Directory Source: https://docs.baslerweb.com/getting-started-with-pylon-ai Change the current directory to the location where the pylon Supplementary Package was extracted. ```bash cd pylon_ai_setup ``` -------------------------------- ### Get EventFrameBurstStartOvertriggerTimestamp Source: https://docs.baslerweb.com/pylonapi/cpp/class_basler___universal_camera_params_1_1_c_universal_camera_params___params__v10__0__0 Retrieve the timestamp for the Frame Burst Start Overtrigger event. Applies to ace USB models. ```cpp Pylon::IIntegerEx & EventFrameBurstStartOvertriggerTimestamp; ``` -------------------------------- ### Controlling and Monitoring Applications Setup Source: https://docs.baslerweb.com/?rhcsh=1&rhmapid=DestinationAddr Instructions for setting up one controlling application and one or more monitoring applications for image data streaming. ```APIDOC ## Controlling and Monitoring Applications When using limited broadcast, subnet-directed broadcast, or multicast, you usually want to send the image data stream from one camera to multiple destinations. To achieve this, you must set up exactly one controlling application and one or more monitoring applications. * The **controlling** application starts and stops image acquisition. It can also change the camera configuration. * The **monitoring** applications receive the stream data. Monitoring applications open the camera in read-only mode. This means that they can't start and stop image acquisition or change the camera configuration. For testing purposes, you can use one instance of the pylon Viewer as the controlling application and another instance of the pylon Viewer as the monitoring application. ### Setting up pylon Viewer as Controlling and Monitoring Applications 1. Start the pylon Viewer and open a GigE device. 2. Start another instance of the pylon Viewer. This will act as the monitoring application: * **Windows:** Start the pylon Viewer. In the **Devices** pane of the pylon Viewer, right-click the GigE device opened in step 1 and then click **Open Device …** > **Monitor Mode**. * **Linux:** At the command line, type: `/opt/pylon5/bin/PylonViewerApp -m` * **macOS:** At the command line, type: `./Applications/pylon Viewer.app/Contents/MacOS/pylon Viewer -m` **Info:** For more information about setting up controlling and monitoring applications, see the GigE Multicast/Broadcast section in the pylon API Documentation. ``` -------------------------------- ### Get EventFrameBurstStartFrameID Source: https://docs.baslerweb.com/pylonapi/cpp/class_basler___universal_camera_params_1_1_c_universal_camera_params___params__v10__0__0 Retrieve the Frame ID for the Frame Burst Start event. Applies to ace USB models. ```cpp Pylon::IIntegerEx & EventFrameBurstStartFrameID; ``` -------------------------------- ### Minimal CMake Project Setup (Linux) Source: https://docs.baslerweb.com/cpp-prog-guide-%28stereo-mini%29 A basic CMakeLists.txt file for a Stereo mini application on Linux, including pylon setup. ```cmake cmake_minimum_required(VERSION 3.21) project(stereo_mini_app LANGUAGES CXX) # Locate pylon on Linux list(APPEND CMAKE_PREFIX_PATH $ENV{PYLON_ROOT}) find_package(pylon 10.0 REQUIRED) add_executable(stereo_mini_app main.cpp) target_link_libraries(stereo_mini_app PRIVATE pylon::pylon) ``` -------------------------------- ### Get Offset Y Source: https://docs.baslerweb.com/pylonapi/cpp/class_pylon_1_1_c_grab_result_data Returns the current starting row of the image data. This is useful for understanding image alignment or cropping. ```cpp uint32_t GetOffsetY() const ``` -------------------------------- ### General syntax for running the example program Source: https://docs.baslerweb.com/stereovisard/tutorials/rc_visard_general/opencv_example The general command-line syntax for executing the `rc_visard_show_streams` program, specifying options and the camera ID. ```bash ./rc_visard_show_streams [options] ``` -------------------------------- ### Configure Sensor Shutter Mode Source: https://docs.baslerweb.com/?rhcsh=1&rhmapid=SensorShutterMode Examples for getting and setting the sensor shutter mode on supported Basler cameras. ```C++ (Native) // Determine the current sensor shutter mode SensorShutterModeEnums shutterMode = camera.SensorShutterMode.GetValue(); // Set the sensor shutter mode to Rolling camera.SensorShutterMode.SetValue(SensorShutterMode_Rolling); ``` ```C++ (Generic) INodeMap& nodemap = camera.GetNodeMap(); // Determine the current sensor shutter mode String_t shutterMode = CEnumParameter(nodemap, "SensorShutterMode").GetValue(); // Set the sensor shutter mode to Rolling CEnumParameter(nodemap, "SensorShutterMode").SetValue("Rolling"); ``` ```C# // Determine the current sensor shutter mode string shutterMode = camera.Parameters[PLCamera.SensorShutterMode].GetValue(); // Set the sensor shutter mode to Rolling camera.Parameters[PLCamera.SensorShutterMode].SetValue(PLCamera.SensorShutterMode.Rolling); ``` ```C (Generic) size_t len = 0; char shutterMode_str[64] = {0}; /* Determine the current sensor shutter mode */ len = sizeof(shutterMode_str); errRes = PylonDeviceFeatureToString(hdev, "SensorShutterMode", shutterMode_str, &len); CHECK(errRes); /* Set the sensor shutter mode to Rolling */ errRes = PylonDeviceFeatureFromString(hdev, "SensorShutterMode", "Rolling"); CHECK(errRes); ``` ```Python # Determine the current sensor shutter mode shutterMode = camera.SensorShutterMode.Value # Set the sensor shutter mode to Rolling camera.SensorShutterMode.Value = "Rolling" ``` -------------------------------- ### Get I/O Line Status in C (Generic) Source: https://docs.baslerweb.com/line-status This C example shows how to select an I/O line and get its boolean status, as well as the status of all lines as a 64-bit integer, using pylon functions. Error checking is included. ```c /* 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 */ _Bool status = false; int64_t lineStatusAll = 0; /* Select a line */ errRes = PylonDeviceFeatureFromString(hdev, "LineSelector", "Line1"); CHECK(errRes); /* Get the status of the line */ errRes = PylonDeviceGetBooleanFeature(hdev, "LineStatus", &status); CHECK(errRes); /* Get the line status of all I/O lines. Because the GenICam interface does not */ /* support 32-bit words, the line status is reported as a 64-bit value. */ errRes = PylonDeviceGetIntegerFeature(hdev, "LineStatusAll", &lineStatusAll); CHECK(errRes); ``` -------------------------------- ### Get I/O Line Status in C++ (Generic) Source: https://docs.baslerweb.com/line-status This generic C++ example demonstrates how to select an I/O line and retrieve its status using GenICam node access. It also shows how to get the status of all lines as a 64-bit integer. ```cpp INodeMap& nodemap = camera.GetNodeMap(); // Select a line CEnumParameter(nodemap, "LineSelector").SetValue("Line1"); // Get the status of the line bool status = CBooleanParameter(nodemap, "LineStatus").GetValue(); // Get the line status of all I/O lines. Because the GenICam interface does not // support 32-bit words, the line status is reported as a 64-bit value. int64_t lineStatusAll = CIntegerParameter(nodemap, "LineStatusAll").GetValue(); ```