Raytrix Light Field SDK  4.0
Logo
Public Types | Public Member Functions | List of all members
Rx::LFR::CCudaCompute Class Reference

Detailed Description

Provides methods for using a CUDA device as the computation unit of the LFR.

Inherits Rx::LFR::CParametersPimpl< CCudaCompute_Impl, Params::ECudaCompute::ID, Interfaces::ECudaCompute::ID >.

Public Types

typedef Interfaces::ECudaCompute::ID EnumInterfaceType
 
typedef Params::ECudaCompute::ID EnumType
 The type of the parameter enum. Is used by managed wrapper classes. More...
 

Public Member Functions

 CCudaCompute ()
 Default constructor. More...
 
 CCudaCompute (CCudaCompute &&xCudaCompute)
 Move constructor. More...
 
 ~CCudaCompute ()
 Destructor. More...
 
void ApplyCalibration (const CCalibration &xCalib, bool bUploadGrayImg=true)
 Applies the given calibration to the algorithms. This must be done every time the calibration changes. More...
 
void ApplyRayImage (const CRayImage &xRayImage)
 Applies the given ray image. More...
 
void Compute_Depth3D ()
 Calculates the depth 3D image. More...
 
void Compute_DepthColorCode (LF::ESpace::ID eSpace=LF::ESpace::View_Object_Pinhole)
 Calculates the colored depth map image. More...
 
void Compute_DepthMap (LF::ESpace::ID eSpace=LF::ESpace::View_Object_Pinhole)
 Calculates the depth map image. This image can be filled to produce a complete filled depth map. More...
 
void Compute_DepthRay ()
 Estimates the depth of the current raw image and creates the ray depth image. More...
 
void Compute_Grid ()
 Calculates the grid image. This is the raw or the gray image with an overlay that shows the current grid calibration. More...
 
void Compute_GridDataImage ()
 Pre-Process a ray image with a minimal set of preprocessing parameters. More...
 
void Compute_Histogram (EImage::ID eImgID, CRxArrayUInt &xHistogram, unsigned &uChannels)
 Calculates the histogram of the image with the given image ID and stores the histogram data in the given array. This array must be large enough to hold 4 * 256 numbers. The number of calculated channels is returned in uChannels. More...
 
void Compute_ImageMinMax (EImage::ID eImgID, unsigned uChannel, float &fMin, float &fMax)
 Calculates the minimum and the maximum value in the given image. More...
 
void Compute_Multiview ()
 Calculates the multi view image. More...
 
void Compute_PreProcess ()
 Pre-Process a ray image. This can apply denoise, brightness and sharpness adjustments. More...
 
void Compute_RefocusBasic ()
 Focus image to a plane perpendicular to the optical axis, i.e. parallel to the image plane. More...
 
void Compute_TotalFocus (LF::ESpace::ID eSpace=LF::ESpace::View_Object_Pinhole)
 Focus on a depth surface. More...
 
CRxImageFormat CreateFocusImageFormat (const CRxImageFormat &xRawFormat, bool bForceLandscape) const
 Creates the image format of the refocus and the total focus image. This considers the Focus_ImageDivisor parameter. More...
 
const CCudaDeviceGetCudaDevice () const
 Gets the CUDA device that has been set by calling SetCudaDevice. Throws an exception if not set yet. More...
 
CCudaCompute_Impl & GetImpl ()
 Gets the non constant implementation. More...
 
const CCudaCompute_Impl & GetImpl () const
 Gets the constant implementation. More...
 
void * GetInterface (Interfaces::ECudaCompute::ID eData)
 Gets the cuda compute interface. More...
 
const void * GetInterface (Interfaces::ECudaCompute::ID eData) const
 Gets the cuda compute interface. More...
 
CParameters< Params::ECudaCompute::ID > & GetParams ()
 
const CParameters< Params::ECudaCompute::ID > & GetParams () const
 
bool HasInterface (Interfaces::ECudaCompute::ID eInterface)
 Queries if this object has the given interface. More...
 
CCudaComputeoperator= (CCudaCompute &&xCudaCompute)
 Move assignment operator. More...
 
void ReinitializeDepthDB ()
 Reinitializes the depth database. More...
 
void RemoveComputationFilterMask ()
 Removes the computation filter mask set by SetComputationFilterMask. More...
 
void ResizeImage (Interop::Runtime28::IImage *pxTrgImg, const Interop::Runtime28::IImage *pxSrcImg, int iDivisor)
 Resize the given source image and store the result in the given target image using the given divisor. More...
 
void SetComputationFilterMask (const CRxImage &xImage)
 Sets the computation filter mask image. More...
 
void SetComputationFilterMask (const CRxString &sxFilename)
 Sets the computation filter mask image. More...
 
