Skip to content

Commit

Permalink
Fix setting OpenNI2 grabber default video mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaegel committed Dec 16, 2013
1 parent d6c6e8a commit 68b4e79
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 143 deletions.
6 changes: 3 additions & 3 deletions io/include/pcl/io/openni2_camera/openni2_convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ namespace openni2_wrapper

const OpenNI2DeviceInfo openni2_convert(const openni::DeviceInfo* pInfo);

const OpenNI2VideoMode openni2_convert(const openni::VideoMode& input);
const openni::VideoMode openni2_convert(const OpenNI2VideoMode& input);
const openni::VideoMode grabberModeToOpenniMode(const OpenNI2VideoMode& input);

const std::vector<OpenNI2VideoMode> openni2_convert(const openni::Array<openni::VideoMode>& input);
const OpenNI2VideoMode openniModeToGrabberMode(const openni::VideoMode& input);
const std::vector<OpenNI2VideoMode> openniModeToGrabberMode(const openni::Array<openni::VideoMode>& input);
}

#endif
14 changes: 8 additions & 6 deletions io/include/pcl/io/openni2_camera/openni2_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#include <string>
#include <vector>

using std::vector;

using openni_wrapper::Image;
using openni_wrapper::DepthImage;
using openni_wrapper::IRImage;
Expand Down Expand Up @@ -119,17 +121,17 @@ namespace openni2_wrapper
const OpenNI2VideoMode getColorVideoMode() throw ();
const OpenNI2VideoMode getDepthVideoMode() throw ();

const std::vector<OpenNI2VideoMode>& getSupportedIRVideoModes() const;
const std::vector<OpenNI2VideoMode>& getSupportedColorVideoModes() const;
const std::vector<OpenNI2VideoMode>& getSupportedDepthVideoModes() const;
const vector<OpenNI2VideoMode>& getSupportedIRVideoModes() const;
const vector<OpenNI2VideoMode>& getSupportedColorVideoModes() const;
const vector<OpenNI2VideoMode>& getSupportedDepthVideoModes() const;

bool isIRVideoModeSupported(const OpenNI2VideoMode& video_mode) const;
bool isColorVideoModeSupported(const OpenNI2VideoMode& video_mode) const;
bool isDepthVideoModeSupported(const OpenNI2VideoMode& video_mode) const;

bool findCompatibleIRMode(const OpenNI2VideoMode& check_mode, OpenNI2VideoMode& mode) const throw ();
bool findCompatibleColorMode(const OpenNI2VideoMode& check_mode, OpenNI2VideoMode& mode) const throw ();
bool findCompatibleDepthMode(const OpenNI2VideoMode& check_mode, OpenNI2VideoMode& mode) const throw ();
bool findCompatibleIRMode( const OpenNI2VideoMode& requested_mode, OpenNI2VideoMode& actual_mode) const throw ();
bool findCompatibleColorMode(const OpenNI2VideoMode& requested_mode, OpenNI2VideoMode& actual_mode) const throw ();
bool findCompatibleDepthMode(const OpenNI2VideoMode& requested_mode, OpenNI2VideoMode& actual_mode) const throw ();

void setIRVideoMode(const OpenNI2VideoMode& video_mode) throw ();
void setColorVideoMode(const OpenNI2VideoMode& video_mode) throw ();
Expand Down
7 changes: 5 additions & 2 deletions io/include/pcl/io/openni2_camera/openni2_video_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,27 @@
#include <cstddef>
#include <ostream>

#include <OpenNI.h>

namespace openni2_wrapper
{

// copied from OniEnums.h
typedef enum
{
// Depth
// Depth
PIXEL_FORMAT_DEPTH_1_MM = 100,
PIXEL_FORMAT_DEPTH_100_UM = 101,
PIXEL_FORMAT_SHIFT_9_2 = 102,
PIXEL_FORMAT_SHIFT_9_3 = 103,

// Color
// Color
PIXEL_FORMAT_RGB888 = 200,
PIXEL_FORMAT_YUV422 = 201,
PIXEL_FORMAT_GRAY8 = 202,
PIXEL_FORMAT_GRAY16 = 203,
PIXEL_FORMAT_JPEG = 204,
PIXEL_FORMAT_YUYV = 205,
} PixelFormat;

struct OpenNI2VideoMode
Expand Down
7 changes: 4 additions & 3 deletions io/include/pcl/io/openni2_grabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ namespace pcl
void
stopSynchronization ();

// TODO: rename to mapConfigMode2OniMode
// TODO: rename to mapMode2OniMode
/** \brief Map config modes. */
bool
mapConfigMode2XnMode (int mode, openni2_wrapper::OpenNI2VideoMode& videoMode) const;
mapMode2XnMode (int mode, openni2_wrapper::OpenNI2VideoMode& videoMode) const;

// callback methods
/** \brief RGB image callback. */
Expand Down Expand Up @@ -465,7 +465,8 @@ namespace pcl
return false;
}
} ;
std::map<int, openni2_wrapper::OpenNI2VideoMode> config2xn_map_;
// Mapping from config (enum) modes to native OpenNI modes
std::map<int, openni2_wrapper::OpenNI2VideoMode> config2oni_map_;

openni2_wrapper::OpenNI2Device::CallbackHandle depth_callback_handle;
openni2_wrapper::OpenNI2Device::CallbackHandle image_callback_handle;
Expand Down
28 changes: 15 additions & 13 deletions io/src/openni2_camera/openni2_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,9 @@ namespace openni2_wrapper
}


const OpenNI2VideoMode openni2_convert(const openni::VideoMode& input)
{
OpenNI2VideoMode output;

output.x_resolution_ = input.getResolutionX();
output.y_resolution_ = input.getResolutionY();
output.frame_rate_ = input.getFps();
output.pixel_format_ = static_cast<PixelFormat>(input.getPixelFormat());

return output;
}

const openni::VideoMode openni2_convert(const OpenNI2VideoMode& input)
const openni::VideoMode grabberModeToOpenniMode(const OpenNI2VideoMode& input)
{

openni::VideoMode output;
Expand All @@ -81,7 +71,19 @@ namespace openni2_wrapper
}


const std::vector<OpenNI2VideoMode> openni2_convert(const openni::Array<openni::VideoMode>& input)
const OpenNI2VideoMode openniModeToGrabberMode(const openni::VideoMode& input)
{
OpenNI2VideoMode output;

output.x_resolution_ = input.getResolutionX();
output.y_resolution_ = input.getResolutionY();
output.frame_rate_ = input.getFps();
output.pixel_format_ = static_cast<PixelFormat>(input.getPixelFormat());

return output;
}

const std::vector<OpenNI2VideoMode> openniModeToGrabberMode(const openni::Array<openni::VideoMode>& input)
{
std::vector<OpenNI2VideoMode> output;

Expand All @@ -90,7 +92,7 @@ namespace openni2_wrapper
output.reserve(size);

for (int i=0; i<size; ++i)
output.push_back(openni2_convert(input[i]));
output.push_back(openniModeToGrabberMode(input[i]));

return output;
}
Expand Down
Loading

0 comments on commit 68b4e79

Please sign in to comment.