P
P
parkito2016-04-12 15:07:49
C++ / C#
parkito, 2016-04-12 15:07:49

How to overcome openCV error?

Hello. I am trying to compile the following code

#include <opencv/cv.h>
#include <opencv2/highgui/highgui.hpp>
int main(int argc, char **argv) {
    // задаём высоту и ширину картинки
    int height = 620;
    int width = 440;
    // задаём точку для вывода текста
    CvPoint pt = cvPoint(height / 4, width / 2);
    // Создаёи 8-битную, 3-канальную картинку
    IplImage *hw = cvCreateImage(cvSize(height, width), 8, 3);
    // заливаем картинку чёрным цветом
    cvSet(hw, cvScalar(0, 0, 0));
    // инициализация шрифта
    CvFont font;
    cvInitFont(&font, CV_FONT_HERSHEY_COMPLEX, 1.0, 1.0, 0, 1, CV_AA);
    // используя шрифт выводим на картинку текст
    cvPutText(hw, "OpenCV Step By Step", pt, &font, CV_RGB(150, 0, 150));
//
    // создаём окошко
 
     cvNamedWindow("Hello World", 0);
    // показываем картинку в созданном окне
    cvShowImage("Hello World", hw);
    // ждём нажатия клавиши
    cvWaitKey(0);

    // освобождаем ресурсы
    cvReleaseImage(&hw);
    cvDestroyWindow("Hello World");
    return 0;
}

However, an error occurs
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/parkito/opencv-3.1.0/opencv/modules/highgui/src/window.cpp, line 527
terminate called after throwing an instance of 'cv::Exception'

Although libgtk2.0-dev, pkg-config are installed.
Google suggests rebuilding openCV with the -D WITH_GTK=ON option , but that didn't help either.
ubuntu system 15.10, clion 2016.1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Klimkin, 2016-04-13
@klimkin3teers

Try to install like here .
Further, in the development environment, you need to set the paths to the header and library files in the compiler settings. -> usr/local/include/opencv , usr/local/include/opencv2 and usr/local/lib
and specify the required libraries (I specify everything in the folder at once).
If it costs codeblocks, I can show you in detail

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question