Beginner Q - declared variable in header, but doesn't register in .cpp file



  • I was following a tutorial from here:
    "youtube vid":http://www.youtube.com/watch?v=0ONxIy8itRA

    When I run it, I get a lot of undeclared identifiers.

    This is a condensed version of the code,
    In my header file I have: (dialog.h)
    @#ifndef DIALOG_H
    #define DIALOG_H

    #include <QTCore>
    #include <QDialog>

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

    private:
    cv::Mat matOriginal; // these 2 variables get "undeclared identifier" error in cpp file.
    cv::Mat matProcessed;
    @

    in my dialog.cpp file:
    @#include "dialog.h"
    #include "ui_dialog.h"
    #include <QtCore>
    #include <opencv2\opencv.hpp>
    #include "opencv2/imgproc/imgproc.hpp"
    #include "opencv2/highgui/highgui.hpp"

    void Dialog::processFrameandUpdateGUI() {
    cv::inRange(matOriginal, cv::Scalar(0,0,175), Scalar(100,100,256), matProcessed);
    cv::GaussianBlur(matProcessed, matProcessed, cv::Size(9,9), 1.5);
    @

    The last 2 lines is where I get an undeclared identifier error in matOriginal and matProcessed. This is happening to all the variables in my program, so I think I'm doing something fundamentally wrong.

    From what I can tell, the variables are being declared in the header file, which is linked to the cpp file, where I use the variable. Anybody have any suggestions? Thanks



  • Hi dumpsta, why are you using cv:: before every type? Is there a "cv" class that you want to use? If the opencv libraries you are using has this type declared, then you don't need to use cv:: before your types.

    Have you tried it without that?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.