Trying to build a test with Opencv and QT












1














Recently build OPENCV 3.4.3 with CMAKE 3.12.4 and MINGW64(32bit) 8.1.0 in Windows 7. Have QT 5.6 and i trying to test this build as QT Console App, but when i compiling with QT only get the message "Press "RETURN" to close this window...".



.PRO file:



CONFIG += c++11
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
OTHER_FILES += test.png
INCLUDEPATH += C:UsersTestDesktopopencvbuildinclude
LIBS += C:UsersTestDesktopmingwbinlibopencv_*.dll


main.cpp:



#include <QCoreApplication>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"

using namespace std;

int main(int argc, char *argv) {
QCoreApplication a(argc, argv);
cout << "Hello World!" << endl;
cv::Mat mat;
mat = cv::imread("test.png");
cvNamedWindow("hello");
cv::imshow("hello",mat);
return a.exec();
}


What im doing wrong?










share|improve this question
























  • The usual problem -- imshow without waitKey.
    – Dan Mašek
    Nov 12 '18 at 16:34
















1














Recently build OPENCV 3.4.3 with CMAKE 3.12.4 and MINGW64(32bit) 8.1.0 in Windows 7. Have QT 5.6 and i trying to test this build as QT Console App, but when i compiling with QT only get the message "Press "RETURN" to close this window...".



.PRO file:



CONFIG += c++11
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
OTHER_FILES += test.png
INCLUDEPATH += C:UsersTestDesktopopencvbuildinclude
LIBS += C:UsersTestDesktopmingwbinlibopencv_*.dll


main.cpp:



#include <QCoreApplication>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"

using namespace std;

int main(int argc, char *argv) {
QCoreApplication a(argc, argv);
cout << "Hello World!" << endl;
cv::Mat mat;
mat = cv::imread("test.png");
cvNamedWindow("hello");
cv::imshow("hello",mat);
return a.exec();
}


What im doing wrong?










share|improve this question
























  • The usual problem -- imshow without waitKey.
    – Dan Mašek
    Nov 12 '18 at 16:34














1












1








1







Recently build OPENCV 3.4.3 with CMAKE 3.12.4 and MINGW64(32bit) 8.1.0 in Windows 7. Have QT 5.6 and i trying to test this build as QT Console App, but when i compiling with QT only get the message "Press "RETURN" to close this window...".



.PRO file:



CONFIG += c++11
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
OTHER_FILES += test.png
INCLUDEPATH += C:UsersTestDesktopopencvbuildinclude
LIBS += C:UsersTestDesktopmingwbinlibopencv_*.dll


main.cpp:



#include <QCoreApplication>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"

using namespace std;

int main(int argc, char *argv) {
QCoreApplication a(argc, argv);
cout << "Hello World!" << endl;
cv::Mat mat;
mat = cv::imread("test.png");
cvNamedWindow("hello");
cv::imshow("hello",mat);
return a.exec();
}


What im doing wrong?










share|improve this question















Recently build OPENCV 3.4.3 with CMAKE 3.12.4 and MINGW64(32bit) 8.1.0 in Windows 7. Have QT 5.6 and i trying to test this build as QT Console App, but when i compiling with QT only get the message "Press "RETURN" to close this window...".



.PRO file:



CONFIG += c++11
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
OTHER_FILES += test.png
INCLUDEPATH += C:UsersTestDesktopopencvbuildinclude
LIBS += C:UsersTestDesktopmingwbinlibopencv_*.dll


main.cpp:



#include <QCoreApplication>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"

using namespace std;

int main(int argc, char *argv) {
QCoreApplication a(argc, argv);
cout << "Hello World!" << endl;
cv::Mat mat;
mat = cv::imread("test.png");
cvNamedWindow("hello");
cv::imshow("hello",mat);
return a.exec();
}


What im doing wrong?







c++ qt opencv mingw-w64






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 13:16

























asked Nov 12 '18 at 13:11









Siewdass Sf

396




396












  • The usual problem -- imshow without waitKey.
    – Dan Mašek
    Nov 12 '18 at 16:34


















  • The usual problem -- imshow without waitKey.
    – Dan Mašek
    Nov 12 '18 at 16:34
















