mariuszhermansdorfer / SandWorm

Augmented Reality Sandbox for Grasshopper & Rhino
MIT License
20 stars 11 forks source link

Add Kinect for Azure Support #61

Closed philipbelesky closed 3 years ago

philipbelesky commented 4 years ago

Will likely involve splitting or augmenting Core.cs and shifting a number of constants regarding FoV/resolution into some sort of manager.

philipbelesky commented 4 years ago

Ok, some initial challenges/thoughts:

philipbelesky commented 4 years ago

Actually, maybe its just easiest to update to .NET 4.6.1? I think that is installed by default on Windows 10 and users can always install it themselves if needed. That would also potentially come with a better JIT compiler and fewer issues with our other dependencies.

mariuszhermansdorfer commented 4 years ago

I think we should upgrade .NET. It's better to do it now before we have shipped the plugin than later when we have a user base counted in millions ;)

Support for Kinect 2 and Azure should definitely persist between sessions. I like the idea of bundling the selection into the options component.

Btw - 4 Kinects Azure DK have just arrived at my desk!

mariuszhermansdorfer commented 4 years ago

OK, merged the PRs you posted. I'm a bit swamped with work now so won't be able to contribute significantly in the coming week, but feel free to ping me with specific questions and issues.

philipbelesky commented 4 years ago

@mariuszhermansdorfer @BarusXXX just a couple of handover notes:

BarusXXX commented 4 years ago

@philipbelesky @mariuszhermansdorfer , I managed to run it with VS2019. I managed to pinpoint the problem with transforming the depth frame. Currently the depth array is present but all values in it are of 0 value. On each item in the array being, assigned by the sensor that value is going to 1000000. Does the issue that philip pointed to use a transformation that is different than the one you had for the other kinects? link image

BarusXXX commented 4 years ago

Thrown at this line; https://github.com/mariuszhermansdorfer/SandWorm/blob/e57a23fce654642efff7a84acbe7aa3187370f75/SandWorm/Sensors/K4AController.cs#L89

System.ArgumentException: 'depthImage must have 0 width in pixels but has 1024. Parameter name: depthImage'

It seems that the transformation requires an array shaped; 0 x 3145728 While we are giving it (1024x1024) @philipbelesky I guess the transform mapping is a known issue? https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/1012#issuecomment-571241628

BarusXXX commented 4 years ago

@philipbelesky With depth mode set to DepthMode = DepthMode.WideViewUnbinned the Stride(bytes for each horizontal line) is 2048 and not 6144, which I get is only the Z value. I am not sure that the function in that line is being used correctly. I have started a new branch with my changes for your review.

BarusXXX commented 4 years ago

https://github.com/microsoft/Azure-Kinect-Sensor-SDK/blob/a227f73b8c78e17db843e7a962a1fabd571c6213/examples/fastpointcloud/main.cpp#L54 Here there is a fast point cloud data fetch example

BarusXXX commented 4 years ago

Some progress at last... image In aspect mode I am seeing something and when I exaggerate the z axis I can resolve that there is some depth to the mesh. So ushorts are being mapped to the wrong height? @philipbelesky do you know if there is some formula to covert depth into height? Or is this resolved when the we implement the transform function?

BarusXXX commented 4 years ago

@mariuszhermansdorfer This is the relevant branch we are working on https://github.com/mariuszhermansdorfer/SandWorm/tree/feature/%2361-MAKS-not-k4a

mariuszhermansdorfer commented 4 years ago

do you know if there is some formula to covert depth into height? Or is this resolved when the we implement the transform function?

@BarusXXX, the depth is converted into height in this function: https://github.com/mariuszhermansdorfer/SandWorm/blob/2b53d409f3cc18aa32da5d14bd61c5a1802dead8/SandWorm/Components/BaseKinectComponent.cs#L185

We multiply it by -1 * unitsMultiplier to flip the direction on the Z axis. Kinect measures the distance looking away from the sensor, while we want to have a 2.5D grid growing away from the table.