void SetCudaDevice (const CCudaDevice &xCudaDevice)
 Sets the CUDA device that allocates the memory required for the operations and that runs the algorithms. More...
 
void UploadRawImage (const Interop::Runtime28::IImage &xSrcImg)
 Uploads the given image as the new raw image of all computations. More...
 

Member Typedef Documentation

The type of the parameter enum. Is used by managed wrapper classes.

Constructor & Destructor Documentation

Rx::LFR::CCudaCompute::CCudaCompute ( )

Default constructor.

Rx::LFR::CCudaCompute::CCudaCompute ( CCudaCompute &&  xCudaCompute)

Move constructor.

Parameters
xCudaCompute[in,out] The CUDA compute instance.
Rx::LFR::CCudaCompute::~CCudaCompute ( )

Destructor.

Member Function Documentation

void Rx::LFR::CCudaCompute::ApplyCalibration ( const CCalibration xCalib,
bool  bUploadGrayImg = true 
)

Applies the given calibration to the algorithms. This must be done every time the calibration changes.

Parameters
xCalibThe calibration.
bUploadGrayImg(Optional) True to upload the gray image of the calibration to CUDA. False to use the current gray image even if it is invalid.
void Rx::LFR::CCudaCompute::ApplyRayImage ( const CRayImage xRayImage)

Applies the given ray image.

This uploads the raw and the gray image to the CUDA device and applies the calibration and the parameters from the meta data to the CUDA algorithms.

Parameters
xRayImageThe ray image.
void Rx::LFR::CCudaCompute::Compute_Depth3D ( )

Calculates the depth 3D image.

This creates a RGBA float image which maps each pixel in the view camera to a 3D position in object space. The R channel is the X coordinate, the G channel is the Y coordinate and the B channel is the Z coordinate. The Z coordinate is relative to the global coordinate system which typically coincides with the light field camera sensor. All coordinate values are given in millimeters. The A channel is the Z coordinate in virtual depths.

Result image:

Required images:

Influencing parameters:

  • none.
void Rx::LFR::CCudaCompute::Compute_DepthColorCode ( LF::ESpace::ID  eSpace = LF::ESpace::View_Object_Pinhole)

Calculates the colored depth map image.

Result image:

Required images:

Influencing parameters:

  • ECCPar::DepthMap_Color_Mode
  • ECCPar::DepthMap_Color_Max
  • ECCPar::DepthMap_Color_Min
  • ECCPar::DepthMap_Color_Map.
Parameters
eSpace(Optional) The space. This is LF::ESpace::View_Virtual or LF::ESpace::View_Object_Pinhole.
void Rx::LFR::CCudaCompute::Compute_DepthMap ( LF::ESpace::ID  eSpace = LF::ESpace::View_Object_Pinhole)

Calculates the depth map image. This image can be filled to produce a complete filled depth map.

Result image:

Required images:

Influencing parameters:

  • ECCPar::Depth_ConsistencyCheck
  • ECCPar::Depth_Fill_Enabled
  • ECCPar::Depth_Fill_IterCnt
  • ECCPar::Depth_Fill_IterSize
  • ECCPar::Depth_Fill_Complete
  • ECCPar::Depth_Fill_ShrinkRangePX
  • ECCPar::Depth_Fill_Filter_Enabled
  • ECCPar::Depth_Fill_Bilateral_Enabled
  • ECCPar::Depth_Fill_Bilateral_Edge
  • ECCPar::Depth_Fill_Bilateral_Range
  • ECCPar::Depth_Fill_Bilateral_FilterRadius.
Parameters
eSpace(Optional) The space. This is LF::ESpace::View_Virtual or LF::ESpace::View_Object_Pinhole.
void Rx::LFR::CCudaCompute::Compute_DepthRay ( )

Estimates the depth of the current raw image and creates the ray depth image.

Result image:

Required images:

Influencing parameters:

  • ECCPar::PreProc_Sharp1_Enable
  • ECCPar::PreProc_Sharp1_OnlyCalc
  • ECCPar::PreProc_Sharp1_BlurStdDev
  • ECCPar::PreProc_Sharp1_Factor
  • ECCPar::Depth_SparseLensSet
  • ECCPar::Depth_NearResolutionLevel
  • ECCPar::Depth_PatchDiameter
  • ECCPar::Depth_PatchStride
  • ECCPar::Depth_MinVirtualDepth
  • ECCPar::Depth_MaxVirtualDepth
  • ECCPar::Depth_MinCorrelation
  • ECCPar::Depth_MinStdDeviation
  • ECCPar::Depth_LensFilterMask.
void Rx::LFR::CCudaCompute::Compute_Grid ( )

