Esempio n. 1
0
        public static void Main(string[] args)
        {
            try
            {
                OpenNI.Initialize();
                device = Device.Open(Device.AnyDevice);

                depthStream = device.CreateVideoStream(Device.SensorType.Depth);
                depthStream.VideoMode = new VideoMode
                                            {
                                                DataPixelFormat = VideoMode.PixelFormat.Depth1Mm, 
                                                Fps = 30, 
                                                Resolution = new Size(640, 480)
                                            };

                colorStream = device.CreateVideoStream(Device.SensorType.Color);
                colorStream.VideoMode = new VideoMode
                                            {
                                                DataPixelFormat = VideoMode.PixelFormat.Rgb888, 
                                                Fps = 30, 
                                                Resolution = new Size(640, 480)
                                            };
                device.DepthColorSyncEnabled = true;
                depthStream.Start();
                colorStream.Start();
                device.ImageRegistration = Device.ImageRegistrationMode.DepthToColor;
                Console.WriteLine("Image registration is active and working well.");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("Press enter to exit.");
            Console.ReadLine();
            if (device != null)
            {
                device.Close();
            }

            OpenNI.Shutdown();
        }
Esempio n. 2
0
        public KinectOpenNi2()
        {
            HandleError(OpenNI.Initialize());

              DeviceInfo[] devices = OpenNI.EnumerateDevices();
              if (devices.Length == 0)
            HandleError(OpenNI.Status.NO_DEVICE);

              kinectDevice = devices[0].OpenDevice();

              colorSensor = kinectDevice.CreateVideoStream(Device.SensorType.COLOR);
              VideoMode[] videoModes = colorSensor.SensorInfo.getSupportedVideoModes();
              colorSensor.VideoMode = videoModes[1];
              colorSensor.Start();
              colorSensor.onNewFrame += new VideoStream.VideoStreamNewFrame(colorSensor_onNewFrame);

              depthSensor = kinectDevice.CreateVideoStream(Device.SensorType.DEPTH);
              videoModes = depthSensor.SensorInfo.getSupportedVideoModes();
              depthSensor.VideoMode = videoModes[0];
              depthSensor.Start();
              depthSensor.onNewFrame += new VideoStream.VideoStreamNewFrame(depthSensor_onNewFrame);
        }
Esempio n. 3
0
        public OpenKinect()
        {
            HandleOpenNIError(OpenNI.Initialize());
            DeviceInfo[] devices = OpenNI.EnumerateDevices();
            if (devices.Length == 0)
                HandleOpenNIError(OpenNI.Status.NoDevice);
            kinectDevice = devices[0].OpenDevice();

            colorSensor = kinectDevice.CreateVideoStream(Device.SensorType.Color);
            colorSensor.VideoMode = colorSensor.SensorInfo.GetSupportedVideoModes()[1];

            //Start Skeleton Sensor
            HandleNiteError(NiTE.Initialize());
            try
            {
                SkeletonSensor = UserTracker.Create();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Esempio n. 4
0
 public static VideoStream Create(Device device, Device.SensorType sensorType)
 {
     return(device.CreateVideoStream(sensorType));
 }
Esempio n. 5
0
 public static VideoStream Create(Device device, Device.SensorType sensorType)
 {
     return device.CreateVideoStream(sensorType);
 }