How to compile mergevec.cpp on Windows? - c++

I have been following this tutorial ( http://note.sonots.com/SciSoftware/haartraining.html ) to do some Haar training. I am currently stuck on merging the generate *.vec files. I am provided with this ( http://note.sonots.com/SciSoftware/haartraining/mergevec.cpp.html ) script and a description of how to build it for Linux, but for Linux only.
I have installed Cygwin, placed mergevec.cpp file into openCV_dir/apps/haartraining and tried to compile it with the following command:
$ g++ 'pkg-config --libs --cflags opencv' -I. -o mergevec mergevec.cpp cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp cvhaartraining.cpp
I recieve following error:
$ g++: error: pkg-config --libs --cflags opencv: No such file or directory
Could someone tell me how should I properly compile it for Windows?
Working on Windows 7, Cygwin x64, OpenCV 2.4.6

I was able to get mergevec.exe from here:
http://note.sonots.com/SciSoftware/haartraining/mergevec.cpp.html
It requires highgui100.dll and cxcore100.dll which I downloaded from:
http://www.dllme.com/

Related

geos: No such file or directory

I am trying to use the geos library on a Raspbery Pi 3, using Debian. I am trying to compile a program in C ++.
The same program can be compiled on other computers, this means that the source code of my program is correct.
When executing the command geos-config --version, version 3.7.1 is returned to me.
A while ago, a friend compiled and has been using the same code in Raspibian. However, I can't run it on Debian. My friend does not remember how he installed the geos library.
Would anyone know of anything that could help me?
make
Building target using GCC compiler: sources/geometry-manager.cpp
g++ -g -c sources/geometry-manager.cpp -std=c++17 -w -c -rdynamic -W `wx-config --cxxflags --libs --gl-libs` `geos-config --cflags` -lgeos -lglut -lGLU -lGL -lm -lGLEW -o builded/geometry-manager.o `pkg-config --libs geographiclib`
In file included from sources/geometry-manager.cpp:14:
sources/../include/geometry-manager.hpp:26:10: fatal error: geos.h: No such file or directory
#include <geos.h>
^~~~~~~~
compilation terminated.
make: *** [Makefile:37: builded/geometry-manager.o] Error 1
geos-config --includes : /usr/include.
geos-config --cflags : -I/usr/include.
geos-config --libs : -L/usr/lib/aarcg64-linux-gnu -lgeos-3.7.1 .
I installed via apt-get. However, as it didn't work, I installed it from the cloned github repository. –
Solution:
I uninstalled geos from my computer. Afterwards, I deleted all the folders related to geos that were still on the computer.
For some reason, the installation from the current repository did not work. So I cloned an old version of the geos.
https://github.com/libgeos/geos.git
I ran autogen.sh script (which didn't work before).
And this time it compiled and installed it successfully.
Thanks

Cross compilation of C++ program which includes OpenCV header files fails

I can cross compile a simple C++ program. (ex. g++ -o test test.cpp & arm-linux-gnueabihf-g++ -o test test.cpp).
But when I include OpenCV header files in a C++ program and cross compile it, it throws an error.(ex. arm-linux-gnueabihf-g++ -o ocv_test ocv_test.cpp $(pkg-config --libs --cflags opencv)).
Also I can compile successfully with the default compiler i.e. g++.(ex. g++ -o ocv_test ocv_test.cpp $(pkg-config --libs --cflags opencv))
I executed cmake with
-D CMAKE_TOOLCHAIN_FILE=../platforms/linux/arm.toolchain.cmake \.
as per the opencv docs. That didn't help.
I added opencv include dir in compilation cmd ie -I/path/to/opencv/include and removing pkg-config. That didn't help.
I tried changing arm-gnueabi.toolchain.cmake by exporting PKG_CONFIG_LIBDIR as per suggestion by someone. That didn't help.
I got the following error:
__/usr/lib/gcc-cross/arm-linux-gnueabihf/7/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_shape
//usr/local/lib/libopencv_stitching.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status__
I want my cross-compiled OpenCV app to run on a RaspberryPI.
I'm confused. Cross compiling OpenCV sources with the -D CMAKE_TOOLCHAIN_FILE option should allow us to cross-compile OpenCV C++ programs. Otherwise we will have to cmake or make (cross-compile) every OpenCV C++ program seperately on a build machine.

How to add files to build "pocketsphinx" in codeblocks?

I can compile the sample continuous.c file by this command inside Ubuntu terminal:
gcc -o continuous continuous.c -DMODELDIR=\"`pkg-config --variable=modeldir pocketsphinx`\" `pkg-config --cflags --libs pocketsphinx sphinxbase`
But if I want to build it inside codeblocks how should I do it?

Graphicsmagick C++ API

I want to use the C++ API for graphicsmagick
I need to convert image data directly from OpenCV and use graphicsmagick to save the file as tiff with group 4 compression
The command line
gm convert input -type bilevel -monochrome -compress group4 output.tif
Could anyone provide some code (see the above command line) to simply convert the output from OpenCV to tiff with group 4 compression
I'm new to C++ :)
testing graphicsmagick
I'm trying to make graphicsmagick work. Found a very simple code in the docs
I can't find Magick++.h
locate /Magick++.h returns nothing
but graphicsmagick is installed
# gm -version
GraphicsMagick 1.3.20 2014-08-16 Q8 http://www.GraphicsMagick.org/
code
/*
* Compile
* g++ gm_test.cpp -o gm_test `GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs`
*/
#include <Magick++.h>
using namespace std;
using namespace Magick;
int main(int argc, char **argv){
InitializeMagick(*argv);
Image image( "100x100", "white" );
image.pixelColor( 49, 49, "red" );
image.write( "red_pixel.png" );
return 0;
}
compile
# g++ gm_test.cpp -o gm_test `GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs`
-bash: GraphicsMagick++-config: command not found
gm_test.cpp:6:22: fatal error: Magick++.h: No such file or directory
#include <Magick++.h>
^
compilation terminated.
Updated Answer
Try looking for a file called GraphicsMagick-config under the directory where you installed GraphicsMagick like this:
find /usr -name "GraphicsMagick-config"
When you find that, you can ask it to tell you the compiler include flags and linker flags like this:
/usr/some/path/GraphicsMagick-config --cflags --libs
Then you can compile with:
gcc $(/usr/some/path/GraphicsMagick-config --cflags --libs) somefile.c -o somefile
Original Answer
Look in the directory where you installed GraphicsMagick for a file ending in .pc, which is the pkg-config file, e.g.
find /usr/local -iname "graphic*.pc"
Then pass this file to pkg-config to get the CFLAGS and LIBS you should use for compiling. So, if your graphicsmagick.pc is in /usr/local/Cellar/graphicsmagick/1.3.23/lib/pkgconfig/GraphicsMagick.pc, use:
pkg-config --cflags --libs /usr/local/Cellar/graphicsmagick/1.3.23/lib/pkgconfig/GraphicsMagick.pc
which will give you this:
/usr/local/Cellar/graphicsmagick/1.3.23/lib/pkgconfig/GraphicsMagick.pc
-I/usr/local/Cellar/graphicsmagick/1.3.23/include/GraphicsMagick -L/usr/local/Cellar/graphicsmagick/1.3.23/lib -lGraphicsMagick
Then you would compile with:
gcc $(pkg-config --cflags --libs somefile.c -o somefile
i don't know if it's helpful, last day i have the same error :no magick++.h when i compile ImageMagick (not graphicsmagick).
so i follows the steps in a official website to reinstall ImageMagick and finally i succeed.web:
1 http://www.imagemagick.org/script/install-source.php
2 http://www.imagemagick.org/script/magick++.php
i download the latest source code(ImageMagick6.9) in centOS-6.5
and then ./configure, make, make install.
i hope it's helpful.
On Ubuntu the GraphicsMagick++-config program you are using to get compile flags is correctly part of the same package which includes Magick++.h. Trying to run it tell you where to find it:
$ g++ gm_test.cpp -o gm_test `GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs`
The program 'GraphicsMagick++-config' is currently not installed. You can install it by typing:
sudo apt-get install libgraphicsmagick++1-dev
gm_test.cpp:6:22: fatal error: Magick++.h: No such file or directory
compilation terminated.
So do what it says:
$ sudo apt-get install libgraphicsmagick++1-dev
Try the compile again and you will get a different error because GraphicsMagick++-config is linking to an uninstalled and unneeded library:
$ g++ gm_test.cpp -o gm_test `GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs`
/usr/bin/ld: cannot find -lwebp
collect2: error: ld returned 1 exit status
You can manually specify the libs and the compile and link works:
$ g++ gm_test.cpp -o gm_test -I/usr/include/GraphicsMagick -Wall -g -fno-strict-aliasing -O2 -pthread -lGraphicsMagick++ -lGraphicsMagick -ljbig
$ ./gm_test
Or you can install the required library:
$ sudo apt-get install libwebp-dev

Cross Compile OpenCV C++ application ARM

I have read all of the related questions with no success trying anything mentioned anywhere. I am new to cross-compiling and have been working on this for over a week with no progress. So please forgive me if you think I am stupid or have overlooked something.
So I have an application running in C++ that works great on my development computer running Ubuntu 14.04 x64. I am trying to cross compile for my Banana Pro running Lubuntu. Based on the documentation from Lemaker I am supposed to cross compile using "arm-linux-gnueabihf-"
So far the farthest I have been able to get is to :
/usr/local/opencv-arm/usr/local/lib/libopencv_calib3d.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
I get this error regardless of what command I run, Here is a list of commands I have tried:
arm-linux-gnueabihf-g++ `arm-linux-gnueabihf-pkg-config arm-opencv --cflags` -Wall test.cpp -o vis-300 `arm-linux-gnueabihf-pkg-config arm-opencv --libs`
arm-linux-gnueabihf-g++ `pkg-config arm-opencv --cflags` -Wall test.cpp -o vis-300 `pkg-config arm-opencv --libs`
arm-linux-gnueabihf-gcc `pkg-config arm-opencv --cflags` -Wall test.cpp -o vis-300 `pkg-config arm-opencv --libs`
arm-linux-gnueabihf-g++ `pkg-config arm-opencv --cflags` test.cpp -o vis-300 `pkg-config arm-opencv --libs`
And there have been many more commands before those with different errors such as:
arm-linux-gnueabihf-gcc: error trying to exec 'cc1plus': execvp: No such file or directory
arm-linux-gnueabihf-cpp fatal error too many input files
I have tried with just normal arm-linux-gnueabihf-gcc/g++, 4.6, 4.7, and 4.8
I have built opencv making small changes for hf using these 2 guides and both produced the same results:
http://processors.wiki.ti.com/index.php/Building_OpenCV_for_ARM_Cortex-A8
http://www.ridgesolutions.ie/index.php/2013/05/24/building-cross-compiling-opencv-for-linux-arm/
and not included in either I install it using this command because it will conflict with my current x86_64 install:
sudo make install DESTDIR=/usr/local/opencv-arm
Also the above pkg-config lines point to my custom pkg config file named arm-opencv.pc
# Package Information for pkg-config
prefix=/usr/local/opencv-arm/usr/local
exec_prefix=${prefix}
libdir=
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include
Name: OpenCV-arm
Description: Open Source Computer Vision Library
Version: 2.4.10
Libs: ${exec_prefix}/lib/libopencv_calib3d.so ${exec_prefix}/lib/libopencv_contrib.so ${exec_prefix}/lib/libopencv_core.so ${exec_prefix}/lib/libopencv_features2d.so ${exec_prefix}/lib/libopencv_flann.so ${exec_prefix}/lib/libopencv_gpu.so ${exec_prefix}/lib/libopencv_highgui.so ${exec_prefix}/lib/libopencv_imgproc.so ${exec_prefix}/lib/libopencv_legacy.so ${exec_prefix}/lib/libopencv_ml.so ${exec_prefix}/lib/libopencv_nonfree.so ${exec_prefix}/lib/libopencv_objdetect.so ${exec_prefix}/lib/libopencv_ocl.so ${exec_prefix}/lib/libopencv_photo.so ${exec_prefix}/lib/libopencv_stitching.so ${exec_prefix}/lib/libopencv_superres.so ${exec_prefix}/lib/libopencv_ts.a ${exec_prefix}/lib/libopencv_video.so ${exec_prefix}/lib/libopencv_videostab.so -lrt -lpthread -lm -ldl
Cflags: -I${includedir_old} -I${includedir_new}
Anyways I have tried a lot of stuff short of just installing everything on the board itself and compiling there. Any help is much appreciated and keep in mind I have never successfully cross-compiled before. I always give up and compile on the board.