Beispiel #1
0
DeviceKinect::DeviceKinect (xn::Context& context, const xn::NodeInfo& device_node, const xn::NodeInfo& image_node, const xn::NodeInfo& depth_node, const xn::NodeInfo& ir_node)
: OpenNIDevice (context, device_node, image_node, depth_node, ir_node)
, debayering_method_ (ImageBayerGRBG::EdgeAwareWeighted)
{
  // setup stream modes
  enumAvailableModes ();
  setDepthOutputMode (getDefaultDepthMode ());
  setImageOutputMode (getDefaultImageMode ());
  setIROutputMode (getDefaultIRMode ());

  // device specific initialization
  XnStatus status;

  unique_lock<mutex> image_lock(image_mutex_);
  // set kinect specific format. Thus input = uncompressed Bayer, output = grayscale = bypass = bayer
  status = image_generator_.SetIntProperty ("InputFormat", 6);
  if (status != XN_STATUS_OK)
    THROW_OPENNI_EXCEPTION ("Error setting the image input format to Uncompressed 8-bit BAYER. Reason: %s", xnGetStatusString (status));

  // Grayscale: bypass debayering -> gives us bayer pattern!
  status = image_generator_.SetPixelFormat (XN_PIXEL_FORMAT_GRAYSCALE_8_BIT);
  if (status != XN_STATUS_OK)
    THROW_OPENNI_EXCEPTION ("Failed to set image pixel format to 8bit-grayscale. Reason: %s", xnGetStatusString (status));
  image_lock.unlock ();

  lock_guard<mutex> depth_lock(depth_mutex_);
  // RegistrationType should be 2 (software) for Kinect, 1 (hardware) for PS
  status = depth_generator_.SetIntProperty ("RegistrationType", 2);
  if (status != XN_STATUS_OK)
    THROW_OPENNI_EXCEPTION ("Error setting the registration type. Reason: %s", xnGetStatusString (status));
}
DevicePrimesense::DevicePrimesense (xn::Context& context, const xn::NodeInfo& device_node, const xn::NodeInfo& image_node, const xn::NodeInfo& depth_node, const xn::NodeInfo& ir_node)
: OpenNIDevice (context, device_node, image_node, depth_node, ir_node)
{
  // setup stream modes
  enumAvailableModes ();
  setDepthOutputMode (getDefaultDepthMode ());
  setImageOutputMode (getDefaultImageMode ());
  setIROutputMode (getDefaultIRMode ());

  unique_lock<mutex> image_lock(image_mutex_);
  XnStatus status = image_generator_.SetIntProperty ("InputFormat", 5);
  if (status != XN_STATUS_OK)
    THROW_OPENNI_EXCEPTION ("Error setting the image input format to Uncompressed YUV422. Reason: %s", xnGetStatusString (status));

  status = image_generator_.SetPixelFormat (XN_PIXEL_FORMAT_YUV422);
  if (status != XN_STATUS_OK)
    THROW_OPENNI_EXCEPTION ("Failed to set image pixel format to YUV422. Reason: %s", xnGetStatusString (status));

  image_lock.unlock ();

  lock_guard<mutex> depth_lock(depth_mutex_);
  status = depth_generator_.SetIntProperty ("RegistrationType", 1);
  if (status != XN_STATUS_OK)
    THROW_OPENNI_EXCEPTION ("Error setting the registration type. Reason: %s", xnGetStatusString (status));
}