NVIDIA GPUDirect for Video#
The technology allows to efficiently transfer video frames into NVIDIA GPU memory at low latencies. It gives you full control to stream video into the GPU at sub-frame transfer times.
GPUDirect for Video technology is available through the Basler Framegrabber API on host PCs using a Windows OS in
- OpenGL (Open Graphics Library), or
- CUDA (Compute Unified Device Architecture), a parallel programming framework by NVIDIA.
NVIDIA GPUDirect for Video is tailored for systems that use an NVIDIA graphics processing unit (GPU). The technology allows to efficiently transfer video frames into NVIDIA GPU memory at low latencies. It gives you full control to stream video into the GPU at sub-frame transfer times.
For details, refer to the manufacturers site, sections NVIDIA GPUDirect for Video technology and GPUDirect Technology Overview.
Requirements#
To use GPUDirect for Video technology in combination with Basler frame grabbers, your system has to meet the following requirements:
Hardware#
NVIDIA Graphics Processing Card:
- Quadro GP100, P6000, P5000, P4000
- Quadro M6000, M5000, M4000
- Quadro K4000, K4200, K5000, K5200 and K6000
- Quadro 4000, 5000, and 6000
- Quadro M5000M equipped mobile workstations
- Quadro K5100M equipped mobile workstations
- GRID K1 and K2
- Tesla K10, K20, K20X, K40
-
Tesla C2075 and M2070Q
For the latest list of supported NVIDIA GPUs, see here.
-
Basler frame grabber of your choice.
Software#
- Basler Framegrabber SDK: Version 5.10.0
- Operating System on Host PC: Windows 10 (64bit)
- Parallel Computing Platform/API (see Installation):
- CUDA (Compute Unified Device Architecture), version 11.6, or
- OpenGL (Open Graphics Library)
- Recommended IDE: Visual Studio 15.x or higher
Info
You may need additional DLL and header files to get GPUDirect for Video running. For more information, contact Basler Technical Support.
The support of GPUDirect for Video technology has been tested under Windows 10 and can be guaranteed for this Windows version.
Installation#
Prerequisites#
- GPU Hardware: An NVIDIA GPU that supports GPUDirect for Video technology has been plugged into your host PC.
- Parallel Computing Platform/API: One of the following packages has been installed on your host PC:
- CUDA (Compute Unified Device Architecture), a parallel programming framework by Nvidia
- OpenGL (Open Graphics Library)
- Frame Grabber Hardware: The Basler frame grabber of your choice has been connected to your host PC. For information how to connect the frame grabber, see Connecting the Frame Grabber.
- Framegrabber SDK: The Basler Framegrabber SDK 5.10.0 has been installed. For information how to install the runtime software, see Installing the Framegrabber SDK.
- Applet: The applet of your choice has been flashed onto your frame grabber (only for marathon frame grabbers) and is selected as active applet. For information how to flash the marathon frame grabber, see Flashing. For information how to select an applet as active applet, see Changing the Active Applet.
- GPUDirect for Video Support Files: Basler provides you with the following files:
- siso_gpudirect.dll: library file
- siso_gpudirect.h: header file covering the general functions always required
- siso_gpudirect_cuda.h: header file required for working with CUDA
- siso_gpudirect_gl.h: header file required for working in OpenGL.
Installing GPUDirect for Video Support#
To install GPUDirect for Video support on your host PC:
- Copy the library file siso_gpudirect.dll into your Basler Framegrabber SDK installation directory into subfolder bin, e.g., C:\Program Files\Basler\FramegrabberSDK_5.XX.X\bin.
- Copy the header files into the into the subfolder include of your Basler Framegrabber SDK installation directory into , e.g., C:\Program Files\Basler\FramegrabberSDK_5.XX.X\include.
After copying the files into the mentioned subfolders of your installation, you can use the functions of GPUDirect for Video via the Basler Framegrabber API.
Function Reference#
You use either CUDA or OpenGL for controlling GPUDirect for Video via the Basler Framegrabber API.
Prerequisites for Using CUDA#
- The library file siso_gpudirect.dll has been copied into the subfolder bin of your Framegrabber SDK installation.
- The header files siso_gpudirect.h and siso_gpudirect_cuda.h have been copied into the subfolder include of your Framegrabber SDK installation.
Prerequisites for Using OpenGL#
- The library file siso_gpudirect.dll has been copied into the subfolder bin of your Framegrabber SDK installation.
- The header files siso_gpudirect.h and siso_gpudirect_gl.h have been copied into the subfolder include of your Framegrabber SDK installation.
Available Functions#
The functions for controlling the GPUDirect for Video technology via the Basler Framegrabber API are the same for CUDA and OpenGL. The Basler Framegrabber API offers the following functions:
Function | GDInitLib |
---|---|
Description | Global Initialization. Call this function prior to any other function for initialization. |
Parameters |
|
Function | GDCloseLib |
---|---|
Description | After no function of the library is needed anymore, you must call this function to clean up the resources from the GDInitLib function call. Each call to GCCloseLib has to be accompanied by a preceding call to GDInitLib . |
Parameters | None |
Function | GDGetContextInfo |
---|---|
Description | Use this function to get information about the current context. |
Parameters |
|
Function | GDRevokeBuffer |
---|---|
Description | Removes an announced buffer from the acquisition engine. This function will free all internally allocated resources associated with this buffer. A buffer can only be revoked if it isn't queued in any queue. |
Parameters | [in] BUFFER_HANDLE Handle referencing to the buffer. The buffer itself has been announced via the function GDAllocateSourceBuffer , GDAnnounceCUDAArray , GDAnnounceTextureGL , or GDAnnounceBufferGL . |
Function | GDStartAcquisition |
---|---|
Description | Starts the acquisition engine. |
Parameters | None |
Function | GDStopAcquisition |
---|---|
Description | Stops the acquisition engine. |
Parameters | None |
Function | GDAllocateSourceBuffer |
---|---|
Description | This function allocates the memory for a single source buffer, announces this buffer to the acquisition engine, and returns a buffer handle which references that single buffer. |
Parameters |
|
Function | GDRegisterEvent |
---|---|
Description | Registers an event object to a certain iEventID . |
Parameters |
|
Function | GDEventGetData |
---|---|
Description | Retrieves the next event data entry from the event data queue associated with the event handle. |
Parameters |
|
Function | GDMemcpy |
---|---|
Description | Copies the next frame that has been delivered by the frame grabber into the GPU. Use this function if you want to trigger the copy process. The result is delivered as EVENT_NEW_BUFFER_DATA type. |
Parameters |
|
Function | GDBufferUnblock |
---|---|
Description | This function unblocks buffer for the copying process. Each buffer that you have received as member of EVENT_NEW_BUFFER_DATA needs to be unblocked via this function (e.g., in order to have buffer for new copy processes). Make sure your operations on the buffer content have been completed before you unblock a buffer. |
Parameters | [in] BUFFER_HANDLE phBuffer |
Function | GDBufferGetDataPtr |
---|---|
Description | This function returns the pointer to the starting point of the memory location of the buffer. The buffer must have been created with the GDAllocateSourceBuffer function. |
Parameters |
|
Function | GGDGetBufferInfo |
---|---|
Description | Use this function to inquire information about the buffer module associated with this buffer handle. |
Parameters |
|
Function | GDGetLastError |
---|---|
Description | Use this function to inquire the message associated with the last error that occurred. |
Parameters |
|
Function | GDAnnounceTextureGL |
---|---|
Description | This function announces a target object as a destination for copy operations and returns a buffer handle which references that single buffer. |
Parameters |
|
Function | GDAnnounceBufferGL |
---|---|
Description | This function announces a target object as a destination for copy operations and returns a buffer handle which references that single buffer. |
Parameters |
|
Function | GDAnnounceCUDAArray |
---|---|
Description | This function announces a target object as a destination for copy operations and returns a buffer handle which references that single buffer. |
Parameters |
|
Data Types#
Name of STRUCT | EVENT_NEW_BUFFER_DATA |
---|---|
Description | The event has copied the content of the source buffer into the target buffer. |
Parameters |
|
Enumerations#
GD_CTX_LIST | |
---|---|
GD_CTX_CUDA | Name of CUDA context |
GD_CTX_OPENGL | Name of OpenGL context |
GD_CTX_D3D9 | Not supported |
GD_CTX_D3D11 | Not supported |
GD_CONTEXT_INFO_LIST | |
---|---|
GD_CONTEXT_STRIDE_LENGTH | Source: https://msdn.microsoft.com/en-us/library/windows/desktop/aa473780(v=vs.85).aspx |
GDBufferTypes |
---|
GD_UNSIGNED_BYTE |
GD_BYTE |
GD_UNSIGNED_SHORT |
GD_SHORT |
GD_UNSIGNED_INT |
GD_INT |
GD_FLOAT |
GD_HALF_FLOAT |
GD_UNSIGNED_BYTE_3_3_2 |
GD_UNSIGNED_BYTE_2_3_3_REV |
GD_UNSIGNED_SHORT_5_6_5 |
GD_UNSIGNED_SHORT_5_6_5_REV |
GD_UNSIGNED_SHORT_4_4_4_4 |
GD_UNSIGNED_SHORT_4_4_4_4_REV |
GD_UNSIGNED_SHORT_5_5_5_1 |
GD_UNSIGNED_SHORT_1_5_5_5_REV |
GD_UNSIGNED_INT_8_8_8_8 |
GD_UNSIGNED_INT_8_8_8_8_REV |
GD_UNSIGNED_INT_10_10_10_2 |
GD_UNSIGNED_INT_2_10_10_10_REV |
EVENT_TYPE_LIST | |
---|---|
EVENT_ERROR | Notification on module errors. |
EVENT_COPY_FINISHED | Notification on newly filled buffers. The event data are stored in an EVENT_NEW_BUFFER_DATA . |
GD_BUFFER_INFO_LIST | |
---|---|
GD_BUFFER_TIMESTAMP | Time stamp last change in buffer |
GD_BUFFER_TIMESTAMP_FREQUENCY | Frequency for time stamp |
GD_BUFFER_PICNUMBER | Index for buffer content |
GD_BUFFER_DATA_PTR | Pointer to the raw data that are managed by the buffer |
Examples#
Prerequisites#
- You have the examples folder you received from Basler available.
- Visual Studio 15.x or higher is installed on your PC.
- CMake is installed on your PC.
- The according libraries are installed on your PC.
Using the Examples#
To use the examples provided by Basler:
-
Copy the examples folder you received from Basler to the hard drive of your host PC.
CUDA Example
For the CUDA example you only need cuda.lib and cudart.lib in addition to the libraries already installed on your PC.
OpenGL Example: Glew must be found by CMake
Make sure CMake can find the glew - otherwise, the project will not be built correctly.
CMake should be able to find the glew without your interaction. However, in case it doesn't find the glew:
-
Set the according enviromnent variables:
GLUT_ROOT_PATH
for example to D:\libs\freeglut-2.8.1\win32GLEW_ROOT_PATH
for example to D:\libs\glew-1.13.0\glew-1.13.0\Win32 -
If CMake has still trouble to find the glew, set the CMake project variables manually:
GLEW_INCLUDE_DIR
for example to D:/libs/glew-1.13.0/glew-1.13.0/x64/includeGLEW_LIBRARY
for example to D:/libs/glew-1.13.0/glew-1.13.0/x64/lib/glew32.libOPENGL_gl_LIBRARY
for example to opengl32OPENGL_glu_LIBRARY
for example to glu32
-
-
Create a project using CMake with examples\gpudirect\cuda or examples\gpudirect\opengl as source directory.
- Run the example.
While executing the examples, you will be asked to select an applet. Select a grayscale applet, for example, Acq_SingleCXP6X4AreaGray.dll for a marathon frame grabber. The name is somewhat cut off, you'll only see the end.
For marathon Frame Grabbers: Use Grayscale Applet for Examples
The Basler NVIDIA GPUDirect for Video support works with color formats as well as with grayscale formats.
However, as both examples are designed for use with grayscale applets, make sure you select a grayscale applet for using the examples, e.g., Acq_SingleCXP6X4AreaGray.dll (only for marathon frame grabbers).