Qt and opencv linux

Ubuntu OpenCV Install and Setup (Qt5 ?)

New Linux user. OS: Ubuntu 14.04 Install: OpenCV 2.4.9 I’m attempting to install OpenCV for use on codeblocks (or other IDE). I’ve followed (or attempted to follow, actually) each and every instruction on the following pages: I first used https://help.ubuntu.com/community/OpenCV including the provided script. Then http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html Finally http://www.samontab.com/web/2012/06/installing-opencv-2-4-1-ubuntu-12-04-lts/ I even saw Add the installation prefix of «Qt5Widgets» to CMAKE_PREFIX_PATH but I’m not even sure what the answer means, let alone if it will work since it apparently didn’t for the Question OP. This is where the errors appear to start in terminal output while running the script:

CMake Warning at cmake/OpenCVFindLibsGUI.cmake:18 (find_package): By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5Core", but CMake did not find one. Could not find a package configuration file provided by "Qt5Core" with any of the following names: Qt5CoreConfig.cmake qt5core-config.cmake Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set "Qt5Core_DIR" to a directory containing one of the above files. If "Qt5Core" provides a separate development package or SDK, be sure it has been installed. Call Stack (most recent call first): CMakeLists.txt:466 (include) CMake Warning at cmake/OpenCVFindLibsGUI.cmake:19 (find_package): By not providing "FindQt5Gui.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5Gui", but CMake did not find one. Could not find a package configuration file provided by "Qt5Gui" with any of the following names: Qt5GuiConfig.cmake qt5gui-config.cmake Add the installation prefix of "Qt5Gui" to CMAKE_PREFIX_PATH or set "Qt5Gui_DIR" to a directory containing one of the above files. If "Qt5Gui" provides a separate development package or SDK, be sure it has been installed. Call Stack (most recent call first): CMakeLists.txt:466 (include) CMake Warning at cmake/OpenCVFindLibsGUI.cmake:20 (find_package): By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5Widgets", but CMake did not find one. Could not find a package configuration file provided by "Qt5Widgets" with any of the following names: Qt5WidgetsConfig.cmake qt5widgets-config.cmake Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or set "Qt5Widgets_DIR" to a directory containing one of the above files. If "Qt5Widgets" provides a separate development package or SDK, be sure it has been installed. Call Stack (most recent call first): CMakeLists.txt:466 (include) CMake Warning at cmake/OpenCVFindLibsGUI.cmake:21 (find_package): By not providing "FindQt5Test.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5Test", but CMake did not find one. Could not find a package configuration file provided by "Qt5Test" with any of the following names: Qt5TestConfig.cmake qt5test-config.cmake Add the installation prefix of "Qt5Test" to CMAKE_PREFIX_PATH or set "Qt5Test_DIR" to a directory containing one of the above files. If "Qt5Test" provides a separate development package or SDK, be sure it has been installed. Call Stack (most recent call first): CMakeLists.txt:466 (include) CMake Warning at cmake/OpenCVFindLibsGUI.cmake:22 (find_package): By not providing "FindQt5Concurrent.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5Concurrent", but CMake did not find one. Could not find a package configuration file provided by "Qt5Concurrent" with any of the following names: Qt5ConcurrentConfig.cmake qt5concurrent-config.cmake Add the installation prefix of "Qt5Concurrent" to CMAKE_PREFIX_PATH or set "Qt5Concurrent_DIR" to a directory containing one of the above files. If "Qt5Concurrent" provides a separate development package or SDK, be sure it has been installed. Call Stack (most recent call first): CMakeLists.txt:466 (include) qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory CMake Error at /usr/share/cmake-2.8/Modules/FindQt4.cmake:1386 (message): Found unsuitable Qt version "" from NOTFOUND, this code requires Qt 4.x Call Stack (most recent call first): cmake/OpenCVFindLibsGUI.cmake:34 (find_package) CMakeLists.txt:466 (include) -- Configuring incomplete, errors occurred! See also "/home/*******/OpenCV/opencv-2.4.9/build/CMakeFiles/CMakeOutput.log". See also "/home/*******/OpenCV/opencv-2.4.9/build/CMakeFiles/CMakeError.log". 

Источник

Читайте также:  Linux mint настройка подключения

Opencv linux qt creator

OpenCV — мощная и развитая библиотека компьютерного зрения с открытым исходным кодом. Если вам понадобилось решить какую-то задачу, связанную с нетривиальной обработкой изображений, то есть большая вероятность, что OpenCV уже предлагает готовое решение.

В этой статье мы соберем и установим OpenCV из исходных кодов под Linux, а затем разработаем тестовое приложение, способное находить лица на фотографии с помощью модуля CascadeClassifier :

Установка OpenCV под Linux

Прежде чем приступать к сборке OpenCV из исходных кодов, рекомендую проверить, что он не доступен в репозиториях вашего дистрибутива Linux. Например, в Archlinux библиотеку OpenCV можно установить следующей командой: Однако даже в этом случае иногда есть смысл сделать сборку OpenCV самому. Основная причина для этого — так вы сможете получить самую последнюю версию как можно раньше (например, при добавлении новых возможностей или исправлении критических ошибок). Поэтому приступим к пошаговой инструкции по сборке OpenCV.

Шаг 1: Получаем исходные коды OpenCV из Git

Шаг 2: Подготавливаем OpenCV к сборке

Шаг 3: Собираем и устанавливаем OpenCV

Если все прошло без ошибок, то процесс сборки и установки OpenCV завершен. Теперь можно перейти в каталог, который мы указали в параметре CMAKE_INSTALL_PREFIX . Там вы должны увидеть примерно такой набор директорий:

Реклама

Разработка Qt-проекта с использованием OpenCV

Начнем с подготовки pro -файла: Для успешной работы с OpenCV в Qt-проекте нужно указать пути, где находятся заголовочные файлы и библиотеки. Например, если мы установили OpenCV в домашнем каталоге: Также не забываем подключать необходимые opencv -библиотеки: Теперь переходим к файлу mainwidget.h : Мы лишь подготовили очень простой виджет, в котором одним из полей является объект класса OpenCV — cv::CascadeClassifier .

Читайте также:  Linux how to enable wifi

Реализация в mainwidget.cpp : Обратите внимание на строку: Здесь мы загружаем классификатор haarcascade_frontalface_default.xml , обученный на распознавание лиц. Найти его можно в каталоге data/haarcascades/ , который расположен в склонированном гит-репозитории OpenCV. Обратите внимание, что этот xml -файл должен находиться в одном каталоге с исполняемым файлом для правильной работы приложения. Следующий важный фрагмент: В этом месте мы и выполняем непосредственное распознавание для загруженной фотографии. «Волшебство» происходит в этой строке: На вход detectMultiScale() получает черно-белое изображение, а возвращает вектор с прямоугольниками, соответствующими всем найденным лицам. Далее мы просто проходим по получившемуся вектору и помечаем все лица на фотографии зеленой рамкой:

Если вы потестируете это приложение подольше, то увидите, что часто встречаются ложные срабатывания (лица находятся там, где их нет). Но решение этой проблемы уже выходит за рамки этой статьи и требует более аккуратного подхода. Источник

Setting up OpenCV in Qt Creator Ubuntu 12.04

I’m trying to set up OpenCV in Qt Creator and I have some problems. I added the OpenCV path in the Qt Creator .pro file And I want to read and show image in this code When I run my project it shows the following message:

Starting /home/vasan/Qt/build-OpenCVWithQt-Desktop-Debug/OpenCVWithQt.
The program has unexpectedly finished.
/home/vasan/Qt/build-OpenCVWithQt-Desktop-Debug/OpenCVWithQt exited with code 0

3 Answers 3

I have also been trying to set up OpenCV for Qt Creator for a few days now. I would recommend you trying the procedure found at

It is simple to follow, and it just WORKS. When you get to section 1.3, run any code sample you got at hand. I used: Your code is correct. I think the problem arise because you are using shadow building. For this reason you should put the image in the shadow building folder (the folder that contains the executable) and not in the project folder (that contains only the code files). Another tip is to insert a return statement in the if case, so program will not quit when it does not find the image. Also, be sure to include the following headers

Not the answer you’re looking for? Browse other questions tagged c++ qt opencv or ask your own question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader. site design / logo © 2020 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2020.9.18.37632

Ubuntu OpenCV Install and Setup (Qt5 ?)

New Linux user. OS: Ubuntu 14.04 Install: OpenCV 2.4.9 I’m attempting to install OpenCV for use on codeblocks (or other IDE). I’ve followed (or attempted to follow, actually) each and every instruction on the following pages: I first used https://help.ubuntu.com/community/OpenCV including the provided script. I even saw Add the installation prefix of «Qt5Widgets» to CMAKE_PREFIX_PATH but I’m not even sure what the answer means, let alone if it will work since it apparently didn’t for the Question OP. This is where the errors appear to start in terminal output while running the script: After prior attempts, I’ve got a folder OpenCV inside Home, with a zip file and folder both named opencv-2.4.9

Читайте также:  Build linux tools package

So «some» things have been done, but not a complete install ready for use. Maybe a simpler explanation of what «»»»»»»»»»»»»(quoted answer from earlier question) This is documented: http://doc-snapshot.qt-project.org/qt5-stable/cmake-manual.html The easiest way to use CMake is to set the CMAKE_PREFIX_PATH environment variable to the install prefix of Qt 5 Do this export CMAKE_PREFIX_PATH=/home/user/Programs/ where references the compiler etc, so that this complete path is valid: /home/user/Programs//bin/qmake «»»»»»»»»»»»»»»* means exactly would solve this. Thanks. (FYI, I can’t/don’t know how to use this because I don’t have programs folder, or even user folder , and the suggested terminal command kicks out an error) Источник

This question must be duplicate many times, but it just doesn’t work and sometimes it still remains unanswered. Sources of information are mainly these
http://www.laganiere.name/opencvCookbook/chap1s1_2.shtml
http://www.youtube.com/watch?v=dgcXYQijV6c This is the summation of what I think one should/can do. (And now it works for me.) Hopefully I mentioned everything from the very beginning, the aim is to write a very clear tutorial.

  1. I have already MS Visual Studio 2010 Professional installed. (I have a free licence as a student) — I think this is not necessary, just a mention
  2. Download: Qt 5.0.1 for Windows 32-bit (MinGW 4.7, 823 MB)
    2.1 Install: Warning, everything that Qt uses (e.g. OpenCV) must be in directories that don’t contain white-spaces in their names. — i.e. «Program Files» is wrong. (But I don’t want different program files to accumulate directly on C, so I’ve only made a folder «Programs» in which everything important is installed)
  3. Download: cmake-2.8.10.2-win32-x86.exe — Install for all users (this can be in Program Files)
  4. Download: OpenCV-2.4.0.exe, extract to: C:\Programs\opencv24 — it’ll create a dir «opencv»; add another folder «opencv_bin». Now it looks like this:
    C:\Programs\opencv24\opencv*
    C:\Programs\opencv24\opencv_bin
  5. Set PATH environment variable, so that there be a link to MinGW compiler. e.g. C:\Programs\Qt\Qt5.0.1\Tools\MinGW\bin;
  6. Start cmake-gui.exe
    6.1 source code: set the default dir for OpenCV; C:\Programs\opencv24\opencv
    6.2 binaries: set the opencv_bin dir; C:\Programs\copencv24\opencv_bin
    6.3 click configure:
    • Choose MinGW Makefiles and Specify native compilers, click next
    • Field C is for gcc.exe; C:/Programs/Qt/Qt5.0.1/Tools/MinGW/bin/gcc.exe
    • Field C++ is for g++.exe; C:/Programs/Qt/Qt5.0.1/Tools/MinGW/bin/g++.exe Field fortran can be empty, click finish

6.4 Many red lines will appear To the search field enter one by one: WITH_QT, WITH_TBB, WITH_IPP, WITH_CUDA, CMAKE_BUILD_TYPE

  • WITH_QT — must be selected.
  • WITH_TBB, WITH_IPP, WITH_CUDA — must be unselected
  • CMAKE_BUILD_TYPE — click and enter a text «Debug» (without quotes). Clear the text from the Search field.

Now I have created a new console app in QtCreator.

Источник

Оцените статью
Adblock
detector