c++ - Simple OpenCV Program crashes -
i having problem. following instructions given in book "opencv 2 computer vision application programming cookbook" creating simple image display program in opencv (2.4.10-1) using qt(5.4), qtcreator in ubuntu 14.04.
the code follows:
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> int main() { // read image cv::mat image = cv::imread("${path_to_home}/pictures/bottle_label.jpg"); if ( image.data == null ) { std::cout << "no data loaded" << std::endl; return -1; } else { // create image window named "my image" cv::namedwindow("my image", 1); // show image on window std::cout << "image loaded" << std::endl; cv::imshow("my image", image); // wait key 5000 ms cv::waitkey(5000); return 0; } }
and contents in .pro file
# standard .pro content qt console application # includepath += /usr/local/include/ libs += -l/usr/local/lib \ -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_features2d -lopencv_calib3d
the code compiles, when run program crashes immediately. debugger points sigsegv occurring in line 17: cv::namedwindow("my image", 1) don't know do. have other programs use qt , opencv libraries in same computer used cmake (qt4 macros) build them , run fine. have wrote similar test program using cmake , new qt5 macros in cmakelist.txt file. program has mainwindow 2 buttons: first opens image selected fileopendialog , second flips image. both images should display using cv::imshow() function. again program compiles, when run it crashes immediately. debugger not points particular line in code. output in console is:
*** error in `${path_to_exec_file}/myguiapp': realloc(): invalid pointer: 0x00007ffff6d840e0 ***
the same console output delivered above mentioned code. please point out problem is?
thank in advance
Comments
Post a Comment