update Kinect Grpc and add submodule

master
uc-hoba 8 years ago
parent bcbb38d97a
commit f6cf76f73d
  1. 4
      .gitmodules
  2. 10
      Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectBufferComposite.compute
  3. 36
      Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectGrpcServer.cs
  4. 1
      of_v0.9.8/addons/ofxUCKinectV2

4
.gitmodules vendored

@ -29,3 +29,7 @@
path = of_v0.9.8/uc_libs/lib_grpc path = of_v0.9.8/uc_libs/lib_grpc
url = https://github.com/UltraCombos/lib_grpc url = https://github.com/UltraCombos/lib_grpc
branch = master branch = master
[submodule "of_v0.9.8/addons/ofxUCKinectV2"]
path = of_v0.9.8/addons/ofxUCKinectV2
url = https://github.com/UltraCombos/ofxUCKinectV2
branch = master

@ -9,8 +9,8 @@ RWStructuredBuffer<float4> kinect_motion_buffer;
RWStructuredBuffer<float4> position_buffer; RWStructuredBuffer<float4> position_buffer;
RWStructuredBuffer<float4> velocity_buffer; RWStructuredBuffer<float4> velocity_buffer;
Texture2D<float> depth_high_texture; Texture2D<float2> depth_texture;
Texture2D<float> depth_low_texture; //Texture2D<float> depth_low_texture;
Texture2D<float2> velocity_texture; Texture2D<float2> velocity_texture;
float4x4 kinect_matrix; float4x4 kinect_matrix;
@ -22,8 +22,8 @@ float3 clip_box;
void CSMain(uint3 id : SV_DispatchThreadID) void CSMain(uint3 id : SV_DispatchThreadID)
{ {
int index = id.y * WIDTH + id.x; int index = id.y * WIDTH + id.x;
int high = (int)(depth_high_texture[id.xy].x * 255.0); int high = (int)(depth_texture[id.xy].y * 255.0);
int low = (int)(depth_low_texture[id.xy].x * 255.0); int low = (int)(depth_texture[id.xy].x * 255.0);
float depth = (float)((high << 8) + low) * 0.001; float depth = (float)((high << 8) + low) * 0.001;
float2 vel = velocity_texture[id.xy].xy * 255.0 - 128.0; float2 vel = velocity_texture[id.xy].xy * 255.0 - 128.0;
@ -69,7 +69,7 @@ void CSMain(uint3 id : SV_DispatchThreadID)
} }
float3 kpos = mul(kinect_matrix, float4(t_p3d, 1.0)).xyz; float3 kpos = mul(kinect_matrix, float4(t_p3d, 1.0)).xyz;
float3 kvel = mul(kinect_matrix, float4(-vel3d, 0.0)).xyz; float3 kvel = mul(kinect_matrix, float4(vel3d, 0.0)).xyz;
if ((kpos.x < -clip_box.x * 0.5 || kpos.x > clip_box.x * 0.5 || if ((kpos.x < -clip_box.x * 0.5 || kpos.x > clip_box.x * 0.5 ||
kpos.z < -clip_box.z * 0.5 || kpos.z > clip_box.z * 0.5 || kpos.z < -clip_box.z * 0.5 || kpos.z > clip_box.z * 0.5 ||

@ -68,10 +68,10 @@ namespace UltraCombos.Kinect2MotionTransmit
public ComputeBuffer FinalVelocityBuffer { get { return final_velocity_buffer; } } public ComputeBuffer FinalVelocityBuffer { get { return final_velocity_buffer; } }
Texture2D depth_high_texture; Texture2D depth_texture;
byte[] depth_high_data; byte[] depth_data;
Texture2D depth_low_texture; //Texture2D depth_low_texture;
byte[] depth_low_data; //byte[] depth_low_data;
Texture2D velocity_texture; Texture2D velocity_texture;
byte[] velocity_data; byte[] velocity_data;
@ -91,13 +91,13 @@ namespace UltraCombos.Kinect2MotionTransmit
private void Start() private void Start()
{ {
buffer = new ComputeBuffer(width * height, sizeof(float) * 4); buffer = new ComputeBuffer(width * height, sizeof(float) * 4);
Debug.LogFormat("[Kinect Grpc] Buffer is created by count {0} and stride {1}", buffer.count, buffer.stride); Debug.LogFormat("Buffer is created by count {0} and stride {1}", buffer.count, buffer.stride);
depth_high_data = new byte[buffer.count / 2]; depth_data = new byte[buffer.count ];
depth_low_data = new byte[buffer.count / 2]; //depth_low_data = new byte[buffer.count / 2];
velocity_data = new byte[buffer.count]; velocity_data = new byte[buffer.count];
depth_high_texture = new Texture2D(width, height, TextureFormat.BC4, false); depth_texture = new Texture2D(width, height, TextureFormat.BC5, false);
depth_low_texture = new Texture2D(width, height, TextureFormat.BC4, false); //depth_low_texture = new Texture2D(width, height, TextureFormat.BC4, false);
velocity_texture = new Texture2D(width, height, TextureFormat.BC5, false); velocity_texture = new Texture2D(width, height, TextureFormat.BC5, false);
final_position_buffer = new ComputeBuffer(width * height, sizeof(float) * 4); final_position_buffer = new ComputeBuffer(width * height, sizeof(float) * 4);
@ -152,19 +152,19 @@ namespace UltraCombos.Kinect2MotionTransmit
kinect.matrix = Matrix4x4.TRS(pos, q, Vector3.one); kinect.matrix = Matrix4x4.TRS(pos, q, Vector3.one);
kinect.ClipBox = new Vector3(data.ClipSizeX, data.ClipSizeY, data.ClipSizeZ); kinect.ClipBox = new Vector3(data.ClipSizeX, data.ClipSizeY, data.ClipSizeZ);
data.DepthHighData.CopyTo(depth_high_data, 0); data.DepthHighData.CopyTo(depth_data, 0);
data.DepthLowData.CopyTo(depth_low_data, 0); //data.DepthLowData.CopyTo(depth_low_data, 0);
data.VelocityData.CopyTo(velocity_data, 0); data.VelocityData.CopyTo(velocity_data, 0);
depth_high_texture.LoadRawTextureData(depth_high_data); depth_texture.LoadRawTextureData(depth_data);
depth_high_texture.Apply(); depth_texture.Apply();
depth_low_texture.LoadRawTextureData(depth_low_data); //depth_low_texture.LoadRawTextureData(depth_low_data);
depth_low_texture.Apply(); //depth_low_texture.Apply();
velocity_texture.LoadRawTextureData(velocity_data); velocity_texture.LoadRawTextureData(velocity_data);
velocity_texture.Apply(); velocity_texture.Apply();
shader.SetTexture(0, "depth_high_texture", depth_high_texture); shader.SetTexture(0, "depth_texture", depth_texture);
shader.SetTexture(0, "depth_low_texture", depth_low_texture); //shader.SetTexture(0, "depth_low_texture", depth_low_texture);
shader.SetTexture(0, "velocity_texture", velocity_texture); shader.SetTexture(0, "velocity_texture", velocity_texture);
shader.SetBuffer(0, "kinect_motion_buffer", buffer); shader.SetBuffer(0, "kinect_motion_buffer", buffer);
shader.SetBuffer(0, "position_buffer", kinect.position); shader.SetBuffer(0, "position_buffer", kinect.position);
@ -257,7 +257,7 @@ namespace UltraCombos.Kinect2MotionTransmit
}; };
server.Start(); server.Start();
Debug.Log("[Kinect Grpc] Start Server"); Debug.Log("Start Server");
} }
catch (System.Exception e) catch (System.Exception e)
{ {

@ -0,0 +1 @@
Subproject commit 7a21425420a8c2f2a0dbef23c3b3684f114d7a15
Loading…
Cancel
Save