From patchwork Mon Sep 23 09:30:45 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: 21332 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 39018C0F1B for ; Mon, 23 Sep 2024 09:33:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C62E863515; Mon, 23 Sep 2024 11:33:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="O+ZXrX4Q"; dkim-atps=neutral Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 667F66350D for ; Mon, 23 Sep 2024 11:33:27 +0200 (CEST) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-2053f6b8201so35684135ad.2 for ; Mon, 23 Sep 2024 02:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1727084005; x=1727688805; 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=t65ZdH9k3KpYKYy8IWDtxVVxE0TR5J85hSoLMh0Yk9Q=; b=O+ZXrX4Q/HdSZaIn63SopqboL3ivWLntbYuo20jKYAJElO97vl80ZbJsC1Y2hd2wu0 Rv69+fsst60/VjV46dOZ8FLKgMJ44cx2/2j+eZEgg3HlNAMhK1MKZ4PfLlNp1SiSf4t0 yDTyWtauHBuJU1GDMGrxKUm/lZdCMwRGgwtgM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727084005; x=1727688805; 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=t65ZdH9k3KpYKYy8IWDtxVVxE0TR5J85hSoLMh0Yk9Q=; b=FzW7k/Ozd3aClGZ0knSWak0hhxMbx1KcXvkDwvVuNqJV8fqUgY0Gn+HoOk+ROlBJkb yyk/YaAWQV6S2qWwNF8RBj0dpVLXcpXZVOdNfsOpnpEjQB+t13PNUtGmz1uibW9NE6eU V7lruAyfvfTxyt1ELzvvDCLZDdHDe7VQ6dH7Sbie4PBHFqAZ+X7pnPPZCNQrV7hVpBip L9frKs0VQ1Hccz/4CLSZqwijgR+pYdj+oE3jN+oc5tAAL6CLgf3gQQnlDgJjah/hn8Z1 HmigseNPGIwFTfTdr/MXJdte9udtU3J0NuK9AeWcvOjaUbiCytR5/9xm4AM5AwujV0wA k4Eg== X-Gm-Message-State: AOJu0YyZmw91dOMHTeuQZWThm3+sItaEOfdDijhyQLaWadtxjxh6iV0Y 1E/RVnfEijirA4qDL3i+xx2Epjagwu+NMYJ2GjSbjVuOkT3ybydVjnOj0JM1yPWKPs6gcA3V8qM = X-Google-Smtp-Source: AGHT+IEkbLYZeRTdH+vdsWFcjTyXLMXXflVO4aZxayTiUTXAcVB2pwp1NaHcAMDzkvNzafn4AcN8yw== X-Received: by 2002:a17:902:ebc4:b0:202:508c:b598 with SMTP id d9443c01a7336-208d9874d94mr139975645ad.59.1727084005621; Mon, 23 Sep 2024 02:33:25 -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-207946d6673sm129864995ad.158.2024.09.23.02.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 02:33:25 -0700 (PDT) From: Harvey Yang X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Yudhistira Erlandinata , becker hsieh , Harvey Yang Subject: [PATCH v5 2/3] libcamera: Add face detection controls Date: Mon, 23 Sep 2024 09:30:45 +0000 Message-ID: <20240923093317.3500444-3-chenghaoyang@google.com> X-Mailer: git-send-email 2.46.0.792.g87dc391469-goog In-Reply-To: <20240923093317.3500444-1-chenghaoyang@google.com> References: <20240923093317.3500444-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 | 85 ++++++++++++++++++++++++++++ src/libcamera/controls.cpp | 6 ++ 3 files changed, 97 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..c0cf5320 100644 --- a/src/libcamera/control_ids_draft.yaml +++ b/src/libcamera/control_ids_draft.yaml @@ -227,4 +227,89 @@ 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. + + The number of faces in each list must be the same. + + 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 faces. + FaceDetectFaceLandmarks and FaceDetectFaceIds is 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. + + 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. + + 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. + + 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. + + 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;