GetPointer
OpenLvVision_OpenCv.lvlib:Cuda.lvlib:HostMem.lvclass:HostMem GetPointer.vi
Returns the raw memory pointer to the pinned data buffer for zero-copy access.
This increments the OpenCV reference count. To prevent memory leaks, the generated handlePtr must be freed after use, either by the external library via the releaseCallback, or explicitly in LabVIEW using the "HostMem ReleasePointer" VI.
struct HostMem_PointerData
{
uintptr_t dataPtr;
int64_t step;
uint64_t totalBytes;
int32_t cols;
int32_t rows;
int32_t elemSize;
int32_t cvType;
int32_t channels;
uintptr_t handlePtr;
uintptr_t releaseCallbackPtr;
};
// LabVIEW registers this function so the external DLL can signal exactly when
// it has finished accessing the pinned buffer. Invoking this safely decrements the
// underlying OpenCV reference count, preventing memory leaks and access violations.
typedef void (*ReleaseCallback)(void* handle);
extern "C" __declspec(dllexport) void Camera_Snap(const HostMem_PointerData* info)
{
// Validate the descriptor and buffer address before dereferencing.
if (info == nullptr || info->dataPtr == 0)
{
return;
}
unsigned char* pixels = reinterpret_cast<unsigned char*>(info->dataPtr);
void* handle = reinterpret_cast<void*>(info->handlePtr);
ReleaseCallback releaseMem = reinterpret_cast<ReleaseCallback>(info->releaseCallbackPtr);
// Forward the pixel buffer to the camera acquisition.
// The subsystem writes the captured frame directly into the LabVIEW-owned
// memory buffer. This achieves a zero-copy data transfer.
Camera::Snap(pixels, info->cols, info->rows);
// Invoke the LabVIEW release callback to transfer buffer ownership back.
// Both the handle and the callback must be valid. If either is absent, the
// buffer relies on LabVIEW's manual lifecycle management to be freed.
if (handle != nullptr && releaseMem != nullptr)
{
releaseMem(handle);
}
}

| error in (no error) The error in cluster can accept error information wired from VIs previously called. Use this information to decide if any functionality should be bypassed in the event of errors from other VIs. The pop-up option Explain Error (or Explain Warning) gives more information about the error displayed. |
| status The status boolean is either TRUE (X) for an error, or FALSE (checkmark) for no error or a warning. The pop-up option Explain Error (or Explain Warning) gives more information about the error displayed. |
| code The code input identifies the error or warning. The pop-up option Explain Error (or Explain Warning) gives more information about the error displayed. |
| source The source string describes the origin of the error or warning. The pop-up option Explain Error (or Explain Warning) gives more information about the error displayed. |
| HostMem in |
| error out The error out cluster passes error or warning information out of a VI to be used by other VIs. The pop-up option Explain Error (or Explain Warning) gives more information about the error displayed. |
| status The status boolean is either TRUE (X) for an error, or FALSE (checkmark) for no error or a warning. The pop-up option Explain Error (or Explain Warning) gives more information about the error displayed. |
| code The code input identifies the error or warning. The pop-up option Explain Error (or Explain Warning) gives more information about the error displayed. |
| source The source string describes the origin of the error or warning. The pop-up option Explain Error (or Explain Warning) gives more information about the error displayed. |
| HostMem out |
| PointerData Memory description of a CUDA-pinned host memory for zero-copy interop. |
| DataPtr The absolute memory address of the first pixel in the image (top-left, coordinate 0,0) |
| Step Also known as the Stride or Line Pitch. This represents the number of bytes between the start of one row and the start of the next row |
| TotalBytes The total physical footprint of the image in RAM. It is calculated as step * rows |
| Cols The horizontal width of the image in pixels |
| Rows The vertical height of the image in pixels |
| ElemSize The number of bytes occupied by a single pixel |
| cvType The internal OpenCV integer constant representing the data format |
| Channels The number of components per pixel |
| handlePtr An opaque 64-bit pointer to allocated cv::cuda::HostMem instance that maintains a +1 reference count on the underlying memory payload. |
| releaseCallbackPtr C-convention function pointer that must be invoked with the handlePtr to safely decrement the OpenCV reference count and deallocate the handle. |













