OpenCV installation help? - opencv

I am on Mac OS X Snow Leopard, and I am trying to get OpenCV to work with CodeBlocks. I downloaded the source files for OpenCV 2.3, and then downloaded the latest version of Cmake. The direct source file contains a folder "include" which has two folders in it labeled OpenCV and OpenCV 2. However after I use Cmake on the source files, the two "OpenCV" and OpenCV 2" folders are gone. Anyone know why this is happening and how to fix it? Instead of the folders all I have now is a CmakeFiles Folder, MakeFile and cmake_install.cmake
Thank You

After you download the source files, go into the opencv folder that's inside the folder you created and execute these commands:
sudo cmake -G "Unix Makefiles" .
sudo make -j8
sudo make install
Don't try to do this from the include folder. That's one level too deep. You want to do it from the folder that contains the include folder.
Terminal is in Applications/Utilities. That's how you get to the Unix command line. To get into your opencv folder, run Terminal and type "cd ". (That's cd followed by a space.) Then drag your opencv folder from a Finder window onto the Terminal window. This will append the folder name to the command line. Then press Return and you'll be in that folder. Then you can enter the commands above.
If you want to use ccmake instead of cmake, just replace "cmake" with "ccmake" in the first command.

Related

How do you compile OpenCV with cmake?

