Ask Your Question

Revision history [back]

image tracking with android and openCv

i am new android devloper , i want to tracking special object in android and replaced by another image ... for example find a book and replace bood by a special image I find bottom code , but it dosen't work . plz help me :( how i can do this project

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
     Mat novo = new Mat();
        Mat resp = new Mat();
        Mat homer = new Mat();

       // resp = inputFrame.gray();
        novo = inputFrame.gray();

        Mat lido = new Mat();
        try {
            lido = Utils.loadResource(this, R.drawable.first);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Imgproc.cvtColor(lido, homer, Imgproc.COLOR_RGB2GRAY);

        FeatureDetector surf = FeatureDetector.create(FeatureDetector.FAST);

        MatOfKeyPoint keypointsHomer = new MatOfKeyPoint();
        MatOfKeyPoint keypoints = new MatOfKeyPoint();

        surf.detect(homer, keypointsHomer);
        surf.detect(novo, keypoints);

        DescriptorExtractor SurfExtractor = DescriptorExtractor.create(FeatureDetector.SURF);

        Mat descriptors = new Mat();
        Mat homerDescriptors = new Mat();

        SurfExtractor.compute(novo, keypoints, descriptors);
        SurfExtractor.compute(homer, keypointsHomer, homerDescriptors);

        DescriptorMatcher m = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE);
        MatOfDMatch matches = new MatOfDMatch();

        m.match(descriptors, homerDescriptors, matches);

        Features2d.drawMatches(novo, keypoints, homer, keypointsHomer, matches, resp);
       // Features2d.drawKeypoints(novo, keypoints, resp);
        //Features2d.drawKeypoints(homer, keypointsHomer, resp);
        return resp;

    //return inputFrame.rgba();

}

}

image tracking with android and openCv

i am new android devloper , i want to tracking special object in android and replaced by another image ... for example find a book and replace bood by a special image I find bottom code , but it dosen't work . plz help me :( how i can do this project

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
     Mat novo = new Mat();
        Mat resp = new Mat();
        Mat homer = new Mat();

       // resp = inputFrame.gray();
        novo = inputFrame.gray();

        Mat lido = new Mat();
        try {
            lido = Utils.loadResource(this, R.drawable.first);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Imgproc.cvtColor(lido, homer, Imgproc.COLOR_RGB2GRAY);

        FeatureDetector surf = FeatureDetector.create(FeatureDetector.FAST);

        MatOfKeyPoint keypointsHomer = new MatOfKeyPoint();
        MatOfKeyPoint keypoints = new MatOfKeyPoint();

        surf.detect(homer, keypointsHomer);
        surf.detect(novo, keypoints);

        DescriptorExtractor SurfExtractor = DescriptorExtractor.create(FeatureDetector.SURF);

        Mat descriptors = new Mat();
        Mat homerDescriptors = new Mat();

        SurfExtractor.compute(novo, keypoints, descriptors);
        SurfExtractor.compute(homer, keypointsHomer, homerDescriptors);

        DescriptorMatcher m = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE);
        MatOfDMatch matches = new MatOfDMatch();

        m.match(descriptors, homerDescriptors, matches);

        Features2d.drawMatches(novo, keypoints, homer, keypointsHomer, matches, resp);
       // Features2d.drawKeypoints(novo, keypoints, resp);
        //Features2d.drawKeypoints(homer, keypointsHomer, resp);
        return resp;

    //return inputFrame.rgba();

}

}