Ask Your Question

Revision history [back]

opencl implementation of canny edge algorithm on java.awt.image.BufferedImage

I need some help understanding the opencl implementation for the canny edge detection algorithm.

I'm trying to compile and run this with jocl, with a java.awt.image.BufferedImage and I've succeeded in getting the kernals compiling. However, when I pass in the array into the kernal, I get no output and the output of the first stage looks like this:

Please let me know what I'm doing wrong and what else I may be able to do.

C:\fakepath\Screen Shot 2018-01-31 at 6.06.18 pm.png

opencl implementation of canny edge algorithm on java.awt.image.BufferedImage

I need some help understanding the opencl implementation for the canny edge detection algorithm.

I'm trying to compile and run this with jocl, with a java.awt.image.BufferedImage and I've succeeded in getting the kernals compiling. However, when I pass in the array into the kernal, I get no output and the output of the first stage looks like this:

Please let me know what I'm doing wrong and what else I may be able to do.

C:\fakepath\Screen Shot 2018-01-31 at 6.06.18 pm.pngC:\fakepath\Screen Shot 2018-01-31 at 6.06.18 pm.png

opencl implementation of canny edge algorithm on java.awt.image.BufferedImage

I need some help understanding the opencl implementation for the canny edge detection algorithm.

I'm trying to compile and run this with jocl, with a java.awt.image.BufferedImage and I've succeeded in getting the kernals compiling. However, when I pass in the array into the kernal, I get no output and the output of the first stage looks like this:

Please let me know what I'm doing wrong and what else I may be able to do.

C:\fakepath\Screen Shot 2018-01-31 at 6.06.18 pm.png

The source code looks something like this. I followed the compilation process for

https://github.com/opencv/opencv/blob/master/modules/imgproc/src/canny.cpp#L227 https://github.com/opencv/opencv/blob/master/modules/imgproc/src/opencl/canny.cl#L119

``` (def canny-stage1 (kernel/load-executive {:name "stage1_with_sobel" :file "opencl/canny.cl" :options "-D WITH_SOBEL -D cn=1 -D TYPE=uchar -D convert_floatN=convert_float -D floatN=float -D GRP_SIZEX=32 -D GRP_SIZEY=8 -D L2GRAD" :worksize (fn [src _ _ _ _ map _ _ _ _] [(.getWidth src) (.getHeight src)]) :arglist [{:type :image :name :src :buffer {:input true} :flags [:read-only]} {:type :int :name :src-step} {:type :int :name :src-offset} {:type :int :name :rows} {:type :int :name :cols} {:type :image :name :map :buffer {:output true} :flags [:write-only]} {:type :int :name :map-step} {:type :int :name :map-offset} {:type :float :name :low-threshold} {:type :float :name :high-threshold}]}))

(def input (javax.imageio.ImageIO/read (io/file "lena-1000x1000.jpg"))

(def buffer (BufferedImage. (.getWidth input) (.getHeight input) BufferedImage/TYPE_BYTE_GRAY))

(let [offset 0 step (.getWidth input) rows (.getHeight input) cols (.getWidth input)] (canny-stage1 input step offset rows cols buffer step offset low-threshold high-threshold))

(display-image buffer)

```

click to hide/show revision 4
None

updated 2018-01-31 11:43:56 -0600

berak gravatar image

opencl implementation of canny edge algorithm on java.awt.image.BufferedImage

I need some help understanding the opencl implementation for the canny edge detection algorithm.

I'm trying to compile and run this with jocl, with a java.awt.image.BufferedImage and I've succeeded in getting the kernals compiling. However, when I pass in the array into the kernal, I get no output and the output of the first stage looks like this:

Please let me know what I'm doing wrong and what else I may be able to do.

C:\fakepath\Screen Shot 2018-01-31 at 6.06.18 pm.png

The source code looks something like this. I followed the compilation process for

https://github.com/opencv/opencv/blob/master/modules/imgproc/src/canny.cpp#L227 https://github.com/opencv/opencv/blob/master/modules/imgproc/src/opencl/canny.cl#L119

```

(def canny-stage1 (kernel/load-executive
                   {:name "stage1_with_sobel"
                    :file "opencl/canny.cl"
                    :options "-D WITH_SOBEL -D cn=1 -D TYPE=uchar -D convert_floatN=convert_float -D floatN=float -D GRP_SIZEX=32 -D GRP_SIZEY=8 -D L2GRAD"
                    :worksize (fn [src _ _ _ _ map _ _ _ _]
                                [(.getWidth  src)
                                 (.getHeight src)])
                    :arglist [{:type :image
                               :name :src
                               :buffer {:input true}
                               :flags [:read-only]}
                              {:type :int
                               :name :src-step}
                              {:type :int
                               :name :src-offset}
                              {:type :int
                               :name :rows}
                              {:type :int
                               :name :cols}
                              {:type :image
                               :name :map
                               :buffer {:output true}
                               :flags [:write-only]}
                              {:type :int
                               :name :map-step}
                              {:type :int
                               :name :map-offset}
                              {:type :float
                               :name :low-threshold}
                              {:type :float
                               :name :high-threshold}]}))

:high-threshold}]})) (def input (javax.imageio.ImageIO/read (io/file "lena-1000x1000.jpg"))

"lena-1000x1000.jpg")) (def buffer (BufferedImage. (.getWidth input) (.getHeight input) BufferedImage/TYPE_BYTE_GRAY))

BufferedImage/TYPE_BYTE_GRAY)) (let [offset 0 step (.getWidth input) rows (.getHeight input) cols (.getWidth input)] (canny-stage1 input step offset rows cols buffer step offset low-threshold high-threshold))

high-threshold)) (display-image buffer)

```

