create convexhull around detected keypoints

asked 2017-04-14 19:46:36 -0600

enassays2@gmail.com gravatar image

updated 2017-04-15 00:48:02 -0600

berak gravatar image

I read an image in android and detect the keypoints using sift algorithm, then I want to create Object of Interest (OOI) around these keypoints by creating a convex hull of the corresponding points How can I create this convexhull and draw it using findcontours ??? this is my code:

    inputImage = BitmapFactory.decodeResource(getResources(), R.drawable.test);
    Mat rgba = new Mat();
    Mat rgbagray = new Mat(rgba.width(),rgba.height(),CV_8UC1);
    Utils.bitmapToMat(inputImage, rgba);
    Imgproc.cvtColor(rgba, rgbagray, Imgproc.COLOR_RGBA2GRAY);

    MatOfKeyPoint keyPoints = new MatOfKeyPoint();
    detector.detect(rgbagray, keyPoints);

    List<MatOfPoint> contours = new ArrayList<>();
    Mat hierarchy = new Mat();

    List<KeyPoint> listpoint = new ArrayList<KeyPoint>();
    listpoint = keyPoints.toList();
        //
        for (int ind = 0; ind < listpoint.size(); ind++) {

           // find region of interest

        }
edit retag flag offensive close merge delete

Comments

hmm, there are no "Objects" found by keypoint detection, keypoints may be at arbitrary positions in the image, so your idea does not make much sense.

what are you trying to achieve with the whole feature detection ? (what's it going to be ?)

berak gravatar imageberak ( 2017-04-15 00:54:16 -0600 )edit

I try to follow this paper (Monocular Vision-Based Obstacle Detection/Avoidance for Unmanned Aerial Vehicles) to do obstacle detection, I worked with SIFT algorithm in order to detect the keypoints in both images (two consecutive frames), then the Brute-Force Algorithm to match them,. Then I should extract the keypoints that its keypoints are expanding in the second image, this is by comparing the size property of the keypoints and save it in a new vector of keypoints. Finally, I want to use the functions to create the the convex hull around the final keypoints after filtering, and drawing it using findContours function. How to do this?

enassays2@gmail.com gravatar image[email protected] ( 2017-04-15 08:12:30 -0600 )edit

ah, ok, then.

i do not have java around, so i can't give you a detailled answer (or even test it), but the gist would be:

  • extract the pt (Point) member from your KeyPoints, and put it in a MatOfPoints or such
  • apply convexHull . sadly it only has the indexed version (do you have to use java ?) so you need to look up the hull points using the indexes returned from your Point array
  • make a new MatOfPoints from those hull points, and finally call drawContours() or polyLines
berak gravatar imageberak ( 2017-04-15 08:33:57 -0600 )edit

I can not understand this point please more details : sadly it only has the indexed version (do you have to use java ?) so you need to look up the hull points using the indexes returned from your Point array

enassays2@gmail.com gravatar image[email protected] ( 2017-04-15 17:01:29 -0600 )edit

in c++ , there is an overload, that gives you the hull points directly (but it'snot available in java)

berak gravatar imageberak ( 2017-04-15 19:35:15 -0600 )edit

can you give me example for convex hull using java ?

enassays2@gmail.com gravatar image[email protected] ( 2017-04-15 20:50:07 -0600 )edit

I want to ask about find contours I take the input and output contours .. what will be the input in this case, will it be the MatOfpoint from keypoints list ??

enassays2@gmail.com gravatar image[email protected] ( 2017-04-15 20:53:28 -0600 )edit