Hi,

the following problem drives me nuts:

I'm using the Sample4Mixed code. I can switch between filters via the menu
implementation. Everything works great so far. So I added a button to
switch between the filters. I used exactly the same code for switching
between the filters (see code snippet below), but I'm always running
(sooner or later) into the assertion failed error while switching from rgb
to gray scale....and the app crashes. The assertion failed error tells me
that the number of channels in the mat is wrong (my Google result so far).
That makes sense, but it's still weird b/c I used the same code as in the
sample and it doesn't seem to happen in the sample (menu implementation),
but it happens with the button implementation. Just push the button a
couple of times....the error message will pop up at some point in time.

My question is: Does anyone know why this is happening?

Any thoughts on this topic are appreciated :).



final Button button1 = (Button)findViewById(R.id.button1);

button1.setOnClickListener(new OnClickListener(){

public void onClick(View arg0) {

int viewMode = mViewMode;

switch (viewMode) {

case VIEW_MODE_RGBA:


mOpenCvCameraView.SetCaptureFormat(Highgui.CV_CAP_ANDROID_GREY_FRAME);
mViewMode = VIEW_MODE_GRAY;

break;

case VIEW_MODE_GRAY:


mOpenCvCameraView.SetCaptureFormat(Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
mViewMode = VIEW_MODE_RGBA;

break;
}
}
});

--

Search Discussions

  • Jjbluesky at Jan 7, 2013 at 7:18 am
    Solved it. The problem was that for some odd reason the program grabbed the
    wrong inputframe...so instead of using a gray matrix the program was using
    a rgba matrix. And so the matrix had the wrong number of channels. You can
    avoid the issue with e.g.:

    if (inputFrame.channels() == 1){
    Imgproc.cvtColor(inputFrame, mRgba, Imgproc.COLOR_GRAY2RGBA, 4);
    }
    else if (inputFrame.channels() == 4){
    //do nothing
    }
    else {
    //whatever
    }


    Am Donnerstag, 20. Dezember 2012 17:58:01 UTC+1 schrieb jjbluesky:
    Hi,

    the following problem drives me nuts:

    I'm using the Sample4Mixed code. I can switch between filters via the menu
    implementation. Everything works great so far. So I added a button to
    switch between the filters. I used exactly the same code for switching
    between the filters (see code snippet below), but I'm always running
    (sooner or later) into the assertion failed error while switching from rgb
    to gray scale....and the app crashes. The assertion failed error tells me
    that the number of channels in the mat is wrong (my Google result so far).
    That makes sense, but it's still weird b/c I used the same code as in the
    sample and it doesn't seem to happen in the sample (menu implementation),
    but it happens with the button implementation. Just push the button a
    couple of times....the error message will pop up at some point in time.

    My question is: Does anyone know why this is happening?

    Any thoughts on this topic are appreciated :).



    final Button button1 = (Button)findViewById(R.id.button1);

    button1.setOnClickListener(new OnClickListener(){

    public void onClick(View arg0) {

    int viewMode = mViewMode;

    switch (viewMode) {

    case VIEW_MODE_RGBA:


    mOpenCvCameraView.SetCaptureFormat(Highgui.CV_CAP_ANDROID_GREY_FRAME);
    mViewMode = VIEW_MODE_GRAY;

    break;

    case VIEW_MODE_GRAY:


    mOpenCvCameraView.SetCaptureFormat(Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
    mViewMode = VIEW_MODE_RGBA;

    break;
    }
    }
    });
    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupandroid-opencv @
categoriesandroid
postedDec 21, '12 at 6:49a
activeJan 7, '13 at 7:18a
posts2
users1
websiteandroid.com

1 user in discussion

Jjbluesky: 2 posts

People

Translate

site design / logo © 2019 Grokbase