Hi,

I am trying to implement a straightforward frame differencing between two
successive frames,
within the ColorBlobDetection example (mostly just a place to test things).
I capture 2 frames
with a delay in between and absdiff() them, but no matter what I do, the
diff frame is always black (i'm able to
display the normal undiffed images just fine.

Here is my code; I usually code in C++ btw:


capture.retrieve(grey1, Highgui.CV_CAP_ANDROID_GREY_FRAME); // grey image

// artificial delay of 1 sec for testing; move camera

try {

Thread.sleep(1000);

} catch (InterruptedException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

capture.retrieve(grey2, Highgui.CV_CAP_ANDROID_GREY_FRAME); // grey image

// frame differencing - i've tried scaling the values too, but that doesn't
seem to help

Core.absdiff(grey1,grey2, grey2);

// this part is a bit summarized

Bitmap mBmp = Bitmap.createBitmap(mRgba.cols(), mRgba.rows(), Bitmap.Config.
RGB_565);

Utils.matToBitmap(grey2, mBmp);


Can anyone please suggest what might be the problem? Using this approach in
regular OpenCV usually works fine.


thanks,

brigit

--

Search Discussions

  • Andrey Pavlenko at Dec 7, 2012 at 1:27 pm
    when you take a diff of two opaque pixels with alpha==255, you're getting a
    transparent pixel with alpha==0 that looks black.
    For displaying use
    grey2 += Scalar(0, 0, 0, 255);
    before conversion to Bitmap.

    --
  • Brigit at Dec 10, 2012 at 8:29 am
    thanks very much! this helped the screen to be visible at least,
    but i don't actually see any differencing.

    this is what i am doing:

    Core.absdiff(grey1,grey2, grey2);

    Core.add(grey2, new Scalar(32, 32, 32, 255), grey2);
    i added 32 just to see something. I am grabbing my frames 1
    second apart, but not seeing any differencing. they each display
    fine on their own. any suggestions? I am going to see if I can
    save off the images somehow to look at....Debug mode in Eclipse
    allows you to see info about a Mat structure, but not the actually
    data (even binary).

    thanks!
    brigit

    On Fri, Dec 7, 2012 at 8:27 AM, Andrey Pavlenko
    wrote:
    when you take a diff of two opaque pixels with alpha==255, you're getting
    a transparent pixel with alpha==0 that looks black.
    For displaying use
    grey2 += Scalar(0, 0, 0, 255);
    before conversion to Bitmap.

    --


    --
  • Andrey Pavlenko at Dec 14, 2012 at 7:42 am
    Try to log both Mat-s as Strings and compare native addresses of their
    elements: the *VideoCapture* possibly returns a reference to its internal
    Mat that is overwritten on every frame (to avoid extra copying).
    You need to use *Mat::clone()* to make a copy of particular frame.

    --
  • Brigit at Dec 14, 2012 at 3:44 pm
    thank you! this makes a lot of sense. I will let you know how it turns out.

    brigit/
    On Fri, Dec 14, 2012 at 2:35 AM, Andrey Pavlenko wrote:

    Try to log both Mat-s as Strings and compare native addresses of their
    elements: the *VideoCapture* possibly returns a reference to its internal
    Mat that is overwritten on every frame (to avoid extra copying).
    You need to use *Mat::clone()* to make a copy of particular frame.

    --


    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupandroid-opencv @
categoriesandroid
postedDec 7, '12 at 7:21a
activeDec 14, '12 at 3:44p
posts5
users2
websiteandroid.com

2 users in discussion

Brigit: 3 posts Andrey Pavlenko: 2 posts

People

Translate

site design / logo © 2019 Grokbase