Camera3: Pass 3A roi data to backend
Read the information from the frameworks settings and pass
the roi data to the 3A
Change-Id: Iaa201910f984870bf5870810d94fff38dd4a5c24
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/camera/QCamera2/HAL3/QCamera3HWI.cpp b/camera/QCamera2/HAL3/QCamera3HWI.cpp
index bf24eeb..e03dc88 100644
--- a/camera/QCamera2/HAL3/QCamera3HWI.cpp
+++ b/camera/QCamera2/HAL3/QCamera3HWI.cpp
@@ -1088,7 +1088,7 @@
for (int i = 0; i < numFaces; i++) {
faceIds[i] = faceDetectionInfo->faces[i].face_id;
faceScores[i] = faceDetectionInfo->faces[i].score;
- convertRegions(faceDetectionInfo->faces[i].face_boundary,
+ convertToRegions(faceDetectionInfo->faces[i].face_boundary,
faceRectangles+j, -1);
convertLandmarks(faceDetectionInfo->faces[i], faceLandmarks+k);
j+= 4;
@@ -1118,7 +1118,7 @@
cam_area_t *hAeRegions =
(cam_area_t *)POINTER_OF(CAM_INTF_META_AEC_ROI, metadata);
int32_t aeRegions[5];
- convertRegions(hAeRegions->rect, aeRegions, hAeRegions->weight);
+ convertToRegions(hAeRegions->rect, aeRegions, hAeRegions->weight);
camMetadata.update(ANDROID_CONTROL_AE_REGIONS, aeRegions, 5);
uint8_t *ae_state =
@@ -1133,7 +1133,7 @@
cam_area_t *hAfRegions =
(cam_area_t *)POINTER_OF(CAM_INTF_META_AF_ROI, metadata);
int32_t afRegions[5];
- convertRegions(hAfRegions->rect, afRegions, hAfRegions->weight);
+ convertToRegions(hAfRegions->rect, afRegions, hAfRegions->weight);
camMetadata.update(ANDROID_CONTROL_AF_REGIONS, afRegions, 5);
uint8_t *afState = (uint8_t *)POINTER_OF(CAM_INTF_META_AF_STATE, metadata);
@@ -1151,7 +1151,7 @@
cam_area_t *hAwbRegions =
(cam_area_t *)POINTER_OF(CAM_INTF_META_AWB_REGIONS, metadata);
int32_t awbRegions[5];
- convertRegions(hAwbRegions->rect, awbRegions, hAwbRegions->weight);
+ convertToRegions(hAwbRegions->rect, awbRegions, hAwbRegions->weight);
camMetadata.update(ANDROID_CONTROL_AWB_REGIONS, awbRegions, 5);
uint8_t *whiteBalanceState =
@@ -1267,7 +1267,7 @@
}
/*===========================================================================
- * FUNCTION : convertRegions
+ * FUNCTION : convertToRegions
*
* DESCRIPTION: helper method to convert from cam_rect_t into int32_t array
*
@@ -1278,15 +1278,44 @@
* else weight = -1
*
*==========================================================================*/
-void QCamera3HardwareInterface::convertRegions(cam_rect_t rect, int32_t* region, int weight){
+void QCamera3HardwareInterface::convertToRegions(cam_rect_t rect, int32_t* region, int weight){
region[0] = rect.left;
region[1] = rect.top;
- region[2] = rect.width;
- region[3] = rect.height;
+ region[2] = rect.left + rect.width;
+ region[3] = rect.top + rect.height;
if (weight > -1) {
region[4] = weight;
}
}
+
+/*===========================================================================
+ * FUNCTION : convertFromRegions
+ *
+ * DESCRIPTION: helper method to convert from array to cam_rect_t
+ *
+ * PARAMETERS :
+ * @rect : cam_rect_t struct to convert
+ * @region : int32_t destination array
+ * @weight : if we are converting from cam_area_t, weight is valid
+ * else weight = -1
+ *
+ *==========================================================================*/
+void QCamera3HardwareInterface::convertFromRegions(cam_area_t* roi,
+ const camera_metadata_t *settings,
+ uint32_t tag){
+ CameraMetadata frame_settings;
+ frame_settings = settings;
+ int32_t x_min = frame_settings.find(tag).data.i32[0];
+ int32_t y_min = frame_settings.find(tag).data.i32[1];
+ int32_t x_max = frame_settings.find(tag).data.i32[2];
+ int32_t y_max = frame_settings.find(tag).data.i32[3];
+ roi->weight = frame_settings.find(tag).data.i32[4];
+ roi->rect.left = x_min;
+ roi->rect.top = y_min;
+ roi->rect.width = x_max - x_min;
+ roi->rect.height = y_max - y_min;
+}
+
/*===========================================================================
* FUNCTION : convertLandmarks
*
@@ -2530,6 +2559,26 @@
sizeof(captureIntent), &captureIntent);
}
+ if (frame_settings.exists(ANDROID_CONTROL_AE_REGIONS)) {
+ cam_area_t roi;
+ convertFromRegions(&roi, settings, ANDROID_CONTROL_AE_REGIONS);
+ rc = AddSetParmEntryToBatch(mParameters, CAM_INTF_META_AEC_ROI,
+ sizeof(roi), &roi);
+ }
+
+ if (frame_settings.exists(ANDROID_CONTROL_AF_REGIONS)) {
+ cam_area_t roi;
+ convertFromRegions(&roi, settings, ANDROID_CONTROL_AF_REGIONS);
+ rc = AddSetParmEntryToBatch(mParameters, CAM_INTF_META_AF_ROI,
+ sizeof(roi), &roi);
+ }
+
+ if (frame_settings.exists(ANDROID_CONTROL_AWB_REGIONS)) {
+ cam_area_t roi;
+ convertFromRegions(&roi, settings, ANDROID_CONTROL_AWB_REGIONS);
+ rc = AddSetParmEntryToBatch(mParameters, CAM_INTF_META_AWB_REGIONS,
+ sizeof(roi), &roi);
+ }
return rc;
}
diff --git a/camera/QCamera2/HAL3/QCamera3HWI.h b/camera/QCamera2/HAL3/QCamera3HWI.h
index 564018c..75b008e 100644
--- a/camera/QCamera2/HAL3/QCamera3HWI.h
+++ b/camera/QCamera2/HAL3/QCamera3HWI.h
@@ -97,7 +97,9 @@
static void makeTable(cam_dimension_t* dimTable, uint8_t size, int32_t* sizeTable);
static void makeFPSTable(cam_fps_range_t* fpsTable, uint8_t size,
int32_t* fpsRangesTable);
- static void convertRegions(cam_rect_t rect, int32_t* region, int weight);
+ static void convertToRegions(cam_rect_t rect, int32_t* region, int weight);
+ static void convertFromRegions(cam_area_t* roi, const camera_metadata_t *settings,
+ uint32_t tag);
static void convertLandmarks(cam_face_detection_info_t face, int32_t* landmarks);
static int32_t getScalarFormat(int32_t format);