-1

I'm not used to C#/mobile programming/Xamarin, so please don't blame me for my dumb mistakes. I'm trying to make a program which will show what my device's camera is capable of. Here's an example of the code:

TextView a = new TextView (this);
A = Java.Lang.Integer ((int)CameraCharacteristics.ColorCorrectionAvailableAberrationModes);

And the error:

"CameraCharacteristics.ColorCorrectionAvailableAberrationModes must declare a body because it is not marked abstract extern or partial"

What do I do?

  • What do I do? first of all learn C#, for what you wrote is obvious you never programed with C# and going to Xamarin with zero knowledge of C# is like trying to pilot a rocket without even having read the manual. – Gusman Oct 06 '16 at 05:58
  • I never said that I haven't programmed in C# at all - what I meant was that I don't use it much. – airbournenation Oct 06 '16 at 06:16
  • Then why are you trying to cast a list of items into an integer and then to a java integer?? if you really know C# (which I doubt) then this is the perfect example of an RTFM question. Did you even tried to read the help? – Gusman Oct 06 '16 at 13:49
  • You seem experienced in this matter. Could you suggest an article or something similar that would help me with my problem? – airbournenation Oct 06 '16 at 14:35
  • Yes, the Xamarin help: https://developer.xamarin.com/api/property/Android.Hardware.Camera2.CameraCharacteristics.ColorCorrectionAvailableAberrationModes/ – Gusman Oct 06 '16 at 14:36

1 Answers1

0

Here is the code in java to print few camera2 Api Characteristics. You can use the same concept and try implementing in c#. This might not be the efficient code but will serve your purpose.

Some of the characteristics will not work in some phones, so it depends what phone you are using for testing. I tried with Nexus 5 and Lenovo phone.

Stream Configuration Map characteristics. From this link :

private void setupCamera(int width, int height) {
 CameraManager cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
    try {
        for(String cameraId: cameraManager.getCameraIdList()) {
            CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId);
            if(cameraCharacteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT) {
                continue;
            }
            StreamConfigurationMap map = cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);

//GET OUTPUT SIZES
mOutputsize = map.getOutputSizes(SurfaceTexture.class);
for(int i=0; i<mOutputsize.length; i++) {
    Log.d("OUTPUT SIZES", String.valueOf(mOutputsize[i]));
}

//GET HIGH SPEED VIDEO SIZE
//All the sizes listed in this method are the subset of getOutputSizes(int) method
 mHighSpeedVideoSize = map.getHighSpeedVideoSizes();
 for(int j=0; j<mHighSpeedVideoSize.length; j++) {
      Log.d("OUTPUT SIZES", "High speed video sizes");
      Log.d("OUTPUT SIZES", mHighSpeedVideoSize[j].toString());
 }

//GET THE IMAGE OUTPUT FORMAT (make sure you check if the array is pointing is null or not, otherwise you will have null point exception. The best way is to comment and see one by one)
 mOutputFormat = map.getOutputFormats();
 Log.d("OUTPUT SIZES", "Image Output Format: ");
 Log.d("OUTPUT SIZES", "Image.format = RAW_SENSOR, Constant Value: 32 (0x00000020) " + String.valueOf(mOutputFormat[0]));
 Log.d("OUTPUT SIZES", "Image.format = JPEG, Constant Value: 256 (0x00000100) " + String.valueOf(mOutputFormat[1]));
 Log.d("OUTPUT SIZES", "Image.format = PRIVATE, Constant Value: 34 (0x00000022) " + String.valueOf(mOutputFormat[2]));
 Log.d("OUTPUT SIZES", "Image.format = YUV_420_888, Constant Value: 35 (0x00000023) " + String.valueOf(mOutputFormat[3]));

I have even tried to print some of the characteristics from this link. Here is goes:

//COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES
  int[] aberration = cameraCharacteristics.get(CameraCharacteristics.COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES);
  String str2;
  for(int i=0; i<aberration.length; i++) {
       str2 = String.valueOf(aberration[i]);
       Log.d("OUTPUT SIZES ABR ", str2);
    }
       Log.d("OUTPUT SIZES Length: ", String.valueOf(aberration.length));

//CONTROL_AE_COMPENSATION_RANGE
 Range<Integer> exposureRange = cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE);
 String maxRange = String.valueOf(exposureRange);
 Log.d("OUTPUT SIZES EXPO range", maxRange + "\n");

//CONTROL_AE_COMPENSATION_STEP
  Rational step = cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP);
  Log.d("OUTPUT SIZE COMP step", String.valueOf(step));


//CONTROL_AE_LOCK_AVAILABLE
  boolean lock = cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_LOCK_AVAILABLE);
  Log.d("OUTPUT SIZES LOCK avai", String.valueOf(lock));


 //CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES
  int[] videoStabilizationModes = cameraCharacteristics.get(CameraCharacteristics.CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES);
   for(int i=0; i<videoStabilizationModes.length; i++) {
       Log.d("OUTPUT SIZES STABI mode", String.valueOf(videoStabilizationModes[i]));
    }

 //CONTROL_MAX_REGIONS_AWB
   Integer regionsAWB = cameraCharacteristics.get(CameraCharacteristics.CONTROL_MAX_REGIONS_AWB);
   Log.d("OUTPUT SIZES REGION AWB", String.valueOf(regionsAWB));

 //JPEG_AVAILABLE_THUMBNAIL_SIZES
  Size[] jpegThumbnail = cameraCharacteristics.get(CameraCharacteristics.JPEG_AVAILABLE_THUMBNAIL_SIZES);
  for(int i=0; i<jpegThumbnail.length; i++) {
  Log.d("OUTPUT SIZES JPEG THUMB", String.valueOf(jpegThumbnail[i]));
  }


 //SENSOR_BLACK_LEVEL_PATTERN
  BlackLevelPattern blackLevelPattern = cameraCharacteristics.get(CameraCharacteristics.SENSOR_BLACK_LEVEL_PATTERN);
  Log.d("OUTPUT SIZES BLCK PTRN", String.valueOf(blackLevelPattern));


   mCameraId = cameraId;
            return;
        }
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }

}

PS: This is not the complete code. This is the snippet from the code I have written for the camera app for this answer. I guess you just need to know the characteristics. There are some varibles I have used in the code but did not declare in this answer. I do not think you need that info for now. Happy coding :)

Sdembla
  • 1,629
  • 13
  • 13