OpenCV Leistung auf template-matching

Ich versuche zu tun, template-matching grundsätzlich auf java. Ich verwendete einfache Algorithmus zu finden, übereinstimmen. Hier ist der code:

minSAD = VALUE_MAX;
//loop through the search image
for ( int x = 0; x <= S_rows - T_rows; x++ ) {
    for ( int y = 0; y <= S_cols - T_cols; y++ ) {
        SAD = 0.0;

        //loop through the template image
        for ( int i = 0; i < T_rows; i++ )
            for ( int j = 0; j < T_cols; j++ ) {

                pixel p_SearchIMG = S[x+i][y+j];

                pixel p_TemplateIMG = T[i][j];

                SAD += abs( p_SearchIMG.Grey - p_TemplateIMG.Grey );
            }
    }

    //save the best found position 
    if ( minSAD > SAD ) {
        minSAD = SAD;
        //give me VALUE_MAX
        position.bestRow = x;
        position.bestCol = y;
        position.bestSAD = SAD;
    }
}

Dieser ist aber sehr langsam Vorgehen. Getestet habe ich 2 Bilder (768 × 1280) und das subimage (384 x 640). Das dauert Ewigkeiten.
Tut openCV durchführen template-matching viel schneller oder nicht mit ready-Funktion cvMatchTemplate()?

InformationsquelleAutor AraZZ | 2011-08-21

Schreibe einen Kommentar