Детектор OpenCV FAST

В моемmain.cpp У меня есть выдержка:

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();
    ...
}

мой файл говорит:

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

Так что можно ожидать, чтоinspectPoint() это функция, которая на самом деле делает что-то.

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
}

Я использую Visual Studio 2013, и для оптимизации задано значение «Полная оптимизация (/ Ox)».

Насколько я знаю, алгоритм FAST проходит через все пиксели? Я полагаю, невозможно, чтобы он обрабатывал каждый пиксель быстрее, чем функцияinspectPoint().

Как быстро FAST детектор? Вернее, почему вложенный цикл такой медленный?

Ответы на вопрос(1)

Ваш ответ на вопрос