OpenCV

OpenCV

OpenCV is a library of programming functions mainly aimed at real-time computer vision. Originally developed by Intel, it was later supported by Willow Garage then Itseez. The library is cross-platform and free for use under the open-source BSD license
Verda  Conroy

Verda Conroy

1591743681

Create a Virtual Pen and Eraser with Python OpenCV - Genial Code

Learn Free how to create a virtual pen and eraser with python and OpenCV with source code and complete guide. This entire application is built fundamentally on contour detection. It can be thought of as something like closed color curves on compromises that have the same color or intensity, it’s like a blob. In this project we use color masking to get the binary mask of our target color pen, then we use the counter detection to find the location of this pen and the contour to find it.

#python #create virtual pen and eraser with opencv #create virtual pen and eraser with python opencv #programming #opencv #python opencv

Create a Virtual Pen and Eraser with Python OpenCV - Genial Code

A Simple HDR Implementation on OpenCV Python

Learn how to create a high dynamic range (HDR) image using Python and OpenCV

HDR images encompass the information of multiple pictures with different exposures. In a scene which the source of light is uneven, a single shot may overexpose certain areas of the image and details will be lost due to elevated brightness. Conversely, this picture may also present underexposed areas which will also lead to information loss.

To create an HDR image you will need:

  1. Take pictures with different exposures. Minimum of 2, generally 3, you can use more than 3 images but it will take a lot of CPU resources.
  2. Align the images. Even if you use a tripod you will need to perform this step (we are talking about pixel level alignment). Not properly aligning your image will lead to artifacts and ‘ghosts’ in your HDR image.
  3. Merge the aligned images into one.
  4. Perform tone mapping on the merged image. In nature the minimum possible brightness is zero but the maximum is not limited to 255, in fact there is no limit to it, it can be infinity. For this reason we need to map the image obtained in the third step to a (0, 255) range. This can be achieved with tone mapping.

#hdr #opencv #computer-vision #python #opencv #opencv python

A Simple HDR Implementation on OpenCV Python
Hertha  Walsh

Hertha Walsh

1604210160

OpenCV + CUDA + AWS EC2 + (No More Tears)

By default, there is no need to enable OpenCV with CUDA for GPU processing, but during production, when you have heavy OpenCV manipulations to do on image/video files, we can make use of the OpenCV CUDA library to make those operations to run on GPU rather than CPU and it saves a lot of time.

It was not easy as it is said to connect the OpenCV library to enable it with CUDA, I had to go through a painful process for a week to establish the connection properly, also its both time & money consuming process. So this time I want to record the overall process for my future, as well as for others.

For the demonstration, I am renting an EC2 instance with a p3.8xlarge instance in the AWS, which has 4 Nvidia GPUs.

Image for post

Source — AWS EC2 Pricing

So if you need any help in starting an EC2 instance for the first time, you can refer to my previous post on Step by Step Creation of an EC2 Instance in AWS and Access it via Putty & WinSCP and during the process select the GPU instance you require.

Now after ssh-ing into the instance, before we get into the process we need to install a lot of packages to make the environment ready.

_Note: I have consolidated all the commands I ran from start to end and added them at the bottom. If you are more curious find them here in this __link _and follow along.

Run the below commands one after another on your instance and also I have attested the screenshots to compare the outputs against mine.

All the screenshots used hereafter are sourced by the author.

Table of Contents:

  1. Install OpenCV Dependencies, Nvidia CUDA driver, CUDA toolkit
  2. Download OpenCV Source Code
  3. Configure Python Virtual Environment
  4. Determine Your CUDA Architecture Version
  5. Configure OpenCV with Nvidia GPU Support
  6. Compile OpenCV and Create a Symbolic link
  7. References
  8. History of Commands

Step 1: Install OpenCV Dependencies, Nvidia CUDA driver, CUDA toolkit.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake unzip pkg-config
sudo apt-get install gcc-6 g++-6
sudo apt-get install screen
sudo apt-get install libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libopenblas-dev libatlas-base-dev liblapack-dev gfortran
sudo apt-get install libhdf5-serial-dev
sudo apt-get install python3-dev python3-tk python-imaging-tk
sudo apt-get install libgtk-3-dev
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-driver-418
sudo reboot

#opencv-in-ubuntu #opencv-python #cuda #nvidia #opencv #ubuntu

OpenCV + CUDA + AWS EC2 + (No More Tears)

OpenCV putText() - Writing Text on Images

Hello fellow learner! In this tutorial, we will learn how to write string text on Images in Python using the OpenCV putText() method. So let’s get started.

