TRM: Tiny AI Models beating Giants on Complex Puzzles
Models with billions, or trillions, of parameters are becoming the norm. These models can write
In this post, we will provide step by step instructions on how to install OpenCV 3 (C++ and Python) on Windows. If you want to install OpenCV 4 from source, please check out this tutorial: Install OpenCV from source on Windows If you want to install OpenCV 4 using a
In this post, we will provide step by step instructions on how to install OpenCV 3 (C++ and Python) on Windows.
If you want to install OpenCV 4 from source, please check out this tutorial: Install OpenCV from source on Windows
We have used Windows Power Shell to run commands. Alternatively, you can use the command prompt too.
Download and install Visual Studio 2015 community edition from https://www.visualstudio.com/vs/older-downloads/. If you are finding it difficult to search for Visual Studio 2015, use this link. If you don’t have a Visual Studio Dev Essentials account, create account and login. Run installer, select "Custom" in "type of installation".
In next screen within Programming Languages, select Visual C++ and Python tools for Visual Studio. Click next.
Now click next. It will take some time to complete the installation.
We have finished installation of Visual Studio 2015.
Note: Since Visual Studio 2017 fails to compile Dlib, we switched back to Visual Studio 2015.
Download and install CMake v3.10.0 from https://cmake.org/download/.
During installation select "Add CMake to system PATH"
Download and install Anaconda 64-bit version from https://www.anaconda.com/products/individual#Downloads.
Note: Dlib ships a prebuilt binary for Python 3 and not Python 2. Building Dlib’s Python bindings from source is a hassle as you have to build Boost.Python first.
So it is advised to install Anaconda 3. In case you want to build OpenCV’s Python bindings for Python 2, you can install Anaconda 2 as well but you won’t be able to use Dlib in Python 2.
While installing Anaconda make sure that you check both options:
Go to https://github.com/opencv/opencv/releases and download opencv-3.3.1 source code zip
Go to https://github.com/opencv/opencv_contrib/releases and download opencv_contrib-3.3.1 source code zip
Extract both zip files. Although you can keep opencv and opencv_contrib folders anywhere, I suggest that you should keep both in the same directory. I have placed these two folders in "My Documents" directory.
NOTE : From hereon we will refer the path to opencv-3.3.1 folder as OPENCV_PATH. For example, in my case OPENCV_PATH is C:/Users/Vaibhaw Chandel/Documents/opencv-3.3.1
Depending upon where you have kept opencv-3.3.1 folder, this path would be different.
Run Cmake, in box "Where is the source code" write value of OPENCV_PATH (which is path to opencv-3.3.1 folder) and path to build directory. We will choose build directory as OPENCV_PATH/build
Now click configure.
You will be asked for permission to create the build folder. Click Yes.
When prompted to select a compiler, select Visual Studio 14 2015 Win64.
Click finish and in the next window keep the default parameters checked.
Click finish. Now CMake will look in the system directories and generate the makefiles.
We will make few changes in the default configuration generated by CMake. Click on the images to see a larger version.
Now click configure to apply these changes.
Now click on configure again to include this change.
This section is only for people who want to generate OpenCV binary for both Python2 and Python 3. If you are going to use just one Python either 2 or 3, you should skip this section.
CMake was unable to find paths for my Python3 files.
So I manually added paths for Python3.
Now click configure again. After configuring is done, search opencv_python in search bar, both BUILD_opencv_python2 and BUILD_opencv_python3 will be automatically checked. Now we are sure that OpenCV binaries for both Python2 and Python 3 will be generated after compilation.
If CMake is able to configure without any errors it should say "Configuring done".
Click generate.
Note: Whenever you make any changes(check/uncheck boxes or change path) to configuration generated by CMake, always click configure and generate.
Open Windows Command Prompt (cmd).
Go to OPENCV_PATH/build directory and run this command
cmake.exe --build . --config Release --target INSTALL
Open CMake GUI again as mentioned in Step 5.
Now in windows command prompt
Go to OPENCV_PATH/build directory and run this command
cmake.exe --build . --config Debug --target INSTALL
Now that we have compiled OpenCV we will find out how to test a OpenCV project using CMake.
First of all we will add OpenCV dll files’ path to our system PATH. Press Windows Super key, search for "environment variables"
Click Environment Variables in System Properties window
Under System Variables, Select Path and click edit
Click New, and give path to OPENCV_PATH\build\install\x64\vc14\bin and click Ok. Depending upon where you have kept opencv-3.3.1 folder and what version of Visual Studio you used to compile OpenCV, this path would be different. In my case full path is:
C:\Users\Vaibhaw Chandel\Documents\opencv-3.3.1\build\install\x64\vc14\bin
Now click Ok to save. Don’t close the Environment Variables window yet. We will update OPENCV_DIR variable in next step.
Click New in "User Variables" (upper half of right hand side window). Under variable name write OPENCV_DIR and under variable value write OPENCV_PATH\build\install.
As you can see in my case variable value is:
C:\Users\Vaibhaw Chandel\Documents\opencv-3.3.1\build\install
This directory contains file "OpenCVConfig.cmake". This is used by CMake to configure OpenCV_LIBS and OpenCV_INCLUDE_DIRS variables to generate project files.
Now click OK to save and close environment variables window.
Note: If you have an open Command Prompt/Power Shell window before these values were updated, you have to close and open a new Command Prompt/Power Shell window again.
Download this redEyeRemover code and extract it into a folder.
Now open Windows Power Shell and navigate to this directory.
Create a file named CMakeLists.txt and put this code in this file.
cmake_minimum_required(VERSION 2.8)
project( redEyeRemover )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( removeRedEyes removeRedEyes.cpp )
target_link_libraries( removeRedEyes ${OpenCV_LIBS} )
This file has information about opencv’s include and library paths.
Now we will compile removeRedEyes.cpp and run it.
# create build directory mkdir build cd build # create Visual Studio project files using cmake cmake -G "Visual Studio 14 2015 Win64" ..
You can see in the screenshot below that CMake found the OpenCV on my machine.
Now we will build our application.
# build our application cmake --build . --config Release # once the build is complete, it will generate exe file in build\Release directory
Since our C++ code assumes that jpg files are in the current directory, we will move to directory RedEyeRemover and run removeRedEyes.exe file from there.
cd .. .\build\Release\removeRedEyes.exe
After running the application you will see two image windows, one with red eyes and another with black eyes.
Quick way to check whether OpenCV for Python is installed correctly or not is to import cv2 in python interpreter.
Open command prompt in Windows, run python command. This will open Python interpreter. Run these two commands
import cv2 print(cv2.__version__)
Anaconda comes with a feature-rich Python interpreter called IPython. I tested these commands in IPython.
If OpenCV for Python is installed correctly, running command "import cv2" will give no errors. If any error comes up it means installation failed.
Open Windows Power Shell and navigate to directory where you have extracted RedEyeRemover.zip
Now run python code like this:
python .\removeRedEyes.py
If the program runs successfully, you will see two image windows one with red-eyes other with black eyes.
Models with billions, or trillions, of parameters are becoming the norm. These models can write
Deploying ML on Arduino Nano 33 BLE. Explore TinyML techniques, setup steps, and why older
Discover VideoRAG, a framework that fuses graph-based reasoning and multi-modal retrieval to enhance LLMs’ ability
Discover VideoRAG, a framework that fuses graph-based reasoning and multi-modal retrieval to enhance LLMs' ability to understand multi-hour videos efficiently.
Learn how to build AI agent from scratch using Moondream3 and Gemini. It is a generic task based agent free from…
Get a comprehensive overview of VLM Evaluation Metrics, Benchmarks and various datasets for tasks like VQA, OCR and Image Captioning.
Subscribe to our email newsletter to get the latest posts delivered right to your email.
We hate SPAM and promise to keep your email address safe.