From patchwork Wed Sep 25 08:12:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-Hao Yang X-Patchwork-Id: 21351 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 16005C0F1B for ; Wed, 25 Sep 2024 08:16:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9BB526350B; Wed, 25 Sep 2024 10:16:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="oLHloQKA"; dkim-atps=neutral Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 22A47634F4 for ; Wed, 25 Sep 2024 10:16:05 +0200 (CEST) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2053525bd90so60170455ad.0 for ; Wed, 25 Sep 2024 01:16:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1727252163; x=1727856963; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GWZlrTn3UIKHPYN3S3TmQEW5JGVkDju8QySmkcDjybo=; b=oLHloQKAy15ePGzt7lJxq9UQ/HTxW+3glvwlLPqL2ARf6+6dSfHRZALhGNwzELnyL2 01kGeZmWdPAm5G07Cpbf8vRFy0iXSb96pOCsPuFeXvk5JuTCDC5Q+5hickNBHgwMZnsy GCzEJbtFR1b5OLyOBzsvduktcExU3kckBE0qk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727252163; x=1727856963; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GWZlrTn3UIKHPYN3S3TmQEW5JGVkDju8QySmkcDjybo=; b=S14OsNZpXMEBnMUXMkR2Ybq54T0SCcVzKqTQ7E4o7806Q5ctaWJpUa0tBmLgFdvVXd y24rJ3iadPdLr/uylB9xOBn/aHkuOGoB3XdGN6ZLNcTWhjfxbYP6+ZGmomhtskrCUotT wFzPw6fQgoWl9W4xz3/PvJM84zZzg458Fj4FHcMkD4krf3z/CZeraQ8vDYrNoNKu0jtQ rDuivmL8vLdENd8ypBmVbZT8DFWjiHWCZNlZ29og0HF2Qf8zOZCTs3rMtAftDhhb9GAI 3vj6Dg1+e4pvd8Z37+xsRoqNvs95r+hZ6HJ3JNjDrQ7YTHhQ0WV272kr98IG6nN3WmFC 4mUQ== X-Gm-Message-State: AOJu0YxBWR2ba5peszyEWcghfgwj1336gHCXr+9HDPDzlkPv+Iom/Ffy apcMAtWQBTrez05z1uN5EZRUVncUbfWaMWagdlrgJzRtEXHcdgoshLYfczrjh3nfI4sfQnTz5kw = X-Google-Smtp-Source: AGHT+IERYT2KthmAJbnfu9sY/NJDGf+saa4glEfOrvG435tjaUV2adnRImTnZWeZhTphQq9AkCmenA== X-Received: by 2002:a17:902:d4c9:b0:1f6:fcd9:5b86 with SMTP id d9443c01a7336-20afc40cfd8mr36086535ad.12.1727252163308; Wed, 25 Sep 2024 01:16:03 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (0.223.81.34.bc.googleusercontent.com. [34.81.223.0]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b002aaa8fsm6336465ad.240.2024.09.25.01.16.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 01:16:02 -0700 (PDT) From: Harvey Yang X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Yudhistira Erlandinata , becker hsieh , Harvey Yang , Jacopo Mondi Subject: [PATCH v8 2/3] libcamera: Add face detection controls Date: Wed, 25 Sep 2024 08:12:25 +0000 Message-ID: <20240925081551.3265942-3-chenghaoyang@google.com> X-Mailer: git-send-email 2.46.0.792.g87dc391469-goog In-Reply-To: <20240925081551.3265942-1-chenghaoyang@google.com> References: <20240925081551.3265942-1-chenghaoyang@google.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Yudhistira Erlandinata Add FaceDetectMode, FaceDetectFaceRectangles, FaceDetectFaceScores, and FaceDetectFaceLandmark. Also add ControlTypePoint for supporting FaceDetectFaceLandmark. Signed-off-by: Yudhistira Erlandinata Co-developed-by: becker hsieh Co-developed-by: Harvey Yang Reviewed-by: Jacopo Mondi --- include/libcamera/controls.h | 6 ++ src/libcamera/control_ids_draft.yaml | 88 ++++++++++++++++++++++++++++ src/libcamera/controls.cpp | 6 ++ 3 files changed, 100 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 7c2bb287..bf1b8609 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -34,6 +34,7 @@ enum ControlType { ControlTypeString, ControlTypeRectangle, ControlTypeSize, + ControlTypePoint, }; namespace details { @@ -87,6 +88,11 @@ struct control_type { static constexpr ControlType value = ControlTypeSize; }; +template<> +struct control_type { + static constexpr ControlType value = ControlTypePoint; +}; + template struct control_type> : public control_type> { }; diff --git a/src/libcamera/control_ids_draft.yaml b/src/libcamera/control_ids_draft.yaml index 9bef5bf1..6a472b48 100644 --- a/src/libcamera/control_ids_draft.yaml +++ b/src/libcamera/control_ids_draft.yaml @@ -227,4 +227,92 @@ controls: value. All of the custom test patterns will be static (that is the raw image must not vary from frame to frame). + - FaceDetectMode: + type: uint8_t + description: | + Reporting mode of face detection. + + Currently identical to ANDROID_STATISTICS_FACE_DETECT_MODE. + + \sa FaceDetectFaceRectangles + \sa FaceDetectFaceScores + \sa FaceDetectFaceLandmarks + \sa FaceDetectFaceIds + + enum: + - name: FaceDetectModeOff + value: 0 + description: | + Pipeline should not report face detection result. + + - name: FaceDetectModeSimple + value: 1 + description: | + Pipeline should at least report FaceDetectFaceRectangles and + FaceDetectFaceScores for each detected face. + FaceDetectFaceLandmarks and FaceDetectFaceIds are optional. + + - name: FaceDetectModeFull + value: 2 + description: | + Pipeline should report all face controls, including + FaceDetectFaceRectangles, FaceDetectFaceScores, + FaceDetectFaceLandmarks, and FaceDeteceFaceIds. + + - FaceDetectFaceRectangles: + type: Rectangle + description: | + Boundary rectangles of the detected faces. + The number of values should be the number of faces reported in + FaceDetectFaceRectangles. + + The FaceDetectFaceRectangles control can only be returned in metadata. + + Currently identical to ANDROID_STATISTICS_FACE_RECTANGLES. + + size: [n] + + - FaceDetectFaceScores: + type: uint8_t + description: | + Confidence score of each of the detected faces by face detector. + The range of score is [0, 100]. + The FaceDetectFaceScores control can only be returned in metadata. + The number of values should be the number of faces reported in + FaceDetectFaceRectangles. + + Currently identical to ANDROID_STATISTICS_FACE_SCORES. + + size: [n] + + - FaceDetectFaceLandmarks: + type: Point + description: | + Array of human face landmark coordinates in format: + [..., left_eye_i, right_eye_i, mouth_i, left_eye_i+1, ...], + with i = index of face. + The number of values should be 3 * the number of faces reported in + FaceDetectFaceRectangles. + + The FaceDetectFaceLandmarks control can only be returned in metadata. + + Currently identical to ANDROID_STATISTICS_FACE_LANDMARKS. + + size: [n] + + - FaceDetectFaceIds: + type: int32_t + description: | + Each detected face is given a unique ID that is valid for as long as + the face is visible to the camera device. A face that leaves the field + of view and later returns may be assigned a new ID. + The number of values should be the number of faces reported in + FaceDetectFaceRectangles. + + The FaceDetectFaceIds control can only be returned in metadata. + + Currently identical to ANDROID_STATISTICS_FACE_IDS. + + size: [n] + ... diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index dba74404..c452e607 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -60,6 +60,7 @@ static constexpr size_t ControlValueSize[] = { [ControlTypeString] = sizeof(char), [ControlTypeRectangle] = sizeof(Rectangle), [ControlTypeSize] = sizeof(Size), + [ControlTypePoint] = sizeof(Point), }; } /* namespace */ @@ -254,6 +255,11 @@ std::string ControlValue::toString() const str += value->toString(); break; } + case ControlTypePoint: { + const Point *value = reinterpret_cast(data); + str += value->toString(); + break; + } case ControlTypeNone: case ControlTypeString: break;