Ask Your Question
1

Android. How to check if contours touch position on screen.

asked 2014-03-01 17:40:34 -0600

Samos gravatar image

Hi. I'm trying to get information, when contours touch some "object" on screen. For exasmple:

On screen I paint rect. Now I want to touch it, and get information "finger is touching rect". Is it possible?

Regards

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-03-01 18:21:48 -0600

Rui Marques gravatar image

updated 2014-03-02 06:33:00 -0600

You can do something like this:

//  List<MatOfPoint> contours; from findCountours  

for(int i = 0; i<contours.size(); i++) {
    MatOfPoint m = contours.get(i);
    List<Point> list = m.toList();
    for(int j = 0; j<list.size(); j++) {
        Point p = list.get(j);
        if(p.x == 500){

        }
    }
}
edit flag offensive delete link more

Comments

Thanks for quickly response. I wanted to explain my problem in a simple way, but now i see that I used bad example. So I will try one more time.

  • I have screen size 1000x500 pixels.
  • In a middle of the screen I have painted vertical line. upper point is x=500 y=0, bottom point x=500, y=500
  • in function public Mat onCameraFrame(CvCameraViewFrame inputFrame) {...} using BackgroundSubtractor I got List<MatOfPoint> contoursPoints using Imgproc.findContours(...).

Question: how can I check if points from contoursPoints list "touch" the line that I had created?

Eitd: I'm trying conwert MatOfPoint to Point and then check x position, but always some of that points got x=1, y=1 :(

Samos gravatar imageSamos ( 2014-03-02 05:28:23 -0600 )edit

That is more clear, I do not know why you didn't ask that way in the first place :p

Rui Marques gravatar imageRui Marques ( 2014-03-02 06:20:17 -0600 )edit

I have tried your algoritm (before your answer), but even I got contours on the right part of the screen, some points have x =1 and y=1. Becouse of that this algoritm don't work very good, epecially, if I want to compare points with two or more separated lines.

Samos gravatar imageSamos ( 2014-03-02 06:53:02 -0600 )edit

Question Tools

Stats

Asked: 2014-03-01 17:40:34 -0600

Seen: 1,193 times

Last updated: Mar 02 '14