ReconstructMe SDK  2.0.819-89134
Real-time 3D reconstruction engine
 All Classes Files Functions Typedefs Enumerations Enumerator Groups Pages
Typedefs
Image

Load, save and manipulate 2D images. More...

Typedefs

typedef int reme_image_t
 Handle referencing a 2D image object.
 
reme_error_t reme_image_create (reme_context_t c, reme_image_t *i)
 Create a new empty image object.
 
reme_error_t reme_image_destroy (reme_context_t c, reme_image_t *i)
 Destroy a previously created image object.
 
reme_error_t reme_image_get_info (reme_context_t c, reme_image_t i, int *width=0, int *height=0, int *num_channels=0, int *num_bytes_per_channel=0, int *row_stride=0)
 Get image information such as size, channels and layout.
 
reme_error_t reme_image_save_to_file (reme_context_t c, reme_image_t i, const char *filename)
 Save the image in the desired format.
 
reme_error_t reme_image_load_from_file (reme_context_t c, reme_image_t i, const char *filename)
 Load image from disk.
 
reme_error_t reme_image_get_bytes (reme_context_t c, reme_image_t i, const void **pixels, int *length)
 Get image pixel data as byte array.
 

Detailed Description

Load, save and manipulate 2D images.

This modules provides methods to load, save and manipulate 2d images.

The example below illustrates the functionality.

// Create a new context that has default options applied
// Create a sensor using a saved data stream
reme_sensor_create(c, "openni;mskinect;file", true, &s);
// Create an image to hold the result
int width, height, nchans;
// Viewer for displaying up to 12 images in parallel
reme_viewer_create_image(c, "Images", &v);
int counter = 0;
while (REME_SUCCESS(reme_sensor_grab(c, s)))
{
// Update internal state of images
// Receive the image into our image handle
if (counter % 30 == 0) {
// Derive the correct image format
reme_image_get_info(c, i, &width, &height, &nchans);
// Save image as PNG
char buffer[50];
sprintf (buffer, "image_%i.png", counter);
reme_image_save_to_file(c, i, buffer);
printf("Saved image (%ix%i - %i channels) to %s \n", width, height, nchans, buffer);
}
// Update the viewer
counter += 1;
}
// Print pending errors
// Make sure to release all memory acquired

In case you want to acces the pixel data itself, you need to get a pointer to the internal data.

const void *data;
int width, height, length;

Next you use reme_image_get_bytes to access the data. In the following snipped OpenCV is used to perform something meaningful with the data.

// Receive the pointer to the data
reme_image_get_bytes(c, i, &data, &length);
// Derive the correct image format
reme_image_get_info(c, i, &width, &height);
// In C++ we could now feed this to OpenCV for visualization
cv::Mat rgb(height, width, CV_8UC3, (char*)data);
cv::Mat bgr;
cv::cvtColor(rgb, bgr, CV_RGB2BGR);
cv::imshow("RGB", bgr);
cv::waitKey(10);

Typedef Documentation

typedef int reme_image_t

Handle referencing a 2D image object.

A reme_image_t represents a 2D image object.

Function Documentation

reme_error_t reme_image_create ( reme_context_t  c,
reme_image_t i 
)
reme_error_t reme_image_destroy ( reme_context_t  c,
reme_image_t i 
)

Destroy a previously created image object.

Parameters
cA pointer to a valid context object
iA mutable pointer to a valid image handle to destroy
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
reme_error_t reme_image_get_info ( reme_context_t  c,
reme_image_t  i,
int *  width = 0,
int *  height = 0,
int *  num_channels = 0,
int *  num_bytes_per_channel = 0,
int *  row_stride = 0 
)

Get image information such as size, channels and layout.

You can pass a zero pointer for those fields you are not interested in.

Parameters
cA valid context object
iA valid image object
widthWidth of image in pixels
heightHeight of image in pixels
num_channelsNumber of channels per pixel
num_bytes_per_channelNumber of bytes per channel
row_strideDistance between successive rows in bytes
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_image.cpp.
reme_error_t reme_image_save_to_file ( reme_context_t  c,
reme_image_t  i,
const char *  filename 
)

Save the image in the desired format.

The exporter is chosen based on the file extension. Currently supported are

  • .PNG - Portable Network Graphics
  • .BMP - Windows Bitmap
  • .JPG - Jpeg
Parameters
cA valid context object
iA valid image object
filenamepath to save image to
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_image.cpp.
reme_error_t reme_image_load_from_file ( reme_context_t  c,
reme_image_t  i,
const char *  filename 
)

Load image from disk.

The importer is chosen based on the file extension. Currently supported are

  • .PNG - Portable Network Graphics
  • .BMP - Windows Bitmap
  • .JPG - Jpeg
Parameters
cA valid context object
iA valid image object
filenamepath to save image to
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
reme_error_t reme_image_get_bytes ( reme_context_t  c,
reme_image_t  i,
const void **  pixels,
int *  length 
)

Get image pixel data as byte array.

Parameters
cA valid context object
iA valid image object
pixelsA mutable pointer that will receive the address of pixel array
lengthA pointer that will receive the length of the array in bytes (use reme_image_get_info to derive the correct format)
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_image.cpp.