<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 23, 2024 at 10:49 PM Harvey Yang <<a href="mailto:chenghaoyang@chromium.org">chenghaoyang@chromium.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Yudhistira Erlandinata <<a href="mailto:yerlandinata@chromium.org" target="_blank">yerlandinata@chromium.org</a>><br>
<br>
Add FaceDetectMode, FaceDetectFaceRectangles, FaceDetectFaceScores,<br>
and FaceDetectFaceLandmark. Also add ControlTypePoint for supporting<br>
FaceDetectFaceLandmark.<br>
<br>
Signed-off-by: Yudhistira Erlandinata <<a href="mailto:yerlandinata@chromium.org" target="_blank">yerlandinata@chromium.org</a>><br>
Co-developed-by: becker hsieh <<a href="mailto:beckerh@chromium.org" target="_blank">beckerh@chromium.org</a>><br>
Co-developed-by: Harvey Yang <<a href="mailto:chenghaoyang@chromium.org" target="_blank">chenghaoyang@chromium.org</a>><br>
---<br>
include/libcamera/controls.h | 6 ++<br>
include/libcamera/meson.build | 3 +-<br>
src/libcamera/control_ids_android.yaml | 98 ++++++++++++++++++++++++++<br>
src/libcamera/control_ranges.yaml | 1 +<br>
src/libcamera/controls.cpp | 6 ++<br>
5 files changed, 113 insertions(+), 1 deletion(-)<br>
create mode 100644 src/libcamera/control_ids_android.yaml<br>
<br>
diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h<br>
index 7c2bb287..bf1b8609 100644<br>
--- a/include/libcamera/controls.h<br>
+++ b/include/libcamera/controls.h<br>
@@ -34,6 +34,7 @@ enum ControlType {<br>
ControlTypeString,<br>
ControlTypeRectangle,<br>
ControlTypeSize,<br>
+ ControlTypePoint,<br>
};<br>
<br>
namespace details {<br>
@@ -87,6 +88,11 @@ struct control_type<Size> {<br>
static constexpr ControlType value = ControlTypeSize;<br>
};<br>
<br>
+template<><br>
+struct control_type<Point> {<br>
+ static constexpr ControlType value = ControlTypePoint;<br>
+};<br>
+<br>
template<typename T, std::size_t N><br>
struct control_type<Span<T, N>> : public control_type<std::remove_cv_t<T>> {<br>
};<br>
diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build<br>
index a969a95d..4fff14d2 100644<br>
--- a/include/libcamera/meson.build<br>
+++ b/include/libcamera/meson.build<br>
@@ -34,6 +34,7 @@ libcamera_headers_install_dir = get_option('includedir') / libcamera_include_dir<br>
<br>
controls_map = {<br>
'controls': {<br>
+ 'android': 'control_ids_android.yaml',<br>
'draft': 'control_ids_draft.yaml',<br>
'core': 'control_ids_core.yaml',<br>
'rpi/vc4': 'control_ids_rpi.yaml',<br>
@@ -55,7 +56,7 @@ foreach mode, entry : controls_map<br>
files_list = []<br>
input_files = []<br>
foreach vendor, header : entry<br>
- if vendor != 'core' and vendor != 'draft'<br>
+ if vendor != 'core' and vendor != 'draft' and vendor != 'android'<br>
if vendor not in pipelines<br>
continue<br>
endif<br>
diff --git a/src/libcamera/control_ids_android.yaml b/src/libcamera/control_ids_android.yaml<br>
new file mode 100644<br>
index 00000000..8b0d624f<br>
--- /dev/null<br>
+++ b/src/libcamera/control_ids_android.yaml<br>
@@ -0,0 +1,98 @@<br>
+# SPDX-License-Identifier: LGPL-2.1-or-later<br>
+#<br>
+# Copyright (C) 2024, Google Inc.<br>
+#<br>
+%YAML 1.1<br>
+---<br>
+# Unless otherwise stated, all controls are bi-directional, i.e. they can be<br>
+# set through Request::controls() and returned out through Request::metadata().<br>
+vendor: android<br>
+controls:<br>
+ - FaceDetectMode:<br>
+ type: uint8_t<br>
+ description: |<br>
+ Reporting mode of face detection.<br>
+<br>
+ Currently identical to ANDROID_STATISTICS_FACE_DETECT_MODE.<br>
+<br>
+ \sa FaceDetectFaceRectangles<br>
+ \sa FaceDetectFaceScores<br>
+ \sa FaceDetectFaceLandmarks<br>
+ \sa FaceDetectFaceIds<br>
+<br>
+ enum:<br>
+ - name: FaceDetectModeOff<br>
+ value: 0<br>
+ description: |<br>
+ Pipeline should not report face detection result.<br>
+ - name: FaceDetectModeSimple<br>
+ value: 1<br>
+ description: |<br>
+ Pipeline should at least report FaceDetectFaceRectangles and<br>
+ FaceDetectFaceScores for each detected faces.<br>
+ FaceDetectFaceLandmarks and FaceDetectFaceIds is optional.<br>
+<br>
+ - name: FaceDetectModeFull<br>
+ value: 2<br>
+ description: |<br>
+ Pipeline should report all face controls, including<br>
+ FaceDetectFaceRectangles, FaceDetectFaceScores,<br>
+ FaceDetectFaceLandmarks, and FaceDeteceFaceIds.<br>
+<br>
+ - FaceDetectFaceRectangles:<br>
+ type: Rectangle<br>
+ description: |<br>
+ Boundary rectangles of the detected faces.<br>
+ The number of values should be the number of faces reported in<br>
+ FaceDetectFaceRectangles.<br>
+<br>
+ The FaceDetectFaceRectangles control can only be returned in metadata.<br>
+<br>
+ Currently identical to ANDROID_STATISTICS_FACE_RECTANGLES.<br>
+<br>
+ size: [n]<br>
+<br>
+ - FaceDetectFaceScores:<br>
+ type: uint8_t<br>
+ description: |<br>
+ Confidence score of each of the detected faces by face detector.<br>
+ The range of score is [0, 100].<br>
+ The FaceDetectFaceScores control can only be returned in metadata.<br>
+ The number of values should be the number of faces reported in<br>
+ FaceDetectFaceRectangles.<br>
+<br>
+ Currently identical to ANDROID_STATISTICS_FACE_SCORES.<br>
+<br>
+ size: [n]<br>
+<br>
+ - FaceDetectFaceLandmarks:<br>
+ type: Point<br>
+ description: |<br>
+ Array of human face landmark coordinates in format:<br>
+ [..., left_eye_i, right_eye_i, mouth_i, left_eye_i+1, ...],<br>
+ with i = index of face.<br>
+ The number of values should be 3 * the number of faces reported in<br>
+ FaceDetectFaceRectangles.<br>
+<br>
+ The FaceDetectFaceLandmarks control can only be returned in metadata.<br>
+<br>
+ Currently identical to ANDROID_STATISTICS_FACE_LANDMARKS.<br>
+<br>
+ size: [n]<br>
+<br>
+ - FaceDetectFaceIds:<br>
+ type: int32_t<br>
+ description: |<br>
+ Each detected face is given a unique ID that is valid for as long as<br>
+ the face is visible to the camera device. A face that leaves the field<br>
+ of view and later returns may be assigned a new ID.<br>
+ The number of values should be the number of faces reported in<br>
+ FaceDetectFaceRectangles.<br>
+<br>
+ The FaceDetectFaceIds control can only be returned in metadata.<br>
+<br>
+ Currently identical to ANDROID_STATISTICS_FACE_IDS.<br>
+<br>
+ size: [n]<br>
+<br>
+...<br>
diff --git a/src/libcamera/control_ranges.yaml b/src/libcamera/control_ranges.yaml<br>
index d42447d0..5c6ca414 100644<br>
--- a/src/libcamera/control_ranges.yaml<br>
+++ b/src/libcamera/control_ranges.yaml<br>
@@ -14,5 +14,6 @@ ranges:<br>
# Raspberry Pi vendor controls<br>
rpi: 20000<br>
# Next range starts at 30000<br>
+ android: 30000<br></blockquote><div><br></div><div>Sorry, I should've updated the comments as well.</div><div>Will update in the next version with other changes to prevent</div><div>spamming.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
...<br>
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp<br>
index dba74404..c452e607 100644<br>
--- a/src/libcamera/controls.cpp<br>
+++ b/src/libcamera/controls.cpp<br>
@@ -60,6 +60,7 @@ static constexpr size_t ControlValueSize[] = {<br>
[ControlTypeString] = sizeof(char),<br>
[ControlTypeRectangle] = sizeof(Rectangle),<br>
[ControlTypeSize] = sizeof(Size),<br>
+ [ControlTypePoint] = sizeof(Point),<br>
};<br>
<br>
} /* namespace */<br>
@@ -254,6 +255,11 @@ std::string ControlValue::toString() const<br>
str += value->toString();<br>
break;<br>
}<br>
+ case ControlTypePoint: {<br>
+ const Point *value = reinterpret_cast<const Point *>(data);<br>
+ str += value->toString();<br>
+ break;<br>
+ }<br>
case ControlTypeNone:<br>
case ControlTypeString:<br>
break;<br>
-- <br>
2.46.0.792.g87dc391469-goog<br>
<br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>BR,</div>Harvey Yang</div></div></div>