Ejemplo n.º 1
0
    public void SwitchCameraEffect(ECameraType type, Camera cam, CameraEvent callback, params object[] args)
    {
        if (cam == null)
        {
            return;
        }
        List <CameraEffectBase> list = new List <CameraEffectBase>();

        cam.GetComponents(list);
        CameraEffectBase effect = null;

        for (int i = 0; i < list.Count; i++)
        {
            if (list[i].Type == type)
            {
                effect = list[i];
            }
            else
            {
                if (list[i].enabled && list[i].Type != ECameraType.FOLLOW)
                {
                    list[i].SwitchState(ECameraState.LEAVE);
                }
            }
        }
        if (effect == null)
        {
            AddCameraEffect(ref effect, type, cam);
        }
        effect.Init(0, cam, callback, args);
    }
Ejemplo n.º 2
0
        private void RenderBody(BodyWrapper body, ECameraType cameraType)
        {
            BodyDrawing bodyDrawing = BodyHelper.Instance.BodyDrawings.Where(x => x.TrackingId == body.TrackingId).FirstOrDefault();
            bool        isNewBody   = false;

            if (bodyDrawing == null)
            {
                bodyDrawing = new BodyDrawing(body, cameraType);
                BodyHelper.Instance.BodyDrawings.Add(bodyDrawing);
                isNewBody = true;
            }
            else
            {
                bodyDrawing.Update(body, cameraType);
            }

            if (_canvasCleared || isNewBody)
            {
                List <Ellipse> ellipses = bodyDrawing.JointEllipses.Select(x => x.Value).ToList();
                foreach (Ellipse ellipse in ellipses)
                {
                    canvasSkeleton.Children.Add(ellipse);
                }

                List <Line> lines = bodyDrawing.BoneLines.Select(x => x.Value).ToList();
                foreach (Line line in lines)
                {
                    canvasSkeleton.Children.Add(line);
                }

                _canvasCleared = false;
            }
        }
Ejemplo n.º 3
0
 public CameraInfo(ECameraManufacturer manufacturer, ECameraType cameraType, string modelName, string serialNo)
 {
     _manufacturer = manufacturer;
     _cameraType   = cameraType;
     _modelName    = modelName;
     _serialNo     = serialNo;
 }
Ejemplo n.º 4
0
        public Point MapCameraToSpace(Vector3 position, ECameraType cameraType)
        {
            CameraSpacePoint jointPosition = new CameraSpacePoint();

            jointPosition.X = position.X;
            jointPosition.Y = position.Y;
            jointPosition.Z = position.Z;

            switch (cameraType)
            {
            case ECameraType.Color:
                ColorSpacePoint colorPoint = KinectHelper.Instance.CoordinateMapper.MapCameraPointToColorSpace(jointPosition);
                return(new Point(float.IsInfinity(colorPoint.X) ? 0.0 : colorPoint.X, float.IsInfinity(colorPoint.X) ? 0.0 : colorPoint.Y));

            case ECameraType.Depth:
                DepthSpacePoint depthPoint = KinectHelper.Instance.CoordinateMapper.MapCameraPointToDepthSpace(jointPosition);
                return(new Point(float.IsInfinity(depthPoint.X) ? 0.0 : depthPoint.X, float.IsInfinity(depthPoint.X) ? 0.0 : depthPoint.Y));

            case ECameraType.Infrared:
                DepthSpacePoint depthPoint1 = KinectHelper.Instance.CoordinateMapper.MapCameraPointToDepthSpace(jointPosition);
                return(new Point(float.IsInfinity(depthPoint1.X) ? 0.0 : depthPoint1.X, float.IsInfinity(depthPoint1.X) ? 0.0 : depthPoint1.Y));

            default:
                return(new Point());
            }
        }
