From patchwork Mon Jan 25 18:48:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10990 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 1EEA6BD808 for ; Mon, 25 Jan 2021 18:49:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B044F682E6; Mon, 25 Jan 2021 19:49:07 +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="dHKi1DuI"; dkim-atps=neutral Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1008F682D1 for ; Mon, 25 Jan 2021 19:49:05 +0100 (CET) Received: by mail-ed1-x531.google.com with SMTP id s11so16759020edd.5 for ; Mon, 25 Jan 2021 10:49:05 -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=Zi4fSpeVN5lxiGy5u0yXSb9pUfzZ83CfLgRG/iSQNTU=; b=dHKi1DuIBRDHVRouKDMOmY5XVBMTEscdAabJBB2BnQla0u6zX4Y4elDe1h38Dirl4a wxDBY2CqG8O7jZDlsrVSAq0oX2RZivL56fulqyOsVPSviezKRtEtS5LSzUlk+3e7EYT1 yqD2wnde3Bh2mbkt2dehlPYMraz8rmZTkffl+vhS3yUWh/7lbU9SVxGPOLR7bFLQd+bL gX+TrOE1oKUAfHe6Efj9VqVVOm0rfo94bkHmIla+0zXGb8/sqdBeHQKb/+HHWMVQyy8T 3Z8+d02TzER6DzLv75Scr95H14bmGRLlzqgFxBtYoI8bnfOBeFQ6bfQAWBpH57VowPPM MqHw== 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=Zi4fSpeVN5lxiGy5u0yXSb9pUfzZ83CfLgRG/iSQNTU=; b=dFgRiBRQTQXr9oPE4b0aSFdIx4gf2clUY3w+IPIdE1wZSkMekT6L5M6XeP9M9kiUhh g7JdBNWLuVfv+enKyg/iShgbWDq6h2CnE9DVDazWoOmMQqPw+mYcjqbupYFuNUjqLEu4 E9Pa4c4+W8D+RNiMlLx0EEipfwDlui+aGnDCePNi2gJVugLQZTFJMoJZcDbuK7eb3oFH ih05es8ubnO3FCw7gPUXLLKXHzNsFUH0uronWD0X403xxsfFqwlsqp14nUaKU5O8DwkC qgAS1aPVcrZDKMfhtGfR7RLo+xsmSZXznf08AKveziPkyUTDQf/y31PpaXm4omCfbOYx njfA== X-Gm-Message-State: AOAM531d16ANWFfodiAf+UltuWSIJkApFY6YUNkmBs1/UEA+xoKXAgGJ n8b+n+p5neHzDq/4p4XXxkeGjL4F/B7ug3+A X-Google-Smtp-Source: ABdhPJy9d02edsGAYsEv1JGszK34o8w7rK0qykDdRv85E4+hOLoteJjeEGH2nUR2iPRS9RQeVdn3fA== X-Received: by 2002:a50:b742:: with SMTP id g60mr1602165ede.113.1611600544425; Mon, 25 Jan 2021 10:49:04 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id y59sm11601836ede.59.2021.01.25.10.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 10:49:03 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Mon, 25 Jan 2021 18:48:54 +0000 Message-Id: <20210125184858.16339-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210125184858.16339-1-david.plowman@raspberrypi.com> References: <20210125184858.16339-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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" Some unhelpful debug statements have been removed. Signed-off-by: David Plowman Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/controller.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/ipa/raspberrypi/controller/controller.cpp b/src/ipa/raspberrypi/controller/controller.cpp index 22461cc4..96b58359 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,6 @@ Controller::~Controller() {} void Controller::Read(char const *filename) { - RPI_LOG("Controller starting"); boost::property_tree::ptree root; boost::property_tree::read_json(filename, root); for (auto const &key_and_value : root) { @@ -36,10 +40,9 @@ 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, Warning) + << "No algorithm found for \"" << key_and_value.first << "\""; } - RPI_LOG("Controller finished"); } Algorithm *Controller::CreateAlgorithm(char const *name) @@ -50,39 +53,31 @@ Algorithm *Controller::CreateAlgorithm(char const *name) void Controller::Initialise() { - RPI_LOG("Controller starting"); for (auto &algo : algorithms_) algo->Initialise(); - RPI_LOG("Controller finished"); } void Controller::SwitchMode(CameraMode const &camera_mode, Metadata *metadata) { - RPI_LOG("Controller starting"); for (auto &algo : algorithms_) algo->SwitchMode(camera_mode, metadata); switch_mode_called_ = true; - RPI_LOG("Controller finished"); } void Controller::Prepare(Metadata *image_metadata) { - RPI_LOG("Controller::Prepare starting"); assert(switch_mode_called_); for (auto &algo : algorithms_) if (!algo->IsPaused()) algo->Prepare(image_metadata); - RPI_LOG("Controller::Prepare finished"); } void Controller::Process(StatisticsPtr stats, Metadata *image_metadata) { - RPI_LOG("Controller::Process starting"); assert(switch_mode_called_); for (auto &algo : algorithms_) if (!algo->IsPaused()) algo->Process(stats, image_metadata); - RPI_LOG("Controller::Process finished"); } Metadata &Controller::GetGlobalMetadata() From patchwork Mon Jan 25 18:48:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10991 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 1C8CDBD808 for ; Mon, 25 Jan 2021 18:49:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0753D682E9; Mon, 25 Jan 2021 19:49:08 +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="rLCbHCQL"; dkim-atps=neutral Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D6A7682D8 for ; Mon, 25 Jan 2021 19:49:06 +0100 (CET) Received: by mail-ed1-x52b.google.com with SMTP id z22so2066347edb.9 for ; Mon, 25 Jan 2021 10:49:06 -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=32lrAXJUjf0NlyXWSNkrlfCQIIMREPBcy/5qhF+MI+4=; b=rLCbHCQLBZbVt3nzYJPHnNK2cy8ZTjqJ6BMzsPIKHxpMfvAAmjiKrxvsPtsVXvh84L 89WHskfygZxznQ7YGIC/T4tL5+Dutpy3WwuoS1EtAy257kqNzdSl4/o2WcFCbhFeK6On oQF78qGPHLjVggGpA97bRpAW9b7sCO+O2Vgi3vod3vK7AHU7lYmLBDSfWVBMTuKgb/Jp ZcIy1YxvM5bHiRvv4w9zv2hnmL90r/5BqVfXBbgMK4PB1pFoGPzBF/qEkAsG3ZSYFcn+ upOez/2TQdz2NuduDnEMEe2CKDIN/LnQ6spB/8eLXTN6Y3mR6IRPSMTAUm7V79mYK5KF qy8Q== 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=32lrAXJUjf0NlyXWSNkrlfCQIIMREPBcy/5qhF+MI+4=; b=agXwhsMIBu4kf6g6tRNXoyP+h20KzmIxyr0BerGZXkqFn354IqcFeK6nCBgGgN5Mqi FWtgcMKg5sUy/up9rbuzvIghMYjj4FrpT+u86kfPPrJCpsieipdeqyLqva5Z+klnSigv 9acPKr9HFgn+bzeEOnyAInai4RX5t1PaeDxQru31KZIeBRC6ZOEU4/oVWjb5qL7bctdZ pYFwPEZFRIZksv1M5Ua96rwySXibbSP7uZSH9JJiv3jmxYV2E4mrA0VWoPAbMo2l42/i pIDuHqv3ApbNB5klvGbk7/dKWLiHaEGT5OTcyd7chXrtIaIGGZtTJxnPOx8VcTOC3aEe KXzw== X-Gm-Message-State: AOAM531X7aGsxWBfVkA2/MTUGngpW6hNOSVGXCa0TF2i5Mquc2MG3UOt /lR4rfA9MobyioE0F6g8LD3nQjpxv77J1OdR X-Google-Smtp-Source: ABdhPJwzlwmnZbDgFMWlRq9TzZIjHaMGmWRbU21mFZCAXlzRczcvwvxoAA9QcEHJjc3iBvsyEo5qMQ== X-Received: by 2002:a05:6402:11c7:: with SMTP id j7mr1642529edw.290.1611600545515; Mon, 25 Jan 2021 10:49:05 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id y59sm11601836ede.59.2021.01.25.10.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 10:49:04 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Mon, 25 Jan 2021 18:48:55 +0000 Message-Id: <20210125184858.16339-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210125184858.16339-1-david.plowman@raspberrypi.com> References: <20210125184858.16339-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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" Some unhelpful debug messages have been removed. Signed-off-by: David Plowman Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/rpi/alsc.cpp | 66 +++++++++++---------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp index c354c985..5262bcab 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,14 @@ 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"); 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 +143,8 @@ 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) + << "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,6 @@ static void add_luminance_to_tables(double results[3][Y][X], void Alsc::Initialise() { - RPI_LOG("Alsc"); frame_count2_ = frame_count_ = frame_phase_ = 0; first_time_ = true; ct_ = config_.default_ct; @@ -252,7 +256,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 +267,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) << "no AWB results found, using " + << awb_status.temperature_K; else - RPI_LOG("Alsc: AWB results found, using " - << awb_status.temperature_K); + LOG(RPiAlsc, Debug) << "AWB results found, using " + << awb_status.temperature_K; return awb_status.temperature_K; } @@ -289,7 +293,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 calculation"; // 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 +301,8 @@ 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,13 +329,12 @@ 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) + << "frame_count " << frame_count_ << " speed " << speed; { std::unique_lock lock(mutex_); - if (async_started_ && async_finished_) { - RPI_LOG("ALSC thread finished"); + if (async_started_ && async_finished_) fetchAsyncResults(); - } } // Apply IIR filter to results and program into the pipeline. double *ptr = (double *)sync_results_, @@ -354,13 +358,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) << "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"); + if (async_started_ == false) restartAsync(stats, image_metadata); - } } } @@ -391,25 +393,26 @@ 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) << "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) << "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) << "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) + << "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 +663,16 @@ 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 Mon Jan 25 18:48:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10992 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 B2135BD808 for ; Mon, 25 Jan 2021 18:49:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6A1D1682ED; Mon, 25 Jan 2021 19:49:08 +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="s34E9KZC"; dkim-atps=neutral Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3578B682D8 for ; Mon, 25 Jan 2021 19:49:07 +0100 (CET) Received: by mail-ed1-x535.google.com with SMTP id g1so16768230edu.4 for ; Mon, 25 Jan 2021 10:49:07 -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=8bPpaA9CK0cvjRVU6Wwh4JeqcPbkw6cR7UVolIZBz7w=; b=s34E9KZCMeUh9/IT3nPYyHwI6YWos5Y5R3kVwncoDyZ6RpfQk76HBXppkUyYm46GfK 2EfqcFR8WO78vSgYWaecJTT9YSzRpAtenRe4QG59IH7hjkt2K1Y+ltcf9Dx0LtApIwgw 9WOnJVa13fgpeHrdsU53sqYnHKpQJVUR5GxLpzyaInJ4HFa0jR4I4laACH+iKvRdbJQz fBTcjXj5hfFK/NPk7+/SPbH+M9/kF1Ekh+y+X2vg74YeDBdhqHHUNwrQ3EPfvs9S1URJ Matbcaat1AWj0I55ujqywbnKxG0XCCUt8Tiv0MsjngnM3JbIdclQ0lSIF58Vl7mJl0yx XciQ== 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=8bPpaA9CK0cvjRVU6Wwh4JeqcPbkw6cR7UVolIZBz7w=; b=qvxKzMGOrptNwXw3jPNykSEb7Yjzat6cwLH6KSBIhErqG3BYddSdjqYExibT98gczC 2UWVPDeHz3Gcha4RokByyHulMztf+mIjTw4SyHnGDSZ4xIF8bjA+/NAFjP0qEU0F5Y8E Z5uYqf5NjWPpfUZrGJ0KHhSn6kRUm3u9wz6JD/jO6+6raznze4hXh+dlHlIQk4LxCOs/ Tdl912XAV/k7k/9/zXlHD6xzhuKdtCXtRjFfhEKNMhqwJWjHbMShSjd4Dzk1ZNoAHmDy ICFvMA/rsezTPLzALaYjqoq/KP6C97ejnfEZMq/LmcfRHuth8ZSJzCCF8b6GqgFguc2q lYMA== X-Gm-Message-State: AOAM532GMlR0L5pAJZ4fl9HM1mI8WE0fBL6+mq+rI9d7wZiex+2OIQCW gQMbS1poGJd8pMOSriVSgauuUopVsoaOSDFn X-Google-Smtp-Source: ABdhPJztPvUye1SZ6I2mV3ddGz2Uvhv31s6CpDeO/ipU1A5ulpC9eNpT+oLCig/LikP6g/D/t3SePA== X-Received: by 2002:a05:6402:228a:: with SMTP id cw10mr1580213edb.195.1611600546441; Mon, 25 Jan 2021 10:49:06 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id y59sm11601836ede.59.2021.01.25.10.49.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 10:49:05 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Mon, 25 Jan 2021 18:48:56 +0000 Message-Id: <20210125184858.16339-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210125184858.16339-1-david.plowman@raspberrypi.com> References: <20210125184858.16339-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/rpi/awb.cpp | 97 ++++++++++++---------- 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp index f66c2b29..62337b13 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,6 @@ static void read_ct_curve(Pwl &ct_r, Pwl &ct_b, void AwbConfig::Read(boost::property_tree::ptree const ¶ms) { - RPI_LOG("AwbConfig"); bayes = params.get("bayes", 1); frame_period = params.get("frame_period", 10); startup_frames = params.get("startup_frames", 10); @@ -104,8 +107,8 @@ 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 calculation"; // this makes a new reference which belongs to the asynchronous thread statistics_ = stats; // store the mode as it could technically change @@ -254,13 +257,12 @@ 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) + << "frame_count " << frame_count_ << " speed " << speed; { std::unique_lock lock(mutex_); - if (async_started_ && async_finished_) { - RPI_LOG("AWB thread finished"); + if (async_started_ && async_finished_) fetchAsyncResults(); - } } // Finally apply IIR filter to results and put into metadata. memcpy(prev_sync_results_.mode, sync_results_.mode, @@ -275,9 +277,10 @@ 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) << "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,14 +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"); + if (async_started_ == false) restartAsync(stats, mode_name, lux_status.lux); - } } } @@ -375,7 +376,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 +439,11 @@ 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 +454,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 +463,9 @@ 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,9 @@ 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 +536,18 @@ 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 " + LOG(RPiAwb, Debug) + << "Finally " << t_test << " r " << r_test << " b " << b_test << ": " << final_log_likelihood - << (final_log_likelihood < best_log_likelihood ? " BEST" - : "")); + << (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 +561,14 @@ 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 +576,9 @@ 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 +590,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 +627,23 @@ 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 " + LOG(RPiAwb, Debug) + << "Using manual white balance: gain_r " << async_results_.gain_r << " gain_b " - << async_results_.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 " + LOG(RPiAwb, Debug) + << "CT found is " << async_results_.temperature_K << " with gains r " << async_results_.gain_r - << " and b " << async_results_.gain_b); + << " and b " << async_results_.gain_b; } } } From patchwork Mon Jan 25 18:48:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10993 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 872B8BD808 for ; Mon, 25 Jan 2021 18:49:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 55F33682F0; Mon, 25 Jan 2021 19:49:11 +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="CZXYArtr"; dkim-atps=neutral Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B165682EC for ; Mon, 25 Jan 2021 19:49:08 +0100 (CET) Received: by mail-ed1-x536.google.com with SMTP id d2so13197260edz.3 for ; Mon, 25 Jan 2021 10:49:08 -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=nf+T2sLGAiYCG1t7z8SE7SFgioCvQetm3oWgC8lIB34=; b=CZXYArtrMzXwsBl9NLpVkaqWUodnuRuBdD1NXIWWpsXS+6Txt2yEF4L4HUQkekrJqn xDIwk62629KutzauaeUJyjL7ayh3S5e+fx1IbDwsh3xsGnZpSS6NNKGzykqUcp0S/THa MlUeuBl3/jzf1r1YVDPwVg+smnGQqhU5c3/uat9G50EAPIeiHNuJWxZXhFt4SOFiTvq4 AVAGFjGA5f78GppLeuee9FTE7uHBbw4OC/269BG/6pUkAbNC6aFmLNVdRB9LOTknAQwo fXQJjrY4inJDrqps+TOU9Xaim77d2bMf90Ldt8lWxxPHARzNWo6TuWuEfi4lgjsXAm8w jzzg== 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=nf+T2sLGAiYCG1t7z8SE7SFgioCvQetm3oWgC8lIB34=; b=ibe4kxa0QKGUC2MH8SLrBZBOAufmmvH2OCz4ECDhOPoD9oLtozt/wbPLUJo8EoFpqK 0v+oDT6KWckW9qrtX381RqXJ71NQ5+PvAaZXKSn34tZiLQ1b8AE2F1BswBooPDeZiCtK VaUOjFdDilO1PFUvuFxI3cNRWU+IjUxCxCHmOD+xDBc4KSFlG3T2pA46tXj2e4P+Q922 6BjOmg3AMsxG2WHzhjhWH+fVduf+NwiOPXIzFBuEZV+Wnh2eM4JbRVIeZg9/B57l7lux Fk4AqF63k8t5l7td+TjsraTb0Lf8SefF7WnnC8Z4NHOZpHGAsdWKryGMf5jA9PTpfk78 SDSQ== X-Gm-Message-State: AOAM532f+nfCJLgBOI2a0mQ8V1g6B2MRdwKoAQ+zkTnuU4nO2MmOF3fj vctncQwm4FSUCJYhruLdqGaKXhcznZKcFGl+ X-Google-Smtp-Source: ABdhPJxTnc3iupWTlSrFQ5dUaDoa+ZK/2kh1N+XUiLo6oAZRg3dGP9+iar8ki1XIu4VF8d0GjB7zLA== X-Received: by 2002:aa7:df86:: with SMTP id b6mr1737742edy.4.1611600547516; Mon, 25 Jan 2021 10:49:07 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id y59sm11601836ede.59.2021.01.25.10.49.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 10:49:06 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Mon, 25 Jan 2021 18:48:57 +0000 Message-Id: <20210125184858.16339-5-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210125184858.16339-1-david.plowman@raspberrypi.com> References: <20210125184858.16339-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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). A few unnecessary debug messages have also been removed. Signed-off-by: David Plowman Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- .../controller/rpi/black_level.cpp | 11 ++++++-- src/ipa/raspberrypi/controller/rpi/ccm.cpp | 26 ++++++++++++------- .../raspberrypi/controller/rpi/contrast.cpp | 20 ++++++++++---- src/ipa/raspberrypi/controller/rpi/dpc.cpp | 8 ++++-- src/ipa/raspberrypi/controller/rpi/geq.cpp | 20 +++++++++----- src/ipa/raspberrypi/controller/rpi/lux.cpp | 11 +++++--- src/ipa/raspberrypi/controller/rpi/noise.cpp | 14 ++++++---- src/ipa/raspberrypi/controller/rpi/sdn.cpp | 21 +++++++++------ .../raspberrypi/controller/rpi/sharpen.cpp | 11 ++++++-- 9 files changed, 97 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..9ac855f5 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,12 +33,15 @@ char const *BlackLevel::Name() const void BlackLevel::Read(boost::property_tree::ptree const ¶ms) { - RPI_LOG(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); black_level_g_ = params.get("black_level_g", black_level); black_level_b_ = params.get("black_level_b", black_level); + LOG(RPiBlackLevel, Debug) + << " Read black levels red " << black_level_r_ + << " green " << black_level_g_ + << " blue " << black_level_b_; } void BlackLevel::Prepare(Metadata *image_metadata) diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.cpp b/src/ipa/raspberrypi/controller/rpi/ccm.cpp index a8a2caff..dbdcbb39 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) << "no colour temperature found"; if (!lux_ok) - RPI_WARN("Ccm: no lux value found"); + LOG(RPiCcm, Warning) << "no lux value found"; Matrix ccm = calculate_ccm(config_.ccms, awb.temperature_K); double saturation = saturation_; struct CcmStatus ccm_status; @@ -144,13 +148,15 @@ 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) + << "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..05ed139f 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,13 @@ 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 +120,13 @@ 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 +136,8 @@ 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..e533cd53 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) << "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..5eff116c 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,12 @@ 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) << "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) + << "no device metadata - use analogue gain of 1x"; GeqStatus geq_status = {}; double strength = config_.strength.Empty() @@ -60,10 +65,11 @@ 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) + << "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..aefd92d4 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,6 @@ char const *Lux::Name() const void Lux::Read(boost::property_tree::ptree const ¶ms) { - RPI_LOG(Name()); reference_shutter_speed_ = params.get("reference_shutter_speed"); reference_gain_ = params.get("reference_gain"); @@ -84,7 +87,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) << ": estimated lux " << estimated_lux; { std::unique_lock lock(mutex_); status_ = status; @@ -93,7 +96,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) << ": 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..156f7501 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,6 @@ void Noise::SwitchMode(CameraMode const &camera_mode, void Noise::Read(boost::property_tree::ptree const ¶ms) { - RPI_LOG(Name()); reference_constant_ = params.get("reference_constant"); reference_slope_ = params.get("reference_slope"); } @@ -58,10 +61,11 @@ 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) + << "constant " << status.noise_constant + << " slope " << status.noise_slope; } else - RPI_WARN(Name() << " no metadata"); + LOG(RPiNoise, Warning) << " 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..0fad2550 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) << "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) + << "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..2cd861ca 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,10 +39,13 @@ void Sharpen::SwitchMode(CameraMode const &camera_mode, void Sharpen::Read(boost::property_tree::ptree const ¶ms) { - RPI_LOG(Name()); threshold_ = params.get("threshold", 1.0); strength_ = params.get("strength", 1.0); limit_ = params.get("limit", 1.0); + LOG(RPiSharpen, Debug) + << "Read threshold " << threshold_ + << " strength " << strength_ + << " limit " << limit_; } void Sharpen::SetStrength(double strength) From patchwork Mon Jan 25 18:48:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10994 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 249EBBD808 for ; Mon, 25 Jan 2021 18:49:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DBD3E682E9; Mon, 25 Jan 2021 19:49:11 +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="rfyGemDy"; dkim-atps=neutral Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 90D93682DB for ; Mon, 25 Jan 2021 19:49:09 +0100 (CET) Received: by mail-ej1-x62e.google.com with SMTP id w1so19496185ejf.11 for ; Mon, 25 Jan 2021 10:49:09 -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=F7wNUmeRHs2H3iF0z3YYd6je6FUdDFpLYC0hRKeo0Qw=; b=rfyGemDy/s5ZR6URTGLr74XfRFH+AAd1sgUps7EQsSMAjQL/jaizWwxfJQbkkcWWkl oVBeurqrYPAWNanBlmnm4nGdlVMvR3K1M2pLHy3mTEpmn8q8jAu0ZuUoa3r09Wqqzfbz tBJUBBJvopmGJTYnODCkcoT3djv38JVZY8d9PsQQzyrgTjNCG31yXl09WEPhfDzYBAu8 3fu7BiiVA44rg2/PeAvVrs3iPoX6P4h20K981FY5QmxvB8XOs5uKyJd5N8DLTV6GESyQ VkIKWZbP2gfhXxsJJn5NrIM/4V3IDfEOwGL2E0bIzcLcDP7eXquGoNC7WitFTHaxZHcW edHg== 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=F7wNUmeRHs2H3iF0z3YYd6je6FUdDFpLYC0hRKeo0Qw=; b=kIs6wJp5he/uE0fxBQpInZYOzAclIkwGiTakJ27hhkneXWdqckYzvieil6al7eEaLy sMYkyQreRRLnIobsKvmxlhaH6XtkwPeeN8T5YJDOT+cQelW4udCMxOcVYrt1TkQ3EsdW HIrYxlmrPxCDwaXmbutlAy82K07VN04vCqYZmtNFwMVI9LlzP326iC7kthPnR8Cq7d5b 7as4qipCO/SWp5HF7WyLFZ/QUsuXfN7FLHCf4JfOyeECsG4FgMAoxAixS0h2AAfxfxNY UinE6Q3wRFwKxGcJQ652+z7aSuRkFNDjcrk3b2C7ImaVVeVQcuVdub8vUR7NLZHWg1d0 g17A== X-Gm-Message-State: AOAM531/4Bleu4b7eDegGolIfBw1EdFVcOfYA5KxlJG2Xr6v+zzamSvb zPxSL07p6Dlj546xz3hfWuumpNIExfmZqdzH X-Google-Smtp-Source: ABdhPJyjqPgfPjzunQjzQ0+po6BhXi4O0iQU4tYtHoa2QcODmwrZNt22RBWwg+4UWB1sfD7mByk7yA== X-Received: by 2002:a17:907:9879:: with SMTP id ko25mr1243130ejc.524.1611600548654; Mon, 25 Jan 2021 10:49:08 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id y59sm11601836ede.59.2021.01.25.10.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 10:49:07 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Mon, 25 Jan 2021 18:48:58 +0000 Message-Id: <20210125184858.16339-6-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210125184858.16339-1-david.plowman@raspberrypi.com> References: <20210125184858.16339-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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: Kieran Bingham 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)