#include <DlibImage.h>
template<class T, class ImageType>
struct VisionAppster::DlibImage🔗

Attaches pixel type to a va_image* or const va_image*.

  • T = pixel type, e.g. unsigned char or dlib::bgr32_pixel

  • ImageType = va_image* or const va_image*

Public Functions

inline DlibImage &ref()🔗

Returns a non-const reference to this.

Makes it possible to use this wrapper class as a non-const argument to Dlib functions.

namespace VisionAppster🔗


template<class T, class ImageType>
DlibImage<T, ImageType> dlibImage(ImageType &img)🔗

Wraps img into a DlibImage with the given pixel type.

The caller must ensure that img->type and T match.

template<template<class> class Function, class ...Args>
static int dlibCall(va_image_type imageType, Args&&... args)🔗

Creates an instance of the callable template Function and calls it with args.

As a template argument to Function, passes the data type that corresponds to imageType.

The general pattern of wrapping a Dlib function is to create a functor template that handles all possible pixel types. This function can then be used to resolve the actual pixel type.


Returns the return value of the function template. If imageType is not supported, returns VA_ERR_INVALID_PARAMETER. If the function throws std::bad_alloc, returns VA_ERR_OUT_OF_MEMORY.

  • imageType: Image type. Will be used to find out the correct template parameter T with which Function can be instantiated. If imageType is one of the recognized types (gray8, gray16, gray32, rgb32, argb32 or argb32premul), Function will instantiated as Function<T>, where T corresponds to imageType. (E.g. unsigned char for gray8)

  • args: The args to be passed to the function template once instantiated.

template <class PixelType>
struct MyOperation
  int operator()(const va_image* in, va_image* out) const
      dlibImage<PixelType>(in),         // const argument
      dlibImage<PixelType>(out).ref()); // non-const argument
    return VA_SUCCESS;

// ... later in code ...
dlibCall<MyOperation>(inputImage->type, inputImage, outputImage);