How to create a Toolbar in Opencv 2.4.9 with Qt - c++

I'm trying to follow this exemple but I'm stuck where the documentation don't show how to actually create the toolbar they're showing ...
(I'm working on Visual Studio 2013 with OpenCV 2.4.9 on a 64bit based aplication)
Am I missing something ?
EDIT : Here's a picture of the Toolbar(left), next to a Trackbar.
Please, if there is still confusion, tell me before downvoting so I can explain more.

You can't create a toolbar. The toolbar is created automatically by the OpenCV highgui module in every "NamedWindow" if OpenCV is compiled with Qt support. If you can't see this toolbars you should re-build OpenCV with Qt support. To do so, build OpenCV from source (by using CMAKE) and make sure the option WITH_QT is set.
If you build OpenCV with CMAKE GUI you can find this option in the configuration menu:
One thing you should have in mind is that OpenCV won't allow you to modify the toolbars as it does with the TrackBar or the NamedWindow.

I had the same problem and now solved it after 2 days :D
I'm using OSX 10.9 with opencv 2.4.9 installed with brew and Qt Creator.
The Problem is the installation in brew. To see the toolbar you have to install -- with qt.
write in terminal (with brew) to install opencv (uninstall if opencv is already installed)
brew install opencv --with-qt
Now you can use the toolbar in Xcode or
in QT Creator, create for instants QT widget App and add in the *.pro file:
QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
LIBS += -L/usr/local/lib
LIBS += \
-lopencv_calib3d \
-lopencv_contrib \
-lopencv_core \
-lopencv_flann \
-lopencv_gpu \
-lopencv_highgui \
-lopencv_imgproc \
-lopencv_legacy \
-lopencv_ml \
-lopencv_objdetect \
-lopencv_ocl \
-lopencv_photo \
-lopencv_stitching \
-lopencv_superres \
-lopencv_ts \
-lopencv_video \
-lopencv_videostab
-lopencv_nonfree
INCLUDEPATH += /usr/local/include/opencv \
/usr/include/opencv \
/usr/local/include
DEPENDPATH += /usr/local/include/opencv/include

Related

opencv2/calib3d.hpp : No suh file or directory (How to link opencv to qt correcttly)

I installed opencv 3.4.0-dev and I want to use it with QT.
In the .pro I added :
LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui -lopencv_calib3d
INCLUDEPATH += /usr/local/include/opencv
but i still have the error
opencv2/calib3d.hpp : No such file or directory
(I also try with highgui, imgcedexs, core, same error)
Any idea to fix it ?
Thank you in advance.
As you've figured by yourself, the opencv header path is now nested in /usr/local/include/opencv4.
As for the error you've flagged in the comment, ximgproc is a contrib module and should be added manually. You therefore need to build OpenCV from source or find a pre-built package that has the contrib modules built in.
This question and this OpenCV doc page answers how to build OpenCV with the contrib modules.
I fixed it by installing following:
sudo apt install libopencv-calib3d-dev

dlib and Qt: building errors

I have installed dlib to have the static library in my computer and i want to use it in a Qt project but the problem is, once the dlib library is linked to my project i can build it and display simple matrix from dlib namespace but if i try to define a deep learning network i got the following error.
/home/jimmy/Desktop/Connected_Robotics_Watson/workco/work/mainWindow.cpp:-1: error: undefined reference to `dlib::cpu::pooling::pooling()'
i am really lost on how to use with Qt.
Here is my .pro file:
QT += network
QT += widgets
TEMPLATE = app
TARGET = Connected
INCLUDEPATH += /usr/local/include
LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui
-lopencv_imgcodecs -lopencv_videoio
QMAKE_CXXFLAGS += -std=c++11
PKGCONFIG = dlib-1
# Input
HEADERS += mainWindow.hpp
SOURCES += main.cpp mainWindow.cpp
If i use the library with normal cpp code and use a cmake to compile, evrything works well.
Does someone have an idea on this problem?

symbol(s) not found for architecture x86_64 with Qt and OpenCV

I am working on a desktop application with the Qt and OpenCV on my mac. I have installed both qmake on version 5.3.2(currently used) and 4.6.8 , OpenCV 2.4.9 , I use the GCC compiler, my Qt version is 5.3.2, Qt creator version is 3.2.2.
Previously I have a Qt project previously run on a Ubuntu, now it migrates to the mac, the only change is just on the .pro, in which the INCLUDEPATH and LIB path must change to the include and lib path of OpenCV in the mac.
Here is my configuration.
INCLUDEPATH += /usr/local/Cellar/opencv/2.4.9/include
LIBS += -L/usr/local/Cellar/opencv/2.4.9/lib \
-lopencv_core \
-lopencv_highgui \
-lopencv_imgproc \
-lopencv_video \
-lopencv_objdetect \
-lopencv_ml \
-lopencv_features2d
/usr/local/Cellar/opencv/2.4.9/include and /usr/local/Cellar/opencv/2.4.9/lib are the exact location for the opencv. There should be no reason to have this error, since the opencv libraries are all there and should be linked in the right format.
right now I could not figure out how and why

libgcc_s_sjlj-1.dll is missing in Qt 5.1

My program won't start, complaining that libgcc_s_sjlj-1.dll is needed. However, this file doesn't exist in Qt directory. I did some search and found that -static-libgcc and -static-libstdc++ should be added. So here is my .pro file:
QT += core gui xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = mouseEventProcess
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
fileOp.cpp \
xmlpraser.cpp \
pixmapOp.cpp \
mathOp.cpp
HEADERS += mainwindow.h \
fileOp.h \
xmlpraser.h \
pixmapOp.h \
mathOp.h
FORMS += mainwindow.ui
#COMPILE LIBGCC_S_SJLJ-1.DLL AND LIBSTDC++-6.DLL INTO THE EXE FILE
win32{
QMAKE_LFLAGS += -static-libgcc
QMAKE_LFLAGS += -static-libstdc++
#BOOST LIBRARIES. CHANGE TO YOUR OWN.
INCLUDEPATH += D:/boost_1_51_0
#OPENCV LIBRARIES. CHANGE TO YOUR OWN.
INCLUDEPATH += D:/opencv2.4.4/include
INCLUDEPATH += D:/opencv2.4.4/release/install/include
LIBS += -LD:/opencv2.4.4/release/install/lib \
-lopencv_core244 \
-lopencv_highgui244 \
-lopencv_imgproc244
#-lopencv_features2d244 \
#-lopencv_calib3d244
}
unix{
#BOOST LIBRARIES. CHANGE TO YOUR OWN.
INCLUDEPATH += /home/panda/boost_1_51_0
#OPENCV LIBRARIES.IF YOU COMPILED AND INSALLED
#OPENCV FROM CMAKE & MINGW, JUST LEAVE IT BE,
#UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING.
INCLUDEPATH += /usr/local/include/opencv
INCLUDEPATH += /usr/local/include/opencv2
LIBS += -lopencv_core -lopencv_imgproc -lopencv_highgui
LIBS += -lopencv_ml -lopencv_video -lopencv_features2d
LIBS += -lopencv_calib3d -lopencv_objdetect -lopencv_contrib
LIBS += -lopencv_legacy -lopencv_flann
}
If this works, neither libgcc_s_sjlj-1.dll and libstdc++-6.dll is needed. However, the program still needs libstdc++-6.dll before I put it into .exe folder.
So my question is: Where can I get libgcc_s_sjlj-1.dll or is there any problem in my .pro file?
Bah, I am stupid. Your 'my program lacks libgcc_s_sjlj-1.dll, not libgcc_s_dw2-1.dll' should have rung a bell.
You compile with the wrong MinGW. There are several different exception handler for MinGW available: sjlj, dwarf, seh. Dwarf is 32bin only. When you have the libgcc_s_dw2-1.dll it means, you have a 32bit only MinGW installed.
You must compile your programs with the same MinGW, which was used to compile your Qt. The sjlj MinGW works for 32bit and 64bit so I suppose it makes sense that the qt-project provides binary packages, which were compiled with sjlj-MinGW.
There are some MinGW packages available, which allow you to choose, which exception handling mechanism you will use. Best choice is probably to use the MinGW, which is bundled in the Qt 5.1.1 installer packages.

OpenCV C++ - Windows IDEs

I'd like to start using OpenCV for C++ on Windows after a bunch of OpenCV4Android work. From this forum post, it seems that not all C++ IDEs have equivalent capabilities to display OpenCV images, since some do not have an integrated GUI plugin. Are there any differences between IDEs in terms of OpenCV functionality that I should be aware of?
Go with Qt Creator. It's a cross-platform IDE for C/C++ development that supports the Qt framework. When you move to Linux/Mac you can continue to use Qt Creator to develop your projects.
It's an IDE that you'll spent a day or two to master, and it will be useful for the rest of your career.
Qt Creator uses a .pro file to configure the project. The instructions on this file are used to build all the Makefiles needed to build the .exe.
This is the .pro file I use to build my Qt Creator projects on Windows/Mac/Linux:
TEMPLATE = app
SOURCES += \
main.cpp \
cvImage.cpp
HEADERS += \
cvImage.h
## OpenCV settings for Unix/Linux
unix:!mac {
message("* Using settings for Unix/Linux.")
INCLUDEPATH += /usr/local/include/opencv
LIBS += -L/usr/local/lib/ \
-lopencv_core \
-lopencv_highgui \
-lopencv_imgproc
}
## OpenCV settings for Mac OS X
macx {
message("* Using settings for Mac OS X.")
INCLUDEPATH += /usr/local/include/opencv
LIBS += -L/usr/local/lib/ \
-lopencv_core \
-lopencv_highgui \
-lopencv_imgproc
}
## OpenCV settings for Windows and OpenCV 2.4.2
win32 {
message("* Using settings for Windows.")
INCLUDEPATH += "C:\\opencv\\build\\include" \
"C:\\opencv\\build\\include\\opencv" \
"C:\\opencv\\build\\include\\opencv2"
LIBS += -L"C:\\opencv\\build\\x86\\vc10\\lib" \
-lopencv_core242 \
-lopencv_highgui242 \
-lopencv_imgproc242
}