Example #1
0
        static public void Canny(TextureData input, Texture2D output, double threshold1 = 50.0, double threshold2 = 200.0)
        {
            CvMat cvMat;

            cvMat = UUtils.TextureToMat8(input);
            //Utils.NewWindowShow( cvMat );

            Cv.Canny(cvMat, cvMat, threshold1, threshold2);
            //Utils.NewWindowShow( cvMat );

            UUtils.CopyMatToTexture2D(cvMat, output);
            //CvMat cvMater = Utils.TextureToMat8( new TextureData(output) );
            //Utils.NewWindowShow( cvMater );
        }
Example #2
0
        public float[] calcNextFrame(CvMat input, Texture2D output = null)
        {
            float[] points = new float[8];             // return this

            ++numFrames;

            //input.Flip(input, FlipMode.Y); // TODO : to check if this is really needed. If yes, it SHOULD go inside "processFrame"
            // src_img == dest_img

            input = processFrame(input);

            if (numFrames < 20)
            {
                // SAY CHEEEESE
                //overlay.release();
                //putText( dest_img, "HOLD ", cvPoint( 30, 30 ),
                //		FONT_HERSHEY_COMPLEX_SMALL, 1, cvScalar( 0, 255, 0, 0 ), 1, CV_AA );
                for (int i = 0; i < 4; i++)
                {
                    outputQuad[i] = new CvPoint2D32f(0, 0);
                }
            }


            if (reset)
            {
                // SAY RESEEEEET
                //overlay.release();
                //putText( dest_img, "RESTART tracker", cvPoint( 30, dest_img.rows / 2 ),
                //		FONT_HERSHEY_COMPLEX_SMALL, 1, cvScalar( 255, 0, 0, 0 ), 1, CV_AA );
            }

            //input.Flip(input, FlipMode.Y); // TODO : to check if this is really needed

            if (output != null)
            {
                UUtils.CopyMatToTexture2D(input, output);
            }

            if (oldPtValid)
            {
                int j = 0;
                for (int i = 0; i < 4; ++i)
                {
                    points[j]     = oldPt[i].X;
                    points[j + 1] = oldPt[i].Y;
                    j++;
                }
            }
            else
            {
                // this points[] is dumb as hell, return something more meaningful
                for (int i = 0; i < 8; i += 2)
                {
                    points[i]     = outputQuad[i >> 1].X;
                    points[i + 1] = outputQuad[i >> 1].Y;
                }
            }

            return(points);
        }
Example #3
0
 // getBoxPoints
 public float[] calcNextFrame(TextureData textureData, Texture2D output = null)
 {
     return(calcNextFrame(UUtils.TextureToMat24(textureData), output));
 }
Example #4
0
        private CvPoint2D32f[] outputQuad = new CvPoint2D32f[4];        // Output Quadrilateral or World plane coordinates

        // NOTE : updates oldPt array after a long, long, long process
        // was: private void processFrame(CvMat inputMat)
        private CvMat processFrame(TextureData textureData)
        {
            return(processFrame(UUtils.TextureToMat24(textureData)));
        }