Skip to content

Commit

Permalink
[bugfix] Orbbec: Depth stream was not started, if both ZImage and Poi…
Browse files Browse the repository at this point in the history
…nt3DImage were activated before Connect.
  • Loading branch information
sisiplac committed Sep 2, 2019
1 parent c739bb5 commit 9559aed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions BetaCameras/OrbbecOpenNI/OrbbecOpenNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ MetriCam2::Cameras::AstraOpenNI::AstraOpenNI()
_uvcColorWidth = 1280;
_uvcColorHeight = 960;
_uvcColorEnforceNewImageInUpdate = false;
_depthStreamRunning = false;
_extrinsicsCache = gcnew System::Collections::Generic::Dictionary<String^, RigidBodyTransformation^>();
_intrinsicsCache = gcnew System::Collections::Generic::Dictionary<String^, ProjectiveTransformation^>();
}
Expand Down Expand Up @@ -496,6 +497,7 @@ void MetriCam2::Cameras::AstraOpenNI::DisconnectImpl()
IrStream.stop();
}
DepthStream.destroy();
_depthStreamRunning = false;
IrStream.destroy();

if (_hasOpenNIColor)
Expand Down Expand Up @@ -660,8 +662,7 @@ void MetriCam2::Cameras::AstraOpenNI::ActivateChannelImpl(String^ channelName)

openni::Status rc;

if ((channelName->Equals(ChannelNames::Point3DImage) && !IsChannelActive(ChannelNames::ZImage))
|| (channelName->Equals(ChannelNames::ZImage) && !IsChannelActive(ChannelNames::Point3DImage)))
if ((channelName->Equals(ChannelNames::Point3DImage) || channelName->Equals(ChannelNames::ZImage)) && !_depthStreamRunning)
{
auto irGainBefore = GetIRGain();

Expand Down Expand Up @@ -693,6 +694,8 @@ void MetriCam2::Cameras::AstraOpenNI::ActivateChannelImpl(String^ channelName)
// Activating the depth channel resets the IR gain to the default value -> we need to restore the value that was set before.
SetIRGain(irGainBefore);
}

_depthStreamRunning = true;
}
else if (channelName->Equals(ChannelNames::Intensity))
{
Expand Down Expand Up @@ -812,6 +815,7 @@ void MetriCam2::Cameras::AstraOpenNI::DeactivateChannelImpl(String^ channelName)
if (channelName->Equals(ChannelNames::ZImage) || channelName->Equals(ChannelNames::Point3DImage))
{
DepthStream.stop();
_depthStreamRunning = false;
}
else if (channelName->Equals(ChannelNames::Intensity))
{
Expand Down
1 change: 1 addition & 0 deletions BetaCameras/OrbbecOpenNI/OrbbecOpenNI.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ namespace MetriCam2
int _uvcColorWidth;
int _uvcColorHeight;
bool _uvcColorEnforceNewImageInUpdate;
bool _depthStreamRunning;
// Compensate for offset between IR and Distance images:
// Translate infrared frame by a certain number of pixels in vertical direction to match infrared with depth image.
int _intensityYTranslation;
Expand Down

0 comments on commit 9559aed

Please sign in to comment.