Skip to content
Permalink
Browse files

Orbbec: Throw exception on timeout and make it configurable.

  • Loading branch information
sisiplac committed Feb 3, 2020
1 parent 577b045 commit 5b8005cfdf424526dc5d4bf5e6e0efa4e5f3b590
Showing with 28 additions and 4 deletions.
  1. +7 −4 BetaCameras/OrbbecOpenNI/OrbbecOpenNI.cpp
  2. +21 −0 BetaCameras/OrbbecOpenNI/OrbbecOpenNI.h
@@ -28,6 +28,7 @@ MetriCam2::Cameras::AstraOpenNI::AstraOpenNI()
_uvcColorHeight = 960;
_uvcColorEnforceNewImageInUpdate = false;
_depthStreamRunning = false;
_updateTimeoutMilliseconds = 500;
_extrinsicsCache = gcnew System::Collections::Generic::Dictionary<String^, RigidBodyTransformation^>();
_intrinsicsCache = gcnew System::Collections::Generic::Dictionary<String^, ProjectiveTransformation^>();
}
@@ -558,19 +559,21 @@ void MetriCam2::Cameras::AstraOpenNI::UpdateImpl()
while (!gotAllRequestedStreams)
{
int changedIndex;
openni::Status rc = openni::OpenNI::waitForAnyStream(ppStreams, numberActivatedOpenNIStreams, &changedIndex, 500);
openni::Status rc = openni::OpenNI::waitForAnyStream(ppStreams, numberActivatedOpenNIStreams, &changedIndex, UpdateTimeoutMilliseconds);
if (openni::STATUS_OK != rc)
{
String^ errorString;
if (openni::STATUS_TIME_OUT == rc)
{
log->ErrorFormat("{0} {1}: Wait failed: timeout", Name, SerialNumber);
errorString = String::Format("{0} {1}: Wait failed: timeout", Name, SerialNumber);
}
else
{
log->ErrorFormat("{0} {1}: Wait failed: rc={2}", Name, SerialNumber, (int)rc);
errorString = String::Format("{0} {1}: Wait failed: rc={2}", Name, SerialNumber, (int)rc);
}
log->Error(errorString);
delete ppStreams;
return;
throw gcnew MetriCam2::Exceptions::MetriCam2Exception(errorString);
}
ppStreams[changedIndex] = NULL;

@@ -132,6 +132,13 @@ namespace MetriCam2
void set(int value) { SetIRGain(value); }
}

/// Timeout for method <see cref="UpdateImpl"/>.
property int UpdateTimeoutMilliseconds
{
int get() { return _updateTimeoutMilliseconds; }
void set(int value) { _updateTimeoutMilliseconds = value; }
}

property UvcColorResolution UVCColorResolution
{
UvcColorResolution get()
@@ -361,6 +368,19 @@ namespace MetriCam2
}
}

property ParamDesc<int>^ UpdateTimeoutMillisecondsDesc
{
inline ParamDesc<int>^ get()
{
ParamDesc<int>^ res = ParamDesc::BuildRangeParamDesc(0, 30000);
res->Unit = "";
res->Description = "Update timeout [ms]";
res->ReadableWhen = ParamDesc::ConnectionStates::Connected | ParamDesc::ConnectionStates::Disconnected;
res->WritableWhen = ParamDesc::ConnectionStates::Connected | ParamDesc::ConnectionStates::Disconnected;
return res;
}
}

property ParamDesc<bool>^ ProximitySensorEnabledDesc
{
inline ParamDesc<bool>^ get()
@@ -460,6 +480,7 @@ namespace MetriCam2
// 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;
int _updateTimeoutMilliseconds;
System::Collections::Generic::Dictionary<String^, RigidBodyTransformation^>^ _extrinsicsCache;
System::Collections::Generic::Dictionary<String^, ProjectiveTransformation^>^ _intrinsicsCache;

0 comments on commit 5b8005c

Please sign in to comment.
You can’t perform that action at this time.