Various options for Python and C++ development environments.
We use Python for learning programming, experimentation and prototyping algorithms.
There are several good tools for running Python on the web. Many include programming tutorials.
- Trinket.io : An easy way to run Python in the browser. It includes visual introduction to code using the Python programming language and Turtles.
- Computer Science Circles : This website teaches computer programming using Python.
- Checkio.org : Checkio is the game for coders.
See the Downloading Python on the Python wiki.
The procedure here was tested on Windows 10. Nevertheless, it should also work on any other relatively modern version of Windows OS.
- Download the 64-bit Python 3.5.2 installer from here.
- Run the installer.
- Check "Add Python 3.5 to PATH".
- Click on "Install Now".
- When installer is finished, verify Python is installed by running
pythonat the command line. You should see output similar toPython 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32. - At the PowerShell command line, run
python -m pip install --upgrade pip - At the command line, change directory to your
Documents(or preferred project) directory. - Run
mkdir venvs. This will create a directory to hold virtual Python environments. - Run
python -m venv .\venvs\cv. - Run
.\venvs\cv\Scripts\Activate.ps1. You should see a(cv)at the beginning of your command prompt. When the virtual environment is activated like this, all packages you install will now be isolated in this virtual environment. - Download
opencv_python-3.1.0+contrib_opencl-cp35-cp35m-win_amd64.whlfrom http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv. - Once downloaded, note where the downloaded file is saved. From the command prompt, run
pip install <downloaded file>. For example, I ranpip install D:\Users\Jeff\Downloads\opencv_python-3.1.0+contrib_opencl-cp35-cp35m-win_amd64.whl. - Download and install Cmake for windows https://cmake.org/download/.
- Download and install Microsoft Visual Studio Community https://www.visualstudio.com/. Install with C++.
- Download and unzip OpenCV source code https://github.com/opencv/opencv/archive/3.1.0.zip to
C:\opencv\sources. - Run Cmake GUI and browse to the source code for "Where is the source code" text entry box.
- Create a build directory
C:\opencv\buildand enter that directory in Cmake's "Where to build the binaries" text entry box. - Click the "Configure" button. After running, Python 3 option should be checked in the checklist with the red background.
- Click the "Generate" button to build Visual Studio Project files in the
C:\opencv\builddirectory. - In Explorer, navigate to
D:\opencv\buildand double-click theALL_BUILD.vcxprojfile to open the project in VS. - In the "Build" menu, select "Build Solution". This step will take a while.
- If successful, in the "Build" menu, select "Build -> INSTALL"
- At the command line, check the installation:
(cv) C:\Users\Jeff\Documents\GitHub\sf\examples\python [master ≡] python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.1.0'
>>>
Perform the following steps in a Terminal window.
- Install Homebrew according to the instructions on its home page.
- Install Python 3
brew install python3- Install Cuda and edit
$PATHto include development tools. You only need to have the Nvidia bin directory in your $PATH during the OpenCV installation step below.
brew cask install cuda
export PATH=/Developer/NVIDIA/CUDA-7.5/bin:$PATH- Install additional OpenCV prerequisites.
brew tap homebrew/python
brew install homebrew/python/numpy
brew install cmake pkg-config jpeg libpng libtiff eigen openexr qt5 tbb- Install OpenCV
brew tap homebrew/science
brew install opencv3 --with-contrib --with-cuda --with-ffmpeg --with-tbb --with-qt5 --c++11 --with-python3- Show Python 3 how to find bindings. This assumes Python 3.5, adjust the paths as appropriate for the version you installed above.
$ echo /usr/local/opt/opencv3/lib/python3.5/site-packages >> /usr/local/lib/python3.5/site-packages/opencv3.pth- Check installation
python
Python 3.5.2 (default, Jul 2 2016, 03:10:20)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.1.0'
>>>
These instructions are adapted from PyImageSearch's Raspbian installation instructions.
- C++
- C++ with exercism: cmake, Boost
- C++ with OpenCV
- C++ with WPI and ARM toolchain