Photo by Washington Oliveira 🇧🇷 on Unsplash

We all know about the structures used in C and C++. The one that allows to bundle multiple primitive data types into user defined data type.

In python, can define a structure using a class, where the user does not define any functions in the class.

Ok, I know that even though C doesn’t, C++ allows function definitions in structure. This is a feature I have never used. I can’t remember making a class with all data members and member functions as public, where it makes sense to use a struct instead of a class.

Structures come very handy to…

This is an application of an article I published a couple of years ago on how to process the output of HoughLines from OpenCV.

I am using the functions from the previous post, to get the corners of the page which I will use to straighten a page in an image.

There are 4 snippets of code that will help us get a straighten page:
1. Get an edge detected image
2. Get the corner points using
3. Fit a rotated rectangle to edge image to get the straight image dimensions
4. …

Photo by Markus Winkler on Unsplash

In this article, we will try our hand to get a big picture view of a huge time series data. Stock market data is a good example of such a data where the data is collected for every second and can be decades long.

To get a good idea of time series data it's better to plot it, which is what I will use as an application for the code discussed in this article.

If you want to see how the stock performed in the last year it is not worth looking at data collected every hour. May be not…

I always had a hard time to add a single file from a GitHub gist on Medium. Everywhere I found was to use the link to the gist and that adds all the files in the gist.

I used to make different gists for every file I needed to add to the article. That made managing the gists for an article, a nightmare.

That did not stop me from trying to find a way to embed a single file from the gist. …

Redacted document images

There were a few times when I had to redact a few details from the document before printing. This made me think if this task could be automated. After all, I was redacting names of people, institutions and places. These can be easily searched and their background can be set to black to get the redaction. So, I decided to try this out in Python.

In Python, there is a package called python-docx which can create and update Microsoft Word (.docx) files. It is easy to add paragraphs with multiple runs and varying styles to an existing or new document.

A man getting ready for a race.
A man getting ready for a race.
Photo by Serghei Trofimov on Unsplash

Pandas library in python provides a lot of features that are useful not only in data science projects but also for quick data manipulations or conversions.

Here I will list a few things that I used in my first Pandas project.

Import pandas

First and foremost you would need to import pandas into your script.

import pandas as pd

Read a comma separated file

Next you can load a data set saved as a comma separated file (.csv) using

df = pd.read_csv(‘datafile.csv’)

I prefer CSV format as it is the vanilla format and if need arises you use a simple text editor to peruse it.

Pandas uses…

Photo by Markus Spiske on Unsplash

Having done a lot of programming in C++0x and then spending a lot of time on Python programming. I got used to a lot of features in Python and remembered how tedious it is to get the things done in C++. Mind you C++ is definitely faster of the two.

One of the Python features I like the most, is the ability to return multiple values of different types from a function. In Python, when you return multiple values of different types from a function you are actually returning a tuple.

I was happy to find out that since C++11…

Photo by Peter Stumpf on Unsplash

There are a lot of ways to add an image overlay on a video. Many of them are GUI based and may be expensive. Here I am going to talk about quick, easy and free option I found to overlay a logo on a video.

FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. To install it on windows all you need to do is download it from here and unzip it. There is a ffmpeg.exe that can be used directly from windows command prompt.

Once you have a logo image to overlay on a…

Threading a string through a needle
Threading a string through a needle
Photo by amirali mirhashemian on Unsplash

With the powerful hardware available, summing up a large array of numbers does not take a lot of time. However, if you still want to shave off a few milliseconds you can sum up the array in parts and asynchronously.

Here is a quick example to use sum up an array using threading or asynchronously.



Single thread total = 400000000 in 831 milliseconds
Multi thread total = 400000000 in 387 milliseconds

As you can see, summing up the array in parts on a separate threads does provide a speed up. …

Recently I had to look for ways to converts a list of integers to a comma separated string in python.

A simple google search lead me to a couple of stack overflow articles [1] and [2], where I found a number of ways to complete the task. However, I had to find the fastest way to accomplish the task as I had to convert integer lists of length between 10000 and 12000, that too a multiple times. So, I decided to run some experiments.

Here is the sample list to convert, with the 7 contenders and outputs:

Except the…

Akshay Chavan

Computer Vision | Machine Learning | Deep Learning

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store