Table of Contents

What is the OpenCV putText() method?

OpenCV Python is a library of programming functions mainly aimed at real-time computer vision and image processing problems.

OpenCV contains putText() method which is used to put text on any image. The method uses following parameters.

  • img: The Image on which you want to write the text.
  • text: The text you want to write on the image.
  • org: It is the coordinates of the Bottom-Left corner of your text. It is represented as a tuple of 2 values (X, Y). X represents the distance from the left edge and Y represents the distance from the top edge of the image.
  • fontFace: It denotes the type of font you want to use. OpenCV supports only a subset of Hershey Fonts.
  • FONT_HERSHEY_SIMPLEX
  • FONT_HERSHEY_PLAIN
  • FONT_HERSHEY_DUPLEX
  • FONT_HERSHEY_COMPLEX
  • FONT_HERSHEY_TRIPLEX
  • FONT_HERSHEY_COMPLEX_SMALL
  • FONT_HERSHEY_SCRIPT_SIMPLEX
  • FONT_HERSHEY_SCRIPT_COMPLEX
  • FONT_ITALIC
  • fontScale: It is used to increase/decrease the size of your text. The font scale factor is multiplied by the font-specific base size.
  • color: It represents the color of the text that you want to give. It takes the value in BGR format, i.e., first blue color value, then green color value, and the red color value all in range 0 to 255.
  • thickness (Optional): It represents the thickness of the lines used to draw a text. The default value is 1.
  • lineType (Optional): It denotes the type of line you want to use. 4 LineTypes available are
  • FILLED
  • LINE_4
  • LINE_8 (Default)
  • LINE_AA
  • bottomLeftOrigin (Optional): When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner. The default value is False.

#python modules #opencv #opencv puttext() #writing text on images #opencv puttext() - writing text on images #puttext() - writing text

OpenCV putText() - Writing Text on Images

Python and OpenCV: Apply Filters to Images

I am pretty sure you have tried out various filters available on the social platforms and your camera as well.

Today in this tutorial, we will be applying few of the filters to images. Exciting right?

Let’s begin!

Table of Contents

1. Importing Modules

2. Loading the initial image

#python programming examples #python and opencv: apply filters to images #apply filters to images #python and opencv #opencv #filters to images

Python and OpenCV: Apply Filters to Images
Hello Jay

Hello Jay

1594439145

Keras vs. OpenCV - Differences Between Keras and OpenCV

OpenCV is the open-source library for computer vision and image processing tasks in machine learning. OpenCV provides a huge suite of algorithms and aims at real-time computer vision. Keras, on the other hand, is a deep learning framework to enable fast experimentation with deep learning. In this Keras Tutorial, we will learn about Keras Vs OpenCV.

Keras Vs OpenCV

First, we will see both the technologies, their application, and then the differences between keras and OpenCv.

About OpenCV

Computer Vision is defined for understanding meaningful descriptions of physical objects from the image.

OpenCV was built to provide an infrastructure for computer vision. This library has a huge range of optimized machine learning and computer vision algorithms. These algorithms include object identification, detecting and recognizing faces, object movement tracking, etc. OpenCV provides support for C++, Python, Java and MATLAB programming languages and works on Windows, Linux, Android and Mac Operating Systems.

The common features in OpenCV are read and write images, save and capture images/videos, filter or transform the image, detecting faces,eyes,cars in images or videos, perform feature detection, background subtraction, and tracking objects.

Applications of OpenCV

  • In Robotics, OpenCV is useful in domains like navigation, obstacle avoiding, and in human-robot interaction.
  • In the medical industry it is useful for classification and detection of diseases, for analyzing brain MRI scans and in surgeries.
  • For security purposes, like in biometric scan and video surveillance.
  • In transportation and autonomous vehicles, self-driving cars.

#keras tutorials #keras vs opencv #keras #opencv

Keras vs. OpenCV - Differences Between Keras and OpenCV

Top 10 Exciting OpenCV Project Ideas & Topics for Freshers & Experienced [2021]

OpenCV or Open Source Computer Vision Library is a powerful machine learning, and AI-based library used to develop and solve computer vision problems. Computer vision includes training a computer to understand and comprehend the visual world, identify elements, and respond to them using deep learning models. Businesses today all over the world leverage it in image manipulation, processing, face detection, voice recognition, motion tracking, and object detection.

Companies like Google, Facebook, Microsoft, and Intel already deploy OpenCV to develop computer vision applications. Mark Zuckerberg, in a 2015 interview had remarked, “If we are able to build computers that could understand what’s in an image and tell a blind person who otherwise couldn’t see that image, that would be pretty amazing as well.”

