Package com.alibaba.simpleimage.analyze.search.engine

Examples of com.alibaba.simpleimage.analyze.search.engine.ImageEngine


        if (!new File(treePath).exists()) {
            System.out.println("Begin to Build Tree");
            train(treePath, path, imageCount, 1);
        }

        ImageEngine ie = new ImageEngine();
        if (new File(indexPath).exists()) {
            System.out.println("Begin to Load Index,Tree,Weight,Histogram");
            ie.loadIndex(indexPath);
            ie.loadWeight(weightPath);
            ie.loadTree(treePath);
            ie.loadHistogram(histogramPath);
        } else {
            System.out.println("Begin to Build Index");
            ie.init(treePath);
            for (int i = 0; i < imageCount; i++) {
                String tmp = String.format("ukbench%05d", i);
                String featfile = path + tmp + ".surf";
                InterestPointListInfo info = InterestPointInfoReader.readComplete(featfile);
                List<SURFInterestPoint> surfPoints = null;
                if (info != null) surfPoints = info.getList();
                ie.buildIndex(surfPoints, i);
            }
            ie.buildWeight();
            ie.saveIndex(indexPath);
            ie.saveHistogram(histogramPath);
            ie.saveWeight(weightPath);
        }

        System.out.println("Begin to Search");
        long start = System.currentTimeMillis();
        String featfile = path + "ukbench00001" + ".surf";
        List<SURFInterestPoint> surfPoints = InterestPointInfoReader.readComplete(featfile).getList();

        List<Integer> visualWords = ie.quntinize(surfPoints);
        ie.getCandidate(visualWords);
        // visualWords = visualWords.subList(0, 20);
        List<Score> scoreList = ie.getRankedList(visualWords, ie.getCandidate(visualWords), 20);
        long end = System.currentTimeMillis();
        System.out.println("Time Cost: " + (end - start) + "ms");
        for (Score score : scoreList) {
            System.out.println(score.getIdentity() + "," + score.getScore());
        }
View Full Code Here

TOP

Related Classes of com.alibaba.simpleimage.analyze.search.engine.ImageEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.