Ask Your Question
0

My simple code doesnt work, it says CV_WINDOWS_NORMAL is an undeclared identifier, what should I do, is there some other lib that I need to include?

asked 2019-10-29 09:23:35 -0600

updated 2019-10-29 11:15:24 -0600

supra56 gravatar image

Code:

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

#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

using namespace std;
using namespace cv;

int main(int argc, char** argv)
{

    VideoCapture capture(0);

    if (argc == 1 && capture.isOpened() == false)
    {
        cerr << "Cannot capture images from the web camera ..." << endl;
        return -1;
    }

    namedWindow("original", CV_WINDOW_NORMAL);
    namedWindow("processed", CV_WINDOW_NORMAL);
    namedWindow("blurred", CV_WINDOW_NORMAL);

    Mat frame;
    Mat grayImage;
    Mat processedImage;
    Mat bluredImage = frame;
    //bluredImage = Scalar::all;
    for (int keyCode = -1; keyCode < 0; )
    {
        if (argc == 1)
            capture >> frame;
        else
            frame = imread(argv[1], CV_LOAD_IMAGE_COLOR);

        if (frame.empty() == true)
            break;

        cvtColor(frame, grayImage, CV_BGR2GRAY);

        //TODO: Add the selected image processing function calls ...
        cvtColor(frame, processedImage, CV_BGR2GRAY); // This should be replaced!

        medianBlur(frame, bluredImage, 3);

        imshow("original", frame);
        imshow("processed", processedImage);
        imshow("blurred", bluredImage);


        if (argc == 1)
            keyCode = waitKey(10) % 256;
        else
            keyCode = waitKey(0) % 256;
    }



    destroyWindow("original");
    destroyWindow("processed");
}
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2019-10-29 10:36:57 -0600

mvuori gravatar image

According to documentation, it should be WINDOW_NORMAL

edit flag offensive delete link more
0

answered 2019-10-29 10:35:24 -0600

berak gravatar image

updated 2019-10-29 10:36:24 -0600

is there some other lib that I need to include?

no, you're trying with outdated 2.4 code, a lot of constants were renamed, e.g it is:

CV_WINDOW_NORMAL -> cv::WINDOW_NORMAL

CV_LOAD_IMAGE_COLOR -> cv::IMREAD_COLOR

CV_BGR2GRAY -> cv::COLOR_BGR2GRAY

please try to use current docs in the future.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-10-29 09:23:35 -0600

Seen: 912 times

Last updated: Oct 29 '19