No package 'opencv' found - c++

I'm trying out this github repository, one of the requirements is to have opencv 3.1
when I run pip list I have opencv-python and opencv-contrib-python both version 4.7.0.68
$ g++ -std=c++11 Heartbeat.cpp opencv.cpp RPPG.cpp `pkg-config --cflags --libs opencv` -o Heartbeat
but when I run the above I get the error below
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc' to the PKG_CONFIG_PATH environment variable
No package 'opencv' found

Please use opencv4 instead of opencv. So your command will look like:
g++ -std=c++11 Heartbeat.cpp opencv.cpp RPPG.cpp `pkg-config --cflags --libs opencv4` -o Heartbeat
It should work.

Related

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

libxml++/libxml++.h: No such file or directory

I am using ubuntu 12.4 g++ i'm working on libxml++ library I have included this library in my program but I am getting an error saying
libxml++/libxml++.h: No such file or directory
i also tried compiling using g++ main.cc -o main pkg-config --cflags --libs libxml++-2.6 but it is not working. I have installed the latest libraries using sudo apt-get install libxml++.
While compiling for libxml we have to use these options. pkg-config --cflags --libs libxml++-2.6 this should be in single quotation mark / Backticks ("`", grave accents), .
So the command should be like this.
$ g++ main.cc -o program `pkg-config --cflags --libs libxml++-2.6`
or go through this once. http://developer.gnome.org/libxml++/stable/

QtCreator and pkg-config

I imported a makefile project into Qt creator for more productive development. When I use make in the terminal:
g++ Size3.o SteerableTests.o MyLib.o Tensor.o Cube.o Steerable.o -lUnitTest++ `pkg-config --libs opencv` -o steerable
It compiles successfully. But when using build option of QtCreator, it keeps saying that pkg-config can't find opencv. How to set the environment path for QtCreator?
11:35:21: Starting: "/usr/bin/make" all
g++ Size3.o SteerableTests.o MyLib.o Tensor.o Cube.o Steerable.o -lUnitTest++ `pkg-config --libs opencv` -o steerable
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
My guess is that the environment variable PKG_CONFIG_PATH is set in your shell, but not in QtCreator's environment.
The easiest way around this that I can think of is to set it explicitly in the Makefile, e.g.
export PKG_CONFIG_PATH=/the/path
To find /the/path, try echo $PKG_CONFIG_PATH in the shell or find opencv.pc using locate (preferably) or find.

pkg-config can't find opencv

I installed opencv on a lubuntu 12.10 distro. Then when I try to compile a code which is using opencv it says it can't find it. So I try in a terminal :
pkg-config --cflags --libs opencv
It answers me that it can't find opencv. But the files are installed in /usr/lib. I don't understand why it can't find them.
You have to put pkg-config --cflags --libs opencv at the end of your g++ line. For example :
g++ test.cpp -o test `pkg-config --cflags --libs opencv`
Compiles
g++ `pkg-config --cflags --libs opencv` test.cpp -o test
Doesn't compile and have undefined reference.
For OpenCV 4 you might have to use:
pkg-config --cflags --libs opencv4
(Note the 4 in the end!)
From OpenCV 4:
add -DOPENCV_GENERATE_PKGCONFIG=YES to cmake build arguments.
Use YES, ON is not working anymore.