Detector OpenCV FAST

En mimain.cpp Tengo un extracto:

Ptr<FastFeatureDetector> fastDetector = FastFeatureDetector::create(80, true);

while (true) {
    Mat image = // get grayscale image 1280x720

    timer.start();
    detector->detect(image, keypoints);
    myfile << "FAST\t" << timer.end() << endl; // timer.end() is how many seconds elapsed since last timer.start()


    keypoints.clear();

    timer.start();
    for (int i = 3; i < image.rows - 3; i++)
    {
        for (int j = 3; j < image.cols - 3; j++)
        {
            if (inspectPoint(image.data, image.cols, i, j)) {
                // this block is never entered
                KeyPoint keypoint(i, j, 3);
                keypoints.push_back(keypoint);
            }
        }
    }
    myfile << "Custom\t" << timer.end() << endl;
    myfile << endl;
    myfile.flush();
    ...
}

mi archivo esta diciendo:

FAST    0.000515495
Custom  0.00221361

FAST    0.000485697
Custom  0.00217653

FAST    0.000490001
Custom  0.00219044

FAST    0.000484373
Custom  0.00216329

FAST    0.000561184
Custom  0.00233214

Entonces uno esperaría queinspectPoint() es una función que realmente está haciendo algo.

bool inspectPoint(const uchar* img, int cols, int i, int j) {
    uchar p = img[i * cols + j];
    uchar pt = img[(i - 3)*cols + j];
    uchar pr = img[i*cols + j + 3];
    uchar pb = img[(i + 3)*cols + j];
    uchar pl = img[i*cols + j - 3];

    return cols < pt - pr + pb - pl + i; // just random check so that the optimizer doesn't skip any calculations
}

Estoy usando Visual Studio 2013 y la optimización está configurada en "Optimización completa (/ Ox)".

Que yo sepa, ¿el algoritmo FAST pasa por todos los píxeles? Supongo que no es posible que realmente procese cada píxel más rápido que la funcióninspectPoint().

¿Cómo es tan rápido el detector FAST? O más bien, ¿por qué el bucle anidado es tan lento?

Respuestas a la pregunta(1)

Su respuesta a la pregunta