Use PYTHON-OPENCV to get a rtsp-stream tutorial __python

Source: Internet
Author: User

The author published this blog in order to get the sea Conway as the code flow fee Dickens, of course, may also be the author of the dish, but since the toss out, they share out for everyone to reference and study. Of course, if there is a better plan, I hope the brothers can share a good plan to come. Compile the installation process as follows:

1. Extract xvidcore_1.3.3.orig.tar.gz files into the xvidcore-1.3.3 folder, execute the following command

CD xvidcore-1.3.3/
CD build/generic/
./configure--prefix=/usr
make
sudo make install

2. Install libx264, execute command sudo apt-get install Libx264-dev
3. Compile and install FFmpeg, extract ffmpeg-3.1.2.tar.bz2 files to ffmpeg-3.1.2 folder, execute the following command:

./configure  --prefix=/usr/local/ffmpeg/  --ENABLE-GPL--enable-libfaac--enable-libmp3lame- Enable-libopencore-amrnb--ENABLE-LIBOPENCORE-AMRWB--enable-libtheora--enable-libvorbis--enable-libx264-- Enable-libxvid--enable-nonfree--enable-postproc--enable-version3--enable-x11grab
make
sudo make install
sudo vim/etc/profile

Add at the bottom line

Export ld_library_path= "$LD _library_path:/usr/local/ffmpeg/lib/"
souce/etc/profile

4. Download opencv2.4.13, after decompression into the directory, the author is using opencv-2.4.13, execute the following command

CD ~/opencv-2.4.13/
mkdir build
CD

The following make command because the author installs the Cuda, therefore inside uses cuda_generation=auto this compilation option, does not use Cuda compiles the child shoe to be possible to delete this piece configuration to compile.

cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local-d build_tiff=on-d build_examples=on-d CUDA_ generation=auto-d build_new_python_support=on  --withffmpeg  .
Make
sudo make install

5. If the above libraries are successfully compiled and installed, you can execute the following test code:

Import cv2
cap = Cv2. Videocapture ("RTSP://ADMIN:ADMIN@192.168.2.64:554//STREAMING/CHANNELS/1")
print cap.isopened ()

while Cap.isopened ():
    ret,frame = Cap.read ()
    cv2.imshow ("frame", frame)
    Cv2.waitkey (1)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.