|
@@ -17,26 +17,13 @@ namespace bbiwarg.InputProviders
|
|
|
|
|
|
//parameters
|
|
|
private IParameterHandle<float> frameRate;
|
|
|
+ private IParameterHandle<int> currentMovieFrame;
|
|
|
private IParameterHandle<float> hfov;
|
|
|
private IParameterHandle<float> vfov;
|
|
|
private IParameterHandle<int> playStep;
|
|
|
|
|
|
//data
|
|
|
- private IDataHandle<int>[] handStatus = new IDataHandle<int>[2];
|
|
|
- private IDataHandle<bool>[] handOpen = new IDataHandle<bool>[2];
|
|
|
- private IDataHandle<int>[] handSides = new IDataHandle<int>[2];
|
|
|
- private IDataHandle<int[]>[] fingerStatus = new IDataHandle<int[]>[2];
|
|
|
- private IDataHandle<Iisu.Data.Vector3>[] palmPositions3D = new IDataHandle<Iisu.Data.Vector3>[2];
|
|
|
- private IDataHandle<Iisu.Data.Vector2>[] palmPositions2D = new IDataHandle<Iisu.Data.Vector2>[2];
|
|
|
- private IDataHandle<Iisu.Data.Vector3>[] tipPositions3D = new IDataHandle<Iisu.Data.Vector3>[2];
|
|
|
- private IDataHandle<Iisu.Data.Vector3>[] forearmPositions3D = new IDataHandle<Iisu.Data.Vector3>[2];
|
|
|
- private IDataHandle<Iisu.Data.Vector3>[] palmNormals3D = new IDataHandle<Iisu.Data.Vector3>[2];
|
|
|
- private IDataHandle<Iisu.Data.Vector3[]>[] fingerTipPositions3D = new IDataHandle<Iisu.Data.Vector3[]>[2];
|
|
|
- private IDataHandle<Iisu.Data.Vector2[]>[] fingerTipPositions2D = new IDataHandle<Iisu.Data.Vector2[]>[2];
|
|
|
private IDataHandle<Iisu.Data.IImageData> depthImage;
|
|
|
- private IDataHandle<Iisu.Data.IImageData> confidenceImage;
|
|
|
- private IDataHandle<Iisu.Data.IImageData> uvImage;
|
|
|
- private IDataHandle<Iisu.Data.IImageData> colorImage;
|
|
|
|
|
|
public IisuInputProvider(String moviePath = "")
|
|
|
{
|
|
@@ -78,6 +65,7 @@ namespace bbiwarg.InputProviders
|
|
|
}
|
|
|
|
|
|
frameRate = device.RegisterParameterHandle<float>("SOURCE.FrameRate");
|
|
|
+ currentMovieFrame = device.RegisterParameterHandle<int>("SOURCE.MOVIE.CurrentFrame");
|
|
|
hfov = device.RegisterParameterHandle<float>("SOURCE.CAMERA.DEPTH.HFOV");
|
|
|
vfov = device.RegisterParameterHandle<float>("SOURCE.CAMERA.DEPTH.VFOV");
|
|
|
|
|
@@ -85,43 +73,7 @@ namespace bbiwarg.InputProviders
|
|
|
device.EventManager.RegisterEventListener("DEVICE.Status", new Iisu.EventDelegates.Device.Status(onDeviceStatusChanged));
|
|
|
|
|
|
// data
|
|
|
- handStatus[0] = device.RegisterDataHandle<int>("CI.HAND1.Status");
|
|
|
- handStatus[1] = device.RegisterDataHandle<int>("CI.HAND2.Status");
|
|
|
-
|
|
|
- handOpen[0] = device.RegisterDataHandle<bool>("CI.HAND1.IsOpen");
|
|
|
- handOpen[1] = device.RegisterDataHandle<bool>("CI.HAND2.IsOpen");
|
|
|
-
|
|
|
- handSides[0] = device.RegisterDataHandle<int>("CI.HAND1.Side");
|
|
|
- handSides[1] = device.RegisterDataHandle<int>("CI.HAND1.Side");
|
|
|
-
|
|
|
- fingerStatus[0] = device.RegisterDataHandle<int[]>("CI.HAND1.FingerStatus");
|
|
|
- fingerStatus[1] = device.RegisterDataHandle<int[]>("CI.HAND2.FingerStatus");
|
|
|
-
|
|
|
- palmPositions3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND1.PalmPosition3D");
|
|
|
- palmPositions3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND2.PalmPosition3D");
|
|
|
-
|
|
|
- palmPositions2D[0] = device.RegisterDataHandle<Iisu.Data.Vector2>("CI.HAND1.PalmPosition2D");
|
|
|
- palmPositions2D[1] = device.RegisterDataHandle<Iisu.Data.Vector2>("CI.HAND2.PalmPosition2D");
|
|
|
-
|
|
|
- tipPositions3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND1.TipPosition3D");
|
|
|
- tipPositions3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND2.TipPosition3D");
|
|
|
-
|
|
|
- forearmPositions3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND1.ForearmPosition3D");
|
|
|
- forearmPositions3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND2.ForearmPosition3D");
|
|
|
-
|
|
|
- palmNormals3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND1.PalmNormal3D");
|
|
|
- palmNormals3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND2.PalmNormal3D");
|
|
|
-
|
|
|
- fingerTipPositions3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3[]>("CI.HAND1.FingerTipPositions3D");
|
|
|
- fingerTipPositions3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3[]>("CI.HAND2.FingerTipPositions3D");
|
|
|
-
|
|
|
- fingerTipPositions2D[0] = device.RegisterDataHandle<Iisu.Data.Vector2[]>("CI.HAND1.FingerTipPositions2D");
|
|
|
- fingerTipPositions2D[1] = device.RegisterDataHandle<Iisu.Data.Vector2[]>("CI.HAND2.FingerTipPositions2D");
|
|
|
-
|
|
|
depthImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.DEPTH.Image");
|
|
|
- colorImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.COLOR.Image");
|
|
|
- confidenceImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.CONFIDENCE.Image");
|
|
|
- uvImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.COLOR.REGISTRATION.UV.Image");
|
|
|
}
|
|
|
|
|
|
private void onDeviceStatusChanged(string eventName, DeviceStatus status)
|
|
@@ -173,172 +125,18 @@ namespace bbiwarg.InputProviders
|
|
|
|
|
|
|
|
|
// Data-methodes
|
|
|
- public DetectionStatus getHandStatus(uint handIndex)
|
|
|
- {
|
|
|
- checkHandIndex(handIndex);
|
|
|
- int status = handStatus[handIndex - 1].Value;
|
|
|
- DetectionStatus result = new DetectionStatus();
|
|
|
- switch (status)
|
|
|
- {
|
|
|
- case 0:
|
|
|
- result = DetectionStatus.Inactive;
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- result = DetectionStatus.Detected;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- result = DetectionStatus.Tracked;
|
|
|
- break;
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- public bool isHandOpen(uint handIndex)
|
|
|
- {
|
|
|
- checkHandIndex(handIndex);
|
|
|
- return handOpen[handIndex - 1].Value;
|
|
|
- }
|
|
|
-
|
|
|
- public HandSide getHandSide(uint handIndex)
|
|
|
- {
|
|
|
- checkHandIndex(handIndex);
|
|
|
- int side = handSides[handIndex - 1].Value;
|
|
|
- switch (side)
|
|
|
- {
|
|
|
- case 1:
|
|
|
- return HandSide.Left;
|
|
|
- case 2:
|
|
|
- return HandSide.Right;
|
|
|
- default:
|
|
|
- return HandSide.Unknown;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public DetectionStatus[] getFingerStatus(uint handIndex)
|
|
|
- {
|
|
|
- checkHandIndex(handIndex);
|
|
|
- int[] status = fingerStatus[handIndex - 1].Value;
|
|
|
- DetectionStatus[] result = new DetectionStatus[status.Length];
|
|
|
- for (int i = 0; i < status.Length; ++i)
|
|
|
- {
|
|
|
- switch (status[i])
|
|
|
- {
|
|
|
- case 0:
|
|
|
- result[i] = DetectionStatus.Inactive;
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- result[i] = DetectionStatus.Detected;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- result[i] = DetectionStatus.Tracked;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- public Vector getPalmPosition3D(uint handIndex)
|
|
|
- {
|
|
|
- checkHandIndex(handIndex);
|
|
|
- return new DenseVector(swapXZYtoXYZ(palmPositions3D[handIndex - 1].Value.ToArray()));
|
|
|
- }
|
|
|
-
|
|
|
- public Vector getPalmPosition2D(uint handIndex)
|
|
|
- {
|
|
|
- checkHandIndex(handIndex);
|
|
|
- return new DenseVector(palmPositions2D[handIndex - 1].Value.ToArray());
|
|
|
- }
|
|
|
-
|
|
|
- public Vector getTipPosition3D(uint handIndex)
|
|
|
- {
|
|
|
- checkHandIndex(handIndex);
|
|
|
- return new DenseVector(swapXZYtoXYZ(tipPositions3D[handIndex - 1].Value.ToArray()));
|
|
|
- }
|
|
|
-
|
|
|
- public Vector getForearmPosition3D(uint handIndex)
|
|
|
- {
|
|
|
- checkHandIndex(handIndex);
|
|
|
- return new DenseVector(swapXZYtoXYZ(forearmPositions3D[handIndex - 1].Value.ToArray()));
|
|
|
- }
|
|
|
-
|
|
|
- public Vector getPalmNormal3D(uint handIndex)
|
|
|
- {
|
|
|
- checkHandIndex(handIndex);
|
|
|
- return new DenseVector(swapXZYtoXYZ(palmNormals3D[handIndex - 1].Value.ToArray()));
|
|
|
- }
|
|
|
-
|
|
|
- public Vector[] getFingerTipPositions3D(uint handIndex)
|
|
|
- {
|
|
|
- checkHandIndex(handIndex);
|
|
|
- Iisu.Data.Vector3[] positions = fingerTipPositions3D[handIndex - 1].Value;
|
|
|
- Vector[] results = new DenseVector[positions.Length];
|
|
|
- for (int i = 0; i < positions.Length; ++i)
|
|
|
- results[i] = new DenseVector(swapXZYtoXYZ(positions[i].ToArray()));
|
|
|
- return results;
|
|
|
- }
|
|
|
-
|
|
|
- public Vector[] getFingerTipPositions2D(uint handIndex)
|
|
|
- {
|
|
|
- checkHandIndex(handIndex);
|
|
|
- Iisu.Data.Vector2[] positions = fingerTipPositions2D[handIndex - 1].Value;
|
|
|
- Vector[] results = new DenseVector[positions.Length];
|
|
|
- for (int i = 0; i < positions.Length; ++i)
|
|
|
- results[i] = new DenseVector(positions[i].ToArray());
|
|
|
- return results;
|
|
|
- }
|
|
|
-
|
|
|
public InputFrame getInputFrame() {
|
|
|
//depthData
|
|
|
Iisu.Data.IImageInfos imageInfos = depthImage.Value.ImageInfos;
|
|
|
int width = (int)imageInfos.Width;
|
|
|
int height = (int)imageInfos.Height;
|
|
|
- int numBytes = (int)imageInfos.BytesRaw;
|
|
|
- IntPtr imageData = depthImage.Value.Raw;
|
|
|
- short[] depthData = new short[width * height];
|
|
|
- Marshal.Copy(imageData, depthData, 0, width * height);
|
|
|
-
|
|
|
- //confidenceData
|
|
|
- imageInfos = confidenceImage.Value.ImageInfos;
|
|
|
- numBytes = (int)imageInfos.BytesRaw;
|
|
|
- imageData = confidenceImage.Value.Raw;
|
|
|
- short[] confidenceData = new short[width * height];
|
|
|
- Marshal.Copy(imageData, confidenceData, 0, width * height);
|
|
|
+ IntPtr rawDepthData = depthImage.Value.Raw;
|
|
|
|
|
|
- //uvData
|
|
|
- imageInfos = uvImage.Value.ImageInfos;
|
|
|
- numBytes = (int)imageInfos.BytesRaw;
|
|
|
- imageData = uvImage.Value.Raw;
|
|
|
- float[] uvData = new float[2 * width * height];
|
|
|
- Marshal.Copy(imageData, uvData, 0, 2 * width * height);
|
|
|
-
|
|
|
- //colorData
|
|
|
- imageInfos = colorImage.Value.ImageInfos;
|
|
|
- int widthRawColor = (int)imageInfos.Width;
|
|
|
- int heightRawColor = (int)imageInfos.Height;
|
|
|
- numBytes = (int)imageInfos.BytesRaw;
|
|
|
- imageData = colorImage.Value.Raw;
|
|
|
- byte[] colorData = new byte[numBytes];
|
|
|
- Marshal.Copy(imageData, colorData, 0, numBytes);
|
|
|
-
|
|
|
- return new InputFrame(width, height, widthRawColor, heightRawColor, depthData, confidenceData, uvData, colorData);
|
|
|
+ return new InputFrame(width, height, rawDepthData);
|
|
|
}
|
|
|
|
|
|
// other
|
|
|
|
|
|
- private void checkHandIndex(uint handIndex)
|
|
|
- {
|
|
|
- if (handIndex < 1 || handIndex > 2)
|
|
|
- throw new ArgumentOutOfRangeException("handIndex is out of range [0,1]");
|
|
|
- }
|
|
|
-
|
|
|
- private float[] swapXZYtoXYZ(float[] vector)
|
|
|
- {
|
|
|
- float dummy = vector[1];
|
|
|
- vector[1] = vector[2];
|
|
|
- vector[2] = dummy;
|
|
|
- return vector;
|
|
|
- }
|
|
|
-
|
|
|
public void pauseMovie()
|
|
|
{
|
|
|
if (sourceIsMovie)
|
|
@@ -351,6 +149,10 @@ namespace bbiwarg.InputProviders
|
|
|
playStep.Value = 1;
|
|
|
}
|
|
|
|
|
|
+ public int getCurrentMovieFrame()
|
|
|
+ {
|
|
|
+ return currentMovieFrame.Value;
|
|
|
+ }
|
|
|
|
|
|
bool IInputProvider.sourceIsMovie()
|
|
|
{
|