Posted on Leave a comment

A Step-by-Step Guide on Installing OpenCV with pip in Windows

OpenCV, or Open Source Computer Vision Library, is a powerful and widely-used open-source computer vision and machine learning software library. It provides a plethora of tools and functions for image and video processing, making it an essential resource for developers, researchers, and hobbyists. Installing OpenCV on a Windows system can be a straightforward process when using the Python package manager, pip. In this article, we’ll walk you through the steps to install OpenCV on your Windows machine using pip.

Prerequisites:

Before diving into the installation process, ensure that you have the following prerequisites:

  1. A Windows operating system.
  2. Python installed on your machine. You can download the latest version of Python from the official website: https://www.python.org/downloads/.

Installation Steps:

Follow these step-by-step instructions to install OpenCV using pip in Windows:

Step 1: Open a Command Prompt

Press Win + R to open the Run dialog, type cmd, and press Enter. This will open the Command Prompt.

Step 2: Upgrade pip

Ensure that your pip is up-to-date by running the following command:

pip install --upgrade pip

This ensures that you have the latest version of pip installed.

Step 3: Install NumPy

NumPy is a prerequisite for OpenCV, as it is used for numerical operations. Install it by running:

pip install numpy

Step 4: Install OpenCV

Now, you can install the OpenCV package using the following command:

pip install opencv-python

This command will download and install the latest stable version of OpenCV along with its dependencies.

Step 5: Verify the Installation

To ensure that OpenCV has been successfully installed, open a Python interpreter or create a simple Python script and import the cv2 module:

import cv2
print(cv2.__version__)

This should print the installed OpenCV version, confirming that the installation was successful.

Posted on Leave a comment

How to make comments in python

In Python, you can make comments using the hash symbol (#).

Any text that appears after the hash symbol (#) on the same line is considered a comment and is ignored by the Python interpreter.

For example:

# This is a comment
print("Hello, world!")  # This is also a comment

In the above example, the first line is a comment, and it is ignored by the Python interpreter. The second line is a print statement, which will print “Hello, world!” to the console when executed. The third line is another comment, which is also ignored.

You can also use multi-line comments by enclosing them in triple quotes (“”” “””). For example:

"""
This is a multi-line
comment in Python.
"""

print("Hello, world!")

In this example, the first three lines are a multi-line comment, and they are ignored by the Python interpreter. The fourth line is a print statement, which will print “Hello, world!” to the console when executed.

Posted on Leave a comment

Python – Basic Mathematical Programs

How to perform addition.

# Addend + Addend = Sum
a = 19
b = 15

sum = a + b

print("Total Sum of a and b =",sum)

How to perform subtraction

#Minuend - Subtrahend = Difference

Minuend = 22
Subtrahend = 140

Difference = Minuend - Subtrahend

print("The Difference equals to ",Difference)

How to perform multiplication

# Multiplicand X multiplier = product

Multiplicand = 56
Multiplier = 12

Product = Multiplicand * Multiplier

print("The product of the Multiplicand and mulitplier is ",Product)

How to perform division

# Dividend / Divisor = Quotient (Remainder)

Dividend = 18
Divisor = 5

Quotient = Dividend / Divisor

print("The quotient + reminder = ",Quotient)

How to perform if-else operations

# If-else Python

a = 1
b = 1

if (a < b):
    print("A is Lesser than B")
elif (a ==b):
    print("A is equal to B")
else:
    print("A is Greater than B")

How to perform a while loop operation

# While Loop
# Using While Loop to perform multiplication using Addition

A = 13131313

sum = 0;
counter = 1

while (counter < 11):
    sum = A + sum
    print(A," x ",counter," = ",sum)
    counter = 1 + counter