Ejemplo n.º 5
0
        //Bones and joints are hidden when inferred and nottracked to avoid spacing of line of the screen
        public void Update(BodyWrapper body, ECameraType cameraType)
        {
            foreach (KeyValuePair <JointType, JointWrapper> joint in body.JointsDictionary)
            {
                Ellipse ellipse = JointEllipses[joint.Key];

                Canvas.SetLeft(ellipse, joint.Value.GetCameraPoint(cameraType).X - _jointRadius);
                Canvas.SetTop(ellipse, joint.Value.GetCameraPoint(cameraType).Y - _jointRadius);

                if (joint.Value.TrackingState == TrackingState.Inferred)
                {
                    //ellipse.Stroke = _inferredBrush;
                    //ellipse.Fill = _inferredBrush;
                    //ellipse.StrokeThickness = _inferredThickness;
                    ellipse.Visibility = Visibility.Hidden;
                }
                else if (joint.Value.TrackingState == TrackingState.NotTracked)
                {
                    ellipse.Visibility = Visibility.Hidden;
                }
                else
                {
                    //ellipse.Stroke = _ellipseFillBrush;
                    //ellipse.StrokeThickness = _boneLineThickness;
                    //ellipse.Fill = _ellipseFillBrush;
                    ellipse.Visibility = Visibility.Visible;
                }
            }

            foreach (Tuple <JointType, JointType> bone in BodyHelper.Instance.BodyHierarchy)
            {
                Line line = BoneLines[bone];
                line.X1 = body.JointsDictionary[bone.Item1].GetCameraPoint(cameraType).X;
                line.Y1 = body.JointsDictionary[bone.Item1].GetCameraPoint(cameraType).Y;
                line.X2 = body.JointsDictionary[bone.Item2].GetCameraPoint(cameraType).X;
                line.Y2 = body.JointsDictionary[bone.Item2].GetCameraPoint(cameraType).Y;

                if (body.JointsDictionary[bone.Item1].TrackingState == TrackingState.Inferred || body.JointsDictionary[bone.Item2].TrackingState == TrackingState.Inferred)
                {
                    //line.Stroke = _inferredBrush;
                    //line.StrokeThickness = _inferredThickness;
                    line.Visibility = Visibility.Visible;
                }
                else if (body.JointsDictionary[bone.Item1].TrackingState == TrackingState.NotTracked || body.JointsDictionary[bone.Item2].TrackingState == TrackingState.NotTracked)
                {
                    line.Visibility = Visibility.Hidden;
                }
                else
                {
                    //line.Stroke = _boneBrush;
                    //line.StrokeThickness = _boneLineThickness;
                    line.Visibility = Visibility.Visible;
                }
            }
        }
Ejemplo n.º 6
0
        public Point GetCameraPoint(ECameraType cameraType)
        {
            switch (cameraType)
            {
            case ECameraType.Color:
                return(PointInColorSpace);

            case ECameraType.Depth:
                return(PointInDepthSpace);

            case ECameraType.Infrared:
                return(PointInDepthSpace);

            default:
                return(PointInColorSpace);
            }
        }
Ejemplo n.º 7
0
    public void AddCameraEffect(ref CameraEffectBase effect, ECameraType type, Camera cam)
    {
        switch (type)
        {
        case ECameraType.FOLLOW:
            effect = cam.gameObject.AddComponent <CameraFollow>();
            break;

        case ECameraType.SHAKE:
            effect = cam.gameObject.AddComponent <CameraShake>();
            break;

        case ECameraType.MOVE:
            effect = cam.gameObject.AddComponent <CameraMove>();
            break;
        }
    }
Ejemplo n.º 8
0
        public BodyDrawing(BodyWrapper body, ECameraType cameraType)
        {
            TrackingId = body.TrackingId;

            JointEllipses = new Dictionary <JointType, Ellipse>();
            BoneLines     = new Dictionary <Tuple <JointType, JointType>, Line>();

            foreach (KeyValuePair <JointType, JointWrapper> joint in body.JointsDictionary)
            {
                Ellipse ellipse = new Ellipse
                {
                    Width           = _jointRadius * 2,
                    Height          = _jointRadius * 2,
                    Fill            = _ellipseFillBrush,
                    StrokeThickness = _jointLineThickness,
                    Stroke          = _ellipseBrush
                };

                Canvas.SetLeft(ellipse, joint.Value.GetCameraPoint(cameraType).X - _jointRadius);
                Canvas.SetTop(ellipse, joint.Value.GetCameraPoint(cameraType).Y - _jointRadius);

                JointEllipses.Add(joint.Key, ellipse);
            }

            foreach (Tuple <JointType, JointType> bone in BodyHelper.Instance.BodyHierarchy)
            {
                Line line = new Line
                {
                    StrokeThickness = _boneLineThickness,
                    Stroke          = _boneBrush,
                    X1 = body.JointsDictionary[bone.Item1].GetCameraPoint(cameraType).X,
                    Y1 = body.JointsDictionary[bone.Item1].GetCameraPoint(cameraType).Y,
                    X2 = body.JointsDictionary[bone.Item2].GetCameraPoint(cameraType).X,
                    Y2 = body.JointsDictionary[bone.Item2].GetCameraPoint(cameraType).Y
                };

                BoneLines.Add(bone, line);
            }
        }
Ejemplo n.º 9
0
        public void RenderBodies(List <BodyWrapper> trackedBodies, ECameraType cameraType)
        {
            if (canvasSkeleton.ActualWidth == 0)
            {
                if (cameraType == ECameraType.Color)
                {
                    canvasSkeleton.Width  = 1920;
                    canvasSkeleton.Height = 1080;
                }
                else
                {
                    canvasSkeleton.Width  = 512;
                    canvasSkeleton.Height = 424;
                }
            }

            DeleteUntrackedBodies(trackedBodies);

            foreach (BodyWrapper body in trackedBodies)
            {
                RenderBody(body, cameraType);
            }
        }
Ejemplo n.º 10
0
    /*
     * //http://docs.opencv.org/doc/tutorials/calib3d/camera_calibration/camera_calibration.html
     * public float fov=60;			//horizontal field of view for the camera measured in degrees
     * public float cameraOffset=0;	//physical offset from human eye
     * public float stereoOffset=0.065f;	//physical distance between both eyes
     *
     * public ECameraRotation[] cameraRotation=new ECameraRotation[2];
     *
     * public Vector2 OpticalCenter=new Vector2(0.5f,0.5f);
     * public Vector2 FocalCoeff=new Vector2(1,1);
     * public Vector4 KPCoeff=Vector4.zero;
     * public string Name="";*/


    public void LoadXML(XmlReader r)
    {
        Name    = r.GetAttribute("Name");
        Encoder = r.GetAttribute("Encoder");
        int.TryParse(r.GetAttribute("StreamsCount"), out StreamsCount);
        int.TryParse(r.GetAttribute("CameraStreams"), out CameraStreams);
        bool.TryParse(r.GetAttribute("OptimizeOVR"), out OptimizeOVRVision);
        bool.TryParse(r.GetAttribute("FlipX"), out FlipXAxis);
        bool.TryParse(r.GetAttribute("FlipY"), out FlipYAxis);
        bool.TryParse(r.GetAttribute("SeparateStreams"), out SeparateStreams);
        float.TryParse(r.GetAttribute("FOV"), out FoV);
        float.TryParse(r.GetAttribute("CameraOffset"), out CameraOffset);
        FrameSize   = Utilities.ParseVector2(r.GetAttribute("FrameSize"));
        LensCenter  = Utilities.ParseVector2(r.GetAttribute("OpticalCenter"));
        FocalLength = Utilities.ParseVector2(r.GetAttribute("FocalCoeff"));
        KPCoeff     = Utilities.ParseVector4(r.GetAttribute("KPCoeff"));
        Vector4 PixelShift = Utilities.ParseVector4(r.GetAttribute("PixelShift"));

        PixelShiftLeft.Set(PixelShift.x, PixelShift.y);
        PixelShiftRight.Set(PixelShift.z, PixelShift.w);
        string rot;

        switch (r.GetAttribute("Type"))
        {
        case "POV":
            CameraType = ECameraType.WebCamera;
            break;

        case "OMNI":
            CameraType = ECameraType.RicohTheta;
            break;
        }
        switch (r.GetAttribute("StreamCodec"))
        {
        case "Raw":
            streamCodec = EStreamCodec.Raw;
            break;

        case "Coded":
            streamCodec = EStreamCodec.Coded;
            break;

        case "Ovrvision":
            streamCodec = EStreamCodec.Ovrvision;
            break;

        case "FoveatedOVR":
            streamCodec = EStreamCodec.FoveatedOvrvision;
            break;

        case "EyegazeRaw":
            streamCodec = EStreamCodec.EyegazeRaw;
            break;
        }
        string[] names = new string[] { "LeftRotation", "RightRotation" };
        for (int i = 0; i < 2; ++i)
        {
            rot = r.GetAttribute(names[i]).ToLower();
            switch (rot)
            {
            case "none":
                Rotation[i] = ECameraRotation.None;
                break;

            case "flipped":
                Rotation[i] = ECameraRotation.Flipped;
                break;

            case "cw":
                Rotation[i] = ECameraRotation.CW;
                break;

            case "ccw":
                Rotation[i] = ECameraRotation.CCW;
                break;
            }
        }

        //look for text Block
        while (r.Read())
        {
            if (r.NodeType == XmlNodeType.Text)
            {
                CamerConfigurationsStr = r.Value;
                break;
            }
        }
    }