OpenCV library in QT Creator
-
Hello, i am new to QT and my job requires me to use opencv for some project. Right now i am having trouble setting up a simple hello world using opencv. This is my current setup
OS:Windows10
QT 5.15.0, Opencv 4.4.0, mingw810_64#include "opencv2/opencv.hpp" #include "opencv2/highgui/highgui.hpp" #include <opencv2/core/types_c.h> using namespace cv; int main() { //create a gui window: namedWindow("Output",1); //initialize a 120X350 matrix of black pixels: Mat output = Mat::zeros( 120, 350, CV_8UC3 ); //write text on the matrix: putText(output, "Hello World :)", cvPoint(15,70), FONT_HERSHEY_PLAIN, 3, cvScalar(0,255,0), 4); //display the image: imshow("Output", output); //wait for the user to press any key: waitKey(0); return 0; }
I get a blank screen with no hello world output. Build seems to work fine
The process "C:\Qt\Tools\mingw810_64\bin\mingw32-make.exe" exited normally.
When i run the program however, i get this.
C:\Users\Shane\Desktop\Project Files\build-Test2-Desktop_Qt_5_15_0_MinGW_64_bit-Debug\debug\Test2.exe exited with code -1073741515
Debugger works fine on simple programs without the need for opencv library. Debugger doesn't work at all on this opencv code.
This is my .pro file
Oh and btw, when i tried running the .exe file without qt creator, it says i have missing dll files. Don't know if this information will be useful but yeah.
-
@Shane00 said in OpenCV library in QT Creator:
namedWindow
you're not using Qt at all, neither Gui components nor core elements, nor an event loop, this is pure opencv
So I would suggest asking in their forum for help. The number of people than use the opencv-gui part are rather sparse in a Qt-Forum
I'm assuming of course, so anyone feel free to correct me :) -
@J-Hilk Not quite sure why i need QT either. My company asked me to use it because of cross platform portability. Anyways i have managed to remedy the problem. I just needed to type setx -m OPENCV_DIR C:\OpenCV\Build\x64\vc14 at the command line. Not quite sure why that made it happen but its working now. Thanks anyways.
-
@Shane00 said in OpenCV library in QT Creator:
Not quite sure why that made it happen but its working now. Thanks anyways
that added opencv to the environment path, and generally a bad idea, especially if you don't know what you're doing 😉
My company asked me to use it because of cross platform portability.
Qt is generally known, for cross platform GUI framework, opencv is generally know for its image processing.
You can combine these, do the processing in opencv do the Gui in Qt. And it's probably what your company want you to do ;)
-
-
@Shane00 said in OpenCV library in QT Creator:
its working now
great, please don't forget to mark your post as solved!