Draw Geometric Shapes on Images Using Python OpenCV Module

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

2K+ Views

The basic operations of OpenCV is to draw over images. The ability to add different geometric shapes just like lines, circles and rectangle etc. Often working with image analysis, we want to highlight a portion of the image, for example by adding a rectangle that defines that portion. Also as example an arrow to indicate something. cv2.line() − This function is used to draw line on an image. cv2.rectangle() − This function is used to draw rectangle on an image. cv2.circle() − This function is used to draw circle on an image. cv2.putText() − This function is used to write ... Read More

Generate All Possible Valid ID Addresses from Given String in Python

Vikyath Ram
Updated on 30-Jul-2019 22:30:23

858 Views

String is given. String contains only digit. Our task is to check all possible valid IP address combinations. Here first we check the length of the string then split by ".". Then we check the different combination of ".". Example Input : "255011123222" It's not a valid IP address. Input : 255011345890 Valid IP address is 255.011.123.222 Algorithm Step 1: First check the length of the string. Step 2: Split the string by ".". We will place 3 dots in the given string. W, X, Y, and Z are numbers from 0-255 the numbers cannot be ... Read More

Read an Image Using Python OpenCV Module

Samual Sam
Updated on 30-Jul-2019 22:30:23

2K+ Views

In OpenCv module, we can use the function cv2.imread() to read an image. When inputting the image path, the image should be in the working directory or a full path of image should be given. cv2.IMREAD_COLOR − This function loads a color image and any transparency of image will be neglected. It is the default flag. cv2.IMREAD_GRAYSCALE − This function loads image in grayscale mode cv2.IMREAD_UNCHANGED − This function loads image as such including alpha channel Source Image Example import numpy as np import cv2 my_img = cv2.imread('C:/Users/TP/Desktop/poor/poverty_india.jpg', 0) cv2.imshow('image', my_img) k = cv2.waitKey(0) & 0xFF # wait ... Read More

Find K-th Smallest Element in a 2D Array Using Python

Arushi
Updated on 30-Jul-2019 22:30:23

483 Views

One n×n user input integer matrix is given and the value of k. Our task is to find out k'th smallest element in a 2D array. Here we use heapq mudule.Heap queue (or heapq) in Python. In Python, it is available using “heapq” module. The technique of this module in python is that each time the smallest of heap element is popped (min heap).nsmallest () method is used to get n least values from a data frame or a series. Example Input Array is:: 10 20 20 40 15 45 40 30 32 33 30 50 ... Read More

Dunder or Magic Methods in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

642 Views

magic methods that allow us to do some pretty neat tricks in object oriented programming. These methods are identified by a two underscores (__) used as prefix and suffix. As example, function as interceptors that are automatically called when certain conditions are met. In python __repr__ is a built-in function used to compute the "official" string representation of an object, while __str__ is a built-in function that computes the "informal" string representations of an object. Example Code Live Demo class String: # magic method to initiate object def __init__(self, string): ... Read More

MySQL Select Query to Select Rows Not in Another Table

Chandu yadav
Updated on 30-Jul-2019 22:30:23

2K+ Views

For our example, we will create two tables and apply Natural Left Join to get the rows from a table not present in the second table. Creating the first table. mysql> create table FirstTableDemo -> ( -> id int, -> name varchar(100) -> ); Query OK, 0 rows affected (0.48 sec) Inserting records into first table. mysql> insert into FirstTableDemo values(1, 'Bob'), (2, 'John'), (3, 'Carol'); Query OK, 3 rows affected (0.13 sec) Records: 3 Duplicates: 0 Warnings: 0 To display all ... Read More

Difference Between Chash and Visual Chash

Arjun Thakur
Updated on 30-Jul-2019 22:30:23

2K+ Views

C# and Visual C# are both the same. When you use Visual Studio for C# development, it is called Visual C# .Consider Visual C# as an implementation of C#. Microsoft Visual Studio is an IDE from Microsoft to develop programs, web app, web services, etc. The current version of Visual Studio is Visual Studio 2017, that supports .NET 3.5 to 4.7 framework. C# is a multi-paradigm programming language whose current version is C# 7.3. The following reasons make C# a widely used professional language − It is a modern, general-purpose programming language It is object oriented. It is ... Read More

Histograms Equalization Using Python OpenCV Module

Samual Sam
Updated on 30-Jul-2019 22:30:23

704 Views

This is a method in image processing to do contrast adjustment using the image's histogram. Actually this method usually increases the global contrast of many images, especially when the usable data of the image is represented by close contrast values and through this adjustment, the intensities can be better distributed on the histogram and it allows for areas of lower local contrast to gain a higher contrast. OpenCV has a function to do this, cv2.equalizeHist() and its input is just grayscale image and output is our histogram equalized image. This technique is good when histogram of the image is confined ... Read More

Remove All Non-Alphanumeric Characters from a String in MySQL

Chandu yadav
Updated on 30-Jul-2019 22:30:23

2K+ Views

Non-alphanumeric characters are as follows − @, !, #, &, (), ?, / There is no inbuilt function to remove non-alphanumeric characters from a string in MySQL. Therefore, we create a function which removes all non-alphanumeric characters. The function declaration and definition is as follows. mysql> delimiter // mysql> CREATE FUNCTION RemoveNonAlphaNumeric( s CHAR(255) ) RETURNS CHAR(255) DETERMINISTIC -> BEGIN -> DECLARE var1, length SMALLINT DEFAULT 1; -> DECLARE result CHAR(255) DEFAULT ''; -> DECLARE ch CHAR(1); ... Read More

Why Do Integers in Database Row Tuple Have an L Suffix in MySQL

Arjun Thakur
Updated on 30-Jul-2019 22:30:23

303 Views

The ‘L’ suffix concept in MySQL can be related with Python. In Python 2, the long integer literal is suffixed with L or l, but int and long have been binded into int in version 3. Therefore, there is no need for L or l. Adding large numbers in Python Version 3.7 (Python 3), without using any suffix. Here, if we suffix L or l, Python 3 gives an error. However, Python Version 2 suffixed with L or l will not give an error. The following is the output with no error. Hence, Python int is ... Read More

Advertisements