Пример #1
0
        public void Start(int w, int h, int fps)
        {
            this.capture = new Capture();
            this.capture.Open(0, w, h, fps);

            this.width    = this.capture.GetWidth();
            this.height   = this.capture.GetHeight();
            this.pixcount = this.width * this.height;

            this.rgbbuffer = Marshal.AllocCoTaskMem(this.width * this.height * 3);
            this.buffer0   = Marshal.AllocCoTaskMem(this.width * this.height * 4);
            this.buffer1   = Marshal.AllocCoTaskMem(this.width * this.height * 4);
            this.size      = this.width * this.height * 4;

            if (this.m_bRunning)
            {
                return;
            }



            this.thr        = new Thread(new ThreadStart(this.Run));
            this.m_bRunning = true;
            this.thr.Start();
        }
Пример #2
0
        public void Start(int w, int h,int fps)
        {
            this.capture = new Capture();
            this.capture.Open(0, w, h, fps);

            this.width = this.capture.GetWidth();
            this.height = this.capture.GetHeight();
            this.pixcount = this.width * this.height;

            this.rgbbuffer = Marshal.AllocCoTaskMem(this.width * this.height * 3);
            this.buffer0 = Marshal.AllocCoTaskMem(this.width * this.height * 4);
            this.buffer1 = Marshal.AllocCoTaskMem(this.width * this.height * 4);
            this.size = this.width * this.height * 4;

            if (this.m_bRunning)
            {
                return;
            }

            this.thr = new Thread(new ThreadStart(this.Run));
            this.m_bRunning = true;
            this.thr.Start();
        }
Пример #3
0
        public void Evaluate(int SpreadMax)
        {
            this.copyframe = false;
            if (c == null || this.FInReset[0])
            {
                if (c != null)
                {
                    c.Close();
                }

                if (this.data != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(this.data);
                }

                c = new Capture();
                c.Open(this.FInDeviceId[0], this.FInFPS[0], this.FInW[0], this.FInH[0]);

                this.size = this.FInW[0] * this.FInH[0] * 4;
                this.pixcount = this.FInW[0] * this.FInH[0];

                this.data = Marshal.AllocCoTaskMem(this.FInW[0] * this.FInH[0] * 3);
                this.rgbadata = Marshal.AllocCoTaskMem((int)size);
                this.invalidate = true;

            }

            if (this.FTextureOutput[0] == null)
            {
                this.FTextureOutput[0] = new DX11Resource<DX11DynamicTexture2D>();
            }

            if (c != null && this.FInEnabled[0])
            {
                this.c.GetPixels(this.data);

                byte* brgb = (byte*) this.data.ToPointer();
                byte* brgba = (byte*)this.rgbadata.ToPointer();

                /*int cnt = 0;
                int cnta = 0;
                for (int i = 0; i < this.FInH[0]; i++)
                {
                    for (int j = 0; j < this.FInW[0]; j++)
                    {
                        brgba[cnta] = brgb[cnt];
                        brgba[cnta + 1] = brgb[cnt + 1];
                        brgba[cnta + 2] = brgb[cnt + 2];

                        cnta += 4;
                        cnt += 3;
                    }
                }*/

                for (int i = 0; i < this.pixcount; i++)
                {
                    brgba[i * 4] = brgb[i * 3];
                    brgba[i * 4 + 1] = brgb[i * 3 + 1];
                    brgba[i * 4 + 2] = brgb[i * 3 + 2];
                }

                this.copyframe = true;

                try
                {
                    this.FOutW[0] = c.GetWidth();
                    this.FOutH[0] = c.GetHeight();
                }
                catch
                {

                }
            }
        }
Пример #4
0
        public void Evaluate(int SpreadMax)
        {
            this.copyframe = false;
            if (c == null || this.FInReset[0])
            {
                if (c != null)
                {
                    c.Close();
                }

                if (this.data != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(this.data);
                }

                c = new Capture();
                c.Open(this.FInDeviceId[0], this.FInFPS[0], this.FInW[0], this.FInH[0]);

                this.size     = this.FInW[0] * this.FInH[0] * 4;
                this.pixcount = this.FInW[0] * this.FInH[0];


                this.data       = Marshal.AllocCoTaskMem(this.FInW[0] * this.FInH[0] * 3);
                this.rgbadata   = Marshal.AllocCoTaskMem((int)size);
                this.invalidate = true;
            }

            if (this.FTextureOutput[0] == null)
            {
                this.FTextureOutput[0] = new DX11Resource <DX11DynamicTexture2D>();
            }

            if (c != null && this.FInEnabled[0])
            {
                this.c.GetPixels(this.data);

                byte *brgb  = (byte *)this.data.ToPointer();
                byte *brgba = (byte *)this.rgbadata.ToPointer();

                /*int cnt = 0;
                 * int cnta = 0;
                 * for (int i = 0; i < this.FInH[0]; i++)
                 * {
                 *  for (int j = 0; j < this.FInW[0]; j++)
                 *  {
                 *      brgba[cnta] = brgb[cnt];
                 *      brgba[cnta + 1] = brgb[cnt + 1];
                 *      brgba[cnta + 2] = brgb[cnt + 2];
                 *
                 *      cnta += 4;
                 *      cnt += 3;
                 *  }
                 * }*/

                for (int i = 0; i < this.pixcount; i++)
                {
                    brgba[i * 4]     = brgb[i * 3];
                    brgba[i * 4 + 1] = brgb[i * 3 + 1];
                    brgba[i * 4 + 2] = brgb[i * 3 + 2];
                }

                this.copyframe = true;

                try
                {
                    this.FOutW[0] = c.GetWidth();
                    this.FOutH[0] = c.GetHeight();
                }
                catch
                {
                }
            }
        }