I'm trying to compile OpenCV so that it has the the sift module.
I downloaded CMake using this tutorial.
I also downloaded and unzipped opencv-4.3.0 and opencv_contrib.
I made an empty folder, opened the terminal, and navigated to it using the following line:
cd ~/opencvMaster/build
Then, while I was in this empty folder in the terminal, I ran the following line:
cmake -DOPENCV_ENABLE_NONFREE:BOOL=ON -DOPENCV_EXTRA_MODULES_PATH= ~/openCVMaster/opencv_contrib-master/modules ~/openCVMaster/opencv-4.3.0
It configured and generated the files. I then input make. Got the following error:
[ 82%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/boostdesc.cpp.o
~/opencvMaster/opencv_contrib-e6f32c6a69043456a806a4e802ee3ce7b7059c93/modules/xfeatures2d/src/boostdesc.cpp:654:20: fatal error: boostdesc_bgm.i: No such file or directory
#include "boostdesc_bgm.i"
^~~~~~~~~~~~~~~~~
compilation terminated.
I followed the suggestion found here, and added the following files:
cd ~/openCVMaster/opencv_contrib-4.3.0/modules/xfeatures2d/src
curl wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_lbgm.i >boostdesc_lbgm.i
curl wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_256.i >boostdesc_binboost_256.i
curl wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_128.i >boostdesc_binboost_128.i
curl wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_064.i >boostdesc_binboost_064.i
curl wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_hd.i >boostdesc_bgm_hd.i
curl wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_bi.i >boostdesc_bgm_bi.i
curl wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm.i >boostdesc_bgm.i
curl wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_120.i > vgg_generated_120.i
curl wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_64.i >vgg_generated_64.i
curl wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_48.i >vgg_generated_48.i
curl wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_80.i >vgg_generated_80.i
This was a step forward: no more errors relating to vgg or boostdesc. A new error appeared: opencv_contrib-master/modules/xfeatures2d/test/test_features2d.cpp:51:10: fatal error: features2d/test/test_detectors_regression.impl.hpp: No such file or directory
Following the advice of ah-ma here) I downloaded https://github.com/opencv/opencv/tree/master/modules. Once downloaded, I located its subfolder 'features2d' and put it in opencv_contrib-master/modules/xfeatures2d/test/.
Still got an error -
~/openCVMaster/opencv_contrib-master/modules/xfeatures2d/test/features2d/misc/java/src/cpp/features2d_converters.cpp:2:10: fatal error: common.h: No such file or directory
#include "common.h"
I added the following:
cd ~/openCVMaster/opencv_contrib-master/modules/xfeatures2d/test/features2d/misc/java/src/cpp
curl wget https://raw.githubusercontent.com/ray-project/common/master/common.h > common.h
I ran make again, and got the following errors:
~/openCVMaster/opencv_contrib-master/modules/xfeatures2d/test/features2d/misc/java/src/cpp/features2d_converters.cpp: In function ‘void Mat_to_vector_KeyPoint(cv::Mat&, std::vector<cv::KeyPoint>&)’:
~/openCVMaster/opencv_contrib-master/modules/xfeatures2d/test/features2d/misc/java/src/cpp/features2d_converters.cpp:7:38: error: ‘LOGD’ was not declared in this scope
#define CHECK_MAT(cond) if(!(cond)){ LOGD("FAILED: " #cond); return; }
~/openCVMaster/opencv_contrib-master/modules/xfeatures2d/test/features2d/misc/java/src/cpp/features2d_converters.cpp:14:5: note: in expansion of macro ‘CHECK_MAT’
CHECK_MAT(mat.type()==CV_32FC(7) && mat.cols==1);
^~~~~~~~~
~/openCVMaster/opencv_contrib-master/modules/xfeatures2d/test/features2d/misc/java/src/cpp/features2d_converters.cpp: In function ‘void Mat_to_vector_DMatch(cv::Mat&, std::vector<cv::DMatch>&)’:
~/openCVMaster/opencv_contrib-master/modules/xfeatures2d/test/features2d/misc/java/src/cpp/features2d_converters.cpp:7:38: error: ‘LOGD’ was not declared in this scope
#define CHECK_MAT(cond) if(!(cond)){ LOGD("FAILED: " #cond); return; }
Any suggestions welcomed.
# Step 1: Install VS 2017 for cmake
# Step 2: Install CMake
Download and install CMake v3.10.0 from https://cmake.org/download/.
During installation select “Add CMake to system PATH”
# step 3: install Anaconda
# step 4: Download and extract opencv-3.3.1 and opencv_contrib-3.3.1
Go to https://github.com/opencv/opencv/releases and download opencv-3.3.1 source code zip
Go to https://github.com/opencv/opencv_contrib/releases and download opencv_contrib-3.3.1 source code zip
Extract both zip files. Although you can keep opencv and opencv_contrib folders anywhere, I suggest that you should keep both in the same directory. I have placed these two folders in “My Documents” directory.
NOTE : From hereon we will refer the path to opencv-3.3.1 folder as OPENCV_PATH. For example, in my case OPENCV_PATH is C:/Users/Vaibhaw Chandel/Documents/opencv-3.3.1
Depending upon where you have kept opencv-3.3.1 folder, this path would be different.
Step 5: Generate Visual Studio project using CMake
Run Cmake, in box “Where is the source code” write value of OPENCV_PATH (which is path to opencv-3.3.1 folder) and path to build directory. We will choose build directory as OPENCV_PATH/build
Now click configure.
You will be asked for permission to create the build folder. Click Yes
When prompted to select a compiler, select Visual Studio 14 2015 Win64.
Click finish and in the next window keep the default parameters checked.
Click finish. Now CMake will look in the system directories and generate the makefiles.
Step 5.1: Additional changes to CMake config
We will make few changes in the default configuration generated by CMake. Click on the images to see a larger version.
Check “INSTALL_C_EXAMPLES” and “INSTALL_PYTHON_EXAMPLES”
In flag “OPENCV_EXTRA_MODULES_PATH”, give path of modules directory within opencv_contrib-3.3.1. In our case we have kept opencv_contrib-3.3.1 in Documents folder so path is “C:/Users/Vaibhaw Chandel/Documents/opencv_contrib-3.3.1/modules”
Now click configure to apply these changes.
On Windows 10, opencv_saliency module fails to build. So we will disable it. Uncheck BUILD_opencv_saliency
Now click on configure again to include this change.
Step 5.2 : Add Python paths for both Python2 and Python3 (optional)
This section is only for people who want to generate OpenCV binary for both Python2 and Python 3. If you are going to use just one Python either 2 or 3, you should skip this section.
CMake was unable to find paths for my Python3 files.
So I manually added paths for Python3
Now click configure again. After configuring is done, search opencv_python in search bar, both BUILD_opencv_python2 and BUILD_opencv_python3 will be automatically checked. Now we are sure that OpenCV binaries for both Python2 and Python 3 will be generated after compilation.
Step 5.3 : Generate build files
If CMake is able to configure without any errors it should say “Configuring done”.
Click generate.
Note: Whenever you make any changes(check/uncheck boxes or change path) to configuration generated by CMake, always click configure and generate.
Step 6: Compile OpenCV
Step 6.1:Compile opencv in Release mode
Open Windows Command Prompt (cmd).
Go to OPENCV_PATH/build directory and run this command
1
cmake.exe --build . --config Release --target INSTALL
Step 6.2 : Compile opencv in Debug mode
Open CMake GUI again as mentioned in Step 5.
Search “python” in search box
Uncheck INSTALL_PYTHON_EXAMPLES, BUILD_opencv_python3 and BUILD_opencv_python2
Click configure
Click generate
Now in windows command prompt
Go to OPENCV_PATH/build directory and run this command
1
cmake.exe --build . --config Debug --target INSTALL
Now that we have compiled OpenCV we will find out how to test a OpenCV project using CMake.
Step 7: Update System Environment Variables
Step 7.1 : Update environment variable – PATH
Step 7.2 : Update user environment variable – OPENCV_DIR
Download opencv-4.3.0.zip and opencv_contrib-4.3.0.zip. Unzip them.
Open opencv_contrib-4.3.0\modules. Copy the folder that says xfeatures2d. Open opencv-4.3.0\modules, and paste the folder just copied (xfeatures2d)
Make an empty folder, and call it 'Build45.'
Open cmake-gui.
In the box that says, 'Where to build the binaries' put the file path representing your empty folder (Build45)
In the box that says, 'Where is the source code' put the file path representing opencv-4.3.0.
Click configure. Choices will appear.
Input 'free' into the search box and check the box that says OPENCV_ENABLE_NONFREE.
Input xfeatures2d and check the box that says 'Build_opencv_xfeatures2d`
Click configure again. (Doublecheck you've done this right: there is a second box in cmake gui that gives build details. You should see Non-free algorithms: YES.
Click Generate.
Check that the build45 folder is now filled with stuff.
Open your terminal and navigate to the build45 folder (cd ~/opencv-master/build45)
Type cmake .
Type make
NOTE:* It will take a couple hours to compile. Make yourself a cup of tea*.
Type sudo make install
Check that it worked: in your terminal, type python3
Type import cv2
Type sift = cv2.xfeatures2d.SIFT_create()
You should get no errors. If you do get errors, the following troubleshooting tools may be helpful:
import cv2
print cv2.getBuildInformation()
import cv2
funcs = dir(cv2)
for f in funcs:
... print(f)
Also, if you are worried about infringing patents, check here for discussion: https://www.reddit.com/r/computervision/comments/ba1l8g/according_to_this_the_patent_on_sift_was_due_to/

install MongoDB C++ Driver problem in ubuntu 16.04

I want to install MongoDB C++ Driver, so first is mongocxx
I follow this installation:
http://mongocxx.org/mongocxx-v3/installation/
but I can not pass step 4
when I run this in mongo-cxx-driver/build
sudo cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
it shows
-- Auto-configuring bsoncxx to use MNMLSTC for polyfills since C++17 is inactive
CMake Error at src/mongocxx/CMakeLists.txt:37 (find_package):
By not providing "Findlibmongoc-1.0.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"libmongoc-1.0", but CMake did not find one.
Could not find a package configuration file provided by "libmongoc-1.0"
(requested version 1.13.0) with any of the following names:
[![enter image description here][1]][1]
libmongoc-1.0Config.cmake
libmongoc-1.0-config.cmake
Add the installation prefix of "libmongoc-1.0" to CMAKE_PREFIX_PATH or set
"libmongoc-1.0_DIR" to a directory containing one of the above files. If
"libmongoc-1.0" provides a separate development package or SDK, be sure it
has been installed.
second question,
Step 2: Choose a C++17 polyfill how can I set MNMLSTC/core?
does anyone can help me,I already trap here for a long time ?
my env:
mongo-c-driver 1.15.1
libmongoc-1.0
mongocxx-3.4.x
Cmake is complaining about not finding a package configuration file (xxx.cmake), probably because you didn't build libmongoc/libbson.
I've tried to reproduce your issue and hit the same problem when I only installed them (apt-get install), so my suggestion is that you get the sources and build them as described at: http://mongoc.org/libmongoc/current/installing.html
Here's the list of commands (with the latest version of mongo-c-driver=1.15.1) which I just tried and worked fine:
wget https://github.com/mongodb/mongo-c-driver/releases/download/1.15.1/mongo-c-driver-1.15.1.tar.gz
tar xzf mongo-c-driver-1.15.1.tar.gz
cd mongo-c-driver-1.15.1
mkdir cmake-build
cd cmake-build
cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..
make
sudo make install
At this point you can go back into mongocxx/build and run again the command you were stuck at:
cd ../../mongo-cxx-driver/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..

Swiftkotlin command line not found for converting Swift to kotlin

I am using Swift kotlin for converting swift code to kotlin which is working on Xcode project but when I am trying to execute from mac terminal it shows SwiftKotlin not found .
Github link: https://github.com/angelolloqui/SwiftKotlin
-bash: swiftkotlin: command not found
Vivek-Mac-mini:~ vivekrawat$
It looks like you need to install the package into
/usr/local/bin/
folder on your Mac, so the terminal can treat it like other command-line commands like cd, open, etc.
From Xcode, run the desired target and copy the generated executables (you can find it under the Products generated folder) in a directory with executable rights for later use. Typically, you could use:
swiftkotlin command line tool: /usr/local/bin/
To do so, you can try the following:
in the left pane of Xcode find the last folder called Products, open it. There should be a file with .app extension.
try to drag the file with .app extension from XCode to your desktop, holding alt key on the keyboard.
open Finder, click Shift+Cmd+G and paste /usr/local/bin/ into the prompt
drag the file from your desktop to that folder
restart the Terminal and try to use the command again

How to install phonegap-2.7.0 for ios?

I have downloaded the phonegap-2.7.0 from http://phonegap.com/,but i don't know how to install it,(There is a Makefile,but nothing happened when execute the "make" command in the terminal,i have already quit the xcode),would anyone help me?
http://docs.phonegap.com/en/2.7.0/guide_getting-started_ios_index.md.html
These instructions are pretty clear, even if the directory tree you get after extracting the zip file is not exactly the one they show.
After installing all the requirements:
extract the content of phonegap-2.7.0.zip wherever you want
go to lib/ios/bin and run the 'create' command with the suggested parameters.
open the finder and go to the directory you used as first parameter of the 'create' command
doubleclick the file with extension xcodeproj to open XCode and the project will be automatically created
To open the finder in the right folder you can use the command line:
open ~/workspace/yourProject
or
cd ~/workspace/yourProject
open `pwd`
my 2c

CMake can't find FFMPEG in custom install path

I am compiling a dependency for a project on Ubuntu 10.10, and instead of having it install to /usr/local by default, I am instead installing it to /tmp/stage/usr/local. How do I go about informing CMake of the location of this custom installed dependency when I call it to generate the build files for said project.
I am running CMake 2.8.1, and I have tried to set CMAKE_PREFIX_PATH on the cmake command line, like so
cmake -D CMAKE_PREFIX_PATH=/tmp/stage/usr/local
but this doesn't seem to make a difference - the project doesn't seem to detect the dependency.
Also, if it matters, the project in question is OpenCV 2.2, and the dependency in question is FFMPEG...
I figured out how to fix my problem, and trying to point CMake at the appropriate install location isn't the issue.
Apparently, CMake is unable to find the pkg-config files for FFMPEG (i.e. libavcodec.pc, libavdevice.pc, etc.) that tell it where the FFMPEG headers and libraries are located. In a typical install scenario, these files would be located at /usr/lib/pkgconfig. However because of the custom install location, they are instead located at /tmp/stage/usr/local/lib/pkgconfig.
So that CMake could find these files, I had to add the following environment variable:
export PKG_CONFIG_PATH=/tmp/stage/usr/local/lib/pkgconfig
After which point, OpenCV built against FFMPEG as expected.

Resources