Ask Your Question

KicoSVK's profile - activity

2020-05-14 02:39:34 -0600 received badge  Popular Question (source)
2018-10-28 05:27:29 -0600 edited question OpenCV C++ Find contour and extreme points

OpenCV C++ Find contour and extreme points Hello there, please I want find some solution. I have these outputs with Open

2018-10-28 05:26:24 -0600 edited question OpenCV C++ Find contour and extreme points

OpenCV C++ Find contour and extreme points Hello there, please I want find some solution. I have these outputs with Open

2018-10-27 17:33:30 -0600 edited question OpenCV C++ Find contour and extreme points

OpenCV C++ Find contour and extreme points Hello there, please I want find some solution. I have these outputs with Open

2018-10-27 17:32:08 -0600 asked a question OpenCV C++ Find contour and extreme points

OpenCV C++ Find contour and extreme points Hello there, please I want find some solution. I have these outputs with Open

2017-04-03 14:02:04 -0600 asked a question Android + OpenCV - Zoom camera frame

Good Evening,

now I have a problem with find some solution for zoom camera frames.

I have a this ...

image description

... and I want zoom it like this.

image description

Of course I am using a onCameraFrame function, here is a code example:

public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {

        return mRgba = inputFrame.rgba();
}

Do you have any idea ? Thanks everyone for any comment and ideas !

2017-03-20 04:38:08 -0600 commented answer Android + OpenCV - Finding extreme points in contours

That is it, but I have array with MathOfPoints data type, there is a problem. I do not know, how can I get a coordinates.

2017-03-19 15:08:46 -0600 asked a question Android + OpenCV - Finding extreme points in contours

Good Evening,

I have a trouble with finding extreme points in frames. I am detecting all contours, but I want find there one extreme point, which is lowest from others (southernmost contour). Here is a preview of screen, what I have.

image description

And here is a preview of screen, what I want ! For example, lowest point will bounded by red rectangle.

image description.

And here is my code, what I have now.

   contours = new ArrayList<MatOfPoint>();
   Rect rect;
   Point c1 = new Point(); Point c2 = new Point();

   Imgproc.cvtColor(mRgba, mGray, Imgproc.COLOR_RGB2GRAY);
   subtractorMOG2.apply(mGray, mFGMask, 0.005);

   Imgproc.threshold(mFGMask, mFGMask, 45, 255, Imgproc.THRESH_BINARY);
   Imgproc.erode(mFGMask, mFGMask, new Mat());
   Imgproc.dilate(mFGMask, mFGMask, new Mat());

   Imgproc.findContours(mFGMask, contours, new Mat(), Imgproc.RETR_EXTERNAL , Imgproc.CHAIN_APPROX_NONE);
   Imgproc.drawContours(mRgba, contours, -1, new Scalar(255, 255, 0), 3);

        /*for (int idx = 0; idx < contours.size(); idx++) {

            double contourarea = Imgproc.contourArea(contours.get(idx));
            rect = boundingRect(contours.get(idx));

            c1.x = rect.x; c1.y = rect.y;
            c2.x = rect.x + rect.width; c2.y = rect.y + rect.height;
            if (contourarea > 1024 && contourarea < 30000) {
                Imgproc.rectangle(mRgba, c1, c2, new Scalar(255, 0, 0), 3);
            }
        }*/

  return mRgba;

Thanks everybody for help and comments !

2017-03-10 13:19:00 -0600 received badge  Enthusiast
2017-03-07 08:02:57 -0600 asked a question Android + OpenCV - frame processing

Hello,

I have a problem with developing my app. I stacked. :/ Here is a preview of screen.

image description

Now, where is a problem... I would like after I click on the CALIBRATE button, last delivered frame will be save to the some matrix. In this matrix, I want a detect this small circle (see in picture) and then display this matrix with detected circles. But I want do it from one last delivered frame, when I click on CALIBRATE button.

