Ask Your Question
0

Sobel using dx=1, dy=0 gives exactly same output as dx=0, dy=1 (bug?)

asked 2017-01-21 06:17:56 -0500

NTxC gravatar image

Greetings,

this piece of code seems to be generating exactly same Sobel gradients for dx=1, dy=0 and dx=0, dy=1. This means I can't subtract gradY from gradX because that leaves me with a black image. Is this a bug in OpenCV?

    Mat gradX = new Mat();
    Mat gradY = new Mat();
    Mat gray = new Mat();
    Mat gradient = new Mat()

    Imgproc.cvtColor( cameraSnapshotFrame, gray, COLOR_BGR2GRAY );

    Imgproc.Sobel( gray, gradX, CV_32F, 1, 0, -1, 1.0, 0 );
    Imgproc.Sobel( gray, gradY, CV_32F, 0, 1, -1, 1.0, 0 ); // for some reason this gives the same result as the line above

    Core.subtract( gradX, gradY, gradient );
    Core.convertScaleAbs( gradient, gradient ); // gradient is an empty black image

Using OpenCV for Android version 3.1.0. Please help.

edit retag flag offensive close merge delete

Comments

1

"... leaves me with a black image." -- small values might not be visible to a human. try:

System.out.println(gradient.dump())

too see, if it's really all 0

berak gravatar imageberak ( 2017-01-21 08:01:28 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-01-21 08:10:42 -0500

NTxC gravatar image

Thanks for the answer. Unfortunately it really was all zeros. The gradients were identical. I have just fixed this issue:

The OpenCV library can be used in two ways on an Android smartphone: it can be embedded within an application directly, or installed as an app - "OpenCV Manager", which then provides the libraries to the OpenCV apps dynamically.

My application was using the OpenCV Manager app to get the libraries. Unfortunately, it appears that OpenCV Manager for Android is bugged, because when I embedded the OpenCV library directly within my app, the Sobel calls started working properly.

So I recommend everyone to link their applications to OpenCV statically.

edit flag offensive delete link more

Comments

1

hmm, i think, this should be reported !

indeed, i could not reproduce your problem on a pc.

berak gravatar imageberak ( 2017-01-21 08:18:33 -0500 )edit

I would also encourage you to report this at the issues page. Thank you in advance.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-01-24 08:31:20 -0500 )edit

I have reported this issue. Thank you for your suggestions.

NTxC gravatar imageNTxC ( 2017-01-24 09:36:18 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-01-21 06:17:56 -0500

Seen: 101 times

Last updated: Jan 21 '17