Inheritance: NewTOAPIA.GL.GLTexture
Ejemplo n.º 1
0
        /// <summary>
        /// Once we have a context, we are able to peform various setup routines
        /// that require us to connect to OpenGL.
        /// </summary>
        protected override void OnSetContext()
        {
            //fCamera1 = VideoTexture.CreateFromDeviceIndex(GI, 0, 640, 480);
            fCamera1 = VideoTexture.CreateFromDeviceIndex(GI, 0, true);
        
            // Turn off features that we don't need, and they 
            // just slow down video processing
            GI.Features.AlphaTest.Disable();
            GI.Features.Blend.Disable();
            GI.Features.DepthTest.Disable();
            GI.Features.Dither.Disable();
            GI.Features.Fog.Disable();
            GI.Features.Lighting.Disable();

            // Create the FaceMesh that will receive the gray texture so we 
            // can break it up into 8x8 squares
            fFaceSize = new Vector3D(fCamera1.Width, fCamera1.Height, 0);

            fBackgroundCreator = new RGBToGray(GI, fCamera1.Width, fCamera1.Height);
            fBackgroundCopier = new UnaryTextureProcessor(GI, fCamera1.Width, fCamera1.Height);
            fBackgroundPixellator = new Pixellate(GI, fCamera1.Width, fCamera1.Height, 8);
            
            fImageOperator = new UnaryTextureProcessor(GI, fCamera1.Width, fCamera1.Height);
            fGrayConverter = new RGBToGray(GI, fCamera1.Width, fCamera1.Height);
            fGammaCorrection = new PowerLawTransform(GI, fCamera1.Width, fCamera1.Height, 1.0f);
            fLuminanceThreshold = new LuminanceThreshold(GI, fCamera1.Width, fCamera1.Height, 0f);
            fLuminanceBinarizer = new LuminanceBinarizer(GI, fCamera1.Width, fCamera1.Height, 0.3f);
            fLuminanceBinarizer.OverColor = ColorRGBA.Black;
            fLuminanceBinarizer.UnderColor = ColorRGBA.White;
            fPixellate = new Pixellate(GI, fCamera1.Width, fCamera1.Height,8);
            fBlocker = new BlockProcessor(GI, fCamera1.Width, fCamera1.Height, 2);
            fAverager = new AverageProcessor(GI, fCamera1.Width, fCamera1.Height);
            fMorpher = new Morph(GI, fCamera1.Width, fCamera1.Height);

            fEdgeEnhance = new ConvolutionProcessor(GI, fCamera1.Width, fCamera1.Height, ConvolutionKernel.EdgeEnhance);
            fEdgeEnhance.Distance = 4;
            fEmboss = new ConvolutionProcessor(GI, fCamera1.Width, fCamera1.Height, ConvolutionKernel.Emboss);
            fSoften = new ConvolutionProcessor(GI, fCamera1.Width, fCamera1.Height, ConvolutionKernel.GaussianBlur);
            fSoften.Distance = 4;
            fSobell = new ConvolutionProcessor(GI, fCamera1.Width, fCamera1.Height, ConvolutionKernel.Sobell);
            fLaplacian = new ConvolutionProcessor(GI, fCamera1.Width, fCamera1.Height, ConvolutionKernel.Laplacian);

            fDifference = new DifferenceProcessor(GI, fCamera1.Width, fCamera1.Height);



            // We want replace mode because we don't care about
            // the values that are currently in place, we just want
            // to replace them.
            GI.TexEnv(TextureEnvModeParam.Replace);

            fGrayMesh = new XYAxesMesh(GI, new Vector3D(fCamera1.Width, fCamera1.Height, 0), new Resolution(2, 2), null);
            fPointMesh = new XYAxesPointMesh(GI, new Vector3D(fCamera1.Width, fCamera1.Height, 0), new Resolution(fCamera1.Width/4, fCamera1.Height/4), null);
        }
Ejemplo n.º 2
0
        public static VideoTexture CreateFromDevicePath(GraphicsInterface gi, string devicePath)
        {
            VideoCaptureDevice vidCap = VideoCaptureDevice.CreateCaptureDeviceFromName(devicePath, 320,240);
            if (null == vidCap)
                return null;

            VideoTexture tex = new VideoTexture(gi, vidCap);

            return tex;
        }
Ejemplo n.º 3
0
        public static VideoTexture CreateFromDeviceIndex(GraphicsInterface gi, int deviceIndex, int width, int height)
        {
            int numDevices = VideoCaptureDevice.GetNumberOfInputDevices();

            if ((deviceIndex >= 0) && (deviceIndex <= numDevices - 1))
            {
                VideoCaptureDevice vidCap = VideoCaptureDevice.CreateCaptureDeviceFromIndex(deviceIndex, width, height);
                VideoTexture tex = new VideoTexture(gi, vidCap);
                return tex;
            }
            else
            {
                //fCubeTexture = TextureHelper.CreateCheckerboardTexture(GI, 320, 240);
                return null;
            }

            // Return a checkerboard pattern
            return null;
        }