Today, the OpenCV technology has proved to be a breakthrough for blind or visually impaired individuals. It allows them to get acquainted with an unfamiliar environment and recognise objects and people nearby to overcome this vision impairment. Computer vision is also the technology behind self-driving cars and intelligent motion sensor devices.

If you are eyeing a career in computer vision, here are ten interesting open cv projects to help you gain real-world experience. So, let’s get started!

#artificial intelligence #opencv project ideas #opencv project topics #opencv projects

Top 10 Exciting OpenCV Project Ideas & Topics for Freshers & Experienced [2021]

Python Imread(): Different Ways to Load an Image using The OpenCV.imread() Method

In this tutorial, we will learn how to use imread() method of OpenCV-Python in detail and different ways to load an image using imread() method.

Table of Contents

What is Python imread()?

Importing OpenCV to use Python imread()

Syntax of the Python imread() method

Image formats supported by Python imread() method

#python modules #opencv-python #python imread() #opencv.imread() #python imread(): different ways to load an image using the opencv.imread() method #load an image

Python Imread(): Different Ways to Load an Image using The OpenCV.imread() Method
Chando Dhar

Chando Dhar

1619799996

Deep Learning Project : Real Time Object Detection in Python & Opencv

Real Time Object Detection in Python And OpenCV

Github Link: https://github.com/Chando0185/Object_Detection

Blog Link: https://knowledgedoctor37.blogspot.com/#

I’m on Instagram as @knowledge_doctor.

Follow Me On Instagram :
https://www.instagram.com/invites/contact/?i=f9n3ongbu8ma&utm_content=jresydt

Like My Facebook Page:

https://www.facebook.com/Knowledge-Doctor-Programming-114082097010409/

#python project #object detection #python opencv #opencv object detection #object detection in python #python opencv for object detection

Deep Learning Project : Real Time Object Detection in Python & Opencv
Jeromy  Lowe

Jeromy Lowe

1598693940

My Fun AI Project - How To Be Invisible?

Most of you must have heard about the Harry Potter series. In that series, Harry potter used an invisibility cloak, that makes him invisible…! Are you wondering how they made invisible cloaks……? That’s not as tough as rocket science to build this invisibility cloak. By using simple techniques in the OpenCV we can implement this invisible cloak. This concept is similar to the green mat used in movie shootings. After shooting, they add graphics in the place of a green mat to give the output.

In this implementation, we will learn how to create our own ‘Invisibility Cloak’ using simple computer vision techniques in OpenCV. Here we are using OpenCV because it provides the best-inbuilt libraries to implement this in a few steps.

#developers corner #computer vision #invisible using opencv #opencv #opencv project

My Fun AI Project - How To Be Invisible?
Xander  Hane

Xander Hane

1616147357

OpenCV Image Translation

In this tutorial, you will learn how to translate and shift images using OpenCV.

Translation is the shifting of an image along the x- and _y-_axis. To translate an image using OpenCV, we must:

  1. Load an image from disk
  2. Define an affine transformation matrix
  3. Apply the  cv2.warpAffine function to perform the translation

This sounds like a complicated process, but as you will see, it can all be done in only two lines of code!

To learn how to translate images with OpenCV, just keep reading.

#opencv #opencv image

OpenCV Image Translation
Art  Lind

Art Lind

1602925200

Face Detection in OpenCV

We will discuss how we can apply Face Detection using OpenCV. We go straightforward with a practical reproducible example.

The logic it the following: We get the image from the URL (or from the hard disk). We convert it to an numpy array and then to a grayscale. Then by applying the proper CascadeClassifier we get the bounding boxes of the faces. Finally, using PIllow (or even OpenCV) we can draw the boxes on the initial image.

