Contents
Initialize the Raytrix Light Field API
Independent of the programming language you are using you have to reference the Raytrix Light Field API in your project.
To start working with the Raytrix Light Field API, you have to include the Raytrix API header or reference the Raytrix API assembly.
#include "Rx.ApiLF\Rx.ApiLF.h"
using namespace Rx::ApiLF;
#include "Rx.ApiLF\Rx.ApiLF.h"
using namespace Rx::Net::ApiLF;
The namespaces allow you to use all API related code without writing the whole namespace each time. After the API header is included you must start with initializing the Raytrix Light Field API.
The function Rx::ApiLF::RxInit initializes the Raytrix Light Field API.
This function has to be called before any other API function, with the exception of
- Rx::ApiLF::RxSleep
- Rx::ApiLF::RxGetTime
- Rx::ApiLF::RxGetTime64
- Rx::ApiLF::RxLogConsoleShow
If you do not specify any parameters the CUDA device is initialized implicitly. All the computational functions are implemented on the CUDA device.
The function Rx::ApiLF::RxCudaSelectDevice allows you to select a CUDA device.
If several CUDA devices are present, you have the possibility to select the CUDA device width the highest graphical processing power. In the most cases it is sufficient to use the function without any parameter settings, which will select the first device that has enough computational power.
RxInit();
RxCudaSelectDevice();
RxInit();
RxCudaSelectDevice();
RxInit();
RxCudaSelectDevice();
- See also
- Full Example
Binding the Source
The Raytrix Light Field SDK allows you to work with three different image sources (Programming with the Raytrix Light Field API). In this example we will demonstrate the usage of a ray image source.
CRxString sxFile = "..\\ExampleImages\\Demo_01.ray";
unsigned uImgID = RxRayLoad(sxFile);
RxRayBind(uImgID);
String^ sFile =
gcnew String(
"..\\ExampleImages\\Demo_01.ray");
unsigned uImgID = RxRayLoad(sFile);
RxRayBind(uImgID);
string sFile = "..\\ExampleImages\\Demo_01.ray";
uint uImgID = RxRayLoad(sFile);
RxRayBind(uImgID);
- Attention
- After a ray image is bound to the Raytrix Light Field API you have to preprocess the image for all further image processing.
- See also
- Preprocess the Bound Image
-
Full Example
Preprocess the Bound Image
The ray image that is bound is a raw Light Field image. Before this ray image can be used by the actual image processing algorithms, it has to be preprocessed.
The function Rx::ApiLF::RxPreProcess prepares the raw image for further image processing
The number of preprocessing tasks that are performed depends on the corresponding API parameters. You can activate or deactivate:
- non-local-means (NLM) denoising of the raw image with EPar::PreProc_DenoiseNLM_Enable
- the standard brightness adjustment with EPar::PreProc_Std_Enable
- sharpening of the raw image with EPar::PreProc_Sharp1_Enable
- Attention
- if the image has a bayer pattern the debayer algorithm is performed by the preprocess step.
Each preprocessing task can be adjusted by further API paramters:
- Rx::ApiLF::EPar::PreProc_Std_Brightness
- Rx::ApiLF::EPar::PreProc_Std_ContrastCenter
- Rx::ApiLF::EPar::PreProc_Std_ContrastScale
- Rx::ApiLF::EPar::PreProc_Std_Gradation
- Rx::ApiLF::EPar::PreProc_Sharp1_BlurStdDev
- Rx::ApiLF::EPar::PreProc_Sharp1_OnlyCalc
- Rx::ApiLF::EPar::PreProc_Demosaic_R
- Rx::ApiLF::EPar::PreProc_Demosaic_G
- Rx::ApiLF::EPar::PreProc_Demosaic_B
- Rx::ApiLF::EPar::PreProc_DenoiseNLM_FilterDia
- Rx::ApiLF::EPar::PreProc_DenoiseNLM_NoiseLevel
- Rx::ApiLF::EPar::PreProc_DenoiseNLM_BlendFactor
After the preprocessing step is executed the image Rx::ApiLF::EImg::Processed_Normalized is created on the CUDA device and further image processing is possible.
- See also
- Image Processing with the Raytrix Light Field API
-
Raytrix Light Field API Computation - Detailed
-
Full Example
Image Processing with the Raytrix Light Field API
- Attention
- After you have preprocessed the raw image you can start your actual image processing.
The Raytrix Light Field API offers a lot of image processing algorithms that are implemented on the CUDA device. Each processing function creates an image on the device. The image that is created can depend on the parameter Rx::ApiLF::EPar::Proj_CurrentTargetView that can be set to one of the values in Rx::Projection::ESpace. The following image and the corresponding table illustrate the relation between the computational functions and the created images:
Ratrix Light Field API - Images
Function | Requirement | Rx::ApiLF::EImg |
Rx::ApiLF::RxRefocusBasic | | Rx::ApiLF::EImgID::RefocusBasic |
Rx::ApiLF::RxTotalFocus | Rx::LF::ESpace::Virtual | Rx::ApiLF::EImgID::TotalFocus_View_Virtual |
Rx::ApiLF::RxTotalFocus | Rx::LF::ESpace::ViewCamera | Rx::ApiLF::EImgID::TotalFocus_View_Object_Pinhole |
Rx::ApiLF::RxMultiview | | Rx::ApiLF::EImgID::Multiview |
Rx::ApiLF::RxDepthRay | | Rx::ApiLF::EImgID::DepthRay |
Rx::ApiLF::RxDepthMap | Rx::LF::ESpace::Virtual | Rx::ApiLF::EImgID::DepthMap_View_Virtual |
Rx::ApiLF::RxDepthMap | Rx::LF::ESpace::ViewCamera | Rx::ApiLF::EImgID::DepthMap_View_Object_Pinhole |
Rx::ApiLF::RxDepth3D | Rx::ApiLF::EImgID::DepthMap_View_Object_Pinhole must exist | Rx::ApiLF::EImgID::Depth3D |
Rx::ApiLF::RxDepthColorCode | Rx::LF::ESpace::Virtual | Rx::ApiLF::EImgID::DepthMapColored_View_Virtual |
Rx::ApiLF::RxDepthColorCode | Rx::LF::ESpace::ViewCamera | Rx::ApiLF::EImgID::DepthMapColored_View_Object_Pinhole |
Further computational functions are:
- Rx::ApiLF::RxGetImageMinMax
- Rx::ApiLF::RxGetImageHistogram
Every processing function can be adjusted with a wide range of parameters RxApiLF_Enum .
The following simple example demonstrates how you can refocus your image in the middle of the near and far plane.
RxSetPar(EPar::Focus_RelativeFocusPlane, 0.5);
RxRefocusBasic();
CRxImage xImage;
RxGetImage(EImgID::RefocusBasic, xImage);
RxSetPar(EPar::Focus_RelativeFocusPlane, 0.5);
RxRefocusBasic();
RxGetImage(EImgID::RefocusBasic, xImage);
RxSetPar(EPar.Focus_RelativeFocusPlane, 0.5);
RxRefocusBasic();
public Image Image;
RxGetImage(EImgID.RefocusBasic, ref Image);
The last section of this page will show you how to finalize the Raytrix Light Field API
- See also
- Finalize the Raytrix Light Field API
-
Full Example
Finalize the Raytrix Light Field API
After you have finished your work with the Raytrix Light Field API you want to make sure that all memory is freed on host and on CUDA device. Furthermore you want to close all cameras properly:
- See also
- Full Example
Full Example
#include "Rx.Interop.Runtime30/CIException.h"
#include "Rx.ApiLF\Rx.ApiLF.h"
using namespace Rx::ApiLF;
int main(int argc, char* argv[])
{
unsigned uImgID = 0;
try
{
RxInit(true, 0);
RxCudaSelectDevice();
sxFile = "..\\ExampleImages\\Demo_01.ray";
RxRayLoad(uImgID, sxFile);
RxRayBind(uImgID);
RxPreProcess();
RxSetPar(EPar::Focus_RelativeFocusPlane, 0.5);
RxRefocusBasic();
RxGetImage(EImgID::RefocusBasic, xImage);
}
{
return -1;
}
RxFinalize();
return 0;
}
#include "Rx.Interop.Runtime30/CIException.h"
#include "Rx.ApiLF\Rx.ApiLF.h"
using namespace Rx::Net::ApiLF;
int main(int argc, char* argv[])
{
unsigned uImgID = 0;
try
{
RxInit(true, 0);
RxCudaSelectDevice();
sxFile = "..\\ExampleImages\\Demo_01.ray";
RxRayLoad(uImgID, sxFile);
RxRayBind(uImgID);
RxPreProcess();
RxSetPar(EPar::Focus_RelativeFocusPlane, 0.5);
RxRefocusBasic();
RxGetImage(EImgID::RefocusBasic, xImage);
}
{
return -1;
}
RxFinalize();
return 0;
}
static void Main(string[] args)
{
uint uImgID = 0;
public Image Image;
string sFile;
try
{
RxInit(true, 0);
RxCudaSelectDevice();
sFile = "..\\ExampleImages\\Demo_01.ray";
RxRayLoad(uImgID, sxFile);
RxRayBind(uImgID);
RxPreProcess();
RxSetPar(EPar.Focus_RelativeFocusPlane, 0.5);
RxRefocusBasic();
RxGetImage(EImgID.RefocusBasic, ref Image);
}
{
}
RxFinalize();
}