buffer)

opencl implementation of canny edge algorithm on java.awt.image.BufferedImage

I need some help understanding the opencl implementation for the canny edge detection algorithm.

I'm trying to compile and run this with jocl, with a java.awt.image.BufferedImage and I've succeeded in getting the kernals compiling. However, when I pass in the array into the kernal, I get no output and the output of the first stage looks like this:

Please let me know what I'm doing wrong and what else I may be able to do.

C:\fakepath\Screen Shot 2018-01-31 at 6.06.18 pm.png

The source code looks something like this. I followed the compilation process for

https://github.com/opencv/opencv/blob/master/modules/imgproc/src/canny.cpp#L227 https://github.com/opencv/opencv/blob/master/modules/imgproc/src/opencl/canny.cl#L119canny.cpp calling the compilation code in canny.cl:

(def canny-stage1 (kernel/load-executive
                   {:name "stage1_with_sobel"
                    :file "opencl/canny.cl"
                    :options "-D WITH_SOBEL -D cn=1 -D TYPE=uchar -D convert_floatN=convert_float -D floatN=float -D GRP_SIZEX=32 -D GRP_SIZEY=8 -D L2GRAD"
                    :worksize (fn [src _ _ _ _ map _ _ _ _]
                                [(.getWidth  src)
                                 (.getHeight src)])
                    :arglist [{:type :image
                               :name :src
                               :buffer {:input true}
                               :flags [:read-only]}
                              {:type :int
                               :name :src-step}
                              {:type :int
                               :name :src-offset}
                              {:type :int
                               :name :rows}
                              {:type :int
                               :name :cols}
                              {:type :image
                               :name :map
                               :buffer {:output true}
                               :flags [:write-only]}
                              {:type :int
                               :name :map-step}
                              {:type :int
                               :name :map-offset}
                              {:type :float
                               :name :low-threshold}
                              {:type :float
                               :name :high-threshold}]}))

(def input (javax.imageio.ImageIO/read (io/file "lena-1000x1000.jpg"))

(def buffer (BufferedImage. (.getWidth input)
                               (.getHeight input)
                               BufferedImage/TYPE_BYTE_GRAY))

(let [offset 0
        step (.getWidth input)
        rows (.getHeight input)
        cols (.getWidth input)]
    (canny-stage1 input
                  step
                  offset
                  rows
                  cols
                  buffer
                  step
                  offset
                  low-threshold
                  high-threshold))

(display-image buffer)

opencl implementation of canny edge algorithm on java.awt.image.BufferedImage

I need some help understanding the opencl implementation for the canny edge detection algorithm.

I'm trying to compile and run this with jocl, with a java.awt.image.BufferedImage and I've succeeded in getting the kernals compiling. However, when I pass in the array into the kernal, I get no output and the output of the first stage looks like this:

Please let me know what I'm doing wrong and what else I may be able to do.

C:\fakepath\Screen Shot 2018-01-31 at 6.06.18 pm.png

The source code looks something like this. I followed the compilation process for canny.cpp calling the compilation code in and canny.cl:

(def canny-stage1 (kernel/load-executive
                   {:name "stage1_with_sobel"
                    :file "opencl/canny.cl"
                    :options "-D WITH_SOBEL -D cn=1 -D TYPE=uchar -D convert_floatN=convert_float -D floatN=float -D GRP_SIZEX=32 -D GRP_SIZEY=8 -D L2GRAD"
                    :worksize (fn [src _ _ _ _ map _ _ _ _]
                                [(.getWidth  src)
                                 (.getHeight src)])
                    :arglist [{:type :image
                               :name :src
                               :buffer {:input true}
                               :flags [:read-only]}
                              {:type :int
                               :name :src-step}
                              {:type :int
                               :name :src-offset}
                              {:type :int
                               :name :rows}
                              {:type :int
                               :name :cols}
                              {:type :image
                               :name :map
                               :buffer {:output true}
                               :flags [:write-only]}
                              {:type :int
                               :name :map-step}
                              {:type :int
                               :name :map-offset}
                              {:type :float
                               :name :low-threshold}
                              {:type :float
                               :name :high-threshold}]}))

(def input (javax.imageio.ImageIO/read (io/file "lena-1000x1000.jpg"))

(def buffer (BufferedImage. (.getWidth input)
                               (.getHeight input)
                               BufferedImage/TYPE_BYTE_GRAY))

(let [offset 0
        step (.getWidth input)
        rows (.getHeight input)
        cols (.getWidth input)]
    (canny-stage1 input
                  step
                  offset
                  rows
                  cols
                  buffer
                  step
                  offset
                  low-threshold
                  high-threshold))

(display-image buffer)