Solving Problem opencv 4.x.x video stream failed


I hope this can help

Change

videocapture = cv2.VideoCapture(0 )

to

videocapture = cv2.VideoCapture(0 , cv2.CAP_V4LĀ )

Cara menginstall opencv 3.4.4 di ubuntu 18.04


Berikut adalah cara saya menginstall opencv 3.4.4 di ubuntu 18.04 saya, saya sudah mencobanya sendiri, silahkan diikuti step by step nya Happy Coding dan salam ngoprek

#update ubuntu anda

sudo apt-get update
sudo apt-get upgrade -y

#masuk directory home
cd ~/

#install dependencies
sudo apt-get install build-essential cmake unzip pkg-config

sudo apt-get install libjpeg-dev libpng-dev libtiff-dev

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev

sudo apt-get install libxvidcore-dev libx264-dev

sudo apt-get install libgtk-3-dev

sudo apt-get install libatlas-base-dev gfortran

sudo apt-get install python3-dev

#buat folder opencv
mkdir opencv
cd opencv
#download opencv di github saya pakai yang 3.4.4 silahkan kalau mau coba versi diatasnya
wget -O opencv.zip https://github.com/opencv/opencv/archive/3.4.4.tar.gz
#extract 
tar -xzvf 3.4.4.tar.gz 
#setelah diextract pindahkan isinya ke /home/<username>/opencv
mv 3.4.4/* /home/<username>/opencv

#buat folder opencv_contrib
mkdir opencv_contrib
cd opencv_contrib
#download opencv_contrib
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/3.4.4.tar.gz
#extract 
tar -xzvf 3.4.4.tar.gz 
#setelah diextract pindahkan isinya ke /home/<username>/opencv
mv 3.4.4/* /home/<username>/opencv_contrib

#download pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py

#install virtualenwrapper
sudo pip install virtualenv virtualenvwrapper
sudo rm -rf ~/get-pip.py ~/.cache/pip

#edit .bashrc
echo -e "\n# virtualenv and virtualenvwrapper" >> ~/.bashrc
echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.bashrc
echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.bashrc
echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc
source ~/.bashrc

#buat virutalenv
mkvirtualenv cv -p python3
workon cv

#install numpy
pip install numpy

#ok buat install file
nano install.sh

#paste code dibawah ini didalam install.sh

Continue reading Cara menginstall opencv 3.4.4 di ubuntu 18.04