From patchwork Mon Mar 24 17:07:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23002 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 9799BC3213 for ; Mon, 24 Mar 2025 17:08:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4CD8E68954; Mon, 24 Mar 2025 18:08:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="C9KU1Mhq"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3FBB868945 for ; Mon, 24 Mar 2025 18:08:16 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:854:5bc6:b2a7:e242]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8D0E7455; Mon, 24 Mar 2025 18:06:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742835989; bh=xWqkUF4YwfxJrRbwmW1md+m0MlZxkpK3+kTodBpdSKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C9KU1MhqVzv5FL1vYTLTnEyxvKq/sb01u8HPdM+qbART+gQuxB6plRdcbxTDffm0M wCnGEP49/d6fgQPx3MdclaMWMeIKQa+swMvp8XU7gNllrC4zUGdDFJssFDm3cpj3n0 J7WWsasVfUfdU+h803HZVu02ZLmIrE02ZgR+5Ofg= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 1/5] test: ipa: libipa: Add histogram tests Date: Mon, 24 Mar 2025 18:07:36 +0100 Message-ID: <20250324170803.103296-2-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250324170803.103296-1-stefan.klug@ideasonboard.com> References: <20250324170803.103296-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add some basic tests for the histogram class. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- test/ipa/libipa/histogram.cpp | 53 +++++++++++++++++++++++++++++++++++ test/ipa/libipa/meson.build | 1 + 2 files changed, 54 insertions(+) create mode 100644 test/ipa/libipa/histogram.cpp diff --git a/test/ipa/libipa/histogram.cpp b/test/ipa/libipa/histogram.cpp new file mode 100644 index 000000000000..220a329e33b3 --- /dev/null +++ b/test/ipa/libipa/histogram.cpp @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2024, Ideas on Board Oy + * + * Histogram tests + */ + +#include "../src/ipa/libipa/histogram.h" + +#include +#include +#include +#include + +#include "test.h" + +using namespace std; +using namespace libcamera; +using namespace ipa; + +#define ASSERT_EQ(a, b) \ + if (!((a) == (b))) { \ + printf(#a " != " #b "\n"); \ + return TestFail; \ + } + +class HistogramTest : public Test +{ +protected: + int run() + { + auto hist = Histogram({ { 50, 50 } }); + + ASSERT_EQ(hist.bins(), 2); + ASSERT_EQ(hist.total(), 100); + + ASSERT_EQ(hist.cumulativeFrequency(1.0), 50); + ASSERT_EQ(hist.cumulativeFrequency(1.5), 75); + ASSERT_EQ(hist.cumulativeFrequency(2.0), 100); + + ASSERT_EQ(hist.quantile(0.0), 0.0); + ASSERT_EQ(hist.quantile(1.0), 2.0); + ASSERT_EQ(hist.quantile(0.5), 1.0); + + ASSERT_EQ(hist.interQuantileMean(0.0, 1.0), 1.0); + ASSERT_EQ(hist.interQuantileMean(0.0, 0.5), 0.5); + ASSERT_EQ(hist.interQuantileMean(0.5, 1.0), 1.5); + + return TestPass; + } +}; + +TEST_REGISTER(HistogramTest) diff --git a/test/ipa/libipa/meson.build b/test/ipa/libipa/meson.build index eaf4b49a187c..f094c1593f1b 100644 --- a/test/ipa/libipa/meson.build +++ b/test/ipa/libipa/meson.build @@ -2,6 +2,7 @@ libipa_test = [ {'name': 'fixedpoint', 'sources': ['fixedpoint.cpp']}, + {'name': 'histogram', 'sources': ['histogram.cpp']}, {'name': 'interpolator', 'sources': ['interpolator.cpp']}, ]