コード例 #1
0
    public static void dumpFormatInfo(Context context)
    {
        CameraManager manager = ((CameraManager)(context.GetSystemService(Context.CameraService)));

        string[] camIds = new string[0];
        try
        {
            camIds = manager.GetCameraIdList();
        }
        catch (CameraAccessException e)
        {
            Log.Debug(TAG, "Cam access exception getting IDs");
        }

        if ((camIds.Length < 1))
        {
            Log.Debug(TAG, "No cameras found");
        }

        string id = camIds[0];

        Log.Debug(TAG, ("Using camera id " + id));
        try
        {
            CameraCharacteristics  characteristics = manager.GetCameraCharacteristics(id);
            StreamConfigurationMap configs         = (Android.Hardware.Camera2.Params.StreamConfigurationMap)characteristics.Get(CameraCharacteristics.ScalerStreamConfigurationMap); //CameraCharacteristics.ScalerStreamConfigurationMap);
            foreach (int format in configs.GetOutputFormats())
            {
                Log.Debug(TAG, ("Getting sizes for format: " + format));
                foreach (Size s in configs.GetOutputSizes(format))
                {
                    Log.Debug(TAG, ("\t" + s.ToString()));
                }
            }

            int[] effects = (int[])characteristics.Get(CameraCharacteristics.ControlAvailableEffects);
            foreach (int effect in effects)
            {
                Log.Debug(TAG, ("Effect available: " + effect));
            }
        }
        catch (CameraAccessException e)
        {
            Log.Debug(TAG, "Cam access exception getting characteristics.");
        }
    }
コード例 #2
0
        /*
         * Helpful debugging method:  Dump all supported camera formats to log.  You don't need to run
         * this for normal operation, but it's very helpful when porting this code to different
         * hardware.
         */
        public static void DumpFormatInfo(Context context)
        {
            // Discover the camera instance
            CameraManager manager = (CameraManager)context.GetSystemService(Context.CameraService);

            string[] camIds = null;
            try
            {
                camIds = manager.GetCameraIdList();
            }
            catch (CameraAccessException e)
            {
                Log.Warn(TAG, "Cannot get the list of available cameras", e);
            }
            if (camIds == null || camIds.Length < 1)
            {
                Log.Debug(TAG, "No cameras found");
                return;
            }
            Log.Debug(TAG, "Using camera id " + camIds[0]);
            try
            {
                CameraCharacteristics  characteristics = manager.GetCameraCharacteristics(camIds[0]);
                StreamConfigurationMap configs         = (StreamConfigurationMap)characteristics.Get(
                    CameraCharacteristics.ScalerStreamConfigurationMap);
                foreach (var format in configs.GetOutputFormats())
                {
                    Log.Debug(TAG, "Getting sizes for format: " + format);
                    foreach (var s in configs.GetOutputSizes(format))
                    {
                        Log.Debug(TAG, "\t" + s.ToString());
                    }
                }

                int[] effects = (int[])characteristics.Get(CameraCharacteristics.ControlAvailableEffects);
                foreach (var effect in effects)
                {
                    Log.Debug(TAG, "Effect available: " + effect);
                }
            }
            catch (CameraAccessException)
            {
                Log.Debug(TAG, "Cam access exception getting characteristics.");
            }
        }