Undeclared identifier CV in opencv4.2.0_ WINDOW_ AUTOSIZE

environment : OpenCV 4.2.0

#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"

#include <iostream>
#include <stdio.h>

using namespace std;
using namespace cv;

//......

    /// 创建窗口
    namedWindow("Source Image", CV_WINDOW_AUTOSIZE);
    
    //......

    /// 对于方法 SQDIFF 和 SQDIFF_NORMED, 越小的数值代表更高的匹配结果. 而对于其他方法, 数值越大匹配越好
    if (match_method == CV_TM_SQDIFF || match_method == CV_TM_SQDIFF_NORMED)
    {
        //......
    }

error :

“CV_WINDOW_AUTOSIZE” : undeclared identifier.

“CV_TM_SQDIFF_NORMED” : undeclared identifier.

reason :

opencv4 partial naming changes, change CV_WINDOW_AUTOSIZE to WINDOW_AUTOSIZE; CV_TM_SQDIFF_NORMED is changed to TM_SQDIFF_NORMED.

Read More: