nebgnahz / cv-rs

Rust wrapper for OpenCV (manual at this point)
https://nebgnahz.github.io/cv-rs/cv/
MIT License
204 stars 41 forks source link

Added Wrappers for Sobel and Scharr Image Gradients #121

Closed geoeo closed 5 years ago

geoeo commented 5 years ago

Added wrapper calls and an example.

https://docs.opencv.org/3.0-beta/modules/imgproc/doc/filtering.html

geoeo commented 5 years ago

No clue how to make formatting acceptable for Travis. I installed clang-format and running the hook script. Or do I have to run a specific clang-format command?

vadixidav commented 5 years ago

@geoeo You need to make sure clang format is using the configuration file at the root of the repository.

geoeo commented 5 years ago

@vadixidav I did. But there seems to be a problem with the new file I added in the example folder. All tests pass, but the diff command fails? Its probably not expecting a new file

Pzixel commented 5 years ago

Just look at travis output

0.08s$ diff -u <(cat native/*) <(clang-format native/*)
cat: native/cuda: Is a directory
Is a directory
--- /dev/fd/63  2019-03-12 11:24:28.369862853 +0000
+++ /dev/fd/62  2019-03-12 11:24:28.361862846 +0000
@@ -699,7 +699,8 @@
         [first_image, second_image, method]() { return cv::compareHist(*first_image, *second_image, method); });
 }

-void cv_sobel(cv::Mat* src, cv::Mat* dst, int ddepth, int dx, int dy, int k_size, double scale, double delta, int borderType) {
+void cv_sobel(
+    cv::Mat* src, cv::Mat* dst, int ddepth, int dx, int dy, int k_size, double scale, double delta, int borderType) {
     cv::Sobel(*src, *dst, ddepth, dx, dy, k_size, scale, delta, borderType);
 }

@@ -760,14 +761,13 @@
                           cv::Mat* back_project,
                           const float** ranges);
 void cv_compare_hist(cv::Mat* first_image, cv::Mat* second_image, int method, Result<double>* result);
-void cv_sobel(cv::Mat* src, cv::Mat* dst, int ddepth, int dx, int dy, int k_size, double scale, double delta, int borderType);
+void cv_sobel(
+    cv::Mat* src, cv::Mat* dst, int ddepth, int dx, int dy, int k_size, double scale, double delta, int borderType);
 void cv_scharr(cv::Mat* src, cv::Mat* dst, int ddepth, int dx, int dy, double scale, double delta, int borderType);
 EmptyResult
 cv_canny(cv::Mat* image, cv::Mat* edges, double threshold1, double threshold2, int aperture_size, bool l2_gradient);
 }

-
-
 #endif  // CV_RS_IMGPROC_H
 #include "mat.h"

The command "diff -u <(cat native/*) <(clang-format native/*)" exited with 1.
geoeo commented 5 years ago

@Pzixel Which tells me? Ive never done this before. If you guys want me to do something then just tell me.

Pzixel commented 5 years ago

It tells that for example repo contains this code

void cv_sobel(cv::Mat* src, cv::Mat* dst, int ddepth, int dx, int dy, int k_size, double scale, double delta, int borderType) {
    cv::Sobel(*src, *dst, ddepth, dx, dy, k_size, scale, delta, borderType);
}

should be (according to clang-format)

void cv_sobel(
    cv::Mat* src, cv::Mat* dst, int ddepth, int dx, int dy, int k_size, double scale, double delta, int borderType) {
    cv::Sobel(*src, *dst, ddepth, dx, dy, k_size, scale, delta, borderType);
}

You aren't expected to manually fix formatting issues, they all should be done automatically. If you get different results you either don't use proper config or probably use different clang-format version.

geoeo commented 5 years ago

Hope its good now. Since I did my first commit without running .sh script the tracking got messed up.

Pzixel commented 5 years ago

Great work!