Skip to content

Commit

Permalink
Update OpenNI2 grabber to support devices without color
Browse files Browse the repository at this point in the history
This commit contains a subset of changes proposed by @metacomgd in PointCloudLibrary#1174.
  • Loading branch information
taketwo committed Oct 11, 2015
1 parent 4b1af99 commit 18e1bce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion io/src/openni2/openni2_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ pcl::io::openni2::OpenNI2Device::OpenNI2Device (const std::string& device_URI) :
// Set default resolution if not reading a file
if (!openni_device_->isFile ())
{
setColorVideoMode (getDefaultColorMode ());
if (openni_device_->hasSensor (openni::SENSOR_COLOR))
{
setColorVideoMode (getDefaultColorMode ());
}
setDepthVideoMode (getDefaultDepthMode ());
setIRVideoMode (getDefaultIRMode ());
}
Expand Down
6 changes: 3 additions & 3 deletions io/src/openni2_grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pcl::io::OpenNI2Grabber::start ()
try
{
// check if we need to start/stop any stream
if (image_required_ && !device_->isColorStreamStarted () )
if (image_required_ && !device_->isColorStreamStarted () && device_->hasColorSensor ())
{
block_signals ();
device_->startColorStream ();
Expand Down Expand Up @@ -401,8 +401,8 @@ pcl::io::OpenNI2Grabber::startSynchronization ()
{
try
{
if (device_->isSynchronizationSupported () && !device_->isSynchronized () && !device_->isFile () &&
device_->getColorVideoMode ().frame_rate_ == device_->getDepthVideoMode ().frame_rate_)
if (device_->hasColorSensor () && (device_->isSynchronizationSupported () && !device_->isSynchronized () && !device_->isFile () &&
device_->getColorVideoMode ().frame_rate_ == device_->getDepthVideoMode ().frame_rate_))
device_->setSynchronization (true);
}
catch (const IOException& exception)
Expand Down

0 comments on commit 18e1bce

Please sign in to comment.