import cv2 as cv
import numpy as np
import PIL
from PIL import Image
import requests
from io import BytesIO
from PIL import ImageDraw
## I have commented out the cat and eye cascade. Notice that the xml files are in the opencv folder that you have downloaded and installed
## so it is good a idea to write the whole path
face_cascade = cv.CascadeClassifier('C:\\opencv\\build\\etc\\haarcascades\\haarcascade_frontalface_default.xml')
#cat_cascade = cv.CascadeClassifier('C:\\opencv\\build\\etc\\haarcascades\\haarcascade_frontalcatface.xml')
#eye_cascade = cv.CascadeClassifier('C:\\opencv\\build\\etc\\haarcascades\\haarcascade_eye.xml')
URL = "https://images.unsplash.com/photo-1525267219888-bb077b8792cc?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80"
response = requests.get(URL)
img = Image.open(BytesIO(response.content))
img_initial = img.copy()
## convert it to np array
img = np.asarray(img)
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray)
## And lets just print those faces out to the screen
#print(faces)
drawing=ImageDraw.Draw(img_initial)
## For each item in faces, lets surround it with a red box
for x,y,w,h in faces:
    ## That might be new syntax for you! Recall that faces is a list of rectangles in (x,y,w,h)
    ## format, that is, a list of lists. Instead of having to do an iteration and then manually
    ## pull out each item, we can use tuple unpacking to pull out individual items in the sublist
    ## directly to variables. A really nice python feature
    #
    ## Now we just need to draw our box
    drawing.rectangle((x,y,x+w,y+h), outline="red")
display(img_initial)

#python #facedetection #ai #opencv #opencv-python

Face Detection in OpenCV

Fix: OpenCV ImShow Not Working

Here is how you can OpenCV fix it in 5 minutes or less

I have spent countless hours trying to fix problems with OpenCV, especially when running cv2.imshow like this:

imshow has just the bad reputation of not working a lot of times.

Since I couldn’t find any solution online, I decided I will write this post, either for the George of the future or for anyone else that might face the same problem!

In my case I had it working for a long time, and all of the sudden after switching python versions and several virtual environments later it just stopped working despite I was using the same computer.

I’m aware of 2 possible problems that can happen to you:

Problem 1:  When calling imshow  the image opens in a window, but when closing it crashes.

Trending AI Articles:

1. Why Corporate AI projects fail?

2. How AI Will Power the Next Wave of Healthcare Innovation?

3. Machine Learning by Using Regression Model

4. Top Data Science Platforms in 2021 Other than Kaggle

Problem 2: When calling imshow the everything just freezes and no window even shows up.

#fix #opencv-python #jupyter-notebook #opencv #troubleshooting

Fix: OpenCV ImShow Not Working
Madaline  Mertz

Madaline Mertz

1622693652

Starting With OpenCV-1 🔥😎

OpenCV is a cross-platform library using which we can develop real-time computer vision applications . It mainly focuses on image processing, video capture, and analysis, including face detection and object detection.

** Let’s Start With Basic Implementation**

“ How we can capture the pic and view it in the new Window? ”

#machine-learning-python #basic-python #opencv-python #opencv

Starting With OpenCV-1 🔥😎
Kim Hans  Jin

Kim Hans Jin

1595403019

Face Recognition with Python and OpenCV

What is face recognition? Or what is recognition? When you look at an apple fruit, your mind immediately tells you that this is an apple fruit. This process, your mind telling you that this is an apple fruit is recognition in simple words. So what is face recognition then? I am sure you have guessed it right. When you look at your friend walking down the street or a picture of him, you recognize that he is your friend Paulo. Interestingly when you look at your friend or a picture of him you look at his face first before looking at anything else. Ever wondered why you do that? This is so that you can recognize him by looking at his face. Well, this is you doing face recognition.

But the real question is how does face recognition works? It is quite simple and intuitive. Take a real-life example, when you meet someone first time in your life you don’t recognize him, right? While he talks or shakes hands with you, you look at his face, eyes, nose, mouth, color, and overall look. This is your mind learning or training for the face recognition of that person by gathering face data. Then he tells you that his name is Paulo. At this point, your mind knows that the face data it just learned belongs to Paulo. Now your mind is trained and ready to do face recognition on Paulo’s face. Next time when you will see Paulo or his face in a picture you will immediately recognize him. This is how to face recognition work. The more you will meet Paulo, the more data your mind will collect about Paulo and especially his face, and the better you will become at recognizing him.

Now the next question is how to code face recognition with OpenCV, after all this is the only reason why you are reading this article, right? OK then. You might say that our mind can do these things easily but to actually code them into a computer is difficult? Don’t worry, it is not. Thanks to OpenCV, coding face recognition is as easier as it feels. The coding steps for face recognition are the same as we discussed in the real-life example above.

  • Training Data Gathering: Gather face data (face images in this case) of the persons you want to recognize
  • Training of Recognizer: Feed that face data (and respective names of each face) to the face recognizer so that it can learn.
  • Recognition: Feed new faces of the persons and see if the face recognizer you just trained recognizes them.

OpenCV comes equipped with a built-in face recognizer, all you have to do is feed it the face data. It’s that simple and this how it will look once we are done coding it.

#face-recognition #facedetection #opencv #opencv-python #python

Face Recognition with Python and OpenCV