From patchwork Fri Jan 22 10:22:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10952 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 1DB86BD808 for ; Fri, 22 Jan 2021 10:22:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D64696823F; Fri, 22 Jan 2021 11:22:25 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ijLXNe1O"; dkim-atps=neutral Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B097668232 for ; Fri, 22 Jan 2021 11:22:24 +0100 (CET) Received: by mail-wr1-x42d.google.com with SMTP id a1so4546863wrq.6 for ; Fri, 22 Jan 2021 02:22:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eYCFwN9iPZG8Rn3ef6s71zt26AGyTT1IJuHDcl/GAew=; b=ijLXNe1O74bXvKrx+I3MpyWVlo2ywZrUTWw9AdxNhtTr+F434FH0K+l/00/ySuZ/JP f+fq+huC2+5V7F5zk777qgRxJOBxp5GHMfdldEywTPSCo0nBUl9C+jRzhfcAbxEsyozb YMliHxQSwbj5zvXlIg/BHsi1cWPNmasEFtk/V6TEk3MfBEHkb2Lr2cW7RYa6KgSHZjI7 vPkr2OjdS4LHOhGphNaLnv5f/bCaiDTinp0yzR/f0xZUNZ1yQevSn+xMmRPzXPAXo5zB dxufCVhmAhd7PeYpdykv2fT2cBnm2GC5TUDOUQ/4nn0DZIKCpBo5xPTL5wmw1O/JI5Bd Bubg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eYCFwN9iPZG8Rn3ef6s71zt26AGyTT1IJuHDcl/GAew=; b=cud8l3L0fiHs++w0vao+4aT+vKPpxGVt1cx7QmJOJoBmOlZsvU9gBqzvOkwetoDasA POdiRUWUR6x4cCL7kzkXFNvKcbyiV8pRWrX6upEQFROG4a84Ka9fwrhPNqY5omzG6F5U 7z0oTS20mwK6IQ6YrNnqf6O56luE1AZKuqHNfCMugDhs7AAx981zAail+pPGObIGrjK2 W9Q0UnlL+NX0yyYon/xLXyFbYm9xDPN7bjvAsUltuWr6egQ2K5Y1qP+PFi4K8rne6jVD Wb1baF01w9nlYh8p6jtWVNbRD5+IAInl1ATFi9CfPwOUPzVP9AtPRiuo2K6y9AuFv7c1 1R3Q== X-Gm-Message-State: AOAM533En6lMDgwv7LMnupAKdNr1VfOhDahGDiAVzbwTwad8lhLaZ1+r ehOBZXL4ZtC5C1N8hhQEHccKwQDY1eVhlQx4 X-Google-Smtp-Source: ABdhPJxJL7CbY3kdwFP3DypbyJoUtK3I2AahMvNaGe9JMsCY5ADnsRG73MRQBlET/WHAbs/qBH/1Dg== X-Received: by 2002:a5d:5283:: with SMTP id c3mr90872wrv.319.1611310944215; Fri, 22 Jan 2021 02:22:24 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id p15sm11469221wrt.15.2021.01.22.02.22.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 02:22:23 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 10:22:07 +0000 Message-Id: <20210122102211.12768-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210122102211.12768-1-david.plowman@raspberrypi.com> References: <20210122102211.12768-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] ipa: raspberrypi: controller: Replace Raspberry Pi debug with libcamera debug 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" Signed-off-by: David Plowman --- src/ipa/raspberrypi/controller/controller.cpp | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/ipa/raspberrypi/controller/controller.cpp b/src/ipa/raspberrypi/controller/controller.cpp index 22461cc4..f81707c2 100644 --- a/src/ipa/raspberrypi/controller/controller.cpp +++ b/src/ipa/raspberrypi/controller/controller.cpp @@ -5,6 +5,8 @@ * controller.cpp - ISP controller */ +#include "libcamera/internal/log.h" + #include "algorithm.hpp" #include "controller.hpp" @@ -12,6 +14,9 @@ #include using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiController) Controller::Controller() : switch_mode_called_(false) {} @@ -27,7 +32,7 @@ Controller::~Controller() {} void Controller::Read(char const *filename) { - RPI_LOG("Controller starting"); + LOG(RPiController, Debug) << "Controller starting"; boost::property_tree::ptree root; boost::property_tree::read_json(filename, root); for (auto const &key_and_value : root) { @@ -36,10 +41,10 @@ void Controller::Read(char const *filename) algo->Read(key_and_value.second); algorithms_.push_back(AlgorithmPtr(algo)); } else - RPI_LOG("WARNING: No algorithm found for \"" - << key_and_value.first << "\""); + LOG(RPiController, Debug) << "WARNING: No algorithm found for \"" + << key_and_value.first << "\""; } - RPI_LOG("Controller finished"); + LOG(RPiController, Debug) << "Controller finished"; } Algorithm *Controller::CreateAlgorithm(char const *name) @@ -50,39 +55,39 @@ Algorithm *Controller::CreateAlgorithm(char const *name) void Controller::Initialise() { - RPI_LOG("Controller starting"); + LOG(RPiController, Debug) << "Controller starting"; for (auto &algo : algorithms_) algo->Initialise(); - RPI_LOG("Controller finished"); + LOG(RPiController, Debug) << "Controller finished"; } void Controller::SwitchMode(CameraMode const &camera_mode, Metadata *metadata) { - RPI_LOG("Controller starting"); + LOG(RPiController, Debug) << "Controller starting"; for (auto &algo : algorithms_) algo->SwitchMode(camera_mode, metadata); switch_mode_called_ = true; - RPI_LOG("Controller finished"); + LOG(RPiController, Debug) << "Controller finished"; } void Controller::Prepare(Metadata *image_metadata) { - RPI_LOG("Controller::Prepare starting"); + LOG(RPiController, Debug) << "Controller::Prepare starting"; assert(switch_mode_called_); for (auto &algo : algorithms_) if (!algo->IsPaused()) algo->Prepare(image_metadata); - RPI_LOG("Controller::Prepare finished"); + LOG(RPiController, Debug) << "Controller::Prepare finished"; } void Controller::Process(StatisticsPtr stats, Metadata *image_metadata) { - RPI_LOG("Controller::Process starting"); + LOG(RPiController, Debug) << "Controller::Process starting"; assert(switch_mode_called_); for (auto &algo : algorithms_) if (!algo->IsPaused()) algo->Process(stats, image_metadata); - RPI_LOG("Controller::Process finished"); + LOG(RPiController, Debug) << "Controller::Process finished"; } Metadata &Controller::GetGlobalMetadata() From patchwork Fri Jan 22 10:22:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10953 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 56E84BD808 for ; Fri, 22 Jan 2021 10:22:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 26E3F68245; Fri, 22 Jan 2021 11:22:28 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Jd4QQug1"; dkim-atps=neutral Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C01AE6823E for ; Fri, 22 Jan 2021 11:22:25 +0100 (CET) Received: by mail-wr1-x430.google.com with SMTP id 7so4559776wrz.0 for ; Fri, 22 Jan 2021 02:22:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BVpqEkyfRSBU5rwlFMvrdOl3XxcNgdfc+RDlkGm4n4o=; b=Jd4QQug1SdAGd4xyjMqA3IYl2PE3WjbmO2jx8PbIbhnbZpwXCubQNfRTvrDpquoqvs CoZUcJ3UGsgwbg15wlwmaMY2YltagEPKdApXNQ5J/BKB3JXyAg8TKf8BHSG0S6Miv4bA mSgJHRTzWD4D3CkPg2dZdK4P5eC7UhAk9wYBQVkPrm2fhV5tRMpEx7X/2YQwXGI3nhGG XivnzEphtp3ppDRqR6dlV/IMgZGGEBBs4yz23u3488J6Z2xhnhGLYeOi9+/1MTfBOyrE 2czAP+XusQ26WEKH+6fhtNzWq0w0xZJfp9o5ImeM6/hJYSHwxIkFDLhg99t+N2fc/BQ2 A4iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BVpqEkyfRSBU5rwlFMvrdOl3XxcNgdfc+RDlkGm4n4o=; b=mXur+gq8tlSHpdjtW8jB0Ehma64MXXgSV7T7wGdtkLLZNUm20nekmk2ImL9LNI6IZL Z214LEjukU6Zqzmdstzontu3MtknZ5GtIp1uOx/AfDyZ9Q4hzGhTNYXIDO/c2WrnRggO uovlzdgsUHw33DHvsKWT0en2fdJSLgeQMHGlyM8Qhp7GyF+NdwWLVKlde5ZuK86weqFV A3RHBR1Gl55Frfo0pV9aIV7VgTUNQjn8YNUxj1816vPEkeGwJhh1vAG+i5Ic+LOb3fa0 rJlSdNua0Z2cByglICSNMdA/4valRu+bexs1Bx5bZj9KDBYLfqibnm7smk5OZ+styn5z zwOg== X-Gm-Message-State: AOAM530qz5n2a9lFUHoaCNHIEw0cTcNvqYk/br3qbfJeriCyCz7Pgkh8 0MikYTgVaD6kU2gwm+w7VzjuviRtKwcH/p5g X-Google-Smtp-Source: ABdhPJwx2wr8BX9HW7FhyeclcOY2QGBMJjwH5lZ6PVRuQrHY0bT4hVxTcuIlM+b6o5dhXhk7WUHLzA== X-Received: by 2002:adf:e610:: with SMTP id p16mr3711421wrm.169.1611310945096; Fri, 22 Jan 2021 02:22:25 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id p15sm11469221wrt.15.2021.01.22.02.22.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 02:22:24 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 10:22:08 +0000 Message-Id: <20210122102211.12768-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210122102211.12768-1-david.plowman@raspberrypi.com> References: <20210122102211.12768-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] ipa: raspberrypi: alsc: Replace Raspberry Pi debug with libcamera debug 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" Signed-off-by: David Plowman --- src/ipa/raspberrypi/controller/rpi/alsc.cpp | 59 +++++++++++---------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp index c354c985..4777238c 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp @@ -6,12 +6,17 @@ */ #include +#include "libcamera/internal/log.h" + #include "../awb_status.h" #include "alsc.hpp" // Raspberry Pi ALSC (Auto Lens Shading Correction) algorithm. using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiAlsc) #define NAME "rpi.alsc" @@ -110,15 +115,15 @@ static void read_calibrations(std::vector &calibrations, "Alsc: too few values for ct " + std::to_string(ct) + " in " + name); calibrations.push_back(calibration); - RPI_LOG("Read " << name << " calibration for ct " - << ct); + LOG(RPiAlsc, Debug) << "Read " << name << " calibration for ct " + << ct; } } } void Alsc::Read(boost::property_tree::ptree const ¶ms) { - RPI_LOG("Alsc"); + LOG(RPiAlsc, Debug) << "Alsc"; config_.frame_period = params.get("frame_period", 12); config_.startup_frames = params.get("startup_frames", 10); config_.speed = params.get("speed", 0.05); @@ -139,7 +144,7 @@ void Alsc::Read(boost::property_tree::ptree const ¶ms) read_lut(config_.luminance_lut, params.get_child("luminance_lut")); else - RPI_WARN("Alsc: no luminance table - assume unity everywhere"); + LOG(RPiAlsc, Warning) << "Alsc: no luminance table - assume unity everywhere"; read_calibrations(config_.calibrations_Cr, params, "calibrations_Cr"); read_calibrations(config_.calibrations_Cb, params, "calibrations_Cb"); config_.default_ct = params.get("default_ct", 4500.0); @@ -164,7 +169,7 @@ static void add_luminance_to_tables(double results[3][Y][X], void Alsc::Initialise() { - RPI_LOG("Alsc"); + LOG(RPiAlsc, Debug) << "Alsc"; frame_count2_ = frame_count_ = frame_phase_ = 0; first_time_ = true; ct_ = config_.default_ct; @@ -252,7 +257,7 @@ void Alsc::SwitchMode(CameraMode const &camera_mode, void Alsc::fetchAsyncResults() { - RPI_LOG("Fetch ALSC results"); + LOG(RPiAlsc, Debug) << "Fetch ALSC results"; async_finished_ = false; async_started_ = false; memcpy(sync_results_, async_results_, sizeof(sync_results_)); @@ -263,11 +268,11 @@ double get_ct(Metadata *metadata, double default_ct) AwbStatus awb_status; awb_status.temperature_K = default_ct; // in case nothing found if (metadata->Get("awb.status", awb_status) != 0) - RPI_WARN("Alsc: no AWB results found, using " - << awb_status.temperature_K); + LOG(RPiAlsc, Warning) << "Alsc: no AWB results found, using " + << awb_status.temperature_K; else - RPI_LOG("Alsc: AWB results found, using " - << awb_status.temperature_K); + LOG(RPiAlsc, Debug) << "Alsc: AWB results found, using " + << awb_status.temperature_K; return awb_status.temperature_K; } @@ -289,7 +294,7 @@ static void copy_stats(bcm2835_isp_stats_region regions[XY], StatisticsPtr &stat void Alsc::restartAsync(StatisticsPtr &stats, Metadata *image_metadata) { - RPI_LOG("Starting ALSC thread"); + LOG(RPiAlsc, Debug) << "Starting ALSC thread"; // Get the current colour temperature. It's all we need from the // metadata. Default to the last CT value (which could be the default). ct_ = get_ct(image_metadata, ct_); @@ -297,7 +302,7 @@ void Alsc::restartAsync(StatisticsPtr &stats, Metadata *image_metadata) // the LSC table that the pipeline applied to them. AlscStatus alsc_status; if (image_metadata->Get("alsc.status", alsc_status) != 0) { - RPI_WARN("No ALSC status found for applied gains!"); + LOG(RPiAlsc, Warning) << "No ALSC status found for applied gains!"; for (int y = 0; y < Y; y++) for (int x = 0; x < X; x++) { alsc_status.r[y][x] = 1.0; @@ -324,11 +329,11 @@ void Alsc::Prepare(Metadata *image_metadata) double speed = frame_count_ < (int)config_.startup_frames ? 1.0 : config_.speed; - RPI_LOG("Alsc: frame_count " << frame_count_ << " speed " << speed); + LOG(RPiAlsc, Debug) << "Alsc: frame_count " << frame_count_ << " speed " << speed; { std::unique_lock lock(mutex_); if (async_started_ && async_finished_) { - RPI_LOG("ALSC thread finished"); + LOG(RPiAlsc, Debug) << "ALSC thread finished"; fetchAsyncResults(); } } @@ -354,11 +359,11 @@ void Alsc::Process(StatisticsPtr &stats, Metadata *image_metadata) frame_phase_++; if (frame_count2_ < (int)config_.startup_frames) frame_count2_++; - RPI_LOG("Alsc: frame_phase " << frame_phase_); + LOG(RPiAlsc, Debug) << "Alsc: frame_phase " << frame_phase_; if (frame_phase_ >= (int)config_.frame_period || frame_count2_ < (int)config_.startup_frames) { if (async_started_ == false) { - RPI_LOG("ALSC thread starting"); + LOG(RPiAlsc, Debug) << "ALSC thread starting"; restartAsync(stats, image_metadata); } } @@ -391,25 +396,25 @@ void get_cal_table(double ct, std::vector const &calibrations, if (calibrations.empty()) { for (int i = 0; i < XY; i++) cal_table[i] = 1.0; - RPI_LOG("Alsc: no calibrations found"); + LOG(RPiAlsc, Debug) << "Alsc: no calibrations found"; } else if (ct <= calibrations.front().ct) { memcpy(cal_table, calibrations.front().table, XY * sizeof(double)); - RPI_LOG("Alsc: using calibration for " - << calibrations.front().ct); + LOG(RPiAlsc, Debug) << "Alsc: using calibration for " + << calibrations.front().ct; } else if (ct >= calibrations.back().ct) { memcpy(cal_table, calibrations.back().table, XY * sizeof(double)); - RPI_LOG("Alsc: using calibration for " - << calibrations.front().ct); + LOG(RPiAlsc, Debug) << "Alsc: using calibration for " + << calibrations.front().ct; } else { int idx = 0; while (ct > calibrations[idx + 1].ct) idx++; double ct0 = calibrations[idx].ct, ct1 = calibrations[idx + 1].ct; - RPI_LOG("Alsc: ct is " << ct << ", interpolating between " - << ct0 << " and " << ct1); + LOG(RPiAlsc, Debug) << "Alsc: ct is " << ct << ", interpolating between " + << ct0 << " and " << ct1; for (int i = 0; i < XY; i++) cal_table[i] = (calibrations[idx].table[i] * (ct1 - ct) + @@ -660,15 +665,15 @@ static void run_matrix_iterations(double const C[XY], double lambda[XY], for (int i = 0; i < n_iter; i++) { double max_diff = fabs(gauss_seidel2_SOR(M, omega, lambda)); if (max_diff < threshold) { - RPI_LOG("Stop after " << i + 1 << " iterations"); + LOG(RPiAlsc, Debug) << "Stop after " << i + 1 << " iterations"; break; } // this happens very occasionally (so make a note), though // doesn't seem to matter if (max_diff > last_max_diff) - RPI_LOG("Iteration " << i << ": max_diff gone up " - << last_max_diff << " to " - << max_diff); + LOG(RPiAlsc, Debug) << "Iteration " << i << ": max_diff gone up " + << last_max_diff << " to " + << max_diff; last_max_diff = max_diff; } // We're going to normalise the lambdas so the smallest is 1. Not sure From patchwork Fri Jan 22 10:22:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10954 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 EB233BD808 for ; Fri, 22 Jan 2021 10:22:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A386C68244; Fri, 22 Jan 2021 11:22:28 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="JsI6qv6W"; dkim-atps=neutral Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C46A968232 for ; Fri, 22 Jan 2021 11:22:26 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id a12so4546978wrv.8 for ; Fri, 22 Jan 2021 02:22:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zb3NETcE7o4MJ7BSr2BjfXSGp5ODCyGLNCbIC2n8h1M=; b=JsI6qv6W/nsQiCM6z8FLjsmaz8urpnVjPVV+AjT7FvmjRqr9hq66oj74jhtPrDiPyN hhHf84e+Tpt95oyt+j/4mZfe5BVtLDrMPR7Q6nbIG/KGlU7/3Q0Z341GekAo5mPD7S6P Zmof0w42w/KHiY6slCdADlyDMrM5HYW3o2+zvP0rj/Xd92ia8Ia9upF0PhN7CCJW1Bpq GF9ZC99luYty8K2DaWPjqeT4xPEc2GXxZjDTZO2ygZTJFh5D2yMcmMqbbWvD7Itjjgk2 XgRxG28xwFe4kfQ9sPsBFwZMTVKG0+Y9p/WIfX/gddOFp5NJsc1aXa1Dw3/TFjLmoH5F vd6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zb3NETcE7o4MJ7BSr2BjfXSGp5ODCyGLNCbIC2n8h1M=; b=Hu62QzdCeU5wyBUoUvwCU/lSNPzvutk8JCq0Hd9PWh8SDkXblhET1u/iSVs5hLaGuN OYqnq0ITh7sWgFOl8iHxhnyQMUYlbym0hy3hyl4rQwfPKQQqR9Bm+es25eoNY30NNuW7 b9RPCt+PrjpGcC5RcthOvq1nX57x5m7mDnD1yA5ac5/jcpRpzMeZU2nteLv8HCkFA8HF 6mCNfTng97U6lrEPsXnIoWNFXWfdX5BdgnltsMcuQPmbtHhTMw8MSBfLrsWeAcwUORDD oYIfN8rKgqhZzO+3qwkJ8m1GBz9FufrKhG6husfjXG4GxOOAMKsIDKWyXkxJpk7XpigS VMmQ== X-Gm-Message-State: AOAM532IcjvVCR4SJ/oDW7/eEX53mK2XUKM8vV8WXZ5gaS7AARNTGd0Z VWddxTf7oamklwp+TvX5I7tuQfcqtVmS0b5g X-Google-Smtp-Source: ABdhPJwycL+cV+BjhJpbVzZWuLQw/w2lpfRpPKhioOtJO1rK75cnCCztSDOTs+wQHx9CeJ9D11ZSGQ== X-Received: by 2002:adf:edc8:: with SMTP id v8mr3713385wro.374.1611310946012; Fri, 22 Jan 2021 02:22:26 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id p15sm11469221wrt.15.2021.01.22.02.22.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 02:22:25 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 10:22:09 +0000 Message-Id: <20210122102211.12768-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210122102211.12768-1-david.plowman@raspberrypi.com> References: <20210122102211.12768-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] ipa: raspberrypi: awb: Replace Raspberry Pi debug with libcamera debug 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" Signed-off-by: David Plowman --- src/ipa/raspberrypi/controller/rpi/awb.cpp | 92 +++++++++++----------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp index f66c2b29..34f3644b 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp @@ -5,12 +5,16 @@ * awb.cpp - AWB control algorithm */ -#include "../logging.hpp" +#include "libcamera/internal/log.h" + #include "../lux_status.h" #include "awb.hpp" using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiAwb) #define NAME "rpi.awb" @@ -58,7 +62,7 @@ static void read_ct_curve(Pwl &ct_r, Pwl &ct_b, void AwbConfig::Read(boost::property_tree::ptree const ¶ms) { - RPI_LOG("AwbConfig"); + LOG(RPiAwb, Debug) << "AwbConfig"; bayes = params.get("bayes", 1); frame_period = params.get("frame_period", 10); startup_frames = params.get("startup_frames", 10); @@ -104,8 +108,7 @@ void AwbConfig::Read(boost::property_tree::ptree const ¶ms) if (bayes) { if (ct_r.Empty() || ct_b.Empty() || priors.empty() || default_mode == nullptr) { - RPI_WARN( - "Bayesian AWB mis-configured - switch to Grey method"); + LOG(RPiAwb, Warning) << "Bayesian AWB mis-configured - switch to Grey method"; bayes = false; } } @@ -220,7 +223,7 @@ void Awb::SwitchMode([[maybe_unused]] CameraMode const &camera_mode, void Awb::fetchAsyncResults() { - RPI_LOG("Fetch AWB results"); + LOG(RPiAwb, Debug) << "Fetch AWB results"; async_finished_ = false; async_started_ = false; sync_results_ = async_results_; @@ -229,7 +232,7 @@ void Awb::fetchAsyncResults() void Awb::restartAsync(StatisticsPtr &stats, std::string const &mode_name, double lux) { - RPI_LOG("Starting AWB thread"); + LOG(RPiAwb, Debug) << "Starting AWB thread"; // this makes a new reference which belongs to the asynchronous thread statistics_ = stats; // store the mode as it could technically change @@ -254,11 +257,11 @@ void Awb::Prepare(Metadata *image_metadata) double speed = frame_count_ < (int)config_.startup_frames ? 1.0 : config_.speed; - RPI_LOG("Awb: frame_count " << frame_count_ << " speed " << speed); + LOG(RPiAwb, Debug) << "Awb: frame_count " << frame_count_ << " speed " << speed; { std::unique_lock lock(mutex_); if (async_started_ && async_finished_) { - RPI_LOG("AWB thread finished"); + LOG(RPiAwb, Debug) << "AWB thread finished"; fetchAsyncResults(); } } @@ -275,9 +278,9 @@ void Awb::Prepare(Metadata *image_metadata) prev_sync_results_.gain_b = speed * sync_results_.gain_b + (1.0 - speed) * prev_sync_results_.gain_b; image_metadata->Set("awb.status", prev_sync_results_); - RPI_LOG("Using AWB gains r " << prev_sync_results_.gain_r << " g " - << prev_sync_results_.gain_g << " b " - << prev_sync_results_.gain_b); + LOG(RPiAwb, Debug) << "Using AWB gains r " << prev_sync_results_.gain_r << " g " + << prev_sync_results_.gain_g << " b " + << prev_sync_results_.gain_b; } void Awb::Process(StatisticsPtr &stats, Metadata *image_metadata) @@ -287,7 +290,7 @@ void Awb::Process(StatisticsPtr &stats, Metadata *image_metadata) frame_phase_++; if (frame_count2_ < (int)config_.startup_frames) frame_count2_++; - RPI_LOG("Awb: frame_phase " << frame_phase_); + LOG(RPiAwb, Debug) << "Awb: frame_phase " << frame_phase_; if (frame_phase_ >= (int)config_.frame_period || frame_count2_ < (int)config_.startup_frames) { // Update any settings and any image metadata that we need. @@ -299,12 +302,12 @@ void Awb::Process(StatisticsPtr &stats, Metadata *image_metadata) struct LuxStatus lux_status = {}; lux_status.lux = 400; // in case no metadata if (image_metadata->Get("lux.status", lux_status) != 0) - RPI_LOG("No lux metadata found"); - RPI_LOG("Awb lux value is " << lux_status.lux); + LOG(RPiAwb, Debug) << "No lux metadata found"; + LOG(RPiAwb, Debug) << "Awb lux value is " << lux_status.lux; std::unique_lock lock(mutex_); if (async_started_ == false) { - RPI_LOG("AWB thread starting"); + LOG(RPiAwb, Debug) << "AWB thread starting"; restartAsync(stats, mode_name, lux_status.lux); } } @@ -375,7 +378,7 @@ double Awb::computeDelta2Sum(double gain_r, double gain_b) double delta_r = gain_r * z.R - 1 - config_.whitepoint_r; double delta_b = gain_b * z.B - 1 - config_.whitepoint_b; double delta2 = delta_r * delta_r + delta_b * delta_b; - //RPI_LOG("delta_r " << delta_r << " delta_b " << delta_b << " delta2 " << delta2); + //LOG(RPiAwb, Debug) << "delta_r " << delta_r << " delta_b " << delta_b << " delta2 " << delta2; delta2 = std::min(delta2, config_.delta_limit); delta2_sum += delta2; } @@ -438,10 +441,10 @@ double Awb::coarseSearch(Pwl const &prior) double prior_log_likelihood = prior.Eval(prior.Domain().Clip(t)); double final_log_likelihood = delta2_sum - prior_log_likelihood; - RPI_LOG("t: " << t << " gain_r " << gain_r << " gain_b " - << gain_b << " delta2_sum " << delta2_sum - << " prior " << prior_log_likelihood << " final " - << final_log_likelihood); + LOG(RPiAwb, Debug) << "t: " << t << " gain_r " << gain_r << " gain_b " + << gain_b << " delta2_sum " << delta2_sum + << " prior " << prior_log_likelihood << " final " + << final_log_likelihood; points_.push_back(Pwl::Point(t, final_log_likelihood)); if (points_.back().y < points_[best_point].y) best_point = points_.size() - 1; @@ -452,7 +455,7 @@ double Awb::coarseSearch(Pwl const &prior) mode_->ct_hi); } t = points_[best_point].x; - RPI_LOG("Coarse search found CT " << t); + LOG(RPiAwb, Debug) << "Coarse search found CT " << t; // We have the best point of the search, but refine it with a quadratic // interpolation around its neighbours. if (points_.size() > 2) { @@ -461,8 +464,8 @@ double Awb::coarseSearch(Pwl const &prior) t = interpolate_quadatric(points_[best_point - 1], points_[best_point], points_[best_point + 1]); - RPI_LOG("After quadratic refinement, coarse search has CT " - << t); + LOG(RPiAwb, Debug) << "After quadratic refinement, coarse search has CT " + << t; } return t; } @@ -514,8 +517,8 @@ void Awb::fineSearch(double &t, double &r, double &b, Pwl const &prior) double gain_r = 1 / r_test, gain_b = 1 / b_test; double delta2_sum = computeDelta2Sum(gain_r, gain_b); points[j].y = delta2_sum - prior_log_likelihood; - RPI_LOG("At t " << t_test << " r " << r_test << " b " - << b_test << ": " << points[j].y); + LOG(RPiAwb, Debug) << "At t " << t_test << " r " << r_test << " b " + << b_test << ": " << points[j].y; if (points[j].y < points[best_point].y) best_point = j; } @@ -532,17 +535,16 @@ void Awb::fineSearch(double &t, double &r, double &b, Pwl const &prior) double gain_r = 1 / r_test, gain_b = 1 / b_test; double delta2_sum = computeDelta2Sum(gain_r, gain_b); double final_log_likelihood = delta2_sum - prior_log_likelihood; - RPI_LOG("Finally " - << t_test << " r " << r_test << " b " << b_test << ": " - << final_log_likelihood - << (final_log_likelihood < best_log_likelihood ? " BEST" - : "")); + LOG(RPiAwb, Debug) << "Finally " + << t_test << " r " << r_test << " b " << b_test << ": " + << final_log_likelihood + << (final_log_likelihood < best_log_likelihood ? " BEST" : ""); if (best_t == 0 || final_log_likelihood < best_log_likelihood) best_log_likelihood = final_log_likelihood, best_t = t_test, best_r = r_test, best_b = b_test; } t = best_t, r = best_r, b = best_b; - RPI_LOG("Fine search found t " << t << " r " << r << " b " << b); + LOG(RPiAwb, Debug) << "Fine search found t " << t << " r " << r << " b " << b; } void Awb::awbBayes() @@ -556,13 +558,13 @@ void Awb::awbBayes() Pwl prior = interpolatePrior(); prior *= zones_.size() / (double)(AWB_STATS_SIZE_X * AWB_STATS_SIZE_Y); prior.Map([](double x, double y) { - RPI_LOG("(" << x << "," << y << ")"); + LOG(RPiAwb, Debug) << "(" << x << "," << y << ")"; }); double t = coarseSearch(prior); double r = config_.ct_r.Eval(t); double b = config_.ct_b.Eval(t); - RPI_LOG("After coarse search: r " << r << " b " << b << " (gains r " - << 1 / r << " b " << 1 / b << ")"); + LOG(RPiAwb, Debug) << "After coarse search: r " << r << " b " << b << " (gains r " + << 1 / r << " b " << 1 / b << ")"; // Not entirely sure how to handle the fine search yet. Mostly the // estimated CT is already good enough, but the fine search allows us to // wander transverely off the CT curve. Under some illuminants, where @@ -570,8 +572,8 @@ void Awb::awbBayes() // though I probably need more real datasets before deciding exactly how // this should be controlled and tuned. fineSearch(t, r, b, prior); - RPI_LOG("After fine search: r " << r << " b " << b << " (gains r " - << 1 / r << " b " << 1 / b << ")"); + LOG(RPiAwb, Debug) << "After fine search: r " << r << " b " << b << " (gains r " + << 1 / r << " b " << 1 / b << ")"; // Write results out for the main thread to pick up. Remember to adjust // the gains from the ones that the "canonical sensor" would require to // the ones needed by *this* sensor. @@ -583,7 +585,7 @@ void Awb::awbBayes() void Awb::awbGrey() { - RPI_LOG("Grey world AWB"); + LOG(RPiAwb, Debug) << "Grey world AWB"; // Make a separate list of the derivatives for each of red and blue, so // that we can sort them to exclude the extreme gains. We could // consider some variations, such as normalising all the zones first, or @@ -620,21 +622,21 @@ void Awb::doAwb() async_results_.gain_r = manual_r_; async_results_.gain_g = 1.0; async_results_.gain_b = manual_b_; - RPI_LOG("Using manual white balance: gain_r " - << async_results_.gain_r << " gain_b " - << async_results_.gain_b); + LOG(RPiAwb, Debug) << "Using manual white balance: gain_r " + << async_results_.gain_r << " gain_b " + << async_results_.gain_b; } else { prepareStats(); - RPI_LOG("Valid zones: " << zones_.size()); + LOG(RPiAwb, Debug) << "Valid zones: " << zones_.size(); if (zones_.size() > config_.min_regions) { if (config_.bayes) awbBayes(); else awbGrey(); - RPI_LOG("CT found is " - << async_results_.temperature_K - << " with gains r " << async_results_.gain_r - << " and b " << async_results_.gain_b); + LOG(RPiAwb, Debug) << "CT found is " + << async_results_.temperature_K + << " with gains r " << async_results_.gain_r + << " and b " << async_results_.gain_b; } } } From patchwork Fri Jan 22 10:22:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10955 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 8D900BD808 for ; Fri, 22 Jan 2021 10:22:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1BCCE68250; Fri, 22 Jan 2021 11:22:29 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="NbDhwyu7"; dkim-atps=neutral Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D62F068232 for ; Fri, 22 Jan 2021 11:22:27 +0100 (CET) Received: by mail-wr1-x430.google.com with SMTP id q7so4523222wre.13 for ; Fri, 22 Jan 2021 02:22:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wi2wYgUewmB6k9vz0bR3FoTRIyJ5PZT7Jge5CyshUWw=; b=NbDhwyu7oqe6yPpLX7w1NLQwdjOe40FYKySueuvXF0HZed8Y8FMDR5R0lYf22m1CLS HHz1Tl+RCjNJ8iRlR4YBw1/wJRXdj2nsDT2KmaeKaq545k4FuaV24KejG+7Quhw9j1NR ti5A32pdsVNS0FPZ+ZGsoJtbX657HPeXwaB40ywmZXRFG+a5wkRdHbb4BxgtVQrTeRzl 4CQGI/Y5dYnh/IIy4nwsjK4nsRgTyC1sbv7u06YNxhyjK9mREEGfIWNUJmhj07b7NmxY qhbJ1S3zo10jdyOTodpFdzvIvGbMvcxk23Ml1fNOVFRwIeBnigfchxGc/QgqBczr3csC XUXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wi2wYgUewmB6k9vz0bR3FoTRIyJ5PZT7Jge5CyshUWw=; b=kbKtqztXs1FIvngwnycFVmnvUtQO36Fx6SDBEZza0OgKMa/WK4fRnovuXNZ75+aeme Q0Ljp9fhYF7wVEimmFfLser9fHCWQ3mjzhlmYgP1Zp4FFZ0XiOVIjgUU54jTFiXnzTXH eS5TeB/poKDT7rTLiyZTmrF7ufZxeHy7hX53eVG1g5+EMxWRmoqG/EqeAVXEAfW4j05f dj/7uIibQp1LhzLq0fztw9GEnEJnJ39JGqB0AxyWo9Mk+zRGsxJTEFrHFxW/SD78fag8 CndXXTAlSHdeY8mlOUsmwI+vk1qD6REtthmbRWixdFhcWU1KgxFznXh54t4sqnNOJsFF 8/cw== X-Gm-Message-State: AOAM533AFQoIVNyeXrf8i2ig3SrbnxHELeYZYwTYB9cx7Xwm5r6jQpkV Jboj4fbLcun2xU0EnkI676lHEBgEjtAMFeR9 X-Google-Smtp-Source: ABdhPJzcnSpne8eo8MBxhGhHSmebRtetoKeT2YxJ2faDYcvmEmWwIHp4lBJ/vSFbjzxlj2kw8HTs/g== X-Received: by 2002:adf:f58f:: with SMTP id f15mr3807351wro.388.1611310947103; Fri, 22 Jan 2021 02:22:27 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id p15sm11469221wrt.15.2021.01.22.02.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 02:22:26 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 10:22:10 +0000 Message-Id: <20210122102211.12768-5-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210122102211.12768-1-david.plowman@raspberrypi.com> References: <20210122102211.12768-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/5] ipa: raspberrypi: Replace Raspberry Pi debug with libcamera debug 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" This commit deals with all the "small" algorithms (that is, not Agc/Awb/Alsc). Signed-off-by: David Plowman --- .../controller/rpi/black_level.cpp | 8 +++++-- src/ipa/raspberrypi/controller/rpi/ccm.cpp | 24 +++++++++++-------- .../raspberrypi/controller/rpi/contrast.cpp | 15 ++++++++---- src/ipa/raspberrypi/controller/rpi/dpc.cpp | 8 +++++-- src/ipa/raspberrypi/controller/rpi/geq.cpp | 18 ++++++++------ src/ipa/raspberrypi/controller/rpi/lux.cpp | 12 ++++++---- src/ipa/raspberrypi/controller/rpi/noise.cpp | 14 +++++++---- src/ipa/raspberrypi/controller/rpi/sdn.cpp | 21 +++++++++------- .../raspberrypi/controller/rpi/sharpen.cpp | 8 +++++-- 9 files changed, 83 insertions(+), 45 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.cpp b/src/ipa/raspberrypi/controller/rpi/black_level.cpp index 0629b77c..99d6dd7f 100644 --- a/src/ipa/raspberrypi/controller/rpi/black_level.cpp +++ b/src/ipa/raspberrypi/controller/rpi/black_level.cpp @@ -8,12 +8,16 @@ #include #include +#include "libcamera/internal/log.h" + #include "../black_level_status.h" -#include "../logging.hpp" #include "black_level.hpp" using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiBlackLevel) #define NAME "rpi.black_level" @@ -29,7 +33,7 @@ char const *BlackLevel::Name() const void BlackLevel::Read(boost::property_tree::ptree const ¶ms) { - RPI_LOG(Name()); + LOG(RPiBlackLevel, Debug) << Name(); uint16_t black_level = params.get( "black_level", 4096); // 64 in 10 bits scaled to 16 bits black_level_r_ = params.get("black_level_r", black_level); diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.cpp b/src/ipa/raspberrypi/controller/rpi/ccm.cpp index a8a2caff..25ac94f8 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.cpp +++ b/src/ipa/raspberrypi/controller/rpi/ccm.cpp @@ -5,15 +5,19 @@ * ccm.cpp - CCM (colour correction matrix) control algorithm */ +#include "libcamera/internal/log.h" + #include "../awb_status.h" #include "../ccm_status.h" -#include "../logging.hpp" #include "../lux_status.h" #include "../metadata.hpp" #include "ccm.hpp" using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiCcm) // This algorithm selects a CCM (Colour Correction Matrix) according to the // colour temperature estimated by AWB (interpolating between known matricies as @@ -129,9 +133,9 @@ void Ccm::Prepare(Metadata *image_metadata) lux_ok = get_locked(image_metadata, "lux.status", lux); } if (!awb_ok) - RPI_WARN("Ccm: no colour temperature found"); + LOG(RPiCcm, Warning) << "Ccm: no colour temperature found"; if (!lux_ok) - RPI_WARN("Ccm: no lux value found"); + LOG(RPiCcm, Warning) << "Ccm: no lux value found"; Matrix ccm = calculate_ccm(config_.ccms, awb.temperature_K); double saturation = saturation_; struct CcmStatus ccm_status; @@ -144,13 +148,13 @@ void Ccm::Prepare(Metadata *image_metadata) for (int i = 0; i < 3; i++) ccm_status.matrix[j * 3 + i] = std::max(-8.0, std::min(7.9999, ccm.m[j][i])); - RPI_LOG("CCM: colour temperature " << awb.temperature_K << "K"); - RPI_LOG("CCM: " << ccm_status.matrix[0] << " " << ccm_status.matrix[1] - << " " << ccm_status.matrix[2] << " " - << ccm_status.matrix[3] << " " << ccm_status.matrix[4] - << " " << ccm_status.matrix[5] << " " - << ccm_status.matrix[6] << " " << ccm_status.matrix[7] - << " " << ccm_status.matrix[8]); + LOG(RPiCcm, Debug) << "CCM: colour temperature " << awb.temperature_K << "K"; + LOG(RPiCcm, Debug) << "CCM: " << ccm_status.matrix[0] << " " << ccm_status.matrix[1] + << " " << ccm_status.matrix[2] << " " + << ccm_status.matrix[3] << " " << ccm_status.matrix[4] + << " " << ccm_status.matrix[5] << " " + << ccm_status.matrix[6] << " " << ccm_status.matrix[7] + << " " << ccm_status.matrix[8]; image_metadata->Set("ccm.status", ccm_status); } diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.cpp b/src/ipa/raspberrypi/controller/rpi/contrast.cpp index 103153db..a70ca612 100644 --- a/src/ipa/raspberrypi/controller/rpi/contrast.cpp +++ b/src/ipa/raspberrypi/controller/rpi/contrast.cpp @@ -6,12 +6,17 @@ */ #include +#include "libcamera/internal/log.h" + #include "../contrast_status.h" #include "../histogram.hpp" #include "contrast.hpp" using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiContrast) // This is a very simple control algorithm which simply retrieves the results of // AGC and AWB via their "status" metadata, and applies digital gain to the @@ -97,11 +102,11 @@ Pwl compute_stretch_curve(Histogram const &histogram, double hist_lo = histogram.Quantile(config.lo_histogram) * (65536 / NUM_HISTOGRAM_BINS); double level_lo = config.lo_level * 65536; - RPI_LOG("Move histogram point " << hist_lo << " to " << level_lo); + LOG(RPiContrast, Debug) << "Move histogram point " << hist_lo << " to " << level_lo; hist_lo = std::max( level_lo, std::min(65535.0, std::min(hist_lo, level_lo + config.lo_max))); - RPI_LOG("Final values " << hist_lo << " -> " << level_lo); + LOG(RPiContrast, Debug) << "Final values " << hist_lo << " -> " << level_lo; enhance.Append(hist_lo, level_lo); // Keep the mid-point (median) in the same place, though, to limit the // apparent amount of global brightness shift. @@ -113,11 +118,11 @@ Pwl compute_stretch_curve(Histogram const &histogram, double hist_hi = histogram.Quantile(config.hi_histogram) * (65536 / NUM_HISTOGRAM_BINS); double level_hi = config.hi_level * 65536; - RPI_LOG("Move histogram point " << hist_hi << " to " << level_hi); + LOG(RPiContrast, Debug) << "Move histogram point " << hist_hi << " to " << level_hi; hist_hi = std::min( level_hi, std::max(0.0, std::max(hist_hi, level_hi - config.hi_max))); - RPI_LOG("Final values " << hist_hi << " -> " << level_hi); + LOG(RPiContrast, Debug) << "Final values " << hist_hi << " -> " << level_hi; enhance.Append(hist_hi, level_hi); enhance.Append(65535, 65535); return enhance; @@ -127,7 +132,7 @@ Pwl apply_manual_contrast(Pwl const &gamma_curve, double brightness, double contrast) { Pwl new_gamma_curve; - RPI_LOG("Manual brightness " << brightness << " contrast " << contrast); + LOG(RPiContrast, Debug) << "Manual brightness " << brightness << " contrast " << contrast; gamma_curve.Map([&](double x, double y) { new_gamma_curve.Append( x, std::max(0.0, std::min(65535.0, diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.cpp b/src/ipa/raspberrypi/controller/rpi/dpc.cpp index 348e1609..a48ae2dd 100644 --- a/src/ipa/raspberrypi/controller/rpi/dpc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/dpc.cpp @@ -5,10 +5,14 @@ * dpc.cpp - DPC (defective pixel correction) control algorithm */ -#include "../logging.hpp" +#include "libcamera/internal/log.h" + #include "dpc.hpp" using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiDpc) // We use the lux status so that we can apply stronger settings in darkness (if // necessary). @@ -37,7 +41,7 @@ void Dpc::Prepare(Metadata *image_metadata) DpcStatus dpc_status = {}; // Should we vary this with lux level or analogue gain? TBD. dpc_status.strength = config_.strength; - RPI_LOG("Dpc: strength " << dpc_status.strength); + LOG(RPiDpc, Debug) << "Dpc: strength " << dpc_status.strength; image_metadata->Set("dpc.status", dpc_status); } diff --git a/src/ipa/raspberrypi/controller/rpi/geq.cpp b/src/ipa/raspberrypi/controller/rpi/geq.cpp index b6c98414..e2bd2b06 100644 --- a/src/ipa/raspberrypi/controller/rpi/geq.cpp +++ b/src/ipa/raspberrypi/controller/rpi/geq.cpp @@ -5,14 +5,18 @@ * geq.cpp - GEQ (green equalisation) control algorithm */ +#include "libcamera/internal/log.h" + #include "../device_status.h" -#include "../logging.hpp" #include "../lux_status.h" #include "../pwl.hpp" #include "geq.hpp" using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiGeq) // We use the lux status so that we can apply stronger settings in darkness (if // necessary). @@ -44,11 +48,11 @@ void Geq::Prepare(Metadata *image_metadata) LuxStatus lux_status = {}; lux_status.lux = 400; if (image_metadata->Get("lux.status", lux_status)) - RPI_WARN("Geq: no lux data found"); + LOG(RPiGeq, Warning) << "Geq: no lux data found"; DeviceStatus device_status = {}; device_status.analogue_gain = 1.0; // in case not found if (image_metadata->Get("device.status", device_status)) - RPI_WARN("Geq: no device metadata - use analogue gain of 1x"); + LOG(RPiGeq, Warning) << "Geq: no device metadata - use analogue gain of 1x"; GeqStatus geq_status = {}; double strength = config_.strength.Empty() @@ -60,10 +64,10 @@ void Geq::Prepare(Metadata *image_metadata) double slope = config_.slope * strength; geq_status.offset = std::min(65535.0, std::max(0.0, offset)); geq_status.slope = std::min(.99999, std::max(0.0, slope)); - RPI_LOG("Geq: offset " << geq_status.offset << " slope " - << geq_status.slope << " (analogue gain " - << device_status.analogue_gain << " lux " - << lux_status.lux << ")"); + LOG(RPiGeq, Debug) << "Geq: offset " << geq_status.offset << " slope " + << geq_status.slope << " (analogue gain " + << device_status.analogue_gain << " lux " + << lux_status.lux << ")"; image_metadata->Set("geq.status", geq_status); } diff --git a/src/ipa/raspberrypi/controller/rpi/lux.cpp b/src/ipa/raspberrypi/controller/rpi/lux.cpp index 5acd49a0..d3f067a7 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.cpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.cpp @@ -8,12 +8,16 @@ #include "linux/bcm2835-isp.h" +#include "libcamera/internal/log.h" + #include "../device_status.h" -#include "../logging.hpp" #include "lux.hpp" using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiLux) #define NAME "rpi.lux" @@ -33,7 +37,7 @@ char const *Lux::Name() const void Lux::Read(boost::property_tree::ptree const ¶ms) { - RPI_LOG(Name()); + LOG(RPiLux, Debug) << Name(); reference_shutter_speed_ = params.get("reference_shutter_speed"); reference_gain_ = params.get("reference_gain"); @@ -84,7 +88,7 @@ void Lux::Process(StatisticsPtr &stats, Metadata *image_metadata) LuxStatus status; status.lux = estimated_lux; status.aperture = current_aperture; - RPI_LOG(Name() << ": estimated lux " << estimated_lux); + LOG(RPiLux, Debug) << Name() << ": estimated lux " << estimated_lux; { std::unique_lock lock(mutex_); status_ = status; @@ -93,7 +97,7 @@ void Lux::Process(StatisticsPtr &stats, Metadata *image_metadata) // algorithms get the latest value. image_metadata->Set("lux.status", status); } else - RPI_WARN(Name() << ": no device metadata"); + LOG(RPiLux, Warning) << Name() << ": no device metadata"; } // Register algorithm with the system. diff --git a/src/ipa/raspberrypi/controller/rpi/noise.cpp b/src/ipa/raspberrypi/controller/rpi/noise.cpp index 9e9eaf1b..ba65b4c5 100644 --- a/src/ipa/raspberrypi/controller/rpi/noise.cpp +++ b/src/ipa/raspberrypi/controller/rpi/noise.cpp @@ -7,13 +7,17 @@ #include +#include "libcamera/internal/log.h" + #include "../device_status.h" -#include "../logging.hpp" #include "../noise_status.h" #include "noise.hpp" using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiNoise) #define NAME "rpi.noise" @@ -37,7 +41,7 @@ void Noise::SwitchMode(CameraMode const &camera_mode, void Noise::Read(boost::property_tree::ptree const ¶ms) { - RPI_LOG(Name()); + LOG(RPiNoise, Debug) << Name(); reference_constant_ = params.get("reference_constant"); reference_slope_ = params.get("reference_slope"); } @@ -58,10 +62,10 @@ void Noise::Prepare(Metadata *image_metadata) status.noise_constant = reference_constant_ * factor; status.noise_slope = reference_slope_ * factor; image_metadata->Set("noise.status", status); - RPI_LOG(Name() << ": constant " << status.noise_constant - << " slope " << status.noise_slope); + LOG(RPiNoise, Debug) << Name() << ": constant " << status.noise_constant + << " slope " << status.noise_slope; } else - RPI_WARN(Name() << " no metadata"); + LOG(RPiNoise, Warning) << Name() << " no metadata"; } // Register algorithm with the system. diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.cpp b/src/ipa/raspberrypi/controller/rpi/sdn.cpp index aa82830b..5de1a60f 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.cpp @@ -5,12 +5,17 @@ * sdn.cpp - SDN (spatial denoise) control algorithm */ +#include "libcamera/internal/log.h" + #include "../noise_status.h" #include "../sdn_status.h" #include "sdn.hpp" using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiSdn) // Calculate settings for the spatial denoise block using the noise profile in // the image metadata. @@ -40,19 +45,19 @@ void Sdn::Prepare(Metadata *image_metadata) struct NoiseStatus noise_status = {}; noise_status.noise_slope = 3.0; // in case no metadata if (image_metadata->Get("noise.status", noise_status) != 0) - RPI_WARN("Sdn: no noise profile found"); - RPI_LOG("Noise profile: constant " << noise_status.noise_constant - << " slope " - << noise_status.noise_slope); + LOG(RPiSdn, Warning) << "Sdn: no noise profile found"; + LOG(RPiSdn, Debug) << "Noise profile: constant " << noise_status.noise_constant + << " slope " + << noise_status.noise_slope; struct SdnStatus status; status.noise_constant = noise_status.noise_constant * deviation_; status.noise_slope = noise_status.noise_slope * deviation_; status.strength = strength_; image_metadata->Set("sdn.status", status); - RPI_LOG("Sdn: programmed constant " << status.noise_constant - << " slope " << status.noise_slope - << " strength " - << status.strength); + LOG(RPiSdn, Debug) << "Sdn: programmed constant " << status.noise_constant + << " slope " << status.noise_slope + << " strength " + << status.strength; } // Register algorithm with the system. diff --git a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp index c953a7d9..18d5cc86 100644 --- a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp @@ -7,12 +7,16 @@ #include -#include "../logging.hpp" +#include "libcamera/internal/log.h" + #include "../sharpen_status.h" #include "sharpen.hpp" using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiSharpen) #define NAME "rpi.sharpen" @@ -35,7 +39,7 @@ void Sharpen::SwitchMode(CameraMode const &camera_mode, void Sharpen::Read(boost::property_tree::ptree const ¶ms) { - RPI_LOG(Name()); + LOG(RPiSharpen, Debug) << Name(); threshold_ = params.get("threshold", 1.0); strength_ = params.get("strength", 1.0); limit_ = params.get("limit", 1.0); From patchwork Fri Jan 22 10:22:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10956 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 8697EBD808 for ; Fri, 22 Jan 2021 10:22:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 538D46824C; Fri, 22 Jan 2021 11:22:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="foj0cTBF"; dkim-atps=neutral Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A9E896824C for ; Fri, 22 Jan 2021 11:22:28 +0100 (CET) Received: by mail-wr1-x431.google.com with SMTP id q7so4523257wre.13 for ; Fri, 22 Jan 2021 02:22:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lzoNnOT+b8DgxM8JeMLr4xrkmbTMR3H8ANBYbi4GV84=; b=foj0cTBF+94MuM+BPTlZOnRUS6+z4Cuu7CiuI+DqHrRzsALWrT1HIz9OuMYNe8mF+I almXaLkuE3BTvsO8EAOF/s4r1MzvG9Ac9kAYjRFbCvmZTzUmSR7ftA6vPoGDf2I4z16v PfX9E2vckGn/atN/NMXmln2q9MYaRpCU5xBwQbHEJO3993mut3Ds/9EUgykTa/Bhs8vI B+EldkgSPDP+e6ACG7hmr6bcduYC4kY3lMmG9BLbKndgr6MMcq6+Xe0xL9QoVR8GRcEn QCp7FL7oiUFgtrD7osTYKpbSpAwBU98hQer/UZY6psEk/pWMTHAYUkuHNDvJhg8MRQiA mG2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lzoNnOT+b8DgxM8JeMLr4xrkmbTMR3H8ANBYbi4GV84=; b=W0YyOUSaGHKywhZff9G1HF31MxJEK8AWwseS7TSG+ZmCqOUTPSolSr7QNAgF2OUFUk +mnaibzLGfzW/2Q18JVRiNnxrRFS6sKe9Vd1bwXC1nBFUWa167JFj9Ig7To+FSamFjh3 vK9UjKOTTRulr3IxplfI1G64mM2Dr96iJdeCc72s33+/KvyG9g7jYy3RLcbpFSnqW3ne dwAUHd+nBm9Mt/2A0ZvNFZy3HwRifUKx79PDl+hCZYduG9jvTG46+BtB9PmZ2QM2bTz4 pnVrD3TKd5gi6xQGFSmSKXxJMsa7uKxgyD6YZpEH1OEZ9FdjVMlj81LP6VJUpJRkxxEb dHQQ== X-Gm-Message-State: AOAM530BzZDNYIpfvBkchyaz+UicMgcyqaRDsec0r6nTJ+ZO7UClcHmJ MWzn8qLQZMZkKui6twd2D4To8xkYW/JtZwMQ X-Google-Smtp-Source: ABdhPJxIDci1P6ADmdRHdDLDlO6/MFdokR6UNy6d5Kl68N97fkj4UIgVowRoGVlwIt7I49iFDzpgAA== X-Received: by 2002:a5d:4d86:: with SMTP id b6mr3779501wru.152.1611310948190; Fri, 22 Jan 2021 02:22:28 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id p15sm11469221wrt.15.2021.01.22.02.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 02:22:27 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 10:22:11 +0000 Message-Id: <20210122102211.12768-6-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210122102211.12768-1-david.plowman@raspberrypi.com> References: <20210122102211.12768-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] ipa: raspberrypi: Remove legacy Rasberry Pi logging 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" Signed-off-by: David Plowman Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/algorithm.hpp | 1 - src/ipa/raspberrypi/controller/logging.hpp | 30 -------------------- 2 files changed, 31 deletions(-) delete mode 100644 src/ipa/raspberrypi/controller/logging.hpp diff --git a/src/ipa/raspberrypi/controller/algorithm.hpp b/src/ipa/raspberrypi/controller/algorithm.hpp index 17423f23..e9b040c7 100644 --- a/src/ipa/raspberrypi/controller/algorithm.hpp +++ b/src/ipa/raspberrypi/controller/algorithm.hpp @@ -14,7 +14,6 @@ #include #include -#include "logging.hpp" #include "controller.hpp" #include diff --git a/src/ipa/raspberrypi/controller/logging.hpp b/src/ipa/raspberrypi/controller/logging.hpp deleted file mode 100644 index f0d306b6..00000000 --- a/src/ipa/raspberrypi/controller/logging.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ -/* - * Copyright (C) 2019-2020, Raspberry Pi (Trading) Limited - * - * logging.hpp - logging macros - */ -#pragma once - -#include - -#ifndef RPI_LOGGING_ENABLE -#define RPI_LOGGING_ENABLE 0 -#endif - -#ifndef RPI_WARNING_ENABLE -#define RPI_WARNING_ENABLE 1 -#endif - -#define RPI_LOG(stuff) \ - do { \ - if (RPI_LOGGING_ENABLE) \ - std::cout << __FUNCTION__ << ": " << stuff << "\n"; \ - } while (0) - -#define RPI_WARN(stuff) \ - do { \ - if (RPI_WARNING_ENABLE) \ - std::cout << __FUNCTION__ << " ***WARNING*** " \ - << stuff << "\n"; \ - } while (0)