Home System Tutorial LINUX How to solve the problem that OpenCV cannot read video files on CentOS

How to solve the problem that OpenCV cannot read video files on CentOS

Jan 04, 2024 am 11:43 AM
opencv Unable to read video

Under CentOS, follow the tutorial steps to install OpenCV, but in the end the video file cannot be read because ffmpeg is missing. So I installed ffmqeg through the software management in CentOS, but it still had no effect. Then I compiled ffmpeg, but it still had no effect. In fact, a key step is missed, which is to associate ffmpeg with OpenCV. details as follows:

1. Obtain ffmpeg:

Download ffmpeg through cvs, command line input: svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg

2. Configure ffmpeg:

Enter the ffmpeg directory and execute ./configure --enable-shared --prefix=/usr (I guess everyone knows the meaning of enabled-shared, but why do you need prefix=/usr? This depends on opencv's CMakeLists.txt and heighgui Speaking of the cvcap_ffmpeg.cpp under, the problems involved here should not cause path problems, but this problem caused me to go all morning. When checking whether ffmpeg is installed in cMakeLists.txt, the default is to /usr Go ahead and check whether the corresponding header files exist, but the default installation of ffmpeg is under /usr/local, and the problem arises, so if you change the installation path, opencv will not be able to detect whether you have already installed it in cmake. ffmpeg installed);

3. make; su -c "make install";

4. The next work to be done is related to whether opencv can successfully compile the related header files of ffmpeg:

4.1) First execute the following command (root) under /usr/include:

mkdir ffmpeg;

cp libav* libsw* ffmpeg; //The reason for this is because opencv configure checks whether ffmpeg is installed here

Checked

4.2) cmake .; //Note that there is a space between cmake and ., if

In the configure result, ffmpeg is 1, not the previous 0, which means we succeeded.

4.3) make install;

5. cp opencv.pc under /usr/local/lib/pkgconfig to /usr/lib/pkgconfig. This step can also be done. It is just a configuration file. At worst, you need to specify the header file yourself when compiling. Heku, in fact, you will know what it is when you open opencv.pc.

6. Under root, vim /etc/ld.so.conf, add a line, /usr/local/lib (because the library file of opencv is in local, by default the library file in local/lib is Not loaded when the system starts)

7. ldconfig.

The above is the detailed content of How to solve the problem that OpenCV cannot read video files on CentOS. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Quickly install OpenCV study guide using pip package manager Quickly install OpenCV study guide using pip package manager Jan 18, 2024 am 09:55 AM

Use the pip command to easily install OpenCV tutorial, which requires specific code examples. OpenCV (OpenSource Computer Vision Library) is an open source computer vision library. It contains a large number of computer vision algorithms and functions, which can help developers quickly build image and video processing related applications. Before using OpenCV, we need to install it first. Fortunately, Python provides a powerful tool pip to manage third-party libraries

python OpenCV image pyramid example analysis python OpenCV image pyramid example analysis May 11, 2023 pm 08:40 PM

1. Theoretical basis of image pyramid Image pyramid is a kind of multi-scale expression of images. It is an effective but conceptually simple structure to explain images at multiple resolutions. An image pyramid is a collection of images with progressively lower resolutions arranged in a pyramid shape and derived from the same original image. It is obtained through ladder down sampling, and the sampling is not stopped until a certain termination condition is reached. We compare images layer by layer to a pyramid. The higher the level, the smaller the image and the lower the resolution. So why do we make an image pyramid? This is because changing the size of a pixel sometimes does not change its characteristics. For example, if you show you a picture of 10 million pixels, you can know that there is a person in it. If you show you a picture of 100,000 pixels, you can also know that there is a person in it. But against the plan

OpenCV installation tutorial: a must-read for PyCharm users OpenCV installation tutorial: a must-read for PyCharm users Feb 22, 2024 pm 09:21 PM

OpenCV is an open source library for computer vision and image processing, which is widely used in machine learning, image recognition, video processing and other fields. When developing using OpenCV, in order to better debug and run programs, many developers choose to use PyCharm, a powerful Python integrated development environment. This article will provide PyCharm users with an installation tutorial for OpenCV, with specific code examples. Step One: Install Python First, make sure you have Python installed

How to achieve the effect of dragging virtual squares with Python+OpenCV How to achieve the effect of dragging virtual squares with Python+OpenCV May 15, 2023 pm 07:22 PM

1. Project effect 2. Core process 1. openCV reads the video stream and draws a rectangle on each frame of the picture. 2. Use mediapipe to obtain the coordinates of finger key points. 3. Based on the coordinate position of the finger and the coordinate position of the rectangle, determine whether the finger point is on the rectangle. If it is, the rectangle will follow the finger movement. 3. Code process environment preparation: python:3.8.8opencv:4.2.0.32mediapipe:0.8.10.1 Note: 1. If the opencv version is too high or too low, there may be some problems such as the camera not being able to open, crashing, etc. The python version affects opencv Optional versions. 2. pipinstallmediapipe may cause op

How to draw lines with arrows in OpenCV using Java? How to draw lines with arrows in OpenCV using Java? Aug 20, 2023 pm 02:41 PM

The org.opencv.imgproc package of the JavaOpenCV library contains a class called Imgproc that provides various methods to process input images. It provides a set of methods for drawing geometric shapes on images. To draw an arrowed line, you need to call the arrowedLine() method of this class. The method accepts the following parameters: a Mat object representing the image on which the line is to be drawn. A Point object representing two points between lines. drawn. A Scalar object representing the line color. (BGR) An integer representing the thickness of the line (default: 1). Example importorg.opencv.core.Core;importo

How to implement video processing using PHP and OpenCV library? How to implement video processing using PHP and OpenCV library? Jul 17, 2023 pm 09:13 PM

How to implement video processing using PHP and OpenCV library? Abstract: Video processing has become an important technology in modern scientific and technological applications. This article will introduce how to use the PHP programming language combined with the OpenCV library to implement some basic video processing functions, and attach corresponding code examples. Keywords: PHP, OpenCV, video processing, code examples Introduction: With the development of the Internet and the popularity of smartphones, video content has become an indispensable part of people's lives. However, to achieve video editing and

In Python, images can be segmented and extracted using methods from the OpenCV library. In Python, images can be segmented and extracted using methods from the OpenCV library. May 08, 2023 pm 10:55 PM

Image segmentation and extraction: Foreground objects are segmented or extracted as target images in images. The background itself is not interested. The watershed algorithm and the GrabCut algorithm segment and extract the image. Use watershed algorithm to achieve image segmentation and extraction. The watershed algorithm vividly compares images to geographical terrain surfaces to achieve image segmentation. This algorithm is very effective. Algorithm Principle Any grayscale image can be regarded as a geographical terrain surface. Areas with high grayscale values ​​can be seen as mountain peaks, and areas with low grayscale values ​​can be seen as valleys. The image on the left is the original image, and the image on the right is its corresponding "topographic surface". This process separates the image into two distinct sets: catchment basins and watershed lines. The dam we constructed is the watershed line, that is, the original image

Newbies please read: Detailed tutorial on how to install OpenCV in PyCharm Newbies please read: Detailed tutorial on how to install OpenCV in PyCharm Feb 26, 2024 pm 03:24 PM

PyCharm is a powerful Python integrated development environment (IDE) developed by JetBrains. It provides a wealth of functions and tools to help Python developers write code, debug programs and manage projects. Using OpenCV, a powerful computer vision library, in PyCharm, you can easily perform image processing, video processing and other tasks. This article will detail the steps to install and configure OpenCV in PyCharm and provide specific code examples. 1.An

See all articles