Here is my code. Thanks everyone ! :/

        bCalibrate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                isCalibration = true;
            }
        });        

        public void onCalibration(Mat inputFrame){
            mCaliration = inputFrame;
            Log.d("log", "mCalibration res"+mCaliration.width() + "x"+mCaliration.height());
        }

    @Override
    public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {

        Log.d("log", ""+inputFrame.rgba().width() + "x"+inputFrame.rgba().height());

        if(isCalibration == true){
            onCalibration(inputFrame.rgba());
            isCalibration = false;
            Log.d("log", "is WORKING");
        }    

        int rows = (int) mRgba.height();
        int cols = (int) mRgba.width();

        if (isMode01Active == true) {

            mRgba = inputFrame.rgba();
            mGray = inputFrame.gray();

            return mRgba;
        }

        else if (isMode02Active == true) {

            return mCaliration;
        }

        else if (isMode03Active == true){
            mRgba = inputFrame.rgba();
            cvtColor(mRgba, mGray, COLOR_RGB2GRAY);

            contours = new ArrayList<MatOfPoint>();
            double approxDistance; // approxDistance

            Rect rect;
            Point c1 = new Point();
            Point c2 = new Point();

            curve = new MatOfPoint2f();
            approxCurve = new MatOfPoint2f();

            Imgproc.GaussianBlur(mGray, mGray, new Size(value03, value03), 0);
            Canny(mGray, mCanny, value01, value02);

            findContours(mCanny, contours, mHierarchy, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);
            //drawContours(mRgba, contours, -1, new Scalar(0,255,255));
            int numberOfObject = 0;

            for(int i = 0; i < contours.size(); ++i)
            {
                // Minimum size allowed for consideration
                curve = new MatOfPoint2f(contours.get(i).toArray());
                //Processing on mMOP2f1 which is in type MatOfPoint2f
                approxDistance = Imgproc.arcLength(curve, true)*Double.MIN_VALUE;
                Imgproc.approxPolyDP(curve, approxCurve, approxDistance, true);
                //Convert back to MatOfPoint
                points = new MatOfPoint(approxCurve.toArray());

                //cArea = contourArea(contours.get(i));
                rect = boundingRect(points);

                c1.x = rect.x;
                c1.y = rect.y;

                c2.x = rect.x + rect.width;
                c2.y = rect.y + rect.height;

                //Mat mContourArea = contours.get(i);
                double contourArea = Imgproc.contourArea(contours.get(i));

                if(((rect.height < 50) && (rect.width < 50) && (rect.width > 25) && (rect.width > 25) && contourArea > 45)){
                    numberOfObject++;
                    Imgproc.rectangle(mRgba, c1, c2, new Scalar(0, 255, 255), 2);
                    Log.d("log", "" + contourArea);
                }

            }
            return mRgba;
        }

        else {
            return mRgba;
        }
    }
}
2017-03-07 07:18:52 -0600 answered a question OpenCV + Android - implement flashlight

Solution is use a JavaCameraView ! In class JavaCameraView insert this functions with this body.

    public void turnOffTheFlash() {
       Camera.Parameters params = mCamera.getParameters();
       params.setFlashMode(params.FLASH_MODE_OFF);
       mCamera.setParameters(params);
    }

    public void turnOnTheFlash() {
       Camera.Parameters params = mCamera.getParameters();
       params.setFlashMode(params.FLASH_MODE_TORCH);
       mCamera.setParameters(params);
    }

Then in your activity class create instance of JavaCameraView class, for example private JavaCameraView mOpenCvCameraView;. Finally with this instance call these functions like this.

mOpenCvCameraView.turnOnTheFlash();

or

mOpenCvCameraView.turnOffTheFlash();
2017-03-05 16:52:06 -0600 received badge  Editor (source)
2017-03-05 15:58:12 -0600 commented question OpenCV + Android - implement flashlight

Thanks a lot for your time, but there is a no way how to implement it.

2017-03-05 15:06:25 -0600 commented question OpenCV + Android - implement flashlight

Hmmm, thanks for answer. So, How can I implement it, is there any simply solution ?

2017-03-05 06:49:49 -0600 asked a question OpenCV + Android - implement flashlight

Hello,

I have a problem with flashlight in my app. I do not know, How can I implement it to my Android app. On frame processing I use a CameraBridgeViewBase and I use a rear mobile camera.

How Can is implement simple camera flashlight ? :O Here is my code. Thanks EVERYONE !

public class MainActivity extends Activity implements CvCameraViewListener2 {

private CameraBridgeViewBase mOpenCvCameraView;
private JavaCameraView cameraView;

private Mat
        mRgba,
        imgGray,
        imgCanny,
        mResizedMat,
        hierarchy;

private TextView
        infoText,
        text01,
        text02,
        text03;

private Button
        button01,
        button02,
        button03;

private boolean
        isMode01Active = false,
        isMode02Active = false,
        isMode03Active = false;

private SeekBar
        seekBar01,
        seekBar02,
        seekBar03;

private int
        value01 = 64,
        value02 = 80,
        value03 = 5;

Camera camera;
Camera.Parameters parameters;

List<MatOfPoint> contours;

private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
    @Override
    public void onManagerConnected(int status) {
        switch (status) {
            case LoaderCallbackInterface.SUCCESS: {
                camera = Camera.open(CAMERA_ID_BACK);
                parameters = camera.getParameters();
                parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
                camera.setParameters(parameters);
                mOpenCvCameraView.enableView();
                mOpenCvCameraView.enableFpsMeter();
            }
            break;
            default: {
                super.onManagerConnected(status);
            }
            break;
        }
    }
};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // - - - > SETTING LAYOUT OF ACTIVITY
    setContentView(R.layout.activity_main);
    setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE);
    // < - - - END

    // - - - > SET ORIENTATION OF SCREEN
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    // < - - - END

    // - - - > DECLARATION OF COMPONENTS
    infoText = (TextView)findViewById(R.id.infoText);
    text01 = (TextView)findViewById(R.id.text01);
    text02 = (TextView)findViewById(R.id.text02);
    text03 = (TextView)findViewById(R.id.text03);

    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.camera_view);
    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
    mOpenCvCameraView.setCvCameraViewListener(this);

    button01 = (Button) findViewById(R.id.button01);
    button02 = (Button) findViewById(R.id.button02);
    button03 = (Button) findViewById(R.id.button03);

    seekBar01 = (SeekBar) findViewById(R.id.seekBar01);
    seekBar02 = (SeekBar) findViewById(R.id.seekBar02);
    seekBar03 = (SeekBar) findViewById(R.id.seekBar03);
    // < - - - END

    isMode01Active = true;
    infoText.setText("MODE1: ACTIVE");

    button01.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mOpenCvCameraView.enableFpsMeter();
            infoText.setText("MODE1: ACTIVE");
            setModelStatus("mode1");
        }
    });

    button02.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mOpenCvCameraView.enableFpsMeter();
            infoText.setText("MODE2: ACTIVE");
            setModelStatus("mode2");
        }
    });

    button03.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mOpenCvCameraView.enableFpsMeter();
            infoText.setText("MODE3: ACTIVE");
            setModelStatus("mode3");
        }
    });

    seekBar01.setMax(150);
    seekBar02.setMax(150);
    seekBar03.setMax(45);
    seekBar01.setProgress(value01);
    seekBar02.setProgress(value02);
    seekBar03.setProgress(value03);
    text01.setText(""+value01);
    text02.setText(""+value02);
    text03.setText(""+value03);


    seekBar01.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {

            value01 = i;
            text01.setText(""+value01);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    seekBar02.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {

            value02 = i;
            text02.setText(""+value02);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    seekBar03.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {

            if(i % 2 != 0)
            value03 = i;
            text03.setText(""+value03);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });
}

@Override
public void onPause() {
    super.onPause();
    if (mOpenCvCameraView != null)
        mOpenCvCameraView.disableView();
}

@Override
public void onResume() {
    super.onResume();
    if (!OpenCVLoader.initDebug()) {
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0, this, mLoaderCallback);
    } else {
        mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }
}

@Override
public void onDestroy() {
    super.onDestroy();
    if (mOpenCvCameraView != null)
        mOpenCvCameraView.disableView();
}

@Override
public void onCameraViewStarted(int ...
(more)