コード例 #1
0
        static public LifeCamCamera CreateFromPrefs(CameraPrefs prefs)
        {
            LifeCamCamera newCamera = new LifeCamCamera(prefs.Name);

            if (newCamera.Source == null)
            {
                throw new Exception("Camera \"" + prefs.Name + "\" not found. Skipping.");
            }

            FieldInfo[] fields = prefs.GetType().GetFields();

            Console.WriteLine("\nApplying \"" + prefs.Name + "\" settings...\n");

            foreach (FieldInfo field in fields)
            {
                try
                {
                    newCamera.GetType().GetProperty(field.Name).SetValue(newCamera, field.GetValue(prefs), null);
                    Console.WriteLine("  => " + field.Name + ": " + field.GetValue(prefs));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    continue;
                }
            }

            return(newCamera);
        }
コード例 #2
0
        static public LifeCamCamera CreateFromPrefs(CameraPrefs prefs)
        {
            LifeCamCamera newCamera = new LifeCamCamera(prefs.Name, prefs.NameContains, prefs.CameraNumber);

            if (newCamera.Source == null)
            {
                throw new Exception("\nCamera not found. Skipping.");
            }

            FieldInfo[] fields = prefs.GetType().GetFields();

            Console.WriteLine("\nApplying settings to camera " + newCamera.cameraNumberFound + "...");

            foreach (FieldInfo field in fields)
            {
                try
                {
                    newCamera.GetType().GetProperty(field.Name).SetValue(newCamera, field.GetValue(prefs), null);
                    Console.WriteLine("  => " + field.Name + ": " + field.GetValue(prefs));
                }
                catch (Exception e)
                {
                    continue;
                }
            }

            return(newCamera);
        }
コード例 #3
0
        static public MyCameraControl CreateFromPrefs(CameraPrefs prefs)
        {
            MyCameraControl newCamera = new MyCameraControl(prefs.Name);
            int             red       = 0;
            int             green     = 0;
            int             blue      = 0;

            if (newCamera.Source == null)
            {
                throw new Exception("Camera \"" + prefs.Name + "\" not found. Skipping.");
            }

            Console.WriteLine("Current settings are:");

            Console.WriteLine("\t" + newCamera.Name + "\n");

            int focusMin = 0, focusMax = 0, focusStep = 0;

            newCamera.GetFocusRange(ref focusMin, ref focusMax, ref focusStep);
            Console.WriteLine("\tFocus:\t\t" + newCamera.Focus);
            Console.WriteLine("\tAuto Focus:\t" + newCamera.AutoFocus);
            Console.WriteLine("\tFocus Range:\t" + focusMin + " <> " + focusMax + ", step: " + focusStep + "\n");

            int exposureMin = 0, exposureMax = 0, exposureStep = 0, exposureDef = 0;

            newCamera.GetExposureRange(ref exposureMin, ref exposureMax, ref exposureStep, ref exposureDef);
            Console.WriteLine("\tExposure:\t" + newCamera.Exposure);
            Console.WriteLine("\tAuto Exposure:\t" + newCamera.AutoExposure);
            Console.WriteLine("\tExposure Range:\t" + exposureMin + " <> " + exposureMax + ", step: " + exposureStep + ", def: " + exposureDef + "\n");

            Console.WriteLine("\tBacklight compensation: " + newCamera.BacklightCompensation + "\n");

            Console.WriteLine("\tBrightness:\t" + newCamera.Brightness);
            Console.WriteLine("\tContrast:\t" + newCamera.Contrast);
            Console.WriteLine("\tWhite balance:\t" + newCamera.WhiteBalance);
            Console.WriteLine("\tSaturation:\t" + newCamera.Saturation);
            Console.WriteLine("\tSharpness:\t" + newCamera.Sharpness + "\n");

            red   = (newCamera.Gain >> 16) & 0x0ff;
            green = (newCamera.Gain >> 8) & 0x0ff;
            blue  = (newCamera.Gain) & 0x0ff;
            Console.WriteLine("\tGain:\t\t" + "red: " + red + " green: " + green + " blue: " + blue);

            red   = (newCamera.Gamma >> 16) & 0x0ff;
            green = (newCamera.Gamma >> 8) & 0x0ff;
            blue  = (newCamera.Gamma) & 0x0ff;
            Console.WriteLine("\tGamma:\t\t" + "red: " + red + " green: " + green + " blue: " + blue);

            red   = (newCamera.Hue >> 16) & 0x0ff;
            green = (newCamera.Hue >> 8) & 0x0ff;
            blue  = (newCamera.Hue) & 0x0ff;
            Console.WriteLine("\tHue:\t\t" + "red: " + red + " green: " + green + " blue: " + blue);

            red   = (newCamera.ColorEnable >> 16) & 0x0ff;
            green = (newCamera.ColorEnable >> 8) & 0x0ff;
            blue  = (newCamera.ColorEnable) & 0x0ff;
            Console.WriteLine("\tColor enable:\t" + "red: " + red + " green: " + green + " blue: " + blue);

            red   = (newCamera.Iris >> 16) & 0x0ff;
            green = (newCamera.Iris >> 8) & 0x0ff;
            blue  = (newCamera.Iris) & 0x0ff;
            Console.WriteLine("\tIris:\t\t" + "red: " + red + " green: " + green + " blue: " + blue + "\n");

            int panMin = 0, panMax = 0, panStep = 0, panDef = 0;

            newCamera.GetPanRange(ref panMin, ref panMax, ref panStep, ref panDef);
            Console.WriteLine("\tPan:\t\t" + newCamera.Pan);
            Console.WriteLine("\tPan Range:\t" + panMin + " <> " + panMax + ", step: " + panStep + ", def: " + panDef + "\n");

            int tiltMin = 0, tiltMax = 0, tiltStep = 0, tiltDef = 0;

            newCamera.GetTiltRange(ref tiltMin, ref tiltMax, ref tiltStep, ref tiltDef);
            Console.WriteLine("\tTilt:\t\t" + newCamera.Tilt);
            Console.WriteLine("\tTilt Range:\t" + tiltMin + " <> " + tiltMax + ", step: " + tiltStep + ", def: " + tiltDef + "\n");

            int zoomMin = 0, zoomMax = 0, zoomStep = 0;

            newCamera.GetZoomRange(out zoomMin, out zoomMax, out zoomStep);
            Console.WriteLine("\tZoom:\t\t" + newCamera.Zoom);
            Console.WriteLine("\tZoom Range:\t" + zoomMin + " <> " + zoomMax + ", step: " + zoomStep + "\n");

            red   = (newCamera.Roll >> 16) & 0x0ff;
            green = (newCamera.Roll >> 8) & 0x0ff;
            blue  = (newCamera.Roll) & 0x0ff;
            Console.WriteLine("\tRoll:\t\t" + "red: " + red + " green: " + green + " blue: " + blue);

            Console.WriteLine("\nApplying \"" + prefs.Name + "\" settings...\n");

            FieldInfo[]  fields = prefs.GetType().GetFields();
            PropertyInfo pi     = null;

            foreach (FieldInfo field in fields)
            {
                try
                {
                    pi = newCamera.GetType().GetProperty(field.Name);

                    if (pi == null)
                    {
                        Console.WriteLine("Camera does not support '" + field.Name + "', setting skipped");
                    }
                    else
                    {
                        pi.SetValue(newCamera, field.GetValue(prefs), null);
                        Console.WriteLine("  => " + field.Name + ": " + field.GetValue(prefs));
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(" Unexpected error white setting camera property '" + field.Name + "': " + e.Message + "\n");
                }
            }

            return(newCamera);
        }