Ask Your Question

Revision history [back]

Use opencv in a simple qt project,when run shows error:'The process was ended forcefully.'

Hi: I install opencv use the 'opencv-4.0.0-alpha-vc14_vc15' follow 'https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows', so I create a new qt project to use it,

here is the .pro:

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets opengl

TARGET = task3 TEMPLATE = app

SOURCES += \ main.cpp

INCLUDEPATH += C:\opencv\build\install\include

LIBS += C:\opencv\build\install\x64\mingw\bin\libopencv_*.dll

and the main.cpp :

include<iostream>

include<opencv2 core.hpp="">

include<opencv2 opencv.hpp="">

include<opencv2 highgui.hpp="">

using namespace cv;

using namespace std;

int main() {

Mat img; int k; string ImgName = "532405845qq.jpg"; VideoCapture cap(0); if (!cap.isOpened()) return 1;

while (1) {
    cap >> img;
    GaussianBlur(img, img, Size(3, 3), 0);
    imshow("1", img);
    k = waitKey(30);
    if (k == 's')//按s保存图片
    {
        imwrite(ImgName, img);
        ImgName.at(0)++;
        img.release();
    }
    else if (k == 27)//Esc键
        break;
}

return 0;

}

when I run the project, I app now show,and shows the error: The process was ended forcefully. I had add the 'C:\opencv\build\install\x64\mingw\lib' to the enviroment path, I have no idea now, please helo me, thanks a lot!