Tag Archives: OpenCV

Opencv2.4.9 + ffmpeg1.2.12 installation configuration and problem solution under Ubuntu 14.04

In the process of video processing, two feature extraction methods, space-time interest points (stip) and improved dense trajectories (IDT), are used. We can find the open algorithm source code on the author’s home page. They need opencv and ffmpeg to run smoothly under Linux. We have used these two tools before, but now we want to use them again after changing the working environment, but there are still many problems in the process of configuration and installation. Therefore, I feel it is necessary to record the specific process, problems and solutions for future use, and hope to bring a little help to others.


Opencv2.4.9 and ffmpeg 1.2.12 source package download

These two software in the official website can be directly found in various versions of the source code package, download, compile and install. If you don’t particularly need the latest version of the software, I suggest that you use the earlier version that has been used by most people, and you can easily find the corresponding solution when there is a problem. I chose opencv2.4.9 and ffmpeg 1.2.12.

Opencv2.4.9 download
the official website provides download links from the earlier version 1.0.0 to 3.1 and 2.4.13, which means that different operating systems have different software packages
http://opencv.org/downloads.html
The download address of version 2.4.9 that I used is as follows:
0 https://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip/downloadFFmpeg1.2.12 The latest version of ffmpeg is 3.1.4, and the update speed is relatively fast. Personal choice of the early version 1.2.12 has been able to meet the actual needs, and the download address is as follows:
0 https://ffmpeg.org/olddownload.html

Ffmpeg compilation configuration

Ffmpeg is a leading multimedia framework, which can be used to record, convert digital audio and video, and convert them into open source programs. It includes the leading audio/video coding libraries libavcodec, libavutil, libavformat, etc.

1. Uninstall the previously installed ffmpeg and x264 software
in order to prevent version problems, it is recommended to uninstall the previously (possibly) installed version first. The order is as follows:

sudo apt-get -qq remove ffmpeg x264 libx264-dev

2. Install dependencies and related software

sudo apt-get install yasm
sudo aptitude install libx264-dev libfaac-dev libmp3lame-dev libtheora-dev libvorbis-dev libxvidcore-dev  libxext-dev libxfixes-dev

3. Compile and install
decompress the ffmpeg package and enter the decompressed directory

cd ffmpeg-1.2.12

Environment configuration [4]

./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-pthreads --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libx264 --enable-libxvid --enable-x11grab --enable-libvorbis --enable-nonfree --enable-pic --enable-shared

Note that there may be carriage return or character problems in the process of copying. If there is a problem with the prompt command, you need to carefully check the space and carriage return. If you use prefix to specify the installation path of the software, you need to modify the corresponding path in the configuration file so that the system can find the installation path of ffmpeg

vi /etc/profile

Press insert and add the following two lines at the end of the file:

export FFMPEG_HOME=/usr/local/ffmpeg 
export PATH=$FFMPEG_HOME/bin:$PATH

Press ESC and enter “: WQ” to exit and save, and then make the above changes take effect. The command is as follows:

source profile

After all configuration is completed, prepare to install. The command is as follows:

make
make install

After installation, you will see three directories in/usr/local/ffmpeg: Bin executable file directory, lib static and dynamic link library directory, and header files used in include programming.

4. Check whether the installation configuration is correct
it is said on the Internet that you can test whether the installation is successful by executing ffplay to play the video file in the bin directory. However, I did not generate ffplay after compiling and installing. There are only ffmpeg and ffserver in the bin directory. Therefore, we directly check whether the version is correct, and there is no problem when we use it later. The order is as follows:

ffmpeg -version

The correct version and configuration information appears, indicating that the installation is successful.

Opencv compilation and installation

The full name of OpenCV is: open source computer vision library. Opencv is a cross platform computer vision library based on BSD license (open source), which can run on Linux, windows and Mac OS operating systems. It is lightweight and efficient, which is composed of a series of C functions and a small number of C + + classes. It also provides the interfaces of python, ruby, MATLAB and other languages, and realizes many general algorithms in image processing and computer vision [5].

