[libcamera-devel] [PATCH 04/17] DNI: ipa: raspberrypi: Code refactoring to match style guidelines
Naushir Patuck
naush at raspberrypi.com
Tue Jul 26 14:45:36 CEST 2022
Refactor the source files under src/ipa/raspberrypi/controller/c* to match the
recommended formatting guidelines for the libcamera project. The vast majority
of changes in this commit comprise of switching from snake_case to CamelCase,
and starting class member functions with a lower case character.
Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
src/ipa/raspberrypi/controller/camera_mode.h | 16 ++--
.../raspberrypi/controller/ccm_algorithm.hpp | 2 +-
.../controller/contrast_algorithm.hpp | 4 +-
src/ipa/raspberrypi/controller/controller.cpp | 74 ++++++++++---------
src/ipa/raspberrypi/controller/controller.hpp | 22 +++---
5 files changed, 60 insertions(+), 58 deletions(-)
diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h
index e2b82828d4b6..8b81ca9df725 100644
--- a/src/ipa/raspberrypi/controller/camera_mode.h
+++ b/src/ipa/raspberrypi/controller/camera_mode.h
@@ -26,21 +26,21 @@ struct CameraMode {
// size in pixels of frames in this mode
uint16_t width, height;
// size of full resolution uncropped frame ("sensor frame")
- uint16_t sensor_width, sensor_height;
+ uint16_t sensorWidth, sensorHeight;
// binning factor (1 = no binning, 2 = 2-pixel binning etc.)
- uint8_t bin_x, bin_y;
+ uint8_t binX, binY;
// location of top left pixel in the sensor frame
- uint16_t crop_x, crop_y;
- // scaling factor (so if uncropped, width*scale_x is sensor_width)
- double scale_x, scale_y;
+ uint16_t cropX, cropY;
+ // scaling factor (so if uncropped, width*scaleX is sensorWidth)
+ double scaleX, scaleY;
// scaling of the noise compared to the native sensor mode
- double noise_factor;
+ double noiseFactor;
// line time
- libcamera::utils::Duration line_length;
+ libcamera::utils::Duration lineLength;
// any camera transform *not* reflected already in the camera tuning
libcamera::Transform transform;
// minimum and maximum fame lengths in units of lines
- uint32_t min_frame_length, max_frame_length;
+ uint32_t minFrameLength, maxFrameLength;
// sensitivity of this mode
double sensitivity;
};
diff --git a/src/ipa/raspberrypi/controller/ccm_algorithm.hpp b/src/ipa/raspberrypi/controller/ccm_algorithm.hpp
index 33d0e30dc856..b8b5879ba99c 100644
--- a/src/ipa/raspberrypi/controller/ccm_algorithm.hpp
+++ b/src/ipa/raspberrypi/controller/ccm_algorithm.hpp
@@ -15,7 +15,7 @@ class CcmAlgorithm : public Algorithm
public:
CcmAlgorithm(Controller *controller) : Algorithm(controller) {}
// A CCM algorithm must provide the following:
- virtual void SetSaturation(double saturation) = 0;
+ virtual void setSaturation(double saturation) = 0;
};
} // namespace RPiController
diff --git a/src/ipa/raspberrypi/controller/contrast_algorithm.hpp b/src/ipa/raspberrypi/controller/contrast_algorithm.hpp
index 7f03bba52844..c76f3cd759ba 100644
--- a/src/ipa/raspberrypi/controller/contrast_algorithm.hpp
+++ b/src/ipa/raspberrypi/controller/contrast_algorithm.hpp
@@ -15,8 +15,8 @@ class ContrastAlgorithm : public Algorithm
public:
ContrastAlgorithm(Controller *controller) : Algorithm(controller) {}
// A contrast algorithm must provide the following:
- virtual void SetBrightness(double brightness) = 0;
- virtual void SetContrast(double contrast) = 0;
+ virtual void setBrightness(double brightness) = 0;
+ virtual void setContrast(double contrast) = 0;
};
} // namespace RPiController
diff --git a/src/ipa/raspberrypi/controller/controller.cpp b/src/ipa/raspberrypi/controller/controller.cpp
index d3433ad2e7e8..e0b152c74384 100644
--- a/src/ipa/raspberrypi/controller/controller.cpp
+++ b/src/ipa/raspberrypi/controller/controller.cpp
@@ -19,85 +19,87 @@ using namespace libcamera;
LOG_DEFINE_CATEGORY(RPiController)
Controller::Controller()
- : switch_mode_called_(false) {}
+ : switchModeCalled_(false)
+{
+}
-Controller::Controller(char const *json_filename)
- : switch_mode_called_(false)
+Controller::Controller(char const *jsonFilename)
+ : switchModeCalled_(false)
{
- Read(json_filename);
- Initialise();
+ read(jsonFilename);
+ initialise();
}
Controller::~Controller() {}
-void Controller::Read(char const *filename)
+void Controller::read(char const *filename)
{
boost::property_tree::ptree root;
boost::property_tree::read_json(filename, root);
- for (auto const &key_and_value : root) {
- Algorithm *algo = CreateAlgorithm(key_and_value.first.c_str());
+ for (auto const &keyAndValue : root) {
+ Algorithm *algo = createAlgorithm(keyAndValue.first.c_str());
if (algo) {
- algo->Read(key_and_value.second);
+ algo->read(keyAndValue.second);
algorithms_.push_back(AlgorithmPtr(algo));
} else
LOG(RPiController, Warning)
- << "No algorithm found for \"" << key_and_value.first << "\"";
+ << "No algorithm found for \"" << keyAndValue.first << "\"";
}
}
-Algorithm *Controller::CreateAlgorithm(char const *name)
+Algorithm *Controller::createAlgorithm(char const *name)
{
- auto it = GetAlgorithms().find(std::string(name));
- return it != GetAlgorithms().end() ? (*it->second)(this) : nullptr;
+ auto it = getAlgorithms().find(std::string(name));
+ return it != getAlgorithms().end() ? (*it->second)(this) : nullptr;
}
-void Controller::Initialise()
+void Controller::initialise()
{
for (auto &algo : algorithms_)
- algo->Initialise();
+ algo->initialise();
}
-void Controller::SwitchMode(CameraMode const &camera_mode, Metadata *metadata)
+void Controller::switchMode(CameraMode const &cameraMode, Metadata *metadata)
{
for (auto &algo : algorithms_)
- algo->SwitchMode(camera_mode, metadata);
- switch_mode_called_ = true;
+ algo->switchMode(cameraMode, metadata);
+ switchModeCalled_ = true;
}
-void Controller::Prepare(Metadata *image_metadata)
+void Controller::prepare(Metadata *imageMetadata)
{
- assert(switch_mode_called_);
+ assert(switchModeCalled_);
for (auto &algo : algorithms_)
- if (!algo->IsPaused())
- algo->Prepare(image_metadata);
+ if (!algo->isPaused())
+ algo->prepare(imageMetadata);
}
-void Controller::Process(StatisticsPtr stats, Metadata *image_metadata)
+void Controller::process(StatisticsPtr stats, Metadata *imageMetadata)
{
- assert(switch_mode_called_);
+ assert(switchModeCalled_);
for (auto &algo : algorithms_)
- if (!algo->IsPaused())
- algo->Process(stats, image_metadata);
+ if (!algo->isPaused())
+ algo->process(stats, imageMetadata);
}
-Metadata &Controller::GetGlobalMetadata()
+Metadata &Controller::getGlobalMetadata()
{
- return global_metadata_;
+ return globalMetadata_;
}
-Algorithm *Controller::GetAlgorithm(std::string const &name) const
+Algorithm *Controller::getAlgorithm(std::string const &name) const
{
// The passed name must be the entire algorithm name, or must match the
// last part of it with a period (.) just before.
- size_t name_len = name.length();
+ size_t nameLen = name.length();
for (auto &algo : algorithms_) {
- char const *algo_name = algo->Name();
- size_t algo_name_len = strlen(algo_name);
- if (algo_name_len >= name_len &&
+ char const *algoName = algo->name();
+ size_t algoNameLen = strlen(algoName);
+ if (algoNameLen >= nameLen &&
strcasecmp(name.c_str(),
- algo_name + algo_name_len - name_len) == 0 &&
- (name_len == algo_name_len ||
- algo_name[algo_name_len - name_len - 1] == '.'))
+ algoName + algoNameLen - nameLen) == 0 &&
+ (nameLen == algoNameLen ||
+ algoName[algoNameLen - nameLen - 1] == '.'))
return algo.get();
}
return nullptr;
diff --git a/src/ipa/raspberrypi/controller/controller.hpp b/src/ipa/raspberrypi/controller/controller.hpp
index 3b50ae770d11..a5e1eb38ab9d 100644
--- a/src/ipa/raspberrypi/controller/controller.hpp
+++ b/src/ipa/raspberrypi/controller/controller.hpp
@@ -34,21 +34,21 @@ class Controller
{
public:
Controller();
- Controller(char const *json_filename);
+ Controller(char const *jsonFilename);
~Controller();
- Algorithm *CreateAlgorithm(char const *name);
- void Read(char const *filename);
- void Initialise();
- void SwitchMode(CameraMode const &camera_mode, Metadata *metadata);
- void Prepare(Metadata *image_metadata);
- void Process(StatisticsPtr stats, Metadata *image_metadata);
- Metadata &GetGlobalMetadata();
- Algorithm *GetAlgorithm(std::string const &name) const;
+ Algorithm *createAlgorithm(char const *name);
+ void read(char const *filename);
+ void initialise();
+ void switchMode(CameraMode const &cameraMode, Metadata *metadata);
+ void prepare(Metadata *imageMetadata);
+ void process(StatisticsPtr stats, Metadata *imageMetadata);
+ Metadata &getGlobalMetadata();
+ Algorithm *getAlgorithm(std::string const &name) const;
protected:
- Metadata global_metadata_;
+ Metadata globalMetadata_;
std::vector<AlgorithmPtr> algorithms_;
- bool switch_mode_called_;
+ bool switchModeCalled_;
};
} // namespace RPiController
--
2.25.1
More information about the libcamera-devel
mailing list