I don't know what is the directory structure of OpenCV 2.3, but in general you need to specify the path to include directories in INCLUDEPATH variable in .pro file. So if in your code you write
#include <opencv2.3/core/core.hpp>
#include <opencv2.3/core/core.hpp>
To copy to clipboard, switch view to plain text mode
and the file "core.hpp" is in (for example) "C:/OpenCV2.3/include/opencv2.3/core" directory, then make sure INCLUDEPATH contains "C:/OpenCV2.3/include" directory.
This is just an example, you need to check the actual paths to your files on disk.
Added after 1 44 minutes:
Looks like including and linking to OpenCV libraries can be problematic, so here is a simple how-to. It will work only on 32 bit Windows system, with MinGW g++ compiler. We are going to keep things as simple as possible:
1) download OpenCV 2.3 "superpack"
2) double click, extract to : C:\ (it will make OpenCV2.3 subfolder automatically)
3) use the following main.cpp and .pro files:
// main.cpp
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
int main(){
cv::Mat image = cv::imread("test.jpg");
cv::namedWindow("My Image");
cv::imshow("My Image", image);
cv::waitKey(-1);
return 0;
}
// main.cpp
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
int main(){
cv::Mat image = cv::imread("test.jpg");
cv::namedWindow("My Image");
cv::imshow("My Image", image);
cv::waitKey(-1);
return 0;
}
To copy to clipboard, switch view to plain text mode
// project.pro
TEMPLATE = app
QT -= gui
TARGET = SimpleCvApp
SOURCES += main.cpp
INCLUDEPATH += C:/OpenCV2.3/opencv/modules/core/include \
C:/OpenCV2.3/opencv/modules/highgui/include
# you can put the opencv .dll files where you want, this is where they are by default
# if you want to use different compiler or architecture, look for the libraries for your configuration in "OpenCV2.3/build" subfolder
LIBS += -L"C:/OpenCV2.3/build/x86/mingw/bin"
LIBS += -lopencv_core230 -lopencv_highgui230
// project.pro
TEMPLATE = app
QT -= gui
TARGET = SimpleCvApp
SOURCES += main.cpp
INCLUDEPATH += C:/OpenCV2.3/opencv/modules/core/include \
C:/OpenCV2.3/opencv/modules/highgui/include
# you can put the opencv .dll files where you want, this is where they are by default
# if you want to use different compiler or architecture, look for the libraries for your configuration in "OpenCV2.3/build" subfolder
LIBS += -L"C:/OpenCV2.3/build/x86/mingw/bin"
LIBS += -lopencv_core230 -lopencv_highgui230
To copy to clipboard, switch view to plain text mode
4) cd to the project folder, run qmake && make
5) place test.jpg in the project folder
6) run debug\SimpleCvApp.exe (or release\SimpleCvApp.exe, depends on what version you compile)
Bookmarks