java/android,how enabling multiple detection of the same object.

asked 2015-02-28 07:26:14 -0600

i'm trying to modify the code from here: http://nummist.com/opencv/5206_04.zip

the code that is detailed in the packtpub publishing of "Android Application Programming with OpenCV" the code is used to recognize a single instance of an image, i'm tryig to modify the code to recognize multiple instances of the same image.

i've found this example online: https://code.google.com/p/find-object...

which does exactly what i want, but i have no clue how to get it to work on android side of things. i tried first finding the first object and than based on the mask from the homography finding the remaining instances by redoing homography again, but doesn't seem to be right.

help is needed.

 Mat mask = new Mat();
        Mat homography = Calib3d.findHomography(
                goodReferencePoints, goodScenePoints, Calib3d.RANSAC, 0.1, mask);

        Core.perspectiveTransform(mReferenceCorners,
                mCandidateSceneCorners, homography);

        mCandidateSceneCorners.convertTo(mIntSceneCorners,
                CvType.CV_32S);
        if (Imgproc.isContourConvex(mIntSceneCorners)) {
            mCandidateSceneCorners.copyTo(mSceneCorners);
            objectFound.add(mSceneCorners);
        }


        if (mask.rows() > 0) {
            for (int i = 0; i < mask.rows(); ++i) {
                    if (mask.get(i, 0)[0] == 1) {
                        goodReferencePointsList.clear();
                        goodScenePointsList.clear();
                        goodReferencePointsList.add(
                                referenceKeypointsList.get(matchesList.get(i).trainIdx).pt);
                        goodScenePointsList.add(
                                sceneKeypointsList.get(matchesList.get(i).queryIdx).pt);

                        homography = Calib3d.findHomography(
                                goodReferencePoints, goodScenePoints);

                        Core.perspectiveTransform(mReferenceCorners,
                                mCandidateSceneCorners, homography);

                        mCandidateSceneCorners.convertTo(mIntSceneCorners,
                                CvType.CV_32S);
                        if (Imgproc.isContourConvex(mIntSceneCorners)) {
                            mCandidateSceneCorners.copyTo(mSceneCorners);
                            objectFound.add(mSceneCorners);
                        }

                    }

            }
edit retag flag offensive close merge delete