[PATCH v2 2/3] test: ipa: libipa: Add CameraSensorHelper Gain Model tests
Paul Elder
paul.elder at ideasonboard.com
Wed Mar 26 09:00:32 CET 2025
From: Kieran Bingham <kieran.bingham at ideasonboard.com>
Introduce a test that validates conversion of the gain model
in each CameraSensorHelper.
It should be expected that if a gainCode produces a given gain
value, then converting that gain back should produce the same
result.
This test fails on the following CameraSensorHelpers:
- imx219 imx258 imx283 imx290 imx296 imx327 imx335 imx477
Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
---
Discussion points:
- Should we duplicate the min/max gain values for all the sensors in the
CameraSensorHelpers? (instead of using 0~240 that comes from the
imx283) Is it fine to duplicate it anyway because we're already
duplicating a lot of other sensor propery values?
- Should we restrict the test to a specific set of sensors so that we
don't have to deal with breaking tests from, for example, sensors that
use gains of different Q formats or non-continuous ranges etc? Or
should we test everything and diligently fix the test for every new
sensor so that we're sure that nothing breaks?
Changes in v2:
- recover from bitrot
---
test/ipa/camera_sensor_helper.cpp | 69 +++++++++++++++++++++++++++++++
test/ipa/meson.build | 1 +
2 files changed, 70 insertions(+)
create mode 100644 test/ipa/camera_sensor_helper.cpp
diff --git a/test/ipa/camera_sensor_helper.cpp b/test/ipa/camera_sensor_helper.cpp
new file mode 100644
index 000000000000..2d37628f87c4
--- /dev/null
+++ b/test/ipa/camera_sensor_helper.cpp
@@ -0,0 +1,69 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2024, Ideas on Board Oy.
+ */
+
+#include "libipa/camera_sensor_helper.h"
+
+#include <iostream>
+#include <string.h>
+
+#include "test.h"
+
+using namespace std;
+using namespace libcamera;
+using namespace libcamera::ipa;
+
+class CameraSensorHelperTest : public Test
+{
+protected:
+ int testGainModel(std::string model)
+ {
+ int ret = TestPass;
+
+ std::unique_ptr<CameraSensorHelper> camHelper_;
+
+ camHelper_ = CameraSensorHelperFactoryBase::create(model);
+ if (!camHelper_) {
+ std::cout
+ << "Failed to create camera sensor helper for "
+ << model;
+ return TestFail;
+ }
+
+ for (unsigned int i = 0; i < 240; i++) {
+ float gain = camHelper_->gain(i);
+ uint32_t gainCode = camHelper_->gainCode(gain);
+
+ if (i != gainCode) {
+ std::cout << model << ": Gain conversions failed: "
+ << i << " : " << gain << " : "
+ << gainCode << std::endl;
+
+ ret = TestFail;
+ }
+ };
+
+ return ret;
+ }
+
+ int run() override
+ {
+ unsigned int failures = 0;
+
+ std::vector<CameraSensorHelperFactoryBase *> factories;
+
+ for (auto factory : CameraSensorHelperFactoryBase::factories()) {
+ const std::string &model = factory->name();
+
+ cout << "Testing CameraSensorHelper for " << model << endl;
+
+ if (testGainModel(factory->name()) == TestFail)
+ failures++;
+ }
+
+ return failures ? TestFail : TestPass;
+ }
+};
+
+TEST_REGISTER(CameraSensorHelperTest)
diff --git a/test/ipa/meson.build b/test/ipa/meson.build
index ceed15ba660a..98aff58b8a1a 100644
--- a/test/ipa/meson.build
+++ b/test/ipa/meson.build
@@ -3,6 +3,7 @@
subdir('libipa')
ipa_test = [
+ {'name': 'camera_sensor_helper', 'sources': ['camera_sensor_helper.cpp']},
{'name': 'ipa_module_test', 'sources': ['ipa_module_test.cpp']},
{'name': 'ipa_interface_test', 'sources': ['ipa_interface_test.cpp']},
]
--
2.47.2
More information about the libcamera-devel
mailing list