thanks for the instructions, saved me a few hours of mucking around, very clear and very appreciated
here are a couple of minor changes to your script to test FFMPEG,
import cv2 cap=cv2.VideoCapture["input_video.mp4"] print cap.isOpened[] # True = read video successfully. False - fail to read video. fourcc = cv2.VideoWriter_fourcc[*'XVID'] out = cv2.VideoWriter["output_video.avi",fourcc, 20.0, [640,360]] print out.isOpened[] # True = write out video successfully. False - fail to write out video. cap.release[] out.release[]
note that your original script fails at a couple of points
[1] in lines 2 and 3 you need to define a handle/[more properly an instance] to cv2.VideoCapture[] and test whether that handle points to an open object, [in your code you’re testing whether the library cv2 is an open object]
[2] as one of the other chaps pointed out FOUR_CC has been moved, and the above syntax appears to work
thanks again
We recommend using Anaconda with Python 3 for the homework assignments. The instruction to install anaconda and Python 3 can be found at //docs.anaconda.com/anaconda/install/linux/. Below is a short tutorial to install the experiment system on the PSU Linux lab machines and on a regular Windows machine. Note, we highly recommend that the homework assignments are completed on a Linux machine and will grade your assignments on Linux only.
Linux:
1. Install anaconda:
wget //repo.continuum.io/archive/Anaconda3-2018.12-Linux-x86_64.sh
bash Anaconda3-2018.12-Linux-x86_64.sh -b -p $HOME/anaconda
export PATH="$HOME/anaconda/bin:$PATH"
conda update --all
2. Install necessary libraries:
1. Download and install anaconda environment Python 3.7:
Download:
//www.anaconda.com/download/#windows
Install: //docs.anaconda.com/anaconda/install/windows/
2. Open Anaconda Prompt
Start Menu / Anaconda3 / Anaconda Prompt
3. In Anaconda Prompt, type commands to install necessary libraries:
pip install
opencv-python==3.4.2.17
pip install opencv-contrib-python==3.4.2.17
4. Run your python program
We’re going to see in this tutorial how to install Python 3 and Opencv 4 on Windows.
Here below you see a list of the steps necessary for a complete installation. If you have any problem following the steps, I suggest you to watch the video tutorial above that will guide you trough it step by step.
Install Python 3:
We pick Python 3.6.8 which at the moment I’m writing this article [march 2019] is the best supported version by the other external libraries needed for computer vision.
- Download Python 3.6.8 from this link.
- Run the installation file.
- On the installation file remember to stick “Add Python 3.6 to PATH”.
- Click on “Install Now” and go ahead until you see the message “Setup was successful”.
Install Opencv 4:
- Download the Opencv binary files here: //www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
- Choose the compatible version of Opencv to your Python. We’ll download the latest version of Opencv [4.1] for Python 3.6.8.
How to understand the right version?
-cp37m-win32.whl means that Opencv is for python 3.7 [32 bit version]
-cp36m-win_amd64.whl means that Opencv is for python 3.6 [64 bit version]
- Run the “Command Prompt” of Windows. You can type “CMD” on the sarch bar to find it.
- Go to the directory where the Opencv binaries that you downloaded is located.
cd YOURPATHfor example in my case:
cd C:\Users\pinolo\Downloads - Now let’s
install the Opencv module using PIP.
python pip -m install opencv_python‑4.0.1+contrib‑cp37‑cp36m‑win_amd64.whl - Now let’s install Numpy using PIP.
python pip -m install numpy - The installation is complete. Now we can test it by running python and importing the libraries cv2 [for opencv] and numpy. If we don’t get any error it means that it has been installed successfully.
Hi there, I’m the founder of Pysource.
I’m a Computer Vision Consultant, developer and Course instructor.
I help Companies and Freelancers to easily and efficiently build Computer Vision Software.