Missing xfeatures2d.hpp in opencv2 folder? - c++

I just installed via cmake (OPENCV_EXTRA_MODULS_PATH) and mingw530 (Qt)
opencv-3.4.2
opencv_contrib-3.4.2
mingw32-make
mingw32-make install
Filestructur is
opencv/source
opencv/build
opencv/release (compile folder)
opencv/contrib
But if I try to insert
#include "opencv2/xfeatures2d.hpp"
it does not find it.
The same problem is already descript here:
http://answers.opencv.org/question/57397/cant-find-xfeatures2dhpp/
But I don't understand the solution
"#Bhatt, on win, you will have to build the INSTALL project. this will copy headers/libs/dlls to your install folder".
My fallback is to insert
#include "E:/PROGRAMS/opencv/opencv_contrib-3.4.2/modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp"
then it works. Can someone explain me what's going wrong?

For who is interested: The equivalent to VS+INSTALL project is mingw32-make install. The clue is the CMAKE_INSTALL_PREFIX in cmake where this files (headers/libs/dlls) are saved. Add to your Qt .pro file INCLUDEPATH += \install\include.

Related

Build c++ Qt CLI Tool with Quazip

so normally I am an embedded software developer first time I need to do something like that... So I am no expert at all at this... I have come this far with a lot of googling and trial and error methods...
What I want to do
I need to write a C++ CLI application which can zip and unzip files.
Quazip
zlib
My general conditions
I want to use Qt and Quazip since Qt doesn't support zipping natively (or does it).
I want to build with Mingw and CMake for Windows 64bit on a Windows 64bit system.
With my knowledge, it would be best if I compile Quazip statically so I don't depend on any other quazip DLL which may be present on other systems...
How I think It works
I need to compile zlib
Then I need to compile Quazip (with zlib)
Link the compiled libraries to my project.
My research
I found two good youtube videos which should help me:
https://www.youtube.com/watch?v=5ZTusMX-Reo
https://www.youtube.com/watch?v=mxlcKmvMK9Q
No of these ways did work out for me.
Also I found that blog post which was a little bit of help...
http://www.antonioborondo.com/2014/10/22/zipping-and-unzipping-files-with-qt/
This site was available till yesterday now it's gone :D
Also I found that old Stackoverflow question which helped me a bit:
How to connect the QuaZip library in CMake
Detailed steps on what I did:
1. Building zlib
Downloaded the latest version of zlib from the official website. version 1.2.11
I build zlib with the following commands:
cd C:/some/Path/zlib-1.2.11
mingw32-make -f win32/Makefile.gcc
That works perfectly I get a
libz.a
libz.dll.a
zlib1.dll
those files and all the header files (11 files) I copy in a seperate folder. Which looks like this:
Build
|
+-include
+-lib
Headers in the include folder the libs in the lib folder.
2. Building Quazip
Now the messy part...
Downloading the newest version of Quazip (version 0.8.1) from the GitHub.
I tried various ways to compile Quazip. The one I stick to was:
Open the .pro file in Qt creator inside the quazip folder (the folder where the sources are located).
So then I added the compiled zlib to the Qmake file.
Following lines I added at the end of the file:
INCLUDEPATH += "C:/Build/include"
LIBS += -L"C:/Build/lib"
LIBS += -lz
Then build Quazip with QtCreator as release Build.
When compiled I get
quazip.dll
libquazip.a
I copy all the header files from quazip (16 fils) in the include folder and the two libs in the lib folder.
Now I have like a zippackage in the build folder.
3. Adding Quazip and zlib to my Project
Copied the FindQuazip.cmake file into my project form the Quazip Repo.
In my CMakeLists.txt I added the following lines:
set(ZLIB_ROOT "C:/BUILD" CACHE PATH "Path to zlib")
find_package(ZLIB REQUIRED)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(QuaZip REQUIRED)
I need to set the ZLIB_ROOT so CMake uses the zlib I want. If I don't set Root he uses a zlib from a ruby installation from my PC.
Also I added
include_directories(
"${BASE_DIR}/sources"
"${QUAZIP_INCLUDE_DIR}"
)
and at the end
add_executable(${PROJECT_NAME} ${SOURCES} ${INC_ALL} )
target_link_libraries(${PROJECT_NAME} Qt5::Network Qt5::Core Qt5::Widgets
${ZLIB_LIBRARIES}
${QUAZIP_LIBRARIES}
)
Then I needed to add the FindQuazip.cmake since it would find the libs: I edited the following:
FIND_PATH(QUAZIP_LIBRARY_DIR
WIN32_DEBUG_POSTFIX d
NAMES libquazip.a #quazip.dll
HINTS "C:/Build/lib"
PATH_SUFFIXES QuaZip/lib
)
FIND_LIBRARY(QUAZIP_LIBRARIES NAMES libquazip.a HINTS ${QUAZIP_LIBRARY_DIR})
FIND_PATH(QUAZIP_INCLUDE_DIR NAMES quazip.h HINTS ${QUAZIP_LIBRARY_DIR}/../include)
FIND_PATH(QUAZIP_ZLIB_INCLUDE_DIR NAMES zlib.h)
Okay so It took me two days to get to there where I am now.
Now when I run CMake every works fine. He finds the libs.
I can even include a the Header files of Quazip. But when I then try to compile a minimal example the linker can't find any symbols.
Minimal Example:
#include <iostream>
#include <QApplication>
#include "JlCompress.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
cout << __cplusplus << endl;
cout << "Hello World!" << endl;
JlCompress::compressDir("C:/WorkspaceLokal/Test/test.zip", "C:/WorkspaceLokal/Test/TestFolder");
return a.exec();
}
By compiling it I get the following error:
C:\some\path\sources\main.cpp:-1: Fehler: undefined reference to `JlCompress::compressDir(QString, QString, bool)'
This means the linker can't link the function...
My Question
What am I doing wrong?
Do I need to compile Quazip in another way?
Edit 4:
since it now works how to I compile the Quazip as a static lib, so that I can link it statically to my application?
Thanks in advance...
Edit 1:
Here are the QUAZIP variables from Qt creator:
Edit 2:
Okay. Some news. the libquazip.a is something else and doesn't work. If I link against the quazip.dll compiling works. But when I run the application it crashes at the function call compressDir...
Edit 3:
It works. I just needed to copy the quazip.dll to the compiled executable...
From QuaZip's pro file:
# You'll need to define this one manually if using a build system other
# than qmake or using QuaZIP sources directly in your project.
CONFIG(staticlib): DEFINES += QUAZIP_STATIC
This should trigger when you add staticlib to the CONFIG in quazip.pro (2nd line):
CONFIG += qt warn_on staticlib
If you are not using qmake to build Quazip, just make sure that you #define QUAZIP_STATIC in a way specific to your build system

Package Qt5GStreamerQuick-1.0 not found

Did anybody got the luck to know the reason for:
"Project ERROR: Package Qt5GStreamerQuick-1.0 not found".
I have installed: qt-gstreamer-dev package
Not working even after manually adding PKG_CONFIG_LIBDIR:
export PKG_CONFIG_LIBDIR=/home/manojsahu/qt-gstreamer-1.2.0/src/QGst/QtGStreamer-1.0.pc.in
I have also added PKGCONFIG alternatively in .pro file like:
PKGCONFIG += Qt5GStreamerQuick-1.0
PKGCONFIG += QtGStreamer-1.0
Can anybody help to resolve this error.
I am trying to compile example in below mentioned link:
https://github.com/detrout/qt-gstreamer/tree/master/examples/qmlplayer
Thanks, I have got one work around to solve "Project ERROR: Package Qt5GStreamerQuick-1.0 not found".
"Qt5GStreamerQuick-1.0" has dependency with "gstreamer-1".
Download "gstreamer-1.6.3" and perform
make then
make install.
Download the qt-gstreamer code, extract freshly and navigate to extracted folder. In my case it is
cd ~/home/manojsahu/qt-gstreamer-1.2.0/
cmake CMakeLists.txt then
make then
sudo make install
Image of the qmlplayer built
Now the example qmlplayer gets built.
But facing error "Failed to create qtvideosink. Make sure it is installed correctly".
Perhaps It did not installed properly. Any workaround to build completely would be appreciated highly.

Why is this happening with cmake

I am working on a c++ project and I am using cmake as the build system, so my workflow here is make changes to code. then,
rm -r build
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
Now I added glew as a dependency to the project, so whenever I try to run make I get an error saying SDL.h not found(this was working before).After sometime I decided to check CMakeCache.txt.opened it using vim then :wq that's all I did now if I run make, my project is building successfully, I am not sure why this is happening, Can anyone tell me why?
ps: added gif of this event, check it out to get a clear picture
(the code i am working on is linked as well, this exact issue is in this commit "dd4452b45c733e0612bc5f3c632e9d1a08be8072")
link to gif
link to code
variables in cmake are limited to the scope of the directory they are in plus their subdirectories.
This, calling find_module() in the gamelib subdirectory does not find that module for use in the main directory.
The preferred way to propagate include directory dependencies is to add them to the target (in the gamelib directory), like this:
target_include_directories(gamelib BEFORE PRIVATE
$<BUILD_INTERFACE:${SDL2_INCLUDE_DIR}>
$<BUILD_INTERFACE:${GLEW_INCLUDE_DIR}>
)
target_include_directories(gamelib SYSTEM BEFORE PUBLIC
$<BUILD_INTERFACE:${SDL2_INCLUDE_DIR}>
$<BUILD_INTERFACE:${GLEW_INCLUDE_DIR}>
)
then you don't need to even mention them in any executable that uses gamelib.

mingw32-make opencv cmake 3rdparty,the pathname of adler32.c.obj was unfound

I want to Install OpenCV for codeblocks for C++
I follow this tuto:
http://kevinhughes.ca/tutorials/opencv-install-on-windows-with-codeblocks-and-mingw/
After the build of openCV with cmake, I use the cmd command.
when I do:
C:\opencv\buid\x86\mingw>mingw32-make.exe
there is a problem in the:
C:\opencv\build\x86\mingw\3rdparty\zlib\CMakeFiles\zlib.dir
==> the file "adler32.c.obj is unfounded.
For sure, this file doesn't exist.
How can I get this file ?
your answer could be really helpfull, I hope there is a solution to solve it

How to add autotools-based project as biicode block?

I need to use log4cpp in my project and I'd like to add this library as biicode block.
I read the documentation and tried to prepare the library for biicode.
I get the source of log4cpp from sourceforge's git here.
log4cpp already has CMakeLists.txt, but when I tried to compile it with cmake on ubuntu linux, there was error: missing file log4cpp/config.h.
Apparently, log4cpp is autotools-based project and needs to run ./autogen.sh and then ./configure to prepare project for compilation on Ubuntu linux. When I called this commands, log4cpp/config.h file is appeared and I was able to compile project with cmake.
Then I added this code to CMakeLists.txt:
if (BIICODE)
include(biicode.cmake)
return()
endif()
and in biicode.cmake I added this code:
# remove tests targets
LIST(REMOVE_ITEM BII_BLOCK_EXES tests_testCategory tests_testConfig tests_testDLL tests_testDailyRollingFileAppender tests_testErrorCollision tests_testFilter tests_testFixedContextCategory tests_testNDC tests_testNDCMain tests_testNTEventLog tests_testPattern tests_testPriority tests_testPropConfig tests_testProperties tests_testPropertyConfig tests_testRollingFileAppender tests_test_convenience tests_testbench tests_testmain)
# remove unnecessary files from lib
LIST(REMOVE_ITEM BII_LIB_SRC
tests/Clock.cpp
tests/Clock.hh
tests/NDCTest.hh
)
ADD_BII_TARGETS()
Now I was able to build block with bii build. But when I published this block to biicode and tried to use it in other sample project, when I run bii find, biicode download log4cpp, but not all sources (for example, RollingFileAppender.cpp is not available after downloading).
My sample project that use log4cpp:
#include "log4cpp/Category.hh"
int main()
{
log4cpp::Category::getInstance("application");
return 0;
}
And I was need to add this section to biicode.conf file of sample project:
[includes]
log4cpp/*: halex2005/log4cpp/include
So, my questions is:
How I can prepare autotools-based project to be the biicode block in right way?
How to run ./auto-gen.sh and ./configure on bii configure command?
How to force biicode to download full list of sources for biicode block?
Thanks in advance!