Image acquisition from camera with Python + OpenCV

Mainly personal notes. If you execute the following code with Ctrl + C & Ctrl + V, it will work.

environment ・ Python2.7 ・ OpenCV2

capture.py


import cv2

cap = cv2.VideoCapture(0)

while(True):

    # Capture frame-by-frame
    ret, frame = cap.read()

    # Display the resulting frame
    cv2.imshow('frame', frame)
    if cv2.waitKey(1) == 27:
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

Recommended Posts

Image acquisition from camera with Python + OpenCV
Image editing with python OpenCV
Camera capture with Python + OpenCV
[Python] Using OpenCV with Python (Image Filtering)
[Python] Using OpenCV with Python (Image transformation)
Face recognition with camera with opencv3 + python2.7
Find image similarity with Python + OpenCV
Light image processing with Python x OpenCV
Binarization with OpenCV / Python
Image processing with Python
Python, OpenCV camera capture
I tried "smoothing" the image with Python + OpenCV
I tried "differentiating" the image with Python + OpenCV
Image processing from scratch with python (5) Fourier transform
Make OpenCV3 available from python3 installed with pyenv
Image processing from scratch with python (4) Contour extraction
I tried "binarizing" the image with Python + OpenCV
[Small story] Test image generation with Python / OpenCV
"Apple processing" with OpenCV3 + Python3
How to scrape image data from flickr with python
[Python] Using OpenCV with Python (Basic)
[OpenCV / Python] I tried image analysis of cells with OpenCV
Sorting image files with Python (3)
Read QR code from image file with Python (Mac)
Tweet with image in Python
Sorting image files with Python
Switch camera resolution from OpenCV
Image processing with Python (Part 3)
Face detection with Python + OpenCV
JPEG image generation by specifying quality with Python + OpenCV
Create miscellaneous Photoshop videos with Python + OpenCV ② Create still image Photoshop
Get image features with OpenCV
[Windows] [Python] Camera calibration of fisheye lens with OpenCV
With skype, notify with skype from python!
Display USB camera video with Python OpenCV with Raspberry Pi
Using OpenCV with Python @Mac
Image recognition with Keras + OpenCV
[Python] Image processing with scikit-image
Try to measure the position of the object on the desk (real coordinate system) from the camera image with Python + OpenCV
Web crawling, web scraping, character acquisition and image saving with python
Paste png with alpha channel as transparent image with Python / OpenCV
Shoot time-lapse from a PC camera using Python and OpenCV
Cut out frames from video by 1 second with Python + OpenCV
[Python] Easy reading of serial number image files with OpenCV
Shining life with Python and OpenCV
Cut out an image with python
Real-time image processing basics with opencv
Call C from Python with DragonFFI
Neural network with OpenCV 3 and Python 3
Using Rstan from Python with PypeR
Install Python from source with Ansible
Create folders from '01' to '12' with python
[Python] Using OpenCV with Python (Edge Detection)
Image processing with Python 100 knocks # 3 Binarization
Easy Python + OpenCV programming with Canopy
Run Aprili from Python with Orange
Let's do image scraping with Python
Try face recognition with python + OpenCV
Cut out face with Python + OpenCV
Load gif images with Python + OpenCV
Call python from nim with Nimpy