User:Hellboyy/sandbox

Virtual TouchScreen

TouchScreen has revolutionized the mobile & tablet market. With touch-screen user can just touch then screen and buttons are pressed. There are no physical buttons. As per the requirement various hotspots/buttons for different size can be place on touch-screen.

Next big change in technology can be wireless interface to mobile or computer. Virtual Touchscreen uses camera for implementing buttons. Hence buttons can be anywhere within range of camera view. Button can be on table, on blackboard, on walls, on roof, on hand, on refrigerator everywhere.

While working on our final year project Robot Dog using webcam, we were able to follow a colored ball. Suddenly an idea strike in my mind that we can divide then image acquired from webcam into 2*2 matrix. Each matrix represents a virtual button. In order to point a particular button we used a red LED in mouse. We can used any colored Led for the same or even we can design our own ring or handheld device for pressing virtual button. Basic principle behind our concept is detecting the redObject in images i.e. fining its X-Y coordinates and labeling them. We call know image consist of 3layers of red, green and blue color. Here we consider than Red object to be recognized have color with green and blue components less than 50 and red component greater than 150 on image with 255levels. By manipulating the threshold levels, other color objects can also be determined. First of all we Remove all those pixels less than 300px.Then we label all the connected components in the image. After that we do the image blob analysis. We get X and Y coordinated of labeled components. We place a marker over the object and display its X-Y coordinates.

We divide then image into 4parts i.e. 2*2matrix Depending upon the X-Y coordinated of detected redObject we change then brightness of that particular area indicating button is pressed.

Further enhancement to this project can be adding various sophisticated techniques so that false detection can be avoided, multiple detection, depth detection, motion and gesture recognition is possible. A sample matlab code for basic virtual touchscreen is provided.

close all;

clear all;

clc; info=imaqhwinfo('winvideo');

x=0;

y=0; num=imread('number_touch_screen.jpg');

vid = videoinput('winvideo',1, 'YUY2_320x240');

set(vid, 'ReturnedColorspace', 'RGB')% snapshot is rgb not preview

preview(vid)

start(vid)

while(1) data=getsnapshot(vid); pause(0.1); imC=rgb2gray(data); imC(:,155:165)=0; imC(115:125,:)=0; % current right and left corner of image % subplot(2,2,1); subplot(2,2,1); imshow(imC);xlabel('2*2 Matrix'); % a=imC(1:115,1:155); imshow(a);subplot(2,2,2);   % current right and left next of image %b=imC(1:115,175:315);imshow(b);subplot(2,2,3); %c=imC(125:240,1:155);imshow(c);subplot(2,2,4);    % current right and left next of image %d=imC(125:240,165:320);imshow(d); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % blob and color analysis diff_im = imsubtract(data(:,:,1), rgb2gray(data)); diff_im = medfilt2(diff_im, [3 3]); % Convert the resulting grayscale image into a binary image. diff_im = im2bw(diff_im,0.18); subplot(2,2,2);imshow(diff_im);xlabel('Difference Image'); % Remove all those pixels less than 300px diff_im = bwareaopen(diff_im,300); % Label all the connected components in the image. bw = bwlabel(diff_im, 8); % Here we do the image blob analysis. stats = regionprops(bw, 'BoundingBox', 'Centroid'); % Display the image subplot(2,2,3);imshow(data);xlabel('RebObject Detection'); hold on   for object = 1:length(stats) bc = stats(object).Centroid; y=round(bc(1)) x=round(bc(2)) plot(bc(1),bc(2), '-m+') a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), '   Y: ', num2str(round(bc(2))))); set(a, 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'yellow'); end hold off % a=imC(1:115,1:155); %b=imC(1:115,175:315); %c=imC(125:240,1:155); %d=imC(125:240,165:320); %x=row 320, 160 %y=column 240, 120 % y has 290 if x ~= 0 && y ~= 0 if x < 115 && y < 165 disp('one'); imC(1:115,1:155 )=0; elseif x < 115 && y >165 %%left down disp('two'); imC(1:115,155:320)=0; elseif x > 115  && y<165 disp('three'); imC(115:240,1:155)=0; elseif x > 115 && y>165 disp('four'); imC(115:240,155:320)=0; end subplot(2,2,1); imshow(imC); pause(0.1); else end x=0;y=0; end