Calculates the grid image. This is the raw or the gray image with an overlay that shows the current grid calibration.

Result image:

Required images:

Influencing parameters:

  • ECCPar::Grid_DrawOnGrayImage
  • ECCPar::Grid_DrawMlaGrid.
void Rx::LFR::CCudaCompute::Compute_GridDataImage ( )

Pre-Process a ray image with a minimal set of preprocessing parameters.

Result image:

Required images:

Influencing parameters:

  • ECCPar::PreProc_Demosaic_R
  • ECCPar::PreProc_Demosaic_G
  • ECCPar::PreProc_Demosaic_B.
void Rx::LFR::CCudaCompute::Compute_Histogram ( EImage::ID  eImgID,
CRxArrayUInt xHistogram,
unsigned &  uChannels 
)

Calculates the histogram of the image with the given image ID and stores the histogram data in the given array. This array must be large enough to hold 4 * 256 numbers. The number of calculated channels is returned in uChannels.

Parameters
eImgIDThe image ID.
xHistogram[out] The histogram.
uChannels[out] The number of channels.
void Rx::LFR::CCudaCompute::Compute_ImageMinMax ( EImage::ID  eImgID,
unsigned  uChannel,
float &  fMin,
float &  fMax 
)

Calculates the minimum and the maximum value in the given image.

Parameters
eImgIDThe image ID. The image must be of type float.
uChannelThe channel of each pixel that is used to get the values.
fMin[out] The minimum.
fMax[out] The maximum.
void Rx::LFR::CCudaCompute::Compute_Multiview ( )

Calculates the multi view image.

Result image:

Required images:

Influencing parameters:

  • ECCPar::Multiview_Type
  • ECCPar::Multiview_EyeSeparation
  • ECCPar::Depth_ConsistencyCheck
  • ECCPar::Depth_Fill_Enabled
  • ECCPar::Depth_Fill_IterCnt
  • ECCPar::Depth_Fill_IterSize
  • ECCPar::Depth_Fill_Complete
  • ECCPar::Depth_Fill_ShrinkRangePX
  • ECCPar::Depth_Fill_Filter_Enabled
  • ECCPar::Depth_Fill_Bilateral_Enabled
  • ECCPar::Depth_Fill_Bilateral_Edge
  • ECCPar::Depth_Fill_Bilateral_Range
  • ECCPar::Depth_Fill_Bilateral_FilterRadius.
void Rx::LFR::CCudaCompute::Compute_PreProcess ( )

Pre-Process a ray image. This can apply denoise, brightness and sharpness adjustments.

Result image:

Required images:

Influencing parameters:

  • ECCPar::PreProc_Demosaic_Enable
  • ECCPar::PreProc_Demosaic_R
  • ECCPar::PreProc_Demosaic_G
  • ECCPar::PreProc_Demosaic_B
  • ECCPar::PreProc_DenoiseNLM_Enable
  • ECCPar::PreProc_DenoiseNLM_FilterDia
  • ECCPar::PreProc_DenoiseNLM_NoiseLevel
  • ECCPar::PreProc_DenoiseNLM_BlendFactor
  • ECCPar::PreProc_Std_Enable
  • ECCPar::PreProc_Std_Gradation
  • ECCPar::PreProc_Sharp1_Enable
  • ECCPar::PreProc_Sharp1_OnlyCalc
  • ECCPar::PreProc_Sharp1_BlurStdDev
  • ECCPar::PreProc_Sharp1_Factor.
void Rx::LFR::CCudaCompute::Compute_RefocusBasic ( )

Focus image to a plane perpendicular to the optical axis, i.e. parallel to the image plane.

This focuses to a plane perpendicular to the optical axis. You can change the relative focal plane. A relative focus value of zero refocuses to the plane furthest away from the viewer and a value of 1 would focus to a plane that passes through the object side focal point of the recording lens.

Result image:

Required images:

Influencing parameters:

  • ECCPar::Focus_RelativeFocusPlane
  • ECCPar::Depth_MinVirtualDepth
  • ECCPar::Depth_MaxVirtualDepth.
void Rx::LFR::CCudaCompute::Compute_TotalFocus ( LF::ESpace::ID  eSpace = LF::ESpace::View_Object_Pinhole)

Focus on a depth surface.

In principle, each pixel of the result image can be focused individually. This function makes this property available by focusing the ray image to the depth surface given in the internal depth image related to the given space.

Result image:

Required images:

Influencing parameters:

  • ECCPar::Focus_RelativeFocusPlane
  • ECCPar::Focus_DepthBlendingScale
  • ECCPar::Depth_MinVirtualDepth
  • ECCPar::Depth_MaxVirtualDepth.
Parameters
eSpace(Optional) The space. This is LF::ESpace::View_Virtual or LF::ESpace::View_Object_Pinhole.
CRxImageFormat Rx::LFR::CCudaCompute::CreateFocusImageFormat ( const CRxImageFormat xRawFormat,
bool  bForceLandscape 
) const

Creates the image format of the refocus and the total focus image. This considers the Focus_ImageDivisor parameter.

Parameters
xRawFormatThe raw image format.
bForceLandscapeTrue to force landscape. Otherwise the calibration is used.
Returns
The image format.
const CCudaDevice& Rx::LFR::CCudaCompute::GetCudaDevice ( ) const

Gets the CUDA device that has been set by calling SetCudaDevice. Throws an exception if not set yet.

Returns
The CUDA device.
CCudaCompute_Impl & Rx::LFR::CPimpl< CCudaCompute_Impl , Interfaces::ECudaCompute::ID >::GetImpl ( )
inlineinherited

Gets the non constant implementation.

Returns
The implementation.
const CCudaCompute_Impl & Rx::LFR::CPimpl< CCudaCompute_Impl , Interfaces::ECudaCompute::ID >::GetImpl ( ) const
inlineinherited

Gets the constant implementation.

Returns
The implementation.
void* Rx::LFR::CCudaCompute::GetInterface ( Interfaces::ECudaCompute::ID  eData)

Gets the cuda compute interface.

Parameters
eDataThe interface type.
Returns
Null if it fails, else the interface.
const void* Rx::LFR::CCudaCompute::GetInterface ( Interfaces::ECudaCompute::ID  eData) const

Gets the cuda compute interface.

Parameters
eDataThe interface type.
Returns
Null if it fails, else the interface.
bool Rx::LFR::CPimpl< CCudaCompute_Impl , Interfaces::ECudaCompute::ID >::HasInterface ( Interfaces::ECudaCompute::ID  eInterface)
inlineinherited

Queries if this object has the given interface.

Parameters
eInterfaceThe interface to query.
Returns
True if this class has the given interface, false if not.
CCudaCompute& Rx::LFR::CCudaCompute::operator= ( CCudaCompute &&  xCudaCompute)

Move assignment operator.

Parameters
xCudaCompute[in,out] The cuda compute instance.
Returns
The instance.
void Rx::LFR::CCudaCompute::ReinitializeDepthDB ( )

Reinitializes the depth database.

This can be useful when calling Compute_DepthMap after changing the ray depth image manually.

void Rx::LFR::CCudaCompute::RemoveComputationFilterMask ( )

Removes the computation filter mask set by SetComputationFilterMask.

void Rx::LFR::CCudaCompute::ResizeImage ( Interop::Runtime28::IImage pxTrgImg,
const Interop::Runtime28::IImage pxSrcImg,
int  iDivisor 
)

Resize the given source image and store the result in the given target image using the given divisor.

Parameters
pxTrgImg[in] The target image. This must not be a moniker. It's created inside.
pxSrcImgThe source image.
iDivisorThe divisor. A value of 2 means that the target image is half the source size.
void Rx::LFR::CCudaCompute::SetComputationFilterMask ( const CRxImage xImage)

Sets the computation filter mask image.

This image is used to reduce the number of lenses used for depth estimation.

It must have the same dimension as the raw image and a pixel type of Rx::Interop::Runtime28::EPixelType::Lum and a data type of Rx::Interop::Runtime28::EDataType::UByte. Otherwise the image is converted.

Each lens of the raw image has a lens center that can be rounded to a pixel. If this pixel has the value 255 in the filter mask image, the corresponding lens is used. If this pixel has another value, the lens is not used.

Parameters
xImageThe computation filter mask image.
void Rx::LFR::CCudaCompute::SetComputationFilterMask ( const CRxString sxFilename)

Sets the computation filter mask image.

This image is used to reduce the number of lenses used for depth estimation.

It must have the same dimension as the raw image and a pixel type of Rx::Interop::Runtime28::EPixelType::Lum and a data type of Rx::Interop::Runtime28::EDataType::UByte. Otherwise the image is converted.

Each lens of the raw image has a lens center that can be rounded to a pixel. If this pixel has the value 255 in the filter mask image, the corresponding lens is used. If this pixel has another value, the lens is not used.

Parameters
sxFilenameThe image file to load.
void Rx::LFR::CCudaCompute::SetCudaDevice ( const CCudaDevice xCudaDevice)

Sets the CUDA device that allocates the memory required for the operations and that runs the algorithms.

Parameters
xCudaDeviceThe CUDA device.
void Rx::LFR::CCudaCompute::UploadRawImage ( const Interop::Runtime28::IImage xSrcImg)

Uploads the given image as the new raw image of all computations.

Parameters
xSrcImgThe source image.