Windows 11 provides a user-friendly environment for developers, making it easier to set up tools and libraries for programming. In this blog, we will walk through the installation process of OpenCV on Windows 11, covering the installation of Python, PIP, and finally, OpenCV. Additionally, we will touch upon configuring Visual Studio Code for running Python projects.

1. Setting Up Python:

  • Download Python: Visit https://www.python.org/downloads/ and grab the latest Python version (currently 3.12).
  • Install Python: Run the downloaded .exe file and follow the prompts. Don’t worry about conflicting with older versions; Python handles multiple installations gracefully. Keep default installation options while installing.
  • Verify Installation: Open a command prompt and type python. If you see the Python version, you’re good to go!

2. Installing PIP and OpenCV:

  • PIP to the Rescue: Python thoughtfully includes PIP, a handy package installer, during its setup. Confirm its presence with pip --version in the command prompt. If prompted, upgrade PIP using the provided instructions.
  • Installing OpenCV: Type pip install opencv-python in the command prompt. This command fetches and installs OpenCV along with NumPy, a crucial dependency.

3. Verification and Visual Studio Code Integration (Optional):

  • Ensure Successful Installation:
    • Open a command prompt and type python.
    • Enter import cv2 and press Enter. No errors? You’re golden!
    • Check the version with cv2.__version__.
  • Visual Studio Code Setup (Optional):
    • Create a Test.py file with the following code:

Python

import cv2
print("Open CV Version " + cv2.__version__)

Install the Python extension if prompted.

– Optionally, add the OpenCV-IntelliSense extension for handy syntax suggestions. – Open the integrated terminal and run `python Test.py` to execute the code and witness the OpenCV version printed.

Congratulations! You’ve successfully installed OpenCV on Windows 11 and optionally integrated it with Visual Studio Code. Now, let the computer vision journey begin!

Categorized in: