Identifiers not found: createHanningWindow and phaseCorrelate

asked 2014-07-31 13:10:06 -0600

Pringles gravatar image

updated 2014-07-31 13:20:24 -0600

#include "opencv2/core/core.hpp"

#include "opencv2/highgui/highgui.hpp"

#include "opencv2/imgproc/imgproc.hpp"

using namespace cv;

int main(int, char* [])

{

// Создание видеопотока с камеры
VideoCapture video(0);
Mat frame, curr, prev, curr64f, prev64f, hann;
int key = 0;

do
{
    video >> frame; // Очередной фрейм
    cvtColor(frame, curr, CV_RGB2GRAY); // Перевод в градации серого

    if(prev.empty())
    {
        prev = curr.clone(); // клонирование изображения
        createHanningWindow(hann, curr.size(), CV_64F); // Создание окна Ханна
    }

    prev.convertTo(prev64f, CV_64F); 
    curr.convertTo(curr64f, CV_64F);

    Point2d shift = phaseCorrelate(prev64f, curr64f, hann); // Фазовая корреляция
    double radius = cv::sqrt(shift.x*shift.x + shift.y*shift.y); // Вычисление радиуса отклонения

    if(radius > 5)
    {
        // вывод на экран окружности и направления смещения
        Point center(curr.cols >> 1, curr.rows >> 1);
        cv::circle(frame, center, (int)radius, cv::Scalar(0, 255, 0), 3, CV_AA);
        cv::line(frame, center, Point(center.x + (int)shift.x, center.y + (int)shift.y), cv::Scalar(0, 255, 0), 3, CV_AA);
    }

    imshow("phase shift", frame);
    key = waitKey(2);

    prev = curr.clone();
} while((char)key != 27); // Esc to exit...

return 0;

}

Hi all. I tried to compile this demo, but something went wrong. Visual Studio said that it couldn't find the identifier "createHanningWindow" and "phaseCorrelate". Help me please, what is the problem.

edit retag flag offensive close merge delete

Comments

weird. both should be in imgproc.hpp

berak gravatar imageberak ( 2014-07-31 14:54:21 -0600 )edit

On one of the forums I was told that trouble can be in the version of OpenCV. They say that these functions appeared just in 2.4.0 version, and I have 2.3.1. Can it be the reason of problem?

Pringles gravatar imagePringles ( 2014-08-01 09:17:01 -0600 )edit

yes, that's the most likely explanation.

berak gravatar imageberak ( 2014-08-01 09:44:52 -0600 )edit