Ankith Reddy

Ankith Reddy

730 Articles Published

Articles by Ankith Reddy

730 articles

Line detection in python with OpenCV?

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 4K+ Views

In this article, we will learn how to detect lines in an image using the Hough Transform technique with OpenCV in Python. What is Hough Transform? Hough Transform is a feature extraction method used to detect simple geometric shapes in images. It can identify shapes even if they are broken or slightly distorted, making it particularly useful for line detection in computer vision applications. A "simple" shape is one that can be represented by only a few parameters. For example: A line requires two parameters: slope and intercept A circle requires three parameters: center coordinates ...

Read More

OpenCV Python Program to blur an image?

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 708 Views

OpenCV is one of the best Python packages for image processing. Like signals carry noise attached to them, images too contain different types of noise mainly from the source itself (camera sensor). Python's OpenCV package provides ways for image smoothing, also called blurring. One of the most common techniques is using a Gaussian filter for image blurring, which smooths sharp edges while minimizing excessive blur. Syntax cv2.GaussianBlur(src, ksize, sigmaX[, dst[, sigmaY[, borderType]]]) Parameters src − Input image ksize − Gaussian kernel size as (width, height). Both values must be odd and positive sigmaX ...

Read More

What is the maximum possible value of an integer in Python?

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 3K+ Views

Python has different integer limits depending on the version. In Python 2, integers had a maximum value before switching to long type, but Python 3 has unlimited precision integers bounded only by available memory. Python 2 Integer Behavior In Python 2, integers automatically switched to long type when they exceeded their limit ? import sys print(type(sys.maxint)) print(type(sys.maxint + 1)) Python 2 Maximum and Minimum Values import sys print(sys.maxint) # Max Integer value print(-sys.maxint - 1) # Min Integer value 2147483647 -2147483648 ...

Read More

Finding modules used by a Python script (modulefinder)

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 1K+ Views

The ModuleFinder class in Python's modulefinder module can determine the set of modules imported by a script. This module provides both a command line interface and programmatic interface for analyzing module dependencies. Sample Script for Testing For demonstration, let's create a test script that imports various modules − # modfinder.py import hello try: import trianglebrowser import nomodule, mymodule except ImportError: pass Command Line Interface Use the module from command line to display modules found and missing − python -m ...

Read More

Python Binary Data Services

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 481 Views

The struct module in Python provides functionality for converting between C structs and Python bytes objects. This is essential for binary data processing, file format handling, and network protocol implementation. Format String Characters The byte order, size, and alignment in format strings are controlled by these characters ? Character Byte order Size Alignment @ native native native = native standard none big-endian standard none ! network (= big-endian) standard none Data Type Format Characters These format characters map ...

Read More

Python Low-level threading API

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 719 Views

The _thread module in Python provides a low-level interface for working with lightweight processes having multiple threads sharing a global data space. For synchronization, simple locks (also called mutexes or binary semaphores) are defined in this module. The threading built-in module provides a higher-level threading API built on top of this module. start_new_thread() Function This module-level function is used to open a new thread in the current process. The function takes a function object as an argument. This function gets invoked on successful creation of the new thread. The span of this function corresponds to the lifespan of ...

Read More

Iterate over lines from multiple input streams in Python

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 788 Views

Python's built-in open() function handles single file operations, but when you need to process multiple files sequentially, the fileinput module provides a powerful solution. This module allows you to iterate over lines from multiple input streams as if they were a single continuous stream. Basic Usage with fileinput.input() The primary interface is the fileinput.input() function, which returns a FileInput object that can iterate over multiple files ? import fileinput # Reading from a single file for line in fileinput.input('data.txt'): print(line, end='') Processing Multiple Files You can pass multiple ...

Read More

How to install Python MySQLdb module using pip?

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 3K+ Views

The MySQLdb module is a Python interface for connecting to MySQL databases. Since MySQLdb is not available for Python 3.x, we'll use PyMySQL or mysql-connector-python as modern alternatives. Why MySQLdb is Not Recommended MySQLdb only supports Python 2.x and is no longer maintained. For Python 3.x applications, use these alternatives ? PyMySQL − Pure Python MySQL client mysql-connector-python − Official MySQL driver Installing PyMySQL (Recommended) Open Command Prompt and install PyMySQL using pip ? pip install PyMySQL Example Usage import pymysql # Connection example (won't execute ...

Read More

Python Interface to Shell Pipelines

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 439 Views

The pipes module in Python provides an interface to shell command pipelines, allowing you to chain UNIX commands together. This module uses /bin/sh command line and works with os.system() and os.popen() methods internally. Note: The pipes module is deprecated as of Python 3.3 and removed in Python 3.11. For modern applications, consider using subprocess module instead. Importing the Module To use this module, import it as follows − import pipes Template Class The pipes module contains the Template class, which is an abstraction of a pipeline that allows you to build and ...

Read More

POSIX Style TTY control using Python

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 628 Views

The termios module provides an interface to the POSIX calls for TTY I/O control. It is only available for Unix-based systems and allows you to control terminal behavior programmatically. Importing the Module To use the termios module, import it as follows − import termios All methods in this module take a file descriptor as an argument. The module provides several methods for controlling terminal attributes. Method termios.tcgetattr(fd) This method returns a list of TTY attributes for the given file descriptor. The attributes include: iflag − Input mode flags oflag − ...

Read More
Showing 1–10 of 730 articles
« Prev 1 2 3 4 5 73 Next »
Advertisements