{"id":16607,"url":"https://patchwork.libcamera.org/api/1.1/patches/16607/?format=json","web_url":"https://patchwork.libcamera.org/patch/16607/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220713084317.24268-10-dse@thaumatec.com>","date":"2022-07-13T08:43:15","name":"[libcamera-devel,v2,09/11] ipa: af_hill_climb: Skip the first frame after triggering auto focus","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ea4d1a96a64daeb2d97df0ad4945de1e91a6947e","submitter":{"id":126,"url":"https://patchwork.libcamera.org/api/1.1/people/126/?format=json","name":"Daniel Semkowicz","email":"dse@thaumatec.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16607/mbox/","series":[{"id":3276,"url":"https://patchwork.libcamera.org/api/1.1/series/3276/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3276","date":"2022-07-13T08:43:06","name":"ipa: rkisp1: Add autofocus algorithm","version":2,"mbox":"https://patchwork.libcamera.org/series/3276/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16607/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16607/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BD29BBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 13 Jul 2022 08:43:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4C9806332C;\n\tWed, 13 Jul 2022 10:43:49 +0200 (CEST)","from mail-wm1-x333.google.com (mail-wm1-x333.google.com\n\t[IPv6:2a00:1450:4864:20::333])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B631F6330D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Jul 2022 10:43:47 +0200 (CEST)","by mail-wm1-x333.google.com with SMTP id ay25so6092244wmb.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Jul 2022 01:43:47 -0700 (PDT)","from localhost.localdomain (ip092042140082.rev.nessus.at.\n\t[92.42.140.82]) by smtp.gmail.com with ESMTPSA id\n\tbg32-20020a05600c3ca000b003a04d19dab3sm5667468wmb.3.2022.07.13.01.43.46\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 13 Jul 2022 01:43:46 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657701829;\n\tbh=ie3aENqbC44ysjMYLpStHnU7FOOcWn4heFKrwvTdjYI=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=t/eYYLAmo7tEuITyi6T3pwLmw2yFN7Tthx6aEQZPWYyqEnXzfD6pSst2PX9nCCids\n\tMQV6tHq11k0UFeXmt6TMHY2bOO5+Zv5e0NoZ2OxXcanQaX6j2W+FhIdhbsp6S7/Mqv\n\tHAtO00I8uoZc+AcUaYx3Anpy+Po/Al5XXTW7DJtJ22himpgK/p92jn8cyLrLKtGDE6\n\tvL5vdfGX28jnMfVy5BRikVze78kgVM2hVWRmvyh2ltGShhJuLVExoUGYPLGghcx9Nm\n\tbHGFnArYvTB3elB2ym5zE/MAgLCCjcPcs1VbsEBJfo/NfJ/SCiTuv+w2qizIeH9VjW\n\trLtaQX66B+Cjg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=thaumatec-com.20210112.gappssmtp.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=EHJVI5NARITEoRsYFHX1Zu3g0dX4ygzx+AElRmV8oEA=;\n\tb=O1WzAwMf+mOLTIUZ1FLvwZ/bmJvRZSgfrzr5HpQLNuvgbXQno/F9WObTO6hVt0GPJF\n\thCOwacYXWQMnGvjZLGWhUXUZcI9JdLLUVj0FvhAMwm1MHdTMY+J4jJfbIgh8nNAholWH\n\tmCae9L+2l1PWfVLBHOCrGPsWiWOpYbVw+6UfhJjK/pWqJ4bQTueWAHOrqdB4rEhUATiE\n\tkRHQhCs09M4Rfba9klxJNG+ihvsToEz2GB4GyB02hvRmYDz2T1XlwQ1UTV8pIkBLvreo\n\t+OeiQC1GNmzulMRDtduYCxiCIZOFG+3BDEtyI6HMeXms9SjFzz1B/YjtMeR5YfPGyeLn\n\tRUtA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=thaumatec-com.20210112.gappssmtp.com\n\theader.i=@thaumatec-com.20210112.gappssmtp.com header.b=\"O1WzAwMf\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=EHJVI5NARITEoRsYFHX1Zu3g0dX4ygzx+AElRmV8oEA=;\n\tb=6suac/I/6SnACOFprgdAhNMY1+7HwouSd1J5MaBy8354JNpz2m4qfjb1XjzCMReT+2\n\trXNAcnYc8TJVOLkZ5qjN+Xjf2X92NF+pzphfavcw7B7lDfzqq2n6FCQgzscv0mkpug6t\n\tKcCqhWdJS3o9WK+VpFtDkuPBx4yGs2J3+sHbJBHUfh0bGMbM3zPZAN3rtohb6V07PnAM\n\t/msBzuk29Sa3jllAfAMOlybxbJ0Lbw5AQ2V8WCSmEsRqWNO/yWt74Vap5vTWNUKaz7hU\n\trFb6ibL1HWdcLw3u2MRNeO/9CB09Ct78VmgTq08kCPH4eNnjsIsNSpQ6WUZFSS4/6z4H\n\tFYqg==","X-Gm-Message-State":"AJIora8EvCsJsD86daJxKIhC8sbaj4JNy8pXaqfixogO4E7+8zj1pKn9\n\tsKcZopxcaE9ei+0sucyzqg3OmVY4SZ4U4Q==","X-Google-Smtp-Source":"AGRyM1sYjbpxZjtcwZqdLAwM3LTx9cbwbxoR/cOoPYTs0hGZ518zfNJfGrxVVdXPp7LfE5iXKjn4NA==","X-Received":"by 2002:a05:600c:33a2:b0:3a2:fda9:6489 with SMTP id\n\to34-20020a05600c33a200b003a2fda96489mr800546wmp.29.1657701827320; \n\tWed, 13 Jul 2022 01:43:47 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 13 Jul 2022 10:43:15 +0200","Message-Id":"<20220713084317.24268-10-dse@thaumatec.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20220713084317.24268-1-dse@thaumatec.com>","References":"<20220713084317.24268-1-dse@thaumatec.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 09/11] ipa: af_hill_climb: Skip the\n\tfirst frame after triggering auto focus","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Daniel Semkowicz via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Daniel Semkowicz <dse@thaumatec.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"When AFTrigger is received, AF algorithm internal state is reset to\ninitial values. If reset happens between frames, then first contrast\nvalue that arrives after this, is interpreted as contrast for initial\nposition. This is wrong, because it was measured for lens position\nbefore the reset. Skip this first frame to allow correct contrast\nmeasure for the initial lens position.\n\nSigned-off-by: Daniel Semkowicz <dse@thaumatec.com>\n---\n .../libipa/algorithms/af_hill_climbing.cpp    |  8 +++++++\n src/ipa/libipa/algorithms/af_hill_climbing.h  | 23 ++++++++++++++++++-\n 2 files changed, 30 insertions(+), 1 deletion(-)","diff":"diff --git a/src/ipa/libipa/algorithms/af_hill_climbing.cpp b/src/ipa/libipa/algorithms/af_hill_climbing.cpp\nindex f666c6c2..28d09176 100644\n--- a/src/ipa/libipa/algorithms/af_hill_climbing.cpp\n+++ b/src/ipa/libipa/algorithms/af_hill_climbing.cpp\n@@ -84,6 +84,14 @@ namespace ipa::common::algorithms {\n  * \\return New lens position calculated by AF algorithm\n  */\n \n+/**\n+ * \\fn AfHillClimbing::setFramesToSkip()\n+ * \\brief Request AF to skip n frames\n+ * \\param[in] n Number of frames to be skipped\n+ *\n+ * Requested number of frames will not be used for AF calculation.\n+ */\n+\n } /* namespace ipa::common::algorithms */\n \n } /* namespace libcamera */\ndiff --git a/src/ipa/libipa/algorithms/af_hill_climbing.h b/src/ipa/libipa/algorithms/af_hill_climbing.h\nindex db9fc058..e251f3eb 100644\n--- a/src/ipa/libipa/algorithms/af_hill_climbing.h\n+++ b/src/ipa/libipa/algorithms/af_hill_climbing.h\n@@ -29,7 +29,7 @@ public:\n \t\t  lensPosition_(0), bestPosition_(0), currentContrast_(0.0),\n \t\t  previousContrast_(0.0), maxContrast_(0.0), maxStep_(0),\n \t\t  coarseCompleted_(false), fineCompleted_(false),\n-\t\t  lowStep_(0), highStep_(kMaxFocusSteps)\n+\t\t  lowStep_(0), highStep_(kMaxFocusSteps), framesToSkip_(0)\n \t{\n \t}\n \n@@ -92,6 +92,9 @@ protected:\n \t{\n \t\tcurrentContrast_ = currentContrast;\n \n+\t\tif (shouldSkipFrame())\n+\t\t\treturn lensPosition_;\n+\n \t\t/* If we are in a paused state, we won't process the stats */\n \t\tif (pauseState_ == libcamera::controls::AfPauseStatePaused)\n \t\t\treturn lensPosition_;\n@@ -113,6 +116,12 @@ protected:\n \t\treturn lensPosition_;\n \t}\n \n+\tvoid setFramesToSkip(uint32_t n)\n+\t{\n+\t\tif (n > framesToSkip_)\n+\t\t\tframesToSkip_ = n;\n+\t}\n+\n private:\n \tvoid afCoarseScan()\n \t{\n@@ -191,6 +200,7 @@ private:\n \t\tcoarseCompleted_ = false;\n \t\tfineCompleted_ = false;\n \t\tmaxContrast_ = 0.0;\n+\t\tsetFramesToSkip(1);\n \t}\n \n \tbool afIsOutOfFocus()\n@@ -206,6 +216,16 @@ private:\n \t\t\treturn false;\n \t}\n \n+\tbool shouldSkipFrame()\n+\t{\n+\t\tif (framesToSkip_ > 0) {\n+\t\t\tframesToSkip_--;\n+\t\t\treturn true;\n+\t\t}\n+\n+\t\treturn false;\n+\t}\n+\n \tcontrols::AfModeEnum mode_;\n \tcontrols::AfStateEnum state_;\n \tcontrols::AfPauseStateEnum pauseState_;\n@@ -229,6 +249,7 @@ private:\n \n \tuint32_t lowStep_;\n \tuint32_t highStep_;\n+\tuint32_t framesToSkip_;\n \n \t/*\n \t* Maximum focus steps of the VCM control\n","prefixes":["libcamera-devel","v2","09/11"]}