|
@@ -71,14 +71,19 @@ namespace BBIWARG.Input.InputProviding
|
|
keepActive();
|
|
keepActive();
|
|
}
|
|
}
|
|
|
|
|
|
- private void initCameraDevice()
|
|
|
|
|
|
+ private bool initCameraDevice()
|
|
{
|
|
{
|
|
senseManager = PXCMSenseManager.CreateInstance();
|
|
senseManager = PXCMSenseManager.CreateInstance();
|
|
PXCMVideoModule.DataDesc ddesc = new PXCMVideoModule.DataDesc();
|
|
PXCMVideoModule.DataDesc ddesc = new PXCMVideoModule.DataDesc();
|
|
ddesc.deviceInfo.streams = PXCMCapture.StreamType.STREAM_TYPE_DEPTH;
|
|
ddesc.deviceInfo.streams = PXCMCapture.StreamType.STREAM_TYPE_DEPTH;
|
|
senseManager.EnableStreams(ddesc);
|
|
senseManager.EnableStreams(ddesc);
|
|
|
|
|
|
- senseManager.Init();
|
|
|
|
|
|
+ var initStatus = senseManager.Init();
|
|
|
|
+
|
|
|
|
+ if (initStatus != pxcmStatus.PXCM_STATUS_NO_ERROR) {
|
|
|
|
+ Console.WriteLine("Could not init camera. Result: " + initStatus);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
|
|
PXCMPointF32 fov = senseManager.captureManager.device.QueryDepthFieldOfView();
|
|
PXCMPointF32 fov = senseManager.captureManager.device.QueryDepthFieldOfView();
|
|
FieldOfViewHorizontal = fov.x;
|
|
FieldOfViewHorizontal = fov.x;
|
|
@@ -86,6 +91,8 @@ namespace BBIWARG.Input.InputProviding
|
|
|
|
|
|
lowConfidenceValue = senseManager.captureManager.device.QueryDepthLowConfidenceValue();
|
|
lowConfidenceValue = senseManager.captureManager.device.QueryDepthLowConfidenceValue();
|
|
senseManager.captureManager.device.SetDepthConfidenceThreshold((UInt16)Parameters.ConfidenceImageMinThreshold);
|
|
senseManager.captureManager.device.SetDepthConfidenceThreshold((UInt16)Parameters.ConfidenceImageMinThreshold);
|
|
|
|
+
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
public void stop()
|
|
public void stop()
|
|
@@ -106,10 +113,12 @@ namespace BBIWARG.Input.InputProviding
|
|
Task<bool> initCameraTask = Task.Run(() => restartCamera());
|
|
Task<bool> initCameraTask = Task.Run(() => restartCamera());
|
|
crashed = !initCameraTask.Wait(TimeSpan.FromSeconds(5)) || !initCameraTask.Result;
|
|
crashed = !initCameraTask.Wait(TimeSpan.FromSeconds(5)) || !initCameraTask.Result;
|
|
|
|
|
|
- Thread.Yield();
|
|
|
|
|
|
+ if (crashed) {
|
|
|
|
+ Console.WriteLine("Something went wrong during init. Waiting a few seconds to cool down...");
|
|
|
|
+ Thread.Sleep(2000);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
-
|
|
|
|
crashed = !tryAcquireAndHandleFrame();
|
|
crashed = !tryAcquireAndHandleFrame();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -146,14 +155,17 @@ namespace BBIWARG.Input.InputProviding
|
|
{
|
|
{
|
|
crashed = false;
|
|
crashed = false;
|
|
senseManager.Dispose();
|
|
senseManager.Dispose();
|
|
- initCameraDevice();
|
|
|
|
|
|
+ return initCameraDevice();
|
|
}
|
|
}
|
|
catch (Exception)
|
|
catch (Exception)
|
|
{
|
|
{
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- return true;
|
|
|
|
|
|
+ public bool IsCrashed()
|
|
|
|
+ {
|
|
|
|
+ return crashed;
|
|
}
|
|
}
|
|
|
|
|
|
protected bool acquireNewFrame() {
|
|
protected bool acquireNewFrame() {
|
|
@@ -185,6 +197,9 @@ namespace BBIWARG.Input.InputProviding
|
|
senseManager.Dispose();
|
|
senseManager.Dispose();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
private void handleNewFrame()
|
|
private void handleNewFrame()
|
|
{
|
|
{
|
|
PXCMCapture.Sample sample = senseManager.QuerySample();
|
|
PXCMCapture.Sample sample = senseManager.QuerySample();
|