1. Install dependencies

sudo apt-get -qq install libopencv-dev build-essential checkinstall cmake pkg-config libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libopencore-amrnb-dev libopencore-amrwb-dev x264 v4l-utils 

2. Compile and install
to unzip the downloaded opencv package and enter the unzipped directory

cd opencv-2.4.9

Create compile directory, compile and install

mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install

It takes a long time to compile here. After completion, the following prompt information will be printed on the last line:

-- Configuring done
-- Generating done
-- Build files have been written to: /opt/opencv-2.4.9

During the compilation process, you may stay in the line “configuring done” for a long time. Don’t stop the compilation in a hurry. You need to wait patiently for the compilation to complete. During the installation process, there will be a progress prompt in the form of “[10%]” percentage, and the process will be very slow. Please wait patiently.

Tip: after cmake is completed, relevant information will appear, in which you can check whether ffmpeg has been supported. If yes is supported, ffmpeg will appear after it. There are also some encoding and formats with yes.

3. Environment configuration
all library files are installed under/usr/local/lib by default, and all header files are installed under/usr/local/include/opcv * /. Modify the environment configuration [6], and the command is as follows:

vim /etc/ld.so.conf

Press the insert key to add in the last line of the file

/usr/local/lib

Press ESC key to enter “: WQ” to exit and save, and then execute the following command:

ldconfig

At this point, opencv installation is complete.

Libcxcore. So. 2 cannot find a solution to the problem

After opencv is installed, the IDT algorithm can run normally, but the following errors appear when executing stip program:

./bin/stipdet: error while loading shared libraries: libcxcore.so.2: cannot open shared object file: No such file or directory

Look at the problem, it means that the shared library file libcxcore. So. 2 can’t be found during the execution of the program. This file or path doesn’t exist. From the online search results, most of the problems are prepared to use stip to obtain video features, but dense track programs do not have this problem. This problem and several solutions are available on the stackoverflow website for reference [7].

I didn’t succeed in creating soft links. Maybe I didn’t set it correctly at that time, and then I didn’t have root permission. Finally, I adopted a temporary method. To set the search directory of shared library, the command is as follows:

export LD_LIBRARY_PATH=[enter your path]/opencv-2.4.9/release/lib

When executing some external programs under Linux, you may be prompted that the shared library cannot be found, which is quite common. The reason for this problem is that although the shared library has been installed, the program cannot find the file when it is ready to call.

My problem is that the shared library file is installed in other “non/lib or/usr/lib” directory, but after the installation, the non root user does not have the permission to add a path in the “/ etc/LD. So. Conf”. So export is a global variable LD_ LIBRARY_ Path, and then run the program will go to this directory to find the shared library [8].

Execute stip program

If you directly execute “.”/bin/stippet – help “in this directory, you will not be able to execute. You must turn stippet and stipshow into executable files. For convenience, I directly changed it to fully open executable permissions [9]. The order is as follows:

chmod 777 bin/stipdet
chmod 777 bin/stipshow

For programs with dense trajectories, the same method can be used to execute normally. In addition, the global variable of export will no longer take effect every time the command window is closed. Therefore, before executing the stip program, we must first set the search directory of the shared library according to the above method, and there will be no problem that libcxcore. So. 2 cannot be found.

Opencv version view

During use, you may need to check the installed version of OpenCV. You can use the following command [10]:

pkg-config --modversion opencv

PKG config is a very useful tool for compiling applications and library files. One of its functions is to check the version number of the library.

Python calls opencv module

If you need to use Python to call opencv module, you can install Python first and then load CV [4]. The order is as follows:

sudo apt-get install python-opencv
sudo apt-get install python-numpy
python
import cv


