1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.cts.verifier.camera.its;
18 
19 import android.util.Log;
20 
21 enum StatsFormat {
22     RAW10_STATS("Raw10Stats"),
23     RAW10_QUAD_BAYER_STATS("Raw10QuadBayerStats"),
24     RAW16_STATS("Raw16Stats"),
25     RAW16_QUAD_BAYER_STATS("Raw16QuadBayerStats");
26 
27     private String value;
28 
StatsFormat(String value)29     private StatsFormat(String value) {
30         this.value = value;
31     }
32 
getValue()33     public String getValue() {
34         return this.value;
35     }
36 }
37 
38 public class StatsImage {
39 
40     static {
41         try {
42             System.loadLibrary("ctsverifier_jni");
43         } catch (UnsatisfiedLinkError e) {
44             Log.e("StatsImage", "Error loading cts verifier JNI library");
45             e.printStackTrace();
46         }
47     }
48 
49     /**
50      * Compute standard bayer or quad bayer stats (mean and variance) images.
51      *
52      * @param img Byte array calculated from raw image.
53      * @param statsFormat Stats image format, which can be one of StatsFormat values.
54      * @param width The width of raw image.
55      * @param height The height of raw image.
56      * @param aaX The x-coordinate of top-left point of active array crop region.
57      * @param aaY The y-coordinate of top-left point of active array crop region.
58      * @param aaW The width of active array crop region.
59      * @param aaH The height of active array crop region.
60      * @param gridW The width of grid region.
61      * @param gridH The height of grid region.
62      * @return Stats images represented by a float array.
63      */
computeStatsImage(byte[] img, String statsFormat, int width, int height, int aaX, int aaY, int aaW, int aaH, int gridW, int gridH)64     public native static float[] computeStatsImage(byte[] img, String statsFormat,
65         int width, int height, int aaX, int aaY, int aaW, int aaH, int gridW, int gridH);
66 
67 }
68