diff --git a/README.md b/README.md index 572cdb36..6cdeaf92 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,27 @@ To get your environment setup with it, follow these steps: --- +### Manage and execute filterchains with bags from telemetry +- Run the dockers for ros-master, ros-bridge and octopus-telemetry (only on linux for now) +- Make sure proc_image_processing is launch. + (in VScode `ctrl+shift+p` + `ROS: Show Core Status` to see services) +- In the proc_image_processing docker, go in the folder /bags where you put the bag(s) to run +- Execute `rosbag play -l ` +- Execute in another terminal in the docker + `rosrun image_transport republish compressed in:= raw out:=` + to uncompress the feed + (the input feed name can be check in the _Image Viewer_ module of the telemetry by refreshing and looking at the dropdown menu) +- Open a web browser on `localhost:3000` to access the telemetry +- In the _Image Viewer_ module, refresh and select the compressed feed of the bag to see it (wow) +- In the _Vision UI_ module, create a new execution by refreshing and selecting the filterchain to apply + and the media as input (the raw video feed in this case) +- In the _filter_ tab of the _Vision UI_ module, refresh and select your execution to manage filters oyour + filterchain +- Click on them to see the parameters and adjust them, etc +- To see the result, in the _Image Viewer_ module, refresh and select the output of the executiocompressed + +--- + ## Code Quality This project uses [SonarCloud](https://sonarcloud.io/) to analyze the code base quality continuously using a GitHub diff --git a/config/filterchain/deep_bat_wolf.yaml b/config/filterchain/deep_bat_wolf.yaml index 86d30809..4b769513 100644 --- a/config/filterchain/deep_bat_wolf.yaml +++ b/config/filterchain/deep_bat_wolf.yaml @@ -6,17 +6,17 @@ filters: value: 1 - name: Debug contour value: 1 - - name: bat + - name: Bat value: 1 - - name: wolf + - name: Wolf value: 1 - - name: vetalas + - name: Vetalas value: 0 - - name: draugr + - name: Draugr value: 0 - - name: jiangshi + - name: Jiangshi value: 0 - - name: answag + - name: Answag value: 0 - - name: vampire + - name: Vampire value: 0 diff --git a/config/filterchain/deep_draugr.yaml b/config/filterchain/deep_draugr.yaml index 5e1b568a..80a13d6e 100644 --- a/config/filterchain/deep_draugr.yaml +++ b/config/filterchain/deep_draugr.yaml @@ -6,17 +6,17 @@ filters: value: 1 - name: Debug contour value: 1 - - name: bat + - name: Bat value: 0 - - name: wolf + - name: Wolf value: 0 - - name: vetalas + - name: Vetalas value: 0 - - name: draugr + - name: Draugr value: 1 - - name: jiangshi + - name: Jiangshi value: 0 - - name: answag + - name: Answag value: 0 - - name: vampire + - name: Vampire value: 0 diff --git a/config/filterchain/deep_front.yaml b/config/filterchain/deep_front.yaml index 81773507..2b0b6a74 100644 --- a/config/filterchain/deep_front.yaml +++ b/config/filterchain/deep_front.yaml @@ -6,23 +6,23 @@ filters: value: 0 - name: Debug contour value: 1 - - name: vetalas + - name: Vetalas value: 0 - - name: draugr + - name: Draugr value: 0 - - name: jiangshi + - name: Jiangshi value: 1 - - name: answag + - name: Answag value: 0 - - name: vampire + - name: Vampire value: 0 - - name: bat + - name: Bat value: 0 - - name: wolf + - name: Wolf value: 0 - name: SubtractAllPlanesFilter parameters: - - name: enable + - name: Enable value: 1 - name: Plane_1 value: 5 diff --git a/config/filterchain/deep_jiangshi.yaml b/config/filterchain/deep_jiangshi.yaml index f1545f8d..95ace09e 100644 --- a/config/filterchain/deep_jiangshi.yaml +++ b/config/filterchain/deep_jiangshi.yaml @@ -6,17 +6,17 @@ filters: value: 1 - name: Debug contour value: 1 - - name: bat + - name: Bat value: 0 - - name: wolf + - name: Wolf value: 0 - - name: vetalas + - name: Vetalas value: 0 - - name: draugr + - name: Draugr value: 0 - - name: jiangshi + - name: Jiangshi value: 1 - - name: answag + - name: Answag value: 0 - - name: vampire + - name: Vampire value: 0 diff --git a/config/filterchain/deep_vampire.yaml b/config/filterchain/deep_vampire.yaml index ecf01f76..fb85d1bd 100644 --- a/config/filterchain/deep_vampire.yaml +++ b/config/filterchain/deep_vampire.yaml @@ -6,17 +6,17 @@ filters: value: 1 - name: Debug contour value: 1 - - name: bat + - name: Bat value: 0 - - name: wolf + - name: Wolf value: 0 - - name: vetalas + - name: Vetalas value: 0 - - name: draugr + - name: Draugr value: 0 - - name: jiangshi + - name: Jiangshi value: 0 - - name: answag + - name: Answag value: 0 - - name: vampire + - name: Vampire value: 1 diff --git a/config/filterchain/deep_vetalas.yaml b/config/filterchain/deep_vetalas.yaml index a4fba262..2948fd8b 100644 --- a/config/filterchain/deep_vetalas.yaml +++ b/config/filterchain/deep_vetalas.yaml @@ -6,17 +6,17 @@ filters: value: 1 - name: Debug contour value: 1 - - name: bat + - name: Bat value: 0 - - name: wolf + - name: Wolf value: 0 - - name: vetalas + - name: Vetalas value: 1 - - name: draugr + - name: Draugr value: 0 - - name: jiangshi + - name: Jiangshi value: 0 - - name: answag + - name: Answag value: 0 - - name: vampire + - name: Vampire value: 0 diff --git a/config/filterchain/simple_align_test.yaml b/config/filterchain/simple_align_test.yaml index e8ecf49e..dadf5004 100644 --- a/config/filterchain/simple_align_test.yaml +++ b/config/filterchain/simple_align_test.yaml @@ -2,7 +2,7 @@ name: simple_align_test filters: - name: SubtractAllPlanesFilter parameters: - - name: enable + - name: Enable value: 1 - name: Plane_1 value: 5 diff --git a/config/filterchain/simple_bin_handle.yaml b/config/filterchain/simple_bin_handle.yaml index 4f84b025..89a80886 100644 --- a/config/filterchain/simple_bin_handle.yaml +++ b/config/filterchain/simple_bin_handle.yaml @@ -14,7 +14,7 @@ filters: value: 0 - name: SubtractAllPlanesFilter parameters: - - name: enable + - name: Enable value: 1 - name: Plane_1 value: 4 diff --git a/config/filterchain/simple_body_baby.yaml b/config/filterchain/simple_body_baby.yaml index fe38b56d..f321e38b 100644 --- a/config/filterchain/simple_body_baby.yaml +++ b/config/filterchain/simple_body_baby.yaml @@ -14,7 +14,7 @@ filters: value: 0 - name: SubtractAllPlanesFilter parameters: - - name: enable + - name: Enable value: 1 - name: Plane_1 value: 6 diff --git a/config/filterchain/simple_coffin_handle.yaml b/config/filterchain/simple_coffin_handle.yaml index ac3f5bc4..208d7ca4 100644 --- a/config/filterchain/simple_coffin_handle.yaml +++ b/config/filterchain/simple_coffin_handle.yaml @@ -14,7 +14,7 @@ filters: value: 0 - name: SubtractAllPlanesFilter parameters: - - name: enable + - name: Enable value: 1 - name: Plane_1 value: 2 diff --git a/config/filterchain/simple_jiangshi_backup.yaml b/config/filterchain/simple_jiangshi_backup.yaml index 8b175eb1..0b91ceed 100644 --- a/config/filterchain/simple_jiangshi_backup.yaml +++ b/config/filterchain/simple_jiangshi_backup.yaml @@ -2,7 +2,7 @@ name: simple_jiangshi_backup filters: - name: SubtractAllPlanesFilter parameters: - - name: enable + - name: Enable value: 1 - name: Plane_1 value: 7 diff --git a/config/filterchain/simple_pipe45.yaml b/config/filterchain/simple_pipe45.yaml index 707ca6e1..8a011d6d 100644 --- a/config/filterchain/simple_pipe45.yaml +++ b/config/filterchain/simple_pipe45.yaml @@ -2,9 +2,9 @@ name: simple_pipe45 filters: - name: RotateFilter parameters: - - name: enable + - name: Enable value: 0 - - name: transpose + - name: Transpose value: 0 - name: Rotation_type value: 3 @@ -22,7 +22,7 @@ filters: value: 17 - name: ContrastAndBrightnessFilter parameters: - - name: enable + - name: Enable value: 0 - name: Contrast value: 1.400000 @@ -30,7 +30,7 @@ filters: value: -134.000000 - name: SubtractAllPlanesFilter parameters: - - name: enable + - name: Enable value: 1 - name: Plane_1 value: 3 diff --git a/config/filterchain/simple_test_octogone.yaml b/config/filterchain/simple_test_octogone.yaml index c9954d61..fd90efd2 100644 --- a/config/filterchain/simple_test_octogone.yaml +++ b/config/filterchain/simple_test_octogone.yaml @@ -14,7 +14,7 @@ filters: value: 0 - name: SubtractAllPlanesFilter parameters: - - name: enable + - name: Enable value: 1 - name: Plane_1 value: 3 diff --git a/config/filterchain/simple_vampire_torpille.yaml b/config/filterchain/simple_vampire_torpille.yaml index 04e588bc..df7a9068 100644 --- a/config/filterchain/simple_vampire_torpille.yaml +++ b/config/filterchain/simple_vampire_torpille.yaml @@ -14,7 +14,7 @@ filters: value: 0 - name: SubtractAllPlanesFilter parameters: - - name: enable + - name: Enable value: 1 - name: Plane_1 value: 2 diff --git a/src/proc_image_processing/cpu/algorithm/parallel_loop_body_wrapper.h b/src/proc_image_processing/cpu/algorithm/parallel_loop_body_wrapper.h new file mode 100644 index 00000000..87566aca --- /dev/null +++ b/src/proc_image_processing/cpu/algorithm/parallel_loop_body_wrapper.h @@ -0,0 +1,22 @@ +#ifndef PROC_IMAGE_PROCESSING_PARALLEL_LOOP_BODY_WRAPPER_H_ +#define PROC_IMAGE_PROCESSING_PARALLEL_LOOP_BODY_WRAPPER_H_ + +#include "opencv2/opencv.hpp" + +namespace proc_image_processing { + + /* + * This class can be derived to create a "body" for the OpenCV parallel_for_() function + */ + class ParallelLoopBodyWrapper : public cv::ParallelLoopBody { + public: + ParallelLoopBodyWrapper() = default; + + ~ParallelLoopBodyWrapper() override = default; + + void operator()(const cv::Range &range) const override = 0; + }; + +} // namespace proc_image_processing + +#endif // PROC_IMAGE_PROCESSING_PARALLEL_LOOP_BODY_WRAPPER_H_ \ No newline at end of file diff --git a/src/proc_image_processing/cpu/filters/custom/deep_2019_filter.h b/src/proc_image_processing/cpu/filters/custom/deep_2019_filter.h index db4b30f2..aee2a874 100644 --- a/src/proc_image_processing/cpu/filters/custom/deep_2019_filter.h +++ b/src/proc_image_processing/cpu/filters/custom/deep_2019_filter.h @@ -20,13 +20,13 @@ namespace proc_image_processing { Filter(globalParams), nh_(ros::NodeHandle("proc_image_processing")), debug_contour_("Debug contour", false, ¶meters_), - vetalas_("vetalas", true, ¶meters_), - draugr_("draugr", true, ¶meters_), - jiangshi_("jiangshi", true, ¶meters_), - answag_("answag", true, ¶meters_), - vampire_("vampire", true, ¶meters_), - bat_("bat", true, ¶meters_), - wolf_("wolf", true, ¶meters_), + vetalas_("Vetalas", true, ¶meters_), + draugr_("Draugr", true, ¶meters_), + jiangshi_("Jiangshi", true, ¶meters_), + answag_("Answag", true, ¶meters_), + vampire_("Vampire", true, ¶meters_), + bat_("Bat", true, ¶meters_), + wolf_("Wolf", true, ¶meters_), color_(0, 0, 0) { image_subscriber_ = ros::NodeHandle("~").subscribe("/deep_detector/bounding_box", 100, &Deep2019Filter::callbackBoundingBox, this); diff --git a/src/proc_image_processing/cpu/filters/detectors/vampire_torpedoes_close_detector.h b/src/proc_image_processing/cpu/filters/detectors/vampire_torpedoes_close_detector.h index 6c3a8873..9331bd93 100644 --- a/src/proc_image_processing/cpu/filters/detectors/vampire_torpedoes_close_detector.h +++ b/src/proc_image_processing/cpu/filters/detectors/vampire_torpedoes_close_detector.h @@ -160,7 +160,6 @@ namespace proc_image_processing { Parameter debug_contour_, look_for_ellipse_, look_for_heart_; RangedParameter min_area_, max_area_; - }; } // namespace proc_image_processing diff --git a/src/proc_image_processing/cpu/filters/low_pass/contrast_and_brightness_filter.h b/src/proc_image_processing/cpu/filters/low_pass/contrast_and_brightness_filter.h index 6d8e9761..3dcfee83 100644 --- a/src/proc_image_processing/cpu/filters/low_pass/contrast_and_brightness_filter.h +++ b/src/proc_image_processing/cpu/filters/low_pass/contrast_and_brightness_filter.h @@ -4,11 +4,11 @@ #define PROC_IMAGE_PROCESSING_FILTERS_CONTRAST_BRIGHTNESS_H_ #include +#include #include "proc_image_processing/cpu/filters/filter.h" #include namespace proc_image_processing { - // Filter showing planes of different analysis (gray, _hsi, _bgr) // No threshold class ContrastAndBrightnessFilter : public Filter { @@ -20,38 +20,44 @@ namespace proc_image_processing { contrast_("Contrast", 0, 0, 256, ¶meters_, "Contrast"), brightness_("Brightness", 0, -256, 256, ¶meters_, - "Set Brightness"), - rows_(0), - cols_(0) { + "Set Brightness") { setName("ContrastAndBrightnessFilter"); } ~ContrastAndBrightnessFilter() override = default; void apply(cv::Mat &image) override { - rows_ = image.rows; - cols_ = image.cols; - - // Set result matrices - cv::Mat result = cv::Mat::zeros(rows_, cols_, image.type()); - - // Replace with new images - for (int y = 0; y < image.rows; y++) { - for (int x = 0; x < image.cols; x++) { - for (int c = 0; c < image.channels(); c++) - result.at(y, x)[c] = cv::saturate_cast( - contrast_() * (image.at(y, x)[c]) + brightness_()); + cv::parallel_for_(cv::Range(0, image.rows * image.cols), ParallelCABF(image, contrast_, brightness_)); + } + + private: + class ParallelCABF : public ParallelLoopBodyWrapper { + public: + explicit ParallelCABF(cv::Mat &image, const RangedParameter &contrast, const RangedParameter &brightness) : + image(image), + contrast_(contrast), + brightness_(brightness) {} + + ~ParallelCABF() override = default; + + void operator()(const cv::Range &range) const override { + for (auto r = range.start; r < range.end; r++) { + int y = r / image.cols; + int x = r % image.cols; + + auto& vec = const_cast(image.at(y, x)); + for (auto c = 0; c < image.channels(); c++) { + vec[c] = cv::saturate_cast(contrast_.getValue() * (vec[c]) + brightness_.getValue()); + } } } - result.copyTo(image); - } + private: + cv::Mat image; + RangedParameter contrast_, brightness_; + }; - private: RangedParameter contrast_, brightness_; - // Color matrices - int rows_; - int cols_; }; } // namespace proc_image_processing diff --git a/src/proc_image_processing/cpu/filters/low_pass/white_filter.h b/src/proc_image_processing/cpu/filters/low_pass/white_filter.h index 52b71d00..a81d1806 100644 --- a/src/proc_image_processing/cpu/filters/low_pass/white_filter.h +++ b/src/proc_image_processing/cpu/filters/low_pass/white_filter.h @@ -28,15 +28,12 @@ namespace proc_image_processing { ~WhiteFilter() override = default; void apply(cv::Mat &image) override { - cv::Mat mask; - cv::Scalar min_pixel_range = cv::Scalar(minimal_1pixel_range_(), minimal_2pixel_range_(), minimal_3pixel_range_()); cv::Scalar max_pixel_range = cv::Scalar(maximal_1pixel_range_(), maximal_2pixel_range_(), maximal_3pixel_range_()); - cv::inRange(image, min_pixel_range, max_pixel_range, mask); - mask.copyTo(image); + cv::inRange(image, min_pixel_range, max_pixel_range, image); } private: diff --git a/src/proc_image_processing/cpu/filters/transformations/rotate_filter.h b/src/proc_image_processing/cpu/filters/transformations/rotate_filter.h index c538297c..aee409ed 100644 --- a/src/proc_image_processing/cpu/filters/transformations/rotate_filter.h +++ b/src/proc_image_processing/cpu/filters/transformations/rotate_filter.h @@ -14,7 +14,7 @@ namespace proc_image_processing { explicit RotateFilter(const GlobalParamHandler &globalParams) : Filter(globalParams), - transpose_("transpose", false, ¶meters_), + transpose_("Transpose", false, ¶meters_), rotate_type_("Rotation_type", 0, 0, 3, ¶meters_, "RotateFilter type: 0=NONE, 1=x axis, 2=y axis, 3=all axis") { setName("RotateFilter");