コード例 #1
0
    public bool PollInfraredFrame(KinectInterop.SensorData sensorData)
    {
        bool bNewFrame = false;

        if ((multiSourceFrameReader != null && multiSourceFrame != null) ||
            infraredFrameReader != null)
        {
            var infraredFrame = multiSourceFrame != null?multiSourceFrame.InfraredFrameReference.AcquireFrame() :
                                    infraredFrameReader.AcquireLatestFrame();

            if (infraredFrame != null)
            {
                var pInfraredData = GCHandle.Alloc(sensorData.infraredImage, GCHandleType.Pinned);
                infraredFrame.CopyFrameDataToIntPtr(pInfraredData.AddrOfPinnedObject(), (uint)sensorData.infraredImage.Length * sizeof(ushort));
                pInfraredData.Free();

                sensorData.lastInfraredFrameTime = infraredFrame.RelativeTime.Ticks;

                infraredFrame.Dispose();
                infraredFrame = null;

                bNewFrame = true;
            }
        }

        return(bNewFrame);
    }
コード例 #2
0
    private void Update()
    {
        if (_Reader != null)
        {
            var frame = _Reader.AcquireLatestFrame();
            if (frame != null)
            {
                frame.CopyFrameDataToArray(_Data);

                var index = 0;
                foreach (var ir in _Data)
                {
                    var intensity = (byte)(ir >> 8);
                    _RawData[index++] = intensity;
                    _RawData[index++] = intensity;
                    _RawData[index++] = intensity;
                    _RawData[index++] = 255; // Alpha
                }

                _Texture.LoadRawTextureData(_RawData);
                _Texture.Apply();

                frame.Dispose();
                frame = null;
            }
        }
    }
コード例 #3
0
        public override void Update()
        {
            trackedBodyJoints.Clear();

            if (infraredReader != null)
            {
                var infraredFrame = infraredReader.AcquireLatestFrame();
                if (infraredFrame != null)
                {
                    infraredFrame.CopyFrameDataToArray(_InfraredData);

                    int index = 0;
                    foreach (var ir in _InfraredData)
                    {
                        byte intensity = (byte)(ir >> 8);
                        _InfraredRawData[index++] = intensity;
                        _InfraredRawData[index++] = intensity;
                        _InfraredRawData[index++] = intensity;
                        _InfraredRawData[index++] = 255;
                    }

                    _InfraredTexture.LoadRawTextureData(_InfraredRawData);
                    _InfraredTexture.Apply();

                    infraredFrame.Dispose();
                    infraredFrame = null;
                }
            }
        }
コード例 #4
0
        public void Update()
        {
            if (reader != null)
            {
                InfraredFrame frame = reader.AcquireLatestFrame();
                if (frame != null)
                {
                    frame.CopyFrameDataToArray(FrameData);

                    int index = 0;
                    foreach (var ir in FrameData)
                    {
                        byte intensity = (byte)(ir >> 8);
                        for (int i = 0; i < 3; i++)
                        {
                            RawData[index++] = intensity;
                        }
                        RawData[index++] = 255; // Alpha
                    }

                    Texture.LoadRawTextureData(RawData);
                    Texture.Apply();

                    frame.Dispose();
                    frame = null;
                }
            }
        }
コード例 #5
0
 /// <summary>
 /// Acquires the latest infrared frame.
 /// It calles the OnInfraredFrameReceived only if the acquired frame is not null.
 /// </summary>
 protected void UpdateInfraredFrame(bool updateFrameView = true)
 {
     if (infraredFrameReader != null)
     {
         using (InfraredFrame frame = infraredFrameReader.AcquireLatestFrame())
         {
             if (frame != null)
             {
                 if (updateFrameView)
                 {
                     frameView.FrameTexture = frame.ToBitmap();
                 }
                 OnInfraredFrameReceived(frame);
             }
         }
     }
 }
コード例 #6
0
ファイル: SourceManager.cs プロジェクト: zsyzgu/3DChess
 void Update()
 {
     if (colorReader != null)
     {
         updateColor(colorReader.AcquireLatestFrame());
     }
     if (infraredReader != null)
     {
         updateInfrared(infraredReader.AcquireLatestFrame());
     }
     if (depthReader != null)
     {
         updateDepth(depthReader.AcquireLatestFrame());
     }
 }
コード例 #7
0
    public static bool PollInfrared(InfraredFrameReader reader, ref ushort[] infraredFrameData)
    {
        bool newInfrared = false;

        if (reader != null)
        {
            var frame = reader.AcquireLatestFrame();
            if (frame != null)
            {
                newInfrared = true;
                frame.CopyFrameDataToArray(infraredFrameData);
                frame.Dispose();
                frame = null;
            }
        }

        return(newInfrared);
    }
コード例 #8
0
    ////////////////////////////////////////INFRA////////////////////////////////////////////////////////


    void Update()
    {
        if (_Reader_Infrared != null && _Reader_Depth != null)
        {
            var infrared_frame = _Reader_Infrared.AcquireLatestFrame();
            var depth_frame    = _Reader_Depth.AcquireLatestFrame();

            if (infrared_frame != null && depth_frame != null)
            {
                infrared_frame.CopyFrameDataToArray(_Data_Infrared);

                depth_frame.CopyFrameDataToArray(_Data_Depth);
                ushort minDepth = depth_frame.DepthMinReliableDistance;
                maxDepth = depth_frame.DepthMaxReliableDistance;


                ///INFRARED
                int index = 0;

                int          column       = 0;
                int          row          = 0;
                List <Coord> blank_spaces = new List <Coord>();

                foreach (var ir in _Data_Infrared)
                {
                    byte intensity = (byte)(ir >> 8);

                    if (column == width)
                    {
                        column = 0;
                        row++;
                    }

                    try
                    {
                        infrared_matrix[row, column] = intensity;
                    }
                    catch (Exception e)
                    {
                        Debug.Log("ERROR: row" + row + " column" + column);
                    }

                    infrared_matrix[row, column] = intensity;

                    //si el punto es completamente blanco, entonces forma parte de un marker
                    if (intensity == 255)
                    {
                        Coord aux = new Coord(row, column);
                        blank_spaces.Add(aux);
                    }

                    /*if (counting < 100 && intensity == 255)
                     * {
                     *  Debug.Log("intensity: " + intensity);
                     *  Debug.Log("index: " + index);
                     *
                     *  counting++;
                     * }*/

                    _RawData[index++] = intensity;
                    _RawData[index++] = intensity;
                    _RawData[index++] = intensity;
                    _RawData[index++] = 255; // Alpha

                    column++;
                }

                _Texture.LoadRawTextureData(_RawData);
                _Texture.Apply();

                infrared_frame.Dispose();
                infrared_frame = null;
                ///INFRARED

                ///DEPTH
                column = 0;
                row    = 0;

                foreach (var depth in _Data_Depth)
                {
                    byte distance = (byte)(depth >= minDepth && depth <= maxDepth ? depth : 0);

                    /*if (distance!=0 && counter < 10)
                     * {
                     *  Debug.Log("distancia: " + distance);
                     *  Debug.Log("X:" + column + " Y:" + row);
                     *  counter++;
                     * }*/
                    if (column == width)
                    {
                        column = 0;
                        row++;
                    }

                    try
                    {
                        depth_matrix[row, column] = depth;
                    }
                    catch (Exception e)
                    {
                        Debug.Log("ERROR: row" + row + " column" + column);
                    }

                    depth_matrix[row, column] = depth;
                    column++;
                }
                depth_frame.Dispose();
                depth_frame = null;
                ///DEPTH

                //checkear si hay demasiado blanco
                if (blank_spaces.Count < width * height * 5 / 100)
                {
                    markers = find_markers(blank_spaces);

                    List <int> tmp_marker_minimum = new List <int>();

                    //algoritmo para llenar una lista con los bordes para cada marcador marcadores
                    for (int i = 0; i < markers.Count; i++)
                    {
                        List <InfraredSourceManager.Coord> marker_pixels = markers[i].pixels;
                        List <InfraredSourceManager.Coord> borders       = get_border(marker_pixels);
                        tmp_marker_minimum.Add(get_minimum(borders));
                    }
                    markers_depth = tmp_marker_minimum;
                }
                else
                {
                    markers       = null;
                    markers_depth = null;
                }


                //Algoritmo de deteccion de marcadores

                /*if (markers.Count>0)
                 *  Debug.Log("TOTAL DE MARCADORES:" + markers.Count);*/

                /* index maximo es 868 352 */
                /* van de 4 en 4 ...asi que son 217 088 */
                /* ventana es 512 424 */
            }
        }
    }