References: <
> 1] https://www.di.ens.fr/~laptev/interestpoints.html
[2] https://lear.inrialpes.fr/people/wang/improved_trajectories
[3] https://ffmpeg.org/about.html
[4] http://blog.csdn.net/u010106759/article/details/51931815
[5] http://opencv.org/
[6] http://blog.csdn.net/firefoxbug/article/details/7554409
[7] http://stackoverflow.com/questions/5212728/libcxcore-so-2-missing-in-opencv
[8] http://blog.csdn.net/sahusoft/article/details/7388617
[9] http://blog.chinaunix.net/uid-21880738-id-1813031.html
[10] http://blog.csdn.net/ppp2006/article/details/47445903

[solution] install opencv3 with opencv4

Step 1: Download opencv download, the source code compilation package of opencv3. Step 2: when cmake, enter: cmake - D cmake_ INSTALL_ PREFIX=/home/username/opencv3 -D CMAKE_ BUILD_ TYPE="Rlease" -D OPENCV_ GENERATE_ Pkgconfig = on.. Step 3: compile and install

    make
    make install

Step 4: configure the environment

    sudo vi  /etc/ld.so.conf.d/opencv.conf
    input: /home/username/opencv3/lib

Step 5: configure bashrc
VI ~ /. Bashrc , and add:

    #opencv-3.4.12
    export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/home/username/opencv3/lib/pkgconfig
    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:./home/username/opencv3/lib

After saving, enter source ~ /. Bashrc
at this time, PKG config — modversion opencv will display 3.4.12, and opencv4 will display 4.2.0

Step 6: use opencv3
to edit CMakeLists.txt Before find (openCV required) , enter: set (cmake)_ PREFIX_ PATH "/home/username/opencv3")

[opencv + openvino] opencv-vino4.5.1 + opencv contrib installation

Get opencv vino

    git clone --branch 4.5.1 https://github.com/opencv/opencv_ contrib.git git clone --branch 4.5.1-openvino https://github.com/opencv/opencv.git opencv_ Place contrib in opencv directory

    Enter the opencv Directory:

      mkdir build & cd buildcmake -D CMAKE_ BUILD_ TYPE=RELEASE -D CMAKE_ INSTALL_ PREFIX=/usr/local -D INSTALL_ PYTHON_ EXAMPLES=ON -D OPENCV_ EXTRA_ MODULES_ PATH=../../opencv_ contrib/modules -D WITH_ INF_ ENGINE=ON -D ENABLE_ CXX11=ON -D PYTHON_ EXECUTABLE=/usr/bin/python ..

    Common errors and solutions:

      opencv_ contrib/modules/xfeatures2d/src/ boostdesc.cpp:673 :20: fatal error: boostdesc_ BGM. I: no such file or directory
      solution:
      source code compilation is adopted, so you can view the log file in the build folder CMakeDownloadLog.txt , in the log file CMakeDownloadLog.txt Search for bootdesc in_ BGM. I keyword (not search in the folder),
      found that the file download failed. The log file has its download address. You can directly copy the download address to the web page to see the source code of the file. You can directly copy the source code and save the file with the same name and put it in OpenCV_ The path of contrib/modules/xfeatures2d/SRC/ is OK.
      Baidu network disk download address: https://pan.baidu.com/s/1BeYF8kqEZLAJYQj-MvxpmA Password: e1wc (thank you for sharing) fatal error: features2d/test/test_ detectors_ regression.impl.hpp : no such file or directory
      solution:
      copy opencv/modules/features2d and paste it into the build directory to solve the problem. Final error: opencv2/xfeatures2d.hpp: no such file or directory
      solution:
      Add OpenCV_ The problem of can be solved by copying the contrib/modules/xfeatures 2D/include/opencv2 folder to the /usr/local/include/opencv2/ folder

When opencv is used, vs is stuck and other software works normally

Problem: when using OpenCV, when the mouse is on mat, vs2017 often gets stuck, the computer doesn’t get stuck, and other software works normally.

Solution:

1. Tools – & gt; options – & gt; text editor – & gt; C/C + + – & gt; advanced – & gt; intelisense – & gt; automatically change quick information to false

2. Right click in any of the definitions in Mat & gt

3. Class CV_ Delete or cut the lengthy passage above exports mat to another place

4. Tools – & gt; options – & gt; text editor – & gt; C/C + + – & gt; advanced – & gt; intelisense – & gt; automatically change quick information back to true

Error: (- 215: assertion failed)

Error: (- 215: assertion failed)

Source code:

import cv2

img = cv2.imread('D:\Work\study\jaffe\train\happy\KA.HA1.29.tiff')
cv2.namedWindow("Image")
cv2.imshow('Image', img)
cv2.waitKey (0)

Error:
traceback (most recent call last):
file “d”:/work/study/study_ cv.py ”, line 6, in
cv2.imshow(‘Image’, img)
cv2.error: OpenCV(3.4.2) C:\Miniconda3\conda-bld\opencv-suite_ 1534379934306\work\modules\highgui\src\ window.cpp:356 : error: (-215:Assertion failed) size.width&gt ;0 && size.height&gt ;0 in function ‘cv::imshow’

Reason:
it can be seen from pychar that

here is understood as escape character

Correction:

import cv2

img = cv2.imread('D:\Work\study\jaffe\\train\happy\KA.HA1.29.tiff')
cv2.namedWindow("Image")
cv2.imshow('Image', img)
cv2.waitKey (0)

AttributeError: module ‘cv2.cv2‘ has no attribute ‘face‘

Today, there was an error when running opencv module attributeerror: module 'CV2. CV2' has no attribute 'face' , CSDN checked and said that it was necessary to uninstall opencv first and then install it again. I felt that it was too troublesome, so I tried to find the answer in stackoverflow, which was effective. I specially recorded it

Opencv has two modules, OpenCV_ contrib_ pythonopencv_ Python let their two version numbers be the same is OK.
If not, adjust the version number of the two modules at the same time and try again. Remember to be consistent

PIP install the specified version

pip install opencv_contrib_python == version

If this helps you, please click like to support it 😀

Mac clion configuring opencv environment

Start by installing OpenCV4.0.1 with Homebrew

$ brew install opencv

If Open3.4.5 is installed

brew install opencv@3

** If you need –with OpenGL ** you need to [download] to [email protected] and change the compilation configuration.
brew install ./[email protected]
Update if you find any updates;
Then configure it in the CLion project cmMakelists.txt as follows:

cmake_minimum_required(VERSION 3.9)
project(untitled1)

set(CMAKE_CXX_STANDARD 11)

#find_library(OpenCV)
find_package(OpenCV)

include_directories(${OpenCV_INCLUDE_DIRS})
set(CMAKE_CXX_STANDARD 11)

add_executable(untitled1 main.cpp)

target_link_libraries(untitled1 ${OpenCV_LIBS})

Then you can write main.cpp to verify that:

#include <iostream>
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;

int main() {
    Mat srcImage = imread("your_img_path.jpg");
    if (!srcImage.data) {
        std::cout << "Image not loaded";
        return -1;
    }
    imshow("[img]", srcImage);
    waitKey(0);
    return 0;
}

You can display the photo, but if you can’t find the photo, change the path to the absolute path.
the original: https://blog.csdn.net/u010319740/article/details/79012810

Environment configuration at the beginning of OpenCV + vs2015

    First of all, the configuration of the system environment (after the computer has configured OpenCV once, there is no need to reconfigure). After the configuration of the system environment variables, the corresponding configuration is carried out on VS2015. First select the new project — VC++ — Win32 console program — empty project, and then right-click the source file to create a corresponding main function;