The usual problem -- imshow without waitKey.
– Dan Mašek
Nov 12 '18 at 16:34




The usual problem -- imshow without waitKey.
– Dan Mašek
Nov 12 '18 at 16:34












1 Answer
1






active

oldest

votes


















2














Imo the problem is not in your code, I just run it (using Qt5.5, Win10, openCV 4 and mingw64), even if I had to change cvNamedWindow to cv::namedWindow.
I have two hints:




  • did you build openCV with mingw64? If not, do so.

  • are the openCV dlls in the path when you run the application? You can also copy all opencv dlls in the program folder to check that quickly...






share|improve this answer





















  • Omg i forgot that x.x now, it works i get this error. "error assertion failed (size.width 0 && size.height 0)" but i resolve it with this: stackoverflow.com/questions/31341845/… thanks!!!!
    – Siewdass Sf
    Nov 12 '18 at 14:12











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53262907%2ftrying-to-build-a-test-with-opencv-and-qt%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Imo the problem is not in your code, I just run it (using Qt5.5, Win10, openCV 4 and mingw64), even if I had to change cvNamedWindow to cv::namedWindow.
I have two hints:




  • did you build openCV with mingw64? If not, do so.

  • are the openCV dlls in the path when you run the application? You can also copy all opencv dlls in the program folder to check that quickly...






share|improve this answer





















  • Omg i forgot that x.x now, it works i get this error. "error assertion failed (size.width 0 && size.height 0)" but i resolve it with this: stackoverflow.com/questions/31341845/… thanks!!!!
    – Siewdass Sf
    Nov 12 '18 at 14:12
















2














Imo the problem is not in your code, I just run it (using Qt5.5, Win10, openCV 4 and mingw64), even if I had to change cvNamedWindow to cv::namedWindow.
I have two hints:




  • did you build openCV with mingw64? If not, do so.

  • are the openCV dlls in the path when you run the application? You can also copy all opencv dlls in the program folder to check that quickly...






share|improve this answer





















  • Omg i forgot that x.x now, it works i get this error. "error assertion failed (size.width 0 && size.height 0)" but i resolve it with this: stackoverflow.com/questions/31341845/… thanks!!!!
    – Siewdass Sf
    Nov 12 '18 at 14:12














2












2








2






Imo the problem is not in your code, I just run it (using Qt5.5, Win10, openCV 4 and mingw64), even if I had to change cvNamedWindow to cv::namedWindow.
I have two hints:




  • did you build openCV with mingw64? If not, do so.

  • are the openCV dlls in the path when you run the application? You can also copy all opencv dlls in the program folder to check that quickly...






share|improve this answer












Imo the problem is not in your code, I just run it (using Qt5.5, Win10, openCV 4 and mingw64), even if I had to change cvNamedWindow to cv::namedWindow.
I have two hints:




  • did you build openCV with mingw64? If not, do so.

  • are the openCV dlls in the path when you run the application? You can also copy all opencv dlls in the program folder to check that quickly...







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 '18 at 13:29









L.C.

19012




19012












  • Omg i forgot that x.x now, it works i get this error. "error assertion failed (size.width 0 && size.height 0)" but i resolve it with this: stackoverflow.com/questions/31341845/… thanks!!!!
    – Siewdass Sf
    Nov 12 '18 at 14:12


















  • Omg i forgot that x.x now, it works i get this error. "error assertion failed (size.width 0 && size.height 0)" but i resolve it with this: stackoverflow.com/questions/31341845/… thanks!!!!
    – Siewdass Sf
    Nov 12 '18 at 14:12
















Omg i forgot that x.x now, it works i get this error. "error assertion failed (size.width 0 && size.height 0)" but i resolve it with this: stackoverflow.com/questions/31341845/… thanks!!!!
– Siewdass Sf
Nov 12 '18 at 14:12




Omg i forgot that x.x now, it works i get this error. "error assertion failed (size.width 0 && size.height 0)" but i resolve it with this: stackoverflow.com/questions/31341845/… thanks!!!!
– Siewdass Sf
Nov 12 '18 at 14:12


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53262907%2ftrying-to-build-a-test-with-opencv-and-qt%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values