Ask Your Question
0

Canny Edge Detector doesn't return filtered image

asked 2018-12-03 07:18:10 -0600

aLx gravatar image

updated 2020-12-09 08:08:50 -0600

I building an APK that receive the image from my android device camera and process with OpenCV library. Just want to convert the image to Gray scale, apply Gaussian Blur filter and run Canny Edge Detector.

My APK runs properly on android device, with no error instead. But it's don't return processed image, just the original.

Here's my onCameraFrame class with image processing code:

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {

Mat mRgba = new Mat();
Mat imgGray = new Mat();

Imgproc.cvtColor(inputFrame.rgba(), imgGray, Imgproc.COLOR_RGBA2GRAY);
Imgproc.GaussianBlur(imgGray, imgGray, new Size(5, 5), 2, 2);
Imgproc.Canny(imgGray, imgGray, 35, 75);

return imgGray;

I think my code isn't wrong, but i don't know how to return the edge detection image.

Someone knows how to help me?

Thanks!

edit retag flag offensive close merge delete

Comments

I have the same problem as you! Tried a simple cvtColor to grayscale but I only get the original rgb frames...

tgpsantos gravatar imagetgpsantos ( 2019-04-29 05:20:35 -0600 )edit

Be sure you are selecting correct conversión, i don't now if is diferent in Android but in Java desktop, images from cameras came in BGR, not RGB.

Greydel gravatar imageGreydel ( 2019-12-04 01:33:33 -0600 )edit

1 answer

Sort by » oldest newest most voted
1

answered 2019-04-30 07:46:16 -0600

Akhil Patel gravatar image

updated 2019-11-23 02:05:43 -0600

please use following code it will work perfect for me :

    public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame)
    {

         Mat rgba = inputFrame.rgba();
         Mat edges = new Mat(rgba.size(), CV_8UC1);

         Imgproc.cvtColor(rgba, edges, Imgproc.COLOR_RGB2GRAY, 4);
         Imgproc.GaussianBlur(edges, edges, new Size(5, 5), 2, 2);
         Canny(edges, edges, 100 ,100);

         return edges;
     }
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-12-03 07:18:10 -0600

Seen: 820 times

Last updated: Nov 23 '19