Then find the property manager in the view – Microsoft.cpp.x64.user in the Debugx64, and right-click to select the property; Add and edit the include file in the VC++ directory:
E:\opencv\opencv\build\include\opencv2
E:\opencv\opencv\build\include\opencv
E:\opencv\opencv\build\include
To add and edit the library directory:
E:\opencv\opencv\build\x64\vc15\lib
Add and edit the — input — attached dependencies in the linker:
Opencv_world341d. Lib
After the above three steps, click Apply and all the variables are configured. At this point, you can choose a simple program to run (e.g., display an image).
# include & lt; opencv2/opencv.hpp>
# include & lt; iostream>
Using the namespace CV;
Using namespace STD.
 
Int main(int argc, char** argv)
{
cout < < “Hello World” & lt; < Endl;
Mat image = imread (” E: \ \ v \ \ c + + \ \ hello word2 \ \ hello word2 \ \ 10. JPG “);
// NamedWindow (” test image “);
Imshow (” ceshi “, image);
/*if (image.empty())
{
imshow(“window”, image);
} * /
waitKey(0);
Return 0;
}
In particular, it is necessary to pay attention to:
1. Be sure to configure it on the solution configuration and solution platform. Debug+x64
2. The images that need to be opened must be placed in the same path as the.cpp file
The escape character in the path is uble slash.
Can consult to solve video https://v.qq.com/x/page/d0519qgy4lu.html?

ECCV 2020 panoramic segmentation papers (2 papers)

preface
The official series of Computer Vision Daily organized the large-scale inventory work of ECCV 2020
See above for details:
2020 target detection ECCV paper large inventory (49 papers) ECCV 2020 semantic segmentation large inventory (article 37) [ECCV paper 2020 instance segmentation paper inventory (12 paper) (https://blog.csdn.net/amusi1994/article/details/108999316)
This paper mainly includes: panoramic segmentation and other directions. Two papers have been sorted out, and the PDF of all papers have been packaged. Baidu cloud resources are as follows:

Link: https://pan.baidu.com/s/12WBsFFJKelcS7Fvrqiv3HQ
extraction code: t7nr

The article directories
Preface Panoramic Segmentation Paper Download PDF

Panoramic segmentation
Joint Semantic Instance Segmentation on Graphs with the Semantic Mutex Watershed

Author units: Heidelberg university paper: https://www.ecva.net/papers/eccv_2020/papers_ECCV/html/5393_ECCV_2020_paper.php code: no Chinese reading: no
Axial-DeepLab: Stand-Alone Axial-Attention for Panoptic Segmentation
Author unit: Johns Hopkins university, Google paper: https://www.ecva.net/papers/eccv_2020/papers_ECCV/html/1564_ECCV_2020_paper.php code: https://github.com/csrhddlam/axial-deeplab in Chinese reading: no
Paper PDF Download
The PDF of the above 14 papers has all been packaged, Baidu Cloud link:

Link: https://pan.baidu.com/s/12WBsFFJKelcS7Fvrqiv3HQ
extraction code: t7nr

Error in configuration process, project files may be invalid in cmake compilation

From http://blog.csdn.net/sduvec/article/details/50084963

Problems encountered while compiling Openv3.0.
Resolve this by re-downloading and replacing IPPICV_WINDOWS_20141027.zip.
After downloading the file, copy it to.. \ Opencv3.0 \ OpenCV \ sources \ 3 rdparty \ ippicv \ downloads \ Windows – b59f865d1ba16e8c84124e19d78eec57 \
Click and replace to the original file.
Configuration: Win7 + Openv3.0 + CMAKE3.4.0

Error configuration process and project file may be invalid appear in cmake compilation

Problems encountered while compiling Openv3.0.
Resolve this by re-downloading and replacing IPPICV_WINDOWS_20141027.zip.
After downloading the file, copy it to.. \ Opencv3.0 \ opencv \ sources \ 3 rdparty \ ippicv \ downloads \ Windows – b59f865d1ba16e8c84124e19d78eec57 \
Click and replace to the original file.
Configuration: Win7 + Openv3.0 + CMAKE3.4.0