Exemplo n.º 1
0
// Perform a query on the database.  This simply runs matchFeatures on
// each image in the database, and returns the feature set of the best
// matching image.
bool performQuery(const FeatureSet &f, const ImageDatabase &db, int &bestIndex, vector<FeatureMatch> &bestMatches, double &bestDistance, int matchType) {
    vector<FeatureMatch> tempMatches;

    for (unsigned int i=0; i<db.size(); i++) {
        if (!matchFeatures(f, db[i].features, tempMatches, matchType)) {
            return false;
        }

        bestIndex = i;
        bestMatches = tempMatches;
    }

    return true;
}
Exemplo n.º 2
0
int main()
{
	vector<string> path;
	path.push_back("C:\\WORK\\Matchmover\\Core\\desk\\_DSC2192.JPG");
	path.push_back("C:\\WORK\\Matchmover\\Core\\desk\\_DSC2193.JPG");
	path.push_back("C:\\WORK\\Matchmover\\Core\\desk\\_DSC2194.JPG");
	path.push_back("C:\\WORK\\Matchmover\\Core\\desk\\_DSC2195.JPG");

	initialize(path);
	matchFeatures();
	reconstruct(27.0, 36.0, 24.0);

	toMax(camList, points3D, "Camera.ms");

	return 0;
}
// Perform a query on the database.  This simply runs matchFeatures on
// each image in the database, and returns the feature set of the best
// matching image.
bool performQuery(const FeatureSet &f, const ImageDatabase &db, int &bestIndex, vector<FeatureMatch> &bestMatches, double &bestScore, int matchType) {
    // Here's a nice low number.
    bestScore = -1e100;

    vector<FeatureMatch> tempMatches;
    double tempScore;

    for (unsigned int i=0; i<db.size(); i++) {
        if (!matchFeatures(f, db[i].features, tempMatches, tempScore, matchType)) {
            return false;
        }

        if (tempScore > bestScore) {
            bestIndex = i;
            bestScore = tempScore;
            bestMatches = tempMatches;
        }
    }

    return true;
}
Exemplo n.º 4
0
 // Match _features.
 JNIEXPORT jint JNICALL
 Java_fr_ensicaen_panandroid_stitcher_StitcherWrapper_matchFeatures
 (JNIEnv* env, jobject obj)
 {
         return matchFeatures();
 }
// Initialize global alignment of all images.
int initGlobalAlign(const vector<FeatureSet> &fs, int minMatches, MotionModel m, float f, int width, int height, int nRANSAC, double RANSACthresh, AlignMatrix &am, vector<CTransform3x3> &ms) {
    int n = fs.size();

    // create the n-by-n alignment matrix
    am.resize(n);
    for (int i=0; i<n; i++)
        am[i].resize(n);

    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            if (i != j) {
                printf("matching image %d with image %d \n", i, j);

                // BEGIN TODO
                // write code to fill in the information for am[i][j]
                //
                // you'll need to call your feature matching routine,
                // then your pair alignment routine
                am[i][j].matches = matchFeatures(fs[i], fs[j]);
                alignImagePair(fs[i], fs[j], am[i][j].matches, m, f, width, height, nRANSAC, RANSACthresh, am[i][j].r, am[i][j].inliers);
                // END TODO

                printf("%d inliers\n", am[i][j].inliers.size());

                if ((int) am[i][j].inliers.size() < minMatches)
                    am[i][j].inliers.clear();
            }
        }
    }
    printf("done..\n");
    vector<AlignmentImage> nodes(n);
    for (int i=1; i<n; i++) {
        nodes[i].added = false;
        nodes[i].nBest = 0;
        nodes[i].imageID = i;
        nodes[i].parentID = -1;
    }

    // create the image heap
    ImageHeap heap(nodes);

    // add the first image and update the match quality of
    // its neighbors
    nodes[0].added = true;

    for (int j=1; j<n; j++) {
        int nMatches = am[0][j].inliers.size();
        if (nodes[j].nBest < nMatches) {
            heap.increaseKey(nodes[j].heapIndex, nMatches);
            nodes[j].parentID = 0;
        }
    }

    AlignmentImage *nextImage;

    // add the rest of the images
    for (int i=0; i<n-1; i++) {
        nextImage = heap.extractMax();

        if (nextImage->nBest == 0) {
            // image set seems to be disconnected
            return -1;
        }

        nextImage->added = true;
        int id = nextImage->imageID;
        int pid = nextImage->parentID;

        // compute the global alignment of the extracted image
        nextImage->r = am[pid][id].r * nodes[pid].r;

        // update the match quality for its neighbor images
        for (int j=0; j<n; j++) {
            if ((id != j) && (!nodes[j].added)) {
                int nMatches = am[id][j].inliers.size();
                if (nodes[j].nBest < nMatches) {
                    heap.increaseKey(nodes[j].heapIndex, nMatches);
                    nodes[j].parentID = id;
                }
            }
        }
    }

    ms.clear();

    // put the global transformations into the output array
    for (int i=0; i<n; i++) {
        ms.push_back(nodes[i].r);
    }

    return 0;
}