Click here to Skip to main content
15,885,546 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...)

in TestingOpenCV.pro
#-------------------------------------------------
#
# Project created by QtCreator 2013-05-12T21:20:01
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = TestingOpenCV
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp \
    testing.cpp

HEADERS  += mainwindow.h \
    testing.h

FORMS    += mainwindow.ui



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

LIBS += -LC:\\OpenCV-2.3.1\\mybuild\\lib\\Debug \
        -lopencv_core231d\
        -lopencv_highgui231d\
        -lopencv_imgproc231d\
        -lopencv_features2d231d\
        -lopencv_calib3d231d

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;

Testing::Testing()
{
}

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(! image.data)                      // 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:
CSS
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...
Posted
Updated 12-May-13 20:30pm
v2
Comments
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