Showing posts with label Robotics. Show all posts
Showing posts with label Robotics. Show all posts
Friday, 17 June 2016
Ubuntu News Application
Synopsis:
The Ubuntu News Application is a python script which takes the input i.e the category of input that user wants the news to be and from that category
the script will try to fetch the latest news from the CNN news Website
and push the titles of the news as a notification in Ubuntu.
Execution:
Execution:
Command : python Ubuntu_News_App.py
Script Link :
Sunday, 14 February 2016
Number Plate Detection in OpenCV - Python
import cv2
# Importing the Opencv Library
import numpy as np
# Importing NumPy,which is the fundamental package for scientific computing with Python
# Reading Image
img = cv2.imread("/home/whoami/Pictures/number1.jpg")
cv2.namedWindow("Original Image",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Original Image",img)
# Display image
# RGB to Gray scale conversion
img_gray = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
cv2.namedWindow("Gray Converted Image",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Gray Converted Image",img_gray)
# Display Image
# Noise removal with iterative bilateral filter(removes noise while preserving edges)
noise_removal = cv2.bilateralFilter(img_gray,9,75,75)
cv2.namedWindow("Noise Removed Image",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Noise Removed Image",noise_removal)
# Display Image
# Histogram equalisation for better results
equal_histogram = cv2.equalizeHist(noise_removal)
cv2.namedWindow("After Histogram equalisation",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("After Histogram equalisation",equal_histogram)
# Display Image
# Morphological opening with a rectangular structure element
kernel = cv2.getStructuringElement(cv2.MORPH_RECT,(5,5))
morph_image = cv2.morphologyEx(equal_histogram,cv2.MORPH_OPEN,kernel,iterations=15)
cv2.namedWindow("Morphological opening",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Morphological opening",morph_image)
# Display Image
# Image subtraction(Subtracting the Morphed image from the histogram equalised Image)
sub_morp_image = cv2.subtract(equal_histogram,morph_image)
cv2.namedWindow("Subtraction image", cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Subtraction image", sub_morp_image)
# Display Image
# Thresholding the image
ret,thresh_image = cv2.threshold(sub_morp_image,0,255,cv2.THRESH_OTSU)
cv2.namedWindow("Image after Thresholding",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Image after Thresholding",thresh_image)
# Display Image
# Applying Canny Edge detection
canny_image = cv2.Canny(thresh_image,250,255)
cv2.namedWindow("Image after applying Canny",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Image after applying Canny",canny_image)
# Display Image
canny_image = cv2.convertScaleAbs(canny_image)
# dilation to strengthen the edges
kernel = np.ones((3,3), np.uint8)
# Creating the kernel for dilation
dilated_image = cv2.dilate(canny_image,kernel,iterations=1)
cv2.namedWindow("Dilation", cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Dilation", dilated_image)
# Displaying Image
# Finding Contours in the image based on edges
new,contours, hierarchy = cv2.findContours(dilated_image, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
contours= sorted(contours, key = cv2.contourArea, reverse = True)[:10]
# Sort the contours based on area ,so that the number plate will be in top 10 contours
screenCnt = None
# loop over our contours
for c in contours:
# approximate the contour
peri = cv2.arcLength(c, True)
approx = cv2.approxPolyDP(c, 0.06 * peri, True) # Approximating with 6% error
# if our approximated contour has four points, then
# we can assume that we have found our screen
if len(approx) == 4: # Select the contour with 4 corners
screenCnt = approx
break
final = cv2.drawContours(img, [screenCnt], -1, (0, 255, 0), 3)
# Drawing the selected contour on the original image
cv2.namedWindow("Image with Selected Contour",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Image with Selected Contour",final)
# Masking the part other than the number plate
mask = np.zeros(img_gray.shape,np.uint8)
new_image = cv2.drawContours(mask,[screenCnt],0,255,-1,)
new_image = cv2.bitwise_and(img,img,mask=mask)
cv2.namedWindow("Final_image",cv2.WINDOW_NORMAL)
cv2.imshow("Final_image",new_image)
# Histogram equal for enhancing the number plate for further processing
y,cr,cb = cv2.split(cv2.cvtColor(new_image,cv2.COLOR_RGB2YCrCb))
# Converting the image to YCrCb model and splitting the 3 channels
y = cv2.equalizeHist(y)
# Applying histogram equalisation
final_image = cv2.cvtColor(cv2.merge([y,cr,cb]),cv2.COLOR_YCrCb2RGB)
# Merging the 3 channels
cv2.namedWindow("Enhanced Number Plate",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Enhanced Number Plate",final_image)
# Display image
cv2.waitKey() # Wait for a keystroke from the user
The test cases and the result obtained from the above script are uploaded in the below pdf file
The code which is written above is also uploaded in my github account here.
Friday, 18 December 2015
How to Install open CV 3.0.0 in UBUNTU 15.04
Step 1:Download open CV
open the link to download open CV 3.0:
Step 2:Extraction
Extract the downloaded archive to any arbitrary folder.
Step 3:Installing the Dependencies:
open terminal and follow the below steps or you can download the script file and run it (with sudo privileges):
- sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip
Go to the extracted folder named opencv-3.0.0 and then start typing the following commands:
- mkdir build
- cd build
- cmake -D WITH_CUDA=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_OPENGL=ON ..
- sudo make -j4
- sudo make install
Step 4: Finishing installation
- sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
- sudo ldconfig
Step 6:Testing(Download this file and extract it and go to that directory and then type these commands)
- sudo cmake .
- sudo make
- ./DisplayImage lena.jpg
Thursday, 17 December 2015
C Code to Perform Sampling Rate Convertion
Sampling Rate Conversion in Real Time(Using a C language)
Upsampling and DownSampling using Reconstruction
(Using sinc Function):
Code:
#include<stdio.h>#include<math.h>
#define PI 3.14
void main()
{
int m,n,samplingrate,chunksize,subchunk2size,newchunksize,newsamplingrate,newsubchunk2size;
float i;
//int noofsamples;
int factor;
unsigned char a,b,c,d,e;
FILE *fp,*fp2;
void writeheaderfile(FILE *fp,int newsamplingrate,int newchunksize,int newsubchunk2size,FILE *fp2);
void writedatafile(FILE *fp,int newsamplingrate,int newchunksize,int newsubchunk2size,float i,int subchunk2size,FILE *fp2);
printf("Original Song is in : song1.wav\nResult is stored in : Createdsong.wav\n");
fp=fopen("song1.wav","r");
fp2=fopen("Createdsong.wav","w+");
fseek(fp,24,SEEK_SET);
fread(&samplingrate,4,1,fp);
printf("Sampling Rate is : %d\n",samplingrate);
fseek(fp,4,SEEK_SET);
fread(&chunksize,4,1,fp);
printf("chunksize is : %d\n",chunksize);
fseek(fp,40,SEEK_SET);
fread(&subchunk2size,4,1,fp);
printf("subchunk2size is : %d\n",subchunk2size);
printf("Enter the New Sampling Rate : ");scanf("%d",&newsamplingrate);
i=(float)samplingrate/newsamplingrate;
//printf("I value is : %f\n",i);
//noofsamples=readnoofsamples(fp);
printf("No of Samples in Given File : %d\n",subchunk2size/4);
newsubchunk2size=subchunk2size/i;
newchunksize=newsubchunk2size+36;
//noofsamples=newsubchunk2size/4;
writeheaderfile(fp,newsamplingrate,newchunksize,newsubchunk2size,fp2);
//fclose(fp2);
// fp2=fopen("Createdsong.wav","w+");
writedatafile(fp,newsamplingrate,newchunksize,newsubchunk2size,i,subchunk2size,fp2);
}
/*int readnoofsamples(FILE *fp)
{
int count=1;
unsigned char c;
fp=fopen("song1.wav","r");
fseek(fp,44,SEEK_SET);
while(1)
{
if(feof(fp)) break;
fscanf(fp,"%c",&c);
count++;
//printf("%d\n",count);
}
//count=count/4;
return count;
}*/
void writedatafile(FILE *fp,int newsamplingrate,int newchunksize,int newsubchunk2size,float i,int subchunk2size,FILE *fp2)
{
//FILE *fp2;
int count=0,samco=1,center,samp=0,previous=0,x,temp;
short int e,r;
long int m,n,sumfr,sumfl;
float suml=0,sumr=0;
unsigned char z,s,v,w,c;
float sinc(int m,float i,int n);
printf("Writing the Samples in File....Please Wait....\n");
//fp=fopen("song1.wav","r");
fseek(fp,40,SEEK_SET);
fread(&subchunk2size,4,1,fp);
//printf("subchunk2size is : %d\n",subchunk2size);
//fclose(fp);
//fp=fopen("song1.wav","r");
//fp2=fopen("Createdsong.wav","a");
fseek(fp,44,SEEK_SET);
fseek(fp2,44,SEEK_SET);
//printf("%d\n",subchunk2size);
for(m=0;m<=subchunk2size;m++)
{
//if(feof(fp)) break;
sumfl=0;
sumr=0;
suml=0;
sumfr=0;
center=rint(m*i);
if(previous==center)
{
}
else
{
for(temp=0;temp<(center-previous);temp++)
{
count++;
}
}
previous=center;
fseek(fp,44+(4*count),SEEK_SET);
for(n=count-10;n<count+10;n++)
{
//printf("m value : %d\n",m);
if(n<0)
{
e=0;
r=0;
}
else
{
fread(&e,2,1,fp);
fread(&r,2,1,fp);
}
sumr=sumr+(e*sinc(m,i,n));
suml=suml+(r*sinc(m,i,n));
sumfl=suml;
sumfr=sumr;
//if(sumfl==0) printf("m=%d\t n=%d\n",m,n);
//printf("m*I=%d\t n=%d\t e=%d\n",m*i,n,e);
//printf("suml=%lf\t sumr=%lf\t n=%d\t count=%d\t e=%d\t r=%d\n",suml,sumr,n,count,e,r);
}
fwrite(&sumfr,2,1,fp2);
fwrite(&sumfl,2,1,fp2);
/*fscanf(fp,"%c",&t);
fscanf(fp,"%c",&s);
fscanf(fp,"%c",&v);
fscanf(fp,"%c",&w);
printf("%d %d %d %d\n",t,s,v,w);*/
//if(sumfr==0) printf("m=%d\t and n=%d\n",m,n);
//printf("m=%d\t and sumfl=%d\t sumfr=%d\n",m,sumfl,sumfr);
//getchar();
}
printf("Process Completed...Result is in Createdsong.wav\n");
fclose(fp);
fclose(fp2);
}
float sinc(int m,float i,int n)
{
float temp;
if(rint(m*i)==n)
{
//printf("sinc value is : %f\n",1.00);
return 1.00;
}
else
{
temp=PI*(m*i-n);
//printf("sinc value is : %f\n",(sin(temp)/temp));
return (sin(temp)/temp);
}
}
void writeheaderfile(FILE *fp,int newsamplingrate,int newchunksize,int newsubchunk2size,FILE *fp2)
{long int count=1;
unsigned char header;
//FILE *fp2;
//fp=fopen("song1.wav","r");
//fp2=fopen("Createdsong.wav","w+");
fseek(fp,0,SEEK_SET);
while(1)
{
fread(&header,4,1,fp);
fwrite(&header,4,1,fp2);
if(ftell(fp)==44) break;
}
fseek(fp2,4,SEEK_SET);
fwrite(&newchunksize,4,1,fp2);
fseek(fp2,24,SEEK_SET);
fwrite(&newsamplingrate,4,1,fp2);
fseek(fp2,40,SEEK_SET);
fwrite(&newsubchunk2size,4,1,fp2);
//fclose(fp2);
//fclose(fp);
//printf("Suc\n");
}
Down Sampling using Decimation(Without Using Sinc Function):
Code:#include<stdio.h>
void main()
{
FILE *fp,*fp2;
unsigned char down;
int samplingrate,ratio,i=4,chunksize,subchunk2size,newchunksize,newsubchunk2size;
int newsamplingrate;
long int count=1;
//Getting the Sampling Rate from the File
// while(1)
// {
fp=fopen("mono.wav","r");
fseek(fp,24,SEEK_SET);
fread(&samplingrate,4,1,fp);
rewind;
fseek(fp,4,SEEK_SET);
fread(&chunksize,4,1,fp);
rewind;
fseek(fp,40,SEEK_SET);
fread(&subchunk2size,4,1,fp);
//fscanf(fp,"%d",&sample);
//**fprintf(stdout,"samplingrate is %u\n chunksize is : %u\nsubchunk2size is : %u\n",samplingrate,chunksize,subchunk2size);
//count++;
//if(count>44) break;
//}
//printf("The count value is : %ld\n",count-1);
fclose(fp);
//printf("Enter the New Sampling Rate : ");scanf("%d",&newsamplingrate);
newsamplingrate=5000;
if(newsamplingrate<samplingrate)
{
ratio=samplingrate/newsamplingrate;
fp=fopen("song1.wav","r");
fseek(fp,44,SEEK_SET);
while(1)
{
fscanf(fp,"%c",&down);
//fprintf(stdout,"%d\t",down);
count++;
i--;
if(feof(fp)) break;
if(i<1)
{
i=4;
fseek(fp,SEEK_CUR+4*(ratio-1)-1,SEEK_CUR);
}
}
fclose(fp);
count=count/4;
// printf("Count is : %ld\n",count);
newsubchunk2size=chunksize/3;
newchunksize=newsubchunk2size+36;
writeheaderfile(fp,newsamplingrate,newchunksize,newsubchunk2size);
writedatafile(fp,newsamplingrate,newchunksize,newsubchunk2size,ratio);
}
/*if(newsamplingrate>samplingrate)
{
ratio=newsamplingrate/samplingrate;
fp=fopen("song1.wav","r");
fseek(fp,44,SEEK_SET);
newsubchunk2size=chunksize*3;
newchunksize=newsubchunk2size+36;
writeheaderfile(fp,newsamplingrate,newchunksize,newsubchunk2size);
writedataupfile(fp,newsamplingrate,newchunksize,newsubchunk2size,ratio);
}*/
}
//Writing the Header Section
void writeheaderfile(FILE *fp,int newsamplingrate,int newchunksize,int newsubchunk2size)
{long int count=1;
unsigned char header;
FILE *fp2;
fp=fopen("mono.wav","r");
fp2=fopen("song2.wav","w+");
//rewind;
while(1)
{
fread(&header,4,1,fp);
//if(ftell(fp)==5) fprintf(fp2,"%c",newchunksize);
//else if(ftell(fp)==17) fprintf(fp2,"%c",newsubchunk2size);
//else if(ftell(fp)==25) fprintf(fp2,"%c",newsamplingrate);
//else fprintf(fp2,"%c",header);
fwrite(&header,4,1,fp2);
if(ftell(fp)==44) {fclose(fp);break;}
}
//fp=fopen("song1.wav","r");
//fp2=fopen("song2.wav","w+");
//rewind(fp2);
fseek(fp2,4,SEEK_SET);
fwrite(&newchunksize,4,1,fp2);//fprintf(fp2,"%c",&newchunksize);
//rewind(fp2);
fseek(fp2,40,SEEK_SET);
fwrite(&newsubchunk2size,4,1,fp2);
//rewind(fp2);
fseek(fp2,24,SEEK_SET);
fwrite(&newsamplingrate,4,1,fp2);
//fclose(fp);
fclose(fp2);
}
//Write data to file
void writedatafile(FILE *fp,int newsamplingrate,int newchunksize,int newsubchunk2size,int ratio)
{unsigned char down;
long int count=1;
int i=4;
FILE *fp2;
fp=fopen("mono.wav","r");
fp2=fopen("song2.wav","a+");
fseek(fp,44,SEEK_SET);
while(1)
{
fscanf(fp,"%c",&down);
fprintf(fp2,"%c",down);
count++;
i--;
if(feof(fp)) break;
if(i<1)
{
i=4;
fseek(fp,SEEK_CUR+4*(ratio-1)-1,SEEK_CUR);
}
}
fclose(fp);
fclose(fp2);
}
Friday, 1 May 2015
Wednesday, 14 January 2015
Doctors Helped By Robots
Doctors Helped By Robots
New Internal Imaging Robot Helps Doctors In Emergency Situations:
The use of robotics in medical field isn't new. But this new Japanese internal imaging robot helps the doctors like no one else, especially during emergency situations. The robot, currently under development by a research group at the Waseda University under the leadership of Dr. Hiroyasu Iwata will help doctors quickly capture images of patient's internals for bleeding and the doctors are able to control it remotely. If a person is injured in an accident, the robot can provide all the necessary information to the doctors while the patient is being rushed to the hospital in the ambulance. That doctors can prepare for the operation even before the patient actually reaches the operation theatre.
The robot just weighs about 2.2 kg and can be attached to the patient's chest using a belt and can be used anywhere as long as there's a network connection available. The ultrasound probe then moves over the affected area and captures images. If there's internal bleeding, then it appears as black shadows.
The team is currently performing tests and making sure that the device passes through the legal barriers. They expect the robot to be ready for use within next 3 years.
Source: DigiInfo
Friday, 9 January 2015
Automated Cameras To Record a Basketball Game
Automated Cameras To Record a Basketball Game
The time has come when the world is looking for robots to further ease the lives of human beings. Recently, some Disney research scientists reported that they’ve developed a system that could automate the cameras to record a complete Basketball game. The robotic cameras they've developed are being trained to follow the game in a way any human operator would. However, a major concern for researchers is that the system is not yet comparable to a flesh-and-bone cameraman who covers the game with remarkable aplomb, especially because Basketball is a fast-paced game.
An engineer at Disney research Peter Carr and a PhD student Jianhui Chen worked on training the cameras to follow the game by anticipating where the ball is going rather than keeping an eye on its position. In a game like basketball, where the ball is constantly in motion, tracking ball could result in jerky action which makes it difficult to watch the game. Hence, there’s a lot of scope for improvement in the recently developed system. Usually players know their positions at different times and this is what gives clues about the ball’s location.
The basketball court is divided into four quadrants to track the motion of ball and create a map of players' positions. The automated cameras will gain information from these maps to predict the players' next location. The currently implemented algorithm can’t be of much use to judge the team-work while passing the ball on the court. However, research shows that it is getting better in predicting where the ball could be in the next move. Researchers presented their first findings at IEEE Winter Conference on Applications of Computer Vision. Though the system is tested only in a basketball game, Carr and Chen expect it be used in other sports as well.
Source:IEEE SPECTRUM
Total Pageviews
Labels
animation
ARM
ARM programming
Assembly programming
augmentedreality
authentication
Bag of Words
build module
CMOS
Companyprofile
computer vision
Cortex M4
CreaticeAssignment
cross build
Cross Compile
culture
embeddedsystems
Exponential Series
Facts
Fibonacci Series
five stage Pipeline
Floating Point
FPU
graphics
Hacking
Hazards
health
HowStuff
iiitb
imageClassifiaction
india
Innovation
Innovators
interview prep
interviewtips
kernel.img
Kmeans
KNN
LDAP
LDAPS
memory
Motivation
native compilation
natural
opencv
os
Pendrivefix
pipeline
pipelined processor
Projectideas.
protocols
python
raspberry pi
RealtimeCoding
Robotics
security
SIFT
Skill
soc
SURF
Technology
techstuff
tls
tutorials
vlsi
Watershed algorithm
writeback
Copyright ©
Learn Delta X | Powered by Blogger
Design by ManojKiran Eda | Blogger Theme by learndeltax