Monday, 3 July 2017

Summing the digits of a number in C++

Q: This is a simple ad-hoc problem which asks to sum up the digits of a number repeatedly until the sum is less than 10. We are required to stop the program when input given is 0.


Saturday, 10 June 2017

Nary Search Using OpenMP

It's been quite a while since I last posted. This post shows how conduct a nary search on an array using OpenMP.

OpenMP


Allows to create threads in C by simple pragma directives, this is one of the easiest ways to get threading done. In case you like the way threading is done here you might want to take a look at the various directives offered by OpenMP for parallel processing.


N-ary Search


You might have worked earlier with maybe ternary, or at least binary search. In this kind of a search we divide the sorted array into n parts at each stage and then perform the search.

Sunday, 2 April 2017

Generating Permutation in Python

This is the best way to generate permutations in python.

from itertools import permutations

j="1234"
for i in permutations(j):
    print "".join(i)


Saturday, 1 April 2017

Ditch Ubuntu Software Centre

Most noobies to Linux love Ubuntu Software. It one of the best things of Ubuntu, a preinstalled GUI package manager.

The Other thing that most guys love is the Software Updater it is extremely fast and efficient when compared to its Windows Counter Part.

Experts

However experts should not be using Ubuntu Software. One of the biggest and main reason is the fact that it is buggy and it hangs even on modern hardware.
It is extremely slow compared to its terminal alternative. I have used GUI package managers on various Arch Distros, they are far more efficient then Ubuntu's Software Centre.

Secondly it has a tendency to acquire a lock and then never release. Software center was taught by canonical lock n key, however turns out it learned from its distant friend Windows lock n hang. 

Usually when it decides to play this game of lock n hang. You need to use ps -aux | grep apt. To find out the process and kill it with kill -9 pid. Finally you need to ensure that the database is not corrupt by use sudo dpkg --configure -a. Failure to do so can have disastrous consequences. So why not ditch it all together ?



Thursday, 30 March 2017

A request to Stop Blocking Adds

I have lately noticed that there has been considerable loss of revenue due to UC Browsers ADD Blocking.

Being a technology blog I expect users to be tech-savy and block adds. However killing revenue for a blog barely showing three adds per page is not justified. Please switch to better browser that doesn't block adds.

UC Browser has been know to be unsecure and compromises user data. This is another reason for you to make the switch. If you still decide to use UC Browser do disable the add-blocker.

Its a race of Add-blockers and Anti-Add-Blockers. The day Add-blockers win, you will lose. No revenue to bloggers, means no more posts. No more posts and no more free knowledge.

UC Browser is no longer supported by Programing Wonders!.

FAD-Facial Age Determinator

FAD - Facial Age Determinator is a Python based software to determine the age of people using skin texture. It determines the age group of people and classifies them into 4 groups, kids(1-10), young(10-25),adults(25-50),seniors(51+).

Applications

  • Vending Machines for cigarettes and beer
  • Age Appropriate Advertisements
  • Targeted Advertisements on Bill Boards
  • Age Restricted Entry Zones(Bars, Adult Cinema)
  • As a filter in other Facial Processing Systems
  • Human Robot Interactions
  • Smart Car System Adaptive Behavior(Determining whether to apply brakes based on age group of pedestrian crossing.)
  • Elderly Assistance Systems
  • Enhanced Security for Kids Only Zones etc 

Implementation Details

Sunday, 26 March 2017

The Fastest and Easiest Way to Install OpenCv for Python on Ubuntu

Python burning gif
When I first installed OpenCV I used an article on which installed opencv from source. However this is unnecessary and time consuming.

The entire process is too complicated. You will need to use that process only if
  1. You are using the latest OpenCV features
  2. You need Python 3 bindings
Before building from the source I highly recommend you trying the method described in this post. It is quick and simple.

Saturday, 25 March 2017

Persistance in Python

Recently I was training a dataset for Facial Age Determination. A considerable amount was spent each time I launched my script.

The Reason: It was retraining the whole dataset at each launch.

Solution : Saving the dataset into a file loading it back.


Serialization in Python


Serialization allows you to save objects to a file and reload them. I have worked with Java and Python Serialization, and with python its a piece of cake.

There are two options

  1. Pickle
  2. CPickle
You usually would want to use cpickle as its faster. It can be over a thousand times faster.

I would be thus demonstration cpickle store and load through this post. The steps for pickle are the same. Just import pickle instead of cpickle and you are good to go.


Thursday, 23 March 2017

Feret Database PreProcessing Script

I am currently working with the Feret Database on Age Determination using Frontal Facial Images using KNN and LBP in Python 3 and OpenCV.

However the Feret Database comes in a tar which when extracted contains a large number of ppm files in bz2 archives which need to be converted into jpegs before any further processing can take place.

I wrote this script in case. I am sure it will be useful to other people working with the Feret Database.