Skip to main content

Posts

OpenCV 2.4.9 JAVA/CPP/Python Installation in Ubuntu 14.04

OpenCV2.4.9 installation in ubuntu is not straight forward , sometimes due to dependencies , some people won't be able to end with successful installation.In this guide, i will show you how to install OpenCV with a lot of the features it provides. Here are some of the things that are going to be enabled when you are finished following through with this installation tutorial: 1.) Qt version of the HighGUI module (Better 2D window interface with zoom, image saving capabilities, etc) 2.) OpenGL support 3.) C++ interface and examples 4.) C interface and examples 5.) Python interface and examples 6.) Java interface and examples OK, so the first step is to make sure that everything in the system is updated and upgraded. Open the terminal and write this: sudo apt-get update sudo apt-get upgrade Now, you need to install many dependencies, such as support for reading and writing image files, drawing on the screen, some needed tools, other libraries, etc… This step is very ea...

Sudoku using dancing link - Java implementation

Here is a algorithm which uses dancing link to solve algorithm X(exact cover) that solves upto 100*100 sudoku. Algorithm has been implemented using  JAVA and can be able to solve Sudoku of any difficulty level(easy,hard,very hard). Algorithm works as follows:- 1.) Algorithm first find out the number of possible elements in each cell , algorithm for this can be seen in the code. 2.) After this apply rule1 which says finds  that cell which has a single possible element , this works recursively until we find single possible element. 3.) After this apply rule2 which says if there is a number which can go into only one cell, then assign that number to that cell. 4.) Rule2 and rule1 run recursively. 5.) Still if we find possible number of elements in some cell then create a dancing link for sudoku puzzle , reduce the puzzle in to exact cover form and solve it using algorithm X in a efficient way.To make it efficient,first we implemented rule1 and rule2 ,firstly algorithm try...

Broadcast data using UDP in Java Socket Programming

If we want client to automatically discover server IP,we can do this by broadcasting a data packet with some identifier to the server , server extracts the client IP and then server send some identifier to the client ,client then extracts the IP from the packet received from the server.Here are simple work flows that is similar to DHCP protocol:- On the server side:- 1.) Open a socket on the server that listens to the UDP request. 2.) Make a loop that handles the UDP request and responses. 3.) Inside the loop,check the received UDP packed to see if its valid by identifier. 4.) Still inside the loop , send a response to the IP and port of the received packet. On the client side:- 1.) Open a socket on a random port. 2.) Loop over the computer network interfaces and get their broadcast address. 3.) send the UDP Packet inside the loop to the interface's broadcast address. 4.) wait for a reply 5.) when we have a reply , check to see if the package is valid. 6.) When its v...

Perfect Hashing and its implementation in C

Perfect hashing simply means hashing with no collision.But there is nothing like perfect hashing(no collision).These are just a work around to achieve perfect hashing.Using this we can able to search the large set of records in a constant time i.e O(1) time complexity.To achieve searching in strict O(1) time ,one needs to implement hash table and then search the given record in to hash table using hash function.         Here in perfect hashing ,one need to implement two level hash table , first level hash table consist a set of pointers that points to the second level hash table,we must select hash function that first maps the key in to first level hash table,so it simply means there must be collision in first level hash table ,thats  why i am saying its just a work around to achieve prefect  hashing.We must wisely choose hash function:                  h(x)=((a*x+b)mod p)mod m x is the key to be map, Here ...

C Program to insert/delete/traverse/display XOR Linked List

Here is the C Program to insert/delete/traverse/display XOR Linked List.XOR linked list is said to be memory efficient version of doubly linked list. _________________________________________________________________________________ #include<stdio.h> #include<string.h> #include<stdlib.h> struct Node{ int data; struct Node *ptr; }; struct Node* XOR(struct Node *a,struct Node *b){ return (struct node*) ((unsigned int) (a) ^ (unsigned int) (b)); } void insertIntoXORLL(struct Node **head,int pos,int data){ struct Node *newNode=(struct Node*)malloc(sizeof(struct Node)); newNode->data=data; if(*head==NULL){ //Insert first Node newNode->data=data; newNode->ptr=NULL; *head=newNode; }else{ struct Node *current=*head; struct Node *previous=NULL,*next=NULL; struct Node *nextNode=NULL; if(pos<=1){ newNode->ptr=XOR(previous,*head); nextNode=XOR((*head)->ptr,previous); (*head)->ptr=XOR(newNode,nextN...