Click here to Skip to main content
14,836,361 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, basically I'm starting learning on how to writing c++ code using openCV to load an image in QT creator tool.

for your information, I create a project called TestingOpenCV, with several .cpp and .hfile :
- .h file:
--- mainwindow.h
--- testing.h
- .cpp file
--- main.cpp
--- mainwindow.cpp
--- testing.cpp (problem occur here...)

# Project created by QtCreator 2013-05-12T21:20:01

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = TestingOpenCV

SOURCES += main.cpp\
        mainwindow.cpp \

HEADERS  += mainwindow.h \

FORMS    += mainwindow.ui

INCLUDEPATH += C:\\OpenCV-2.3.1\\opencv\\build\\include

LIBS += -LC:\\OpenCV-2.3.1\\mybuild\\lib\\Debug \

in testing.cpp (error here...)
#include "testing.h"

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

using namespace cv;


void Testing::activateTextingFunction()
    string address = .... // state the address to retrieve the image1
    string imgFile = address + "image1.jpg";

/*     E R R O R     H E R E . . .     */
    Mat image;
    image = imread(imgFile, CV_LOAD_IMAGE_COLOR); // Read the file

    if(!                      // Check for invalid input
        cout <<  "Could not open or find the image" << endl;

    namedWindow( "Display window", WINDOW_AUTOSIZE ); // Create a window for display.
    imshow( "Display window", image );                // Show our image inside it.

    waitKey(0); // Wait for a keystroke in the window
/*     E N D     O F     E R R O R     */

although I build this program with no error, However, when I run this program...

it state that:
Starting C:\Users\user\Desktop\Qt_Stuff\build-TestingOpenCV-Desktop_Qt_5_0_2_MSVC2010_32bit-Debug\debug\TestingOpenCV...

The program has unexpectedly finished.

C:\Users\user\Desktop\Qt_Stuff\build-TestingOpenCV-Desktop_Qt_5_0_2_MSVC2010_32bit-Debug\debug\TestingOpenCV exited with code -1073741515

Please... can anyone help me to solve this problem ?
I have try to search all the website base on such problem... however, I find no solution for that problem...
Can anyone help me on how to solve this problem ?

your kindness and helpfulness is very much appreciated...
Updated 12-May-13 20:30pm
Malli_S 14-May-13 3:34am
Try putting Try-Catch around the suspected code. Or use the OpenCV error handling mechanism to catch the error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900