Merge "Camera: Register LensShadingMap marshaler"

This commit is contained in:
Jag Saund
2023-01-10 16:05:49 +00:00
committed by Gerrit Code Review
3 changed files with 77 additions and 1 deletions

View File

@@ -88,8 +88,8 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
@@ -1027,6 +1027,19 @@ public class CameraMetadataNative implements Parcelable {
return fixedFaceRectangles; return fixedFaceRectangles;
} }
private boolean setLensShadingMap(LensShadingMap lensShadingMap) {
if (lensShadingMap == null) {
return false;
}
float[] lsmArray = new float[lensShadingMap.getGainFactorCount()];
lensShadingMap.copyGainFactors(lsmArray, 0);
setBase(CaptureResult.STATISTICS_LENS_SHADING_MAP, lsmArray);
Size s = new Size(lensShadingMap.getRowCount(), lensShadingMap.getColumnCount());
setBase(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE, s);
return true;
}
private LensShadingMap getLensShadingMap() { private LensShadingMap getLensShadingMap() {
float[] lsmArray = getBase(CaptureResult.STATISTICS_LENS_SHADING_MAP); float[] lsmArray = getBase(CaptureResult.STATISTICS_LENS_SHADING_MAP);
Size s = get(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE); Size s = get(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE);
@@ -1851,6 +1864,13 @@ public class CameraMetadataNative implements Parcelable {
metadata.setAERegions(value); metadata.setAERegions(value);
} }
}); });
sSetCommandMap.put(CaptureResult.STATISTICS_LENS_SHADING_CORRECTION_MAP.getNativeKey(),
new SetCommand() {
@Override
public <T> void setValue(CameraMetadataNative metadata, T value) {
metadata.setLensShadingMap((LensShadingMap) value);
}
});
} }
private boolean setAvailableFormats(int[] value) { private boolean setAvailableFormats(int[] value) {

View File

@@ -0,0 +1 @@
include platform/frameworks/av:/camera/OWNERS

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.camera2.impl;
import static com.google.common.truth.Truth.assertThat;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.params.LensShadingMap;
import android.util.Size;
import androidx.test.filters.SmallTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Arrays;
@SmallTest
@RunWith(JUnit4.class)
/** Tests for {@link CameraMetadataNative} class. */
public class CaptureMetadataNativeTest {
@Test
public void setLensShadingMap() {
final Size s = new Size(10, 10);
// 4 x rows x columns
final float[] elements = new float[400];
Arrays.fill(elements, 42);
final LensShadingMap lensShadingMap =
new LensShadingMap(elements, s.getHeight(), s.getWidth());
CameraMetadataNative captureResults = new CameraMetadataNative();
captureResults.set(CaptureResult.STATISTICS_LENS_SHADING_CORRECTION_MAP, lensShadingMap);
final LensShadingMap output =
captureResults.get(CaptureResult.STATISTICS_LENS_SHADING_CORRECTION_MAP);
assertThat(output).isEqualTo(lensShadingMap);
}
}