[Python] Webcam frame size and FPS settings with OpenCV

One of the series that I re-examine every time I need it. This is a method to set the frame size and FPS when handling a webcam using OpenCV.

video_input.set(cv2.CAP_PROP_FPS, 60)           #Set camera FPS to 60 FPS
video_input.set(cv2.CAP_PROP_FRAME_WIDTH, 1280) #Set the width of the camera image to 1280
video_input.set(cv2.CAP_PROP_FRAME_HEIGHT, 720) #Set the vertical width of the camera image to 720

print video_input.get(cv2.CAP_PROP_FPS)
print video_input.get(cv2.CAP_PROP_FRAME_WIDTH)
print video_input.get(cv2.CAP_PROP_FRAME_HEIGHT)

The reason why I investigated it again is that it is the successor to the ace c920r in the USB 2.0 Web camera world. I bought the Logitech c922. [Logitech C922](https://www.amazon.co.jp/Logitech-%E3%83%AD%E3%82%B8%E3%82%AF%E3%83%BC%E3%83%AB- C922-% E3% 82% B9% E3% 83% 88% E3% 83% AA% E3% 83% BC% E3% 83% 9F% E3% 83% B3% E3% 82% B0-% E3% 82% A6% E3% 82% A7% E3% 83% 96% E3% 82% AB% E3% 83% A0 / dp / B01LYTKPDT "Logitech C922")

There is almost no difference in performance from c920r, but I was attracted to the notation of 720p (60fps) and purchased it. Even if it is a USB3.0 type industrial camera, it is rare for a Web camera that claims 60fps on a commercial machine.

Below, a trial shot video ↓ After all, object tracking is more stable when the frame rate is higher. [[Ubuntu] [Python] Object tracking using dlib (60fps confirmation)](https://www.youtube.com / watch? v = jOI7IaZHcVw)

The source code is below ↓ It also incorporates a program to change fps. [Ubuntu] [Python] Object tracking using dlib

that's all.

Recommended Posts

[Python] Webcam frame size and FPS settings with OpenCV
Shining life with Python and OpenCV
Neural network with OpenCV 3 and Python 3
Save video frame by frame with Python OpenCV
Install OpenCV 4.0 and Python 3.7 on Windows 10 with Anaconda
Binarization with OpenCV / Python
Display and shoot webcam video with Python Kivy [GUI]
Reading, displaying and speeding up gifs with python [OpenCV]
Programming with Python and Tkinter
Encryption and decryption with Python
"Apple processing" with OpenCV3 + Python3
Python and hardware-Using RS232C with Python-
Image editing with python OpenCV
Camera capture with Python + OpenCV
[Python] Using OpenCV with Python (Basic)
Face detection with Python + OpenCV
python with pyenv and venv
Using OpenCV with Python @Mac
Works with Python and R
Convert video to black and white with ffmpeg + python + opencv
Communicate with FX-5204PS with Python and PyUSB
Environment construction of python and opencv
Automatic image interpolation with OpenCV and Python (Fast Marching Method, Navier-Stokes)
Robot running with Arduino and python
Install Python 2.7.9 and Python 3.4.x with pip.
AM modulation and demodulation with python
[Python] font family and font with matplotlib
Scraping with Node, Ruby and Python
[Python] Using OpenCV with Python (Image transformation)
Scraping with Python, Selenium and Chromedriver
[Python] Using OpenCV with Python (Edge Detection)
Create a striped illusion with gamma correction for Python3 and openCV3
Scraping with Python and Beautiful Soup
How to make a surveillance camera (Security Camera) with Opencv and Python
Make a simple OMR (mark sheet reader) with Python and OpenCV
JSON encoding and decoding with python
Hadoop introduction and MapReduce with Python
Draw a watercolor illusion with edge detection in Python3 and openCV3
Reading and writing NetCDF with Python
Try face recognition with python + OpenCV
Cut out face with Python + OpenCV
Multi-line size specification reading with python
Face recognition with camera with opencv3 + python2.7
Load gif images with Python + OpenCV
Reading and writing CSV with Python
Find image similarity with Python + OpenCV
Use OpenCV with Python 3 in Window
Multiple integrals with Python and Sympy
Draw an illustration with Python + OpenCV
Make blur videos look like fixed-point cameras with Python and OpenCV
Coexistence of Python2 and 3 with CircleCI (1.0)
Track baseball balls with Python + OpenCV
Easy modeling with Blender and Python
Graph Based Segmentation with Python + OpenCV
Draw shapes with OpenCV and PIL
Sugoroku game and addition game with python
FM modulation and demodulation with Python
Draw arrows (vectors) with opencv / python
[Python] Try to recognize characters from images with OpenCV and pyocr
Basic study of OpenCV with Python
Don't work Python with OpenCV on AMD Ryzen CPU on WSL2 Ubuntu 18.04 And 20.04