Make a condition on OpenCV4Android

asked 2016-06-06 10:35:54 -0500

Michele Jane gravatar image

Hey Everyone, Im newbie on OpenCV4Android "BlobColorDetection" . I try to knowing the HSV Color from this object with this Toast. My question how to make a condition when Value = 160 - 180 then show message Color = Blue. Someone can help me ?

Toast.makeText(this, "Value = " + mBlobColorHsv, Toast.LENGTH_LONG).show();

This is the fullcode.

// Calculate average color of touched region
    mBlobColorHsv = Core.sumElems(touchedRegionHsv);
    int pointCount = touchedRect.width*touchedRect.height;
    for (int i = 0; i < mBlobColorHsv.val.length; i++)
        mBlobColorHsv.val[i] /= pointCount;

    mBlobColorRgba = converScalarHsv2Rgba(mBlobColorHsv);


    Toast.makeText(this, "Value = " + mBlobColorHsv, Toast.LENGTH_LONG).show();

    Log.i(TAG, "Touched rgba color: (" + mBlobColorRgba.val[0] + ", " + mBlobColorRgba.val[1] +
            ", " + mBlobColorRgba.val[2] + ", " + mBlobColorRgba.val[3] + ")");

    mDetector.setHsvColor(mBlobColorHsv);

    Imgproc.resize(mDetector.getSpectrum(), mSpectrum, SPECTRUM_SIZE);

    mIsColorSelected = true;

    touchedRegionRgba.release();
    touchedRegionHsv.release();

image description

edit retag flag offensive close merge delete