Loading core/java/android/hardware/camera2/impl/CameraMetadataNative.java +21 −1 Original line number Diff line number Diff line Loading @@ -88,8 +88,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; Loading Loading @@ -1027,6 +1027,19 @@ public class CameraMetadataNative implements Parcelable { 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() { float[] lsmArray = getBase(CaptureResult.STATISTICS_LENS_SHADING_MAP); Size s = get(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE); Loading Loading @@ -1851,6 +1864,13 @@ public class CameraMetadataNative implements Parcelable { 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) { Loading core/tests/coretests/src/android/hardware/camera2/OWNERS 0 → 100644 +1 −0 Original line number Diff line number Diff line include platform/frameworks/av:/camera/OWNERS core/tests/coretests/src/android/hardware/camera2/impl/CaptureMetadataNativeTest.java 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * 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); } } Loading
core/java/android/hardware/camera2/impl/CameraMetadataNative.java +21 −1 Original line number Diff line number Diff line Loading @@ -88,8 +88,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; Loading Loading @@ -1027,6 +1027,19 @@ public class CameraMetadataNative implements Parcelable { 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() { float[] lsmArray = getBase(CaptureResult.STATISTICS_LENS_SHADING_MAP); Size s = get(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE); Loading Loading @@ -1851,6 +1864,13 @@ public class CameraMetadataNative implements Parcelable { 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) { Loading
core/tests/coretests/src/android/hardware/camera2/OWNERS 0 → 100644 +1 −0 Original line number Diff line number Diff line include platform/frameworks/av:/camera/OWNERS
core/tests/coretests/src/android/hardware/camera2/impl/CaptureMetadataNativeTest.java 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * 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); } }