From 303ed722447205aa76938dd42d33ebae60b992ac Mon Sep 17 00:00:00 2001 From: Anthony Tarbinian Date: Sun, 23 Jun 2024 19:57:25 +0000 Subject: [PATCH] lint --- include/camera/mock.hpp | 2 +- include/cv/aggregator.hpp | 2 +- include/ticks/mission_prep.hpp | 4 +++- src/camera/mock.cpp | 10 +++++----- src/cv/aggregator.cpp | 3 ++- src/cv/saliency.cpp | 12 ++++++------ src/ticks/cv_loiter.cpp | 4 ++-- src/ticks/mission_prep.cpp | 14 +++++++------- src/utilities/datatypes.cpp | 4 ++-- 9 files changed, 29 insertions(+), 26 deletions(-) diff --git a/include/camera/mock.hpp b/include/camera/mock.hpp index feb97742..ef97ed27 100644 --- a/include/camera/mock.hpp +++ b/include/camera/mock.hpp @@ -64,7 +64,7 @@ class MockCamera : public CameraInterface { std::thread captureThread; // Get telemetry from JSON file adjacent to given image file. - // Ex: given path to "0003.jpg", telemetry will be looked for in + // Ex: given path to "0003.jpg", telemetry will be looked for in // "0003.json" std::optional getTelemetryFromJsonFile(std::filesystem::path img_path); }; diff --git a/include/cv/aggregator.hpp b/include/cv/aggregator.hpp index af6533cf..ce71aca5 100644 --- a/include/cv/aggregator.hpp +++ b/include/cv/aggregator.hpp @@ -16,7 +16,7 @@ struct CVResults { std::vector detected_targets; - // mapping from bottle -> index into detected_targets + // mapping from bottle -> index into detected_targets // (optional is none if we don't have a match yet) std::unordered_map> matches; }; diff --git a/include/ticks/mission_prep.hpp b/include/ticks/mission_prep.hpp index 17bd34b4..047f85bb 100644 --- a/include/ticks/mission_prep.hpp +++ b/include/ticks/mission_prep.hpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include "ticks/tick.hpp" #include "cv/pipeline.hpp" @@ -25,7 +27,7 @@ class MissionPrepTick : public Tick { Tick* tick() override; private: - std::vector> + std::vector> generateReferenceImages(std::array competitionObjectives); std::string getNotStolenRoute(const Bottle& target); diff --git a/src/camera/mock.cpp b/src/camera/mock.cpp index e396d17c..a125377d 100644 --- a/src/camera/mock.cpp +++ b/src/camera/mock.cpp @@ -22,13 +22,13 @@ MockCamera::MockCamera(CameraConfig config) : CameraInterface(config) { cv::Mat img = cv::imread(dir_entry.path().string()); // if the image is read if (img.data != NULL) { - std::optional telemetry = this->getTelemetryFromJsonFile(dir_entry.path()); + std::optional telemetry = + this->getTelemetryFromJsonFile(dir_entry.path()); ImageData img_data( img, 0, - telemetry - ); + telemetry); this->mock_images.push_back(img_data); } }); @@ -126,7 +126,7 @@ std::optional MockCamera::getTelemetryFromJsonFile(std::filesyst if (!telemetry_stream.is_open()) { // no corresponding telemetry json found return {}; - } + } nlohmann::json json = nlohmann::json::parse(telemetry_stream, nullptr, true, true); return ImageTelemetry { .latitude_deg = json["latitude_deg"], @@ -138,4 +138,4 @@ std::optional MockCamera::getTelemetryFromJsonFile(std::filesyst .pitch_deg = json["pitch_deg"], .roll_deg = json["roll_deg"], }; -} \ No newline at end of file +} diff --git a/src/cv/aggregator.cpp b/src/cv/aggregator.cpp index 32763542..88f4a6d2 100644 --- a/src/cv/aggregator.cpp +++ b/src/cv/aggregator.cpp @@ -51,7 +51,8 @@ void CVAggregator::worker(ImageData image, int thread_num) { // newly inserted target, once we insert it after the if/else size_t detected_target_index = this->results->detected_targets.size(); - std::optional curr_match_idx = this->results->matches[curr_target.likely_bottle]; + std::optional curr_match_idx = + this->results->matches[curr_target.likely_bottle]; if (!curr_match_idx.has_value()) { LOG_F(INFO, "Made first match between target %ld and bottle %d", detected_target_index, curr_target.likely_bottle); diff --git a/src/cv/saliency.cpp b/src/cv/saliency.cpp index 25e6aa6e..3d6f9c32 100644 --- a/src/cv/saliency.cpp +++ b/src/cv/saliency.cpp @@ -35,7 +35,7 @@ std::vector Saliency::salience(cv::Mat image) { tensor = tensor.toType(c10::kFloat).div(255); // swap axis tensor = Saliency::transpose(tensor, { (2), (0), (1) }); - + // eventually add device as member of Saliency c10::Device device = torch::cuda::is_available() ? torch::kCUDA : torch::kCPU; auto tensor_cuda = tensor.to(device); @@ -61,12 +61,12 @@ std::vector Saliency::salience(cv::Mat image) { targets = extractTargets(listDetections, image); LOG_F(INFO, "saliency found %ld targets", targets.size()); - for (auto const& target: targets) { - LOG_F(INFO, "\ttarget at bbox: (%d, %d, %d, %d). ismannikin: %d", - target.bbox.x1, + for (auto const& target : targets) { + LOG_F(INFO, "\ttarget at bbox: (%d, %d, %d, %d). ismannikin: %d", + target.bbox.x1, target.bbox.y1, - target.bbox.x2, - target.bbox.y2, + target.bbox.x2, + target.bbox.y2, target.isMannikin); } return targets; diff --git a/src/ticks/cv_loiter.cpp b/src/ticks/cv_loiter.cpp index 2750052a..baa5cf41 100644 --- a/src/ticks/cv_loiter.cpp +++ b/src/ticks/cv_loiter.cpp @@ -23,12 +23,12 @@ void CVLoiterTick::setStatus(Status status) { Tick* CVLoiterTick::tick() { // Tick is called if Search Zone coverage path is finished - + // // print out current state of matching for debugging // LockPtr cv_results = this->state->getCV()->getResults(); // for (const auto& match: cv_results.data->matches) { // if (match.second.has_value()) { - // LOG_F(INFO, "Bottle %d is matched with target at lat: %f, lon: %f", + // LOG_F(INFO, "Bottle %d is matched with target at lat: %f, lon: %f", // match.first, // cv_results.data->detected_targets.at(match.second.value()).coord.latitude(), // cv_results.data->detected_targets.at(match.second.value()).coord.longitude() diff --git a/src/ticks/mission_prep.cpp b/src/ticks/mission_prep.cpp index 954595e5..e17a35d6 100644 --- a/src/ticks/mission_prep.cpp +++ b/src/ticks/mission_prep.cpp @@ -55,9 +55,8 @@ Tick* MissionPrepTick::tick() { } -std::vector> - MissionPrepTick::generateReferenceImages(std::array competitionObjectives) { - +std::vector> MissionPrepTick::generateReferenceImages + (std::array competitionObjectives) { std::vector> ref_imgs; int curr_bottle_idx = BottleDropIndex::Undefined; @@ -70,7 +69,8 @@ std::vector> continue; } - httplib::Client client(this->state->config.cv.not_stolen_addr, this->state->config.cv.not_stolen_port); + httplib::Client client(this->state->config.cv.not_stolen_addr, + this->state->config.cv.not_stolen_port); auto res = client.Get(this->getNotStolenRoute(bottle)); // connection failed if (!res) { @@ -85,9 +85,9 @@ std::vector> LOG_F(ERROR, "Got invalid response from not-stolen: %s", res->body.c_str()); continue; } - std::vector vectordata(res->body.begin(),res->body.end()); + std::vector vectordata(res->body.begin(), res->body.end()); cv::Mat data_mat(vectordata, true); - cv::Mat ref_img(cv::imdecode(data_mat,1)); //put 0 if you want greyscale + cv::Mat ref_img(cv::imdecode(data_mat, 1)); // put 0 if you want greyscale ref_imgs.push_back({ref_img, (BottleDropIndex)curr_bottle_idx}); } @@ -101,7 +101,7 @@ std::string MissionPrepTick::getNotStolenRoute(const Bottle& target) { std::string shape_type = ODLCShapeToString(target.shape()); std::string shape_color = ODLCColorToString(target.shapecolor()); - return std::string("/generate?shape_type=") + shape_type + + return std::string("/generate?shape_type=") + shape_type + std::string("&shape_color=") + shape_color + std::string("&char_type=") + char_type + std::string("&char_color=") + char_color; diff --git a/src/utilities/datatypes.cpp b/src/utilities/datatypes.cpp index d86d70f4..b8ce733b 100644 --- a/src/utilities/datatypes.cpp +++ b/src/utilities/datatypes.cpp @@ -126,7 +126,7 @@ std::string ODLCColorToString(const ODLCColor& color) { case ODLCColor::Brown: return "BROWN"; case ODLCColor::Orange: return "ORANGE"; // maybe return optional nullopt here instead of defaulting to WHITE - // in case of an unknown color + // in case of an unknown color default: return "WHITE"; } -} \ No newline at end of file +}