Ejemplo n.º 4
0
        public static VideoTexture CreateFromDeviceIndex(GraphicsInterface gi, int deviceIndex)
        {
            int numDevices = VideoCaptureDevice.GetNumberOfInputDevices();

            if ((deviceIndex >= 0) && (deviceIndex <= numDevices - 1))
            {
                VideoCaptureDevice vidCap = VideoCaptureDevice.CreateCaptureDeviceFromIndex(deviceIndex,0,0);
                VideoTexture tex = new VideoTexture(gi, vidCap);
                return tex;
            }

            // Return a checkerboard pattern
            return null;
        }
Ejemplo n.º 5
0
        protected override void  OnSetContext()
        {
            GraphicsInterface.gCheckErrors = true;

            //fViewer = new SketchViewer(GI, 620, 440);

            
            // Sections of the wall
            fSection0 = new CylinderSection(GI, 14.0f, 12.0f, 72, 10, 10, new RectangleF(4.0f/5,1, 1.0f/5, 1));

            fSection72 = new CylinderSection(GI, 14.0f, 12.0f, 72, 10, 10, new RectangleF(3.0f/5, 1, 1.0f / 5, 1));

            fSection144 = new CylinderSection(GI, 14.0f, 12.0f, 72, 10, 10, new RectangleF(2.0f / 5, 1, 1.0f / 5, 1));

            fSection216 = new CylinderSection(GI, 14.0f, 12.0f, 72, 10, 10, new RectangleF(1.0f / 5, 1, 1.0f / 5, 1));

            fSection288 = new CylinderSection(GI, 14.0f, 12.0f, 72, 10, 10, new RectangleF(0.0f / 5, 1, 1.0f / 5, 1));


            // Sections displaying current speaker
            fSpeakerSection0 = new CylinderSection(GI, 4.0f, 4.0f, 45, 10, 10);
            fSpeakerSection90 = new CylinderSection(GI, 4.0f, 4.0f, 45, 10, 10);
            fSpeakerSection180 = new CylinderSection(GI, 4.0f, 4.0f, 45, 10, 10);
            fSpeakerSection270 = new CylinderSection(GI, 4.0f, 4.0f, 45, 10, 10);



            GI.Features.DepthTest.Enable();

            // Medium Cyan background
            GI.Buffers.ColorBuffer.Color = ColorRGBA.MediumCyan;

            // Cull backs of polygons
            //GI.CullFace(GLFace.Back);
            GI.FrontFace(FrontFaceDirection.Ccw);
            //GI.Enable(GLOption.CullFace);

            GI.Features.DepthTest.Enable();

            // Setup light parameters
            //GI.LightModel(LightModelParameter.LightModelAmbient, fNoLight);
            GI.LightModel(LightModelParameter.LightModelAmbient, fBrightLight);
            GI.Features.Lighting.Light0.Ambient = new ColorRGBA(fLowLight);
            GI.Features.Lighting.Light0.Diffuse = new ColorRGBA(fBrightLight);
            GI.Features.Lighting.Light0.Specular = new ColorRGBA(fBrightLight);
            GI.Features.Lighting.Enable();
            GI.Features.Lighting.Light0.Enable();

            // Mostly use material tracking
            GI.Features.ColorMaterial.Enable();
            GI.ColorMaterial(GLFace.FrontAndBack, ColorMaterialParameter.AmbientAndDiffuse);
            GI.Material(GLFace.FrontAndBack, MaterialParameter.Shininess, 128);


            string PanoramicName = "Microsoft RoundTable Panoramic Video";
            string SpeakerName = "Microsoft RoundTable Active Speaker Video";

            //fWallTexture = TextureHelper.CreateCheckerboardTexture(GI, 512, 512);
            //fWallTexture = VideoTexture.CreateVideoDeviceTexture(GI, PanoramicName);
            fWallVideo = VideoTexture.CreateFromDeviceIndex(GI, 0);
            fWallTexture = fWallVideo;


            //fSpeakerTexture = TextureHelper.CreateCheckerboardTexture(GI, 512, 512);
            //fSpeakerTexture = VideoTexture.CreateVideoDeviceTexture(GI, SpeakerName);
            //fSpeakerTexture = VideoTexture.CreateFromDeviceIndex(GI, 1);
            fSpeakerVideo = VideoTexture.CreateFromDeviceIndex(GI, 1);
            fSpeakerTexture = fSpeakerVideo;

            fDesktopTexture = TextureHelper.CreateCheckerboardTexture(GI, 512, 512);
        }