Python script to detect lines and circles in an image using Hough Transform algorithms in a video capture.
This script makes use of OpenCV python. The code is compatible with both OpenCV 2 and 3 versions.
-
Install python 2.7 and add it to your system path.
-
On Windows systems, open up Advanced System Settings, edit your Path variable and append
C:\Python27\Scripts
at the end. -
Install OpenCV python on your system.
-
For Windows: 1. Download a precompiled version of OpenCV. 2. Install by double clicking the executable file. 3. Now, copy the cv2.pyd file at opencv\build\python\2.7\cv2.pyd to C:\python27\Scripts\site-packages.
-
For MacOS: 1. Install homebrew. 2. Install homebrew branch of python using
brew install python
. 3. Add this to your ~/.bash_profile.export PATH=/usr/local/bin:$PATH
to specify the target packages for homebrew. 4. Refresh your bash profile usingsource ~/.bash_profile
. 5. Install numpy withpip install numpy
6. Install opencv withbrew install opencv3
-
For Ubuntu, install with
sudo apt-get install python-numpy python-opencv
. This should install a stable version of OpenCV-Python 2.4.9. -
Test the installation by opening a terminal. Type in
python
. -
In the prompt type,
import cv2
and thencv2.__version__
.
- Run
python LineAndCircleDetection.py