2015-01-09 3 views
0

사용자의 머리를 기준으로 사용자의 바닥 위치를 감지 할 수있는 Kinect (v1) 응용 프로그램을 개발 중입니다.WPF 캔버스의 Kinect 공간에서 3D 점을 정확하게 그리는 방법은 무엇입니까?

사용자의 머리 부분에서 시작하여 헤드 포인트에 가장 가까운 바닥 평면의 점에서 끝나는 캔버스에서 WPF로 선을 그립니다 (완전히 수직선이어야 함).

그러나 저는 WPF, 캔버스 및 Kinect를 처음 사용하기 때문에 새로운 것보다 훨씬 더 아래쪽으로 끝나는 스케일 문제가 있습니다. (Kinect 피드 그리드 외부). 내가 스케일링 문제라고 생각하는 이유는 그것이 완전히 수직이고 카메라에서 더 멀리 또는 더 멀리 걸을 때 정확하게 위아래로 움직이기 때문입니다.

SkeletonPoint headPos = currentSkeleton.Joints[JointType.Head].Position; 
SkeletonPoint floorPoint = getSkeletonFloorPoint(headPos, floorPlane);  
CoordinateMapper mapper = new CoordinateMapper(KinectSensor); 

ColorImagePoint colorHeadPoint = mapper.MapSkeletonPointToColorPoint(headPos, ColorImageFormat.RgbResolution640x480Fps30); 
Point mappedHeadPoint = new Point(colorHeadPoint.X, colorHeadPoint.Y); 


ColorImagePoint colorFloorPoint = mapper.MapSkeletonPointToColorPoint(floorPoint, ColorImageFormat.RgbResolution640x480Fps30); 
Point mappedFloorPoint = new Point(colorFloorPoint.X, colorFloorPoint.Y); 


drawUserPosition(userPos, mappedHeadPoint, mappedFloorPoint); 

선두 위치에 기초하여 상기 바닥 지점을 계산이 방법 : 광고 위치

private SkeletonPoint getSkeletonFloorPoint(SkeletonPoint skeletonHeadPos, Tuple<float, float, float, float> floorPlane) 
{ 
    Point3D headPos = new Point3D(skeletonHeadPos.X, skeletonHeadPos.Y, skeletonHeadPos.Z); 
    Point3D pointOnPlane = new Point3D(0, (double) -(floorPlane.Item2/floorPlane.Item4), 0); 
    Vector3D planeNorm = new Vector3D(floorPlane.Item1, floorPlane.Item2, floorPlane.Item3); 
    Vector3D planeToHead = Point3D.Subtract(headPos, pointOnPlane); 

    double dist = Vector3D.DotProduct(planeNorm, planeToHead); 
    Point3D floorPoint = Vector3D.Add(Vector3D.Multiply(-dist, planeNorm), headPos); 

    SkeletonPoint skeletonFloorPoint = new SkeletonPoint(); 
    skeletonFloorPoint.X = (float) floorPoint.X; 
    skeletonFloorPoint.Y = (float) floorPoint.Y; 
    skeletonFloorPoint.Z = (float) floorPoint.Z; 

    return skeletonFloorPoint; 
} 

이 세트 :

이것은이 동작 코드의 본체는

private void drawUserPosition(Line userPos, Point headPoint, Point floorPoint) 
{ 
    userPos.X1 = headPoint.X; 
    userPos.Y1 = headPoint.Y; 
    userPos.X2 = floorPoint.X; 
    userPos.Y2 = floorPoint.Y; 

} 

이것은 캔버스의 XAML입니다.

내가 말했듯이
<Canvas> 
    <kt:KinectSkeletonViewer 
     KinectSensorManager="{Binding KinectSensorManager}" 
     Visibility="{Binding KinectSensorManager.ColorStreamEnabled, Converter={StaticResource BoolToVisibilityConverter}}" 
     Width="{Binding ElementName=ColorViewer,Path=ActualWidth}" 
     Height="{Binding ElementName=ColorViewer,Path=ActualHeight}" 
     ImageType="Color" /> 

    <Line X1="0" Y1="0" X2="0" Y2="0" Name="userPos" Stroke="Red" StrokeThickness="2" /> 

</Canvas> 

, 정말 내가 잘못 가고 곳이 꽤 확신 그냥 WPF 어떤 경험이없는, 형상이 올바른지 생각 .

도움을 주셔서 감사합니다. 더 쉽게 해결할 수 있도록 제공 할 수있는 세부 정보가 있으면 제공해 드리겠습니다.

답변

0

죄송합니다. 저의 바보 같은 실수입니다.

내가 실수 한 부문에 두 개의 값을 뒤집어 바닥면에 임의의 지점을 찾기 위해 노력 :

Point3D pointOnPlane = new Point3D(0, (double) -(floorPlane.Item2/floorPlane.Item4), 0); 

이 올바른 코드 :

Point3D pointOnPlane = new Point3D(0, (double) -(floorPlane.Item4/floorPlane.Item2), 0); 
관련 문제