コード例 #1
0
        //Continually requests frames that will be displayed in the live view window.
        private void updateWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <List <byte> >   lFramesRGB   = new List <List <byte> >();
            List <List <Single> > lFramesVerts = new List <List <Single> >();
            List <List <Body> >   lFramesBody  = new List <List <Body> >();

            BackgroundWorker worker = (BackgroundWorker)sender;

            while (!worker.CancellationPending)
            {
                Thread.Sleep(1);
                oServer.GetLatestFrame(lFramesRGB, lFramesVerts, lFramesBody);

                //Update the vertex and color lists that are common between this class and the OpenGLWindow.
                lock (lAllVertices)
                {
                    lAllVertices.Clear();
                    lAllColors.Clear();
                    lAllBodies.Clear();
                    lAllCameraPoses.Clear();

                    for (int i = 0; i < lFramesRGB.Count; i++)
                    {
                        /*
                         * if (frameCounter < 20)
                         * {
                         *  ExportFrame(lFramesVerts[i], lFramesRGB[i], lFramesBody[i]);
                         * }
                         */
                        lAllVertices.AddRange(lFramesVerts[i]);
                        lAllColors.AddRange(lFramesRGB[i]);
                        lAllBodies.AddRange(lFramesBody[i]);

                        var frame = LocalFrames[frameCounter % LocalFrames.Count];

                        frame.Vertices = Transformer.Apply3DTransform(frame.Vertices, Transformer.GetYRotationTransform(90));

                        lAllColors.AddRange(frame.RGB);
                        lAllVertices.AddRange(frame.Vertices);
                        lAllBodies.AddRange(frame.Bodies);

                        frameCounter++;
                    }

                    lAllCameraPoses.AddRange(oServer.lCameraPoses);
                }

                //Notes the fact that a new frame was downloaded, this is used to estimate the FPS.
                if (oOpenGLWindow != null)
                {
                    oOpenGLWindow.CloudUpdateTick();
                }
            }
        }
コード例 #2
0
        //Continually requests frames that will be displayed in the live view window.
        private void updateWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <List <byte> >   lFramesRGB     = new List <List <byte> >();
            List <List <Single> > lFramesVerts   = new List <List <Single> >();
            List <List <short> >  lFramesNormals = new List <List <short> >();
            List <List <short> >  lFramesUVs     = new List <List <short> >();
            List <List <ushort> > lFramesIndices = new List <List <ushort> >();
            List <List <Body> >   lFramesBody    = new List <List <Body> >();

            BackgroundWorker worker = (BackgroundWorker)sender;

            while (!worker.CancellationPending)
            {
                Thread.Sleep(1);
                oServer.GetLatestFrame(lFramesRGB, lFramesVerts, lFramesNormals, lFramesUVs, lFramesIndices, lFramesBody);

                //Update the vertex and color lists that are common between this class and the OpenGLWindow.
                lock (lAllVertices)
                {
                    lAllVertices.Clear();
                    lAllNormals.Clear();
                    lAllUVs.Clear();
                    lAllIndices.Clear();
                    lAllColors.Clear();
                    lAllBodies.Clear();
                    lAllCameraPoses.Clear();

                    for (int i = 0; i < lFramesRGB.Count; i++)
                    {
                        lAllVertices.AddRange(lFramesVerts[i]);
                        lAllNormals.AddRange(lFramesNormals[i]);
                        lAllUVs.AddRange(lFramesUVs[i]);
                        lAllIndices.AddRange(lFramesIndices[i]);
                        lAllColors.AddRange(lFramesRGB[i]);
                        lAllBodies.AddRange(lFramesBody[i]);
                    }

                    lAllCameraPoses.AddRange(oServer.lCameraPoses);
                }

                //Notes the fact that a new frame was downloaded, this is used to estimate the FPS.
                if (oOpenGLWindow != null)
                {
                    oOpenGLWindow.CloudUpdateTick();
                }
            }
        }
コード例 #3
0
        //Continually requests frames that will be displayed in the live view window.
        private void updateWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <List <Body> > lFramesBody = new List <List <Body> >();

            VertexC4ubV3f[]  lFramesVerts     = new VertexC4ubV3f[0];
            int[]            lFramesTriangles = new int[0];
            BackgroundWorker worker           = (BackgroundWorker)sender;

            while (!worker.CancellationPending)
            {
                Thread.Sleep(1);

                //oServer.RequestLastFrames();
                oServer.CopyLatestFrames();
                oServer.RequestLastFrames();
                oServer.CorrectRadialDistortionsForDepthMaps();
                oServer.GenerateAndGetMesh(out lFramesVerts, lFramesBody, out lFramesTriangles);

                //Update the vertex and color lists that are common between this class and the OpenGLWindow.

                lock (lAllVerticesLock)
                {
                    //lAllVertices.Clear();
                    //lAllBodies.Clear();
                    //lAllTriangles.Clear();

                    int TotalVerticesCount             = 0;
                    int TotalTrianglesElementsCount    = 0;
                    int ActTotalTrianglesElementsCount = 0;
                    lAllVertices  = lFramesVerts;
                    lAllTriangles = lFramesTriangles;
                    //lAllVertices.AddRange(lFramesVerts);
                    //lAllTriangles.AddRange(lFramesTriangles);
                    for (int i = 0; i < lAllBodies.Count; i++)
                    {
                        lAllBodies.AddRange(lFramesBody[i]);

                        ActTotalTrianglesElementsCount = lAllTriangles.Count();
                        for (int v = TotalTrianglesElementsCount; v < ActTotalTrianglesElementsCount; v++)
                        {
                            lAllTriangles[v] += TotalVerticesCount / 3;
                        }

                        TotalTrianglesElementsCount = lAllTriangles.Count();
                        TotalVerticesCount          = lAllVertices.Count();
                    }
                }

                // adding camera poses is in separate range, because oServer.lCameraPoses "get" locks oClientSocketLock
                // that may cause deadlock when locking with lAllVertices
                List <AffineTransform> cameraPoses = oServer.lCameraPoses;

                lock (lAllVerticesLock)
                {
                    lAllCameraPoses.Clear();
                    lAllCameraPoses.AddRange(cameraPoses);
                }
                //Notes the fact that a new frame was downloaded, this is used to estimate the FPS.
                if (oOpenGLWindow != null)
                {
                    oOpenGLWindow.SetNewVerticesAndTriangles(lAllVertices, lAllTriangles);
                    oOpenGLWindow.CloudUpdateTick();
                }

                oTransferServer.updateMesh(lAllVertices, lAllTriangles);
            }
        }