Real-time edge detection with OpenCV

1. Install opencv

Raspberry Pi

See python development environment construction

Windows

Introducing tensorflow and opencv with anaconda

mac

When entering the system(opencv2)


$ brew install gcc
$ brew install cmake
$ brew install tesseract
$ brew tap homebrew/science
$ brew install opencv
$ ln -s /usr/local/Cellar/opencv/2.4.13.2/lib/python2.7/site-packages/cv2.so /Users/riki/.pyenv/versions/ML-2.7.13/lib/python2.7/site-packages/

When using anaconda(opencv3)


$ pyenv install anaconda3-4.1.1
$ cd <workspace with opencv3>
$ pyenv local anaconda3-4.1.1
$ conda install -c https://conda.anaconda.org/menpo opencv3
$ conda update hdf5

2. Script creation

Use opencv's canny edge detection.

edge-detection.py


import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
    ret, frame = cap.read()
    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    frame =  cv2.Canny(frame, threshold1 = 100, threshold2=300)
    cv2.imshow('frame',frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()
スクリーンショット 2017-08-15 16.58.07.png

Recommended Posts

Real-time edge detection with OpenCV
Try edge detection with OpenCV
[Python] Using OpenCV with Python (Edge Detection)
Face detection with Python + OpenCV
Anime face detection with OpenCV
Real-time image processing basics with opencv
OpenCV feature detection with Google Colaboratory
Cat detection with OpenCV (model distribution)
Draw a watercolor illusion with edge detection in Python3 and openCV3
[Python] Real-time object detection with iPad camera
Hello World and face detection with OpenCV 4.3 + Python
Edge extraction with python + OpenCV (Sobel filter, Laplacian filter)
Resize, mosaic, face detection with OpenCV, sometimes Zojirushi
Detect stoop with OpenCV
Binarization with OpenCV / Python
Rotate sprites with OpenCV
Real-time drawing with matplotlib
Data Augmentation with openCV
Easy TopView with OpenCV
Stumble with homebrew opencv3
Improve detection accuracy quickly by specifying parameters with openCV face detection
Face recognition with Python's OpenCV
"Apple processing" with OpenCV3 + Python3
Real-time face recognition with video acquired by getUserMedia [HTML5, openCV]
Image editing with python OpenCV
Camera capture with Python + OpenCV
Edge detection (Laplacian, Sobel, Canny)
[Python] Using OpenCV with Python (Basic)
Binarize photo data with OpenCV
Loop video loading with opencv
Get image features with OpenCV
Face recognition / cutting with OpenCV
Blockchain tampering detection with Python
Face detection with Haar Cascades
Try OpenCV with Google Colaboratory
Real-time web with Django Channels
Cascade classifier creation with opencv
Using OpenCV with Python @Mac
Image recognition with Keras + OpenCV
Real-time object detection Android app with TensorFlow and Camera X
[Image processing] Edge detection using Python and OpenCV makes Poo naked!
Shining life with Python and OpenCV
Face detection with YOLO Face (Windows10, Python3.6)
[Python] Using OpenCV with Python (Image Filtering)
Neural network with OpenCV 3 and Python 3
I tried trimming efficiently with OpenCV
[Python] Using OpenCV with Python (Image transformation)
Face detection with Lambda (Python) + Rekognition
Erase certain colors with OpenCV + PySimpleGUI
Introducing OpenCV on Mac with homebrew
Make OpenCV object detection rotation invariant
Easy Python + OpenCV programming with Canopy
Finding the simplest mistakes with OpenCV
[OpenCV] Personal identification with face photo
Try face recognition with python + OpenCV
I tried face detection with MTCNN
Rotate sprites with OpenCV # 2 ~ Mastering cv2.warpAffine () ~
Cut out face with Python + OpenCV
Change point detection with Kalman filter
Face recognition with camera with opencv3 + python2.7
Search for homeomorphic idioms with opencv