Wikipedia
Search results
Monday, 7 August 2017
SOURCE CODE FOR VEHICLE NUMBER PLATE DETECTION USING MATLAB IMAGE PROCESSING
clc; % Clear command window.
clear all; % Delete all variables.
close all; % Close all figure windows except those created by imtool.
imtool close all; % Close all figure windows created by imtool.
workspace; % Make sure the workspace panel is showing.
% Read Image
I = imread ('CAR3.jpg');
figure(1);
imshow(I);
% Extract Y component (Convert an Image to Gray)
Igray = rgb2gray(I);
[rows cols] = size(Igray);
%% Dilate and Erode Image in order to remove noise
Idilate = Igray;
for i = 1:rows
for j = 2:cols-1
temp = max(Igray(i,j-1), Igray(i,j));
Idilate(i,j) = max(temp, Igray(i,j+1));
end
end
I = Idilate;
figure(2);
imshow(Igray);
figure(3);
title('Dilated Image')
imshow(Idilate);
figure(4);
imshow(I);
difference = 0;
sum = 0;
total_sum = 0;
difference = uint32(difference);
%% PROCESS EDGES IN HORIZONTAL DIRECTION
disp('Processing Edges Horizontally...');
max_horz = 0;
maximum = 0;
for i = 2:cols
sum = 0;
for j = 2:rows
if(I(j, i) > I(j-1, i))
difference = uint32(I(j, i) - I(j-1, i));
else
difference = uint32(I(j-1, i) - I(j, i));
end
if(difference > 20)
sum = sum + difference;
end
end
horz1(i) = sum;
% Find Peak Value
if(sum > maximum)
max_horz = i;
maximum = sum;
end
total_sum = total_sum + sum;
end
average = total_sum / cols;
figure(5);
% Plot the Histogram for analysis
subplot(3,1,1);
plot (horz1);
title('Horizontal Edge Processing Histogram');
xlabel('Column Number ->');
ylabel('Difference ->');
%% Smoothen the Horizontal Histogram by applying Low Pass Filter
sum = 0;
horz = horz1;
for i = 21:(cols-21)
sum = 0;
for j = (i-20):(i+20)
sum = sum + horz1(j);
end
horz(i) = sum / 41;
end
subplot(3,1,2);
plot (horz);
title('Histogram after passing through Low Pass Filter');
xlabel('Column Number ->');
ylabel('Difference ->');
%% Filter out Horizontal Histogram Values by applying Dynamic Threshold
disp('Filter out Horizontal Histogram...');
for i = 1:cols
if(horz(i) < average)
horz(i) = 0;
for j = 1:rows
I(j, i) = 0;
end
end
end
subplot(3,1,3);
plot (horz);
title('Histogram after Filtering');
xlabel('Column Number ->');
ylabel('Difference ->');
%% PROCESS EDGES IN VERTICAL DIRECTION
difference = 0;
total_sum = 0;
difference = uint32(difference);
disp('Processing Edges Vertically...');
maximum = 0;
max_vert = 0;
for i = 2:rows
sum = 0;
for j = 2:cols %cols
if(I(i, j) > I(i, j-1))
difference = uint32(I(i, j) - I(i, j-1));
end
if(I(i, j) <= I(i, j-1))
difference = uint32(I(i, j-1) - I(i, j));
end
if(difference > 20)
sum = sum + difference;
end
end
vert1(i) = sum;
%% Find Peak in Vertical Histogram
if(sum > maximum)
max_vert = i;
maximum = sum;
end
total_sum = total_sum + sum;
end
average = total_sum / rows;
figure(6)
subplot(3,1,1);
plot (vert1);
title('Vertical Edge Processing Histogram');
xlabel('Row Number ->');
ylabel('Difference ->');
%% Smoothen the Vertical Histogram by applying Low Pass Filter
disp('Passing Vertical Histogram through Low Pass Filter...');
sum = 0;
vert = vert1;
for i = 21:(rows-21)
sum = 0;
for j = (i-20):(i+20)
sum = sum + vert1(j);
end
vert(i) = sum / 41;
end
subplot(3,1,2);
plot (vert);
title('Histogram after passing through Low Pass Filter');
xlabel('Row Number ->');
ylabel('Difference ->');
%% Filter out Vertical Histogram Values by applying Dynamic Threshold
disp('Filter out Vertical Histogram...');
for i = 1:rows
if(vert(i) < average)
vert(i) = 0;
for j = 1:cols
I(i, j) = 0;
end
end
end
subplot(3,1,3);
plot (vert);
title('Histogram after Filtering');
xlabel('Row Number ->');
ylabel('Difference ->');
figure(7), imshow(I);
%% Find Probable candidates for Number Plate
j = 1;
for i = 2:cols-2
if(horz(i) ~= 0 && horz(i-1) == 0 && horz(i+1) == 0)
column(j) = i;
column(j+1) = i;
j = j + 2;
elseif((horz(i) ~= 0 && horz(i-1) == 0) || (horz(i) ~= 0 && horz(i+1) == 0))
column(j) = i;
j = j+1;
end
end
j = 1;
for i = 2:rows-2
if(vert(i) ~= 0 && vert(i-1) == 0 && vert(i+1) == 0)
row(j) = i;
row(j+1) = i;
j = j + 2;
elseif((vert(i) ~= 0 && vert(i-1) == 0) || (vert(i) ~= 0 && vert(i+1) == 0))
row(j) = i;
j = j+1;
end
end
[temp column_size] = size (column);
if(mod(column_size, 2))
column(column_size+1) = cols;
end
[temp row_size] = size (row);
if(mod(row_size, 2))
row(row_size+1) = rows;
end
%% Region of Interest Extraction
%Check each probable candidate
for i = 1:2:row_size
for j = 1:2:column_size
% If it is not the most probable region remove it from image
if(~((max_horz >= column(j) && max_horz <= column(j+1)) && (max_vert >=row(i) && max_vert <= row(i+1))))
%This loop is only for displaying proper output to User
for m = row(i):row(i+1)
for n = column(j):column(j+1)
I(m, n) = 0;
end
end
end
end
end
figure(8), imshow(I);
imshow(I);
clear all; % Delete all variables.
close all; % Close all figure windows except those created by imtool.
imtool close all; % Close all figure windows created by imtool.
workspace; % Make sure the workspace panel is showing.
% Read Image
I = imread ('CAR3.jpg');
figure(1);
imshow(I);
% Extract Y component (Convert an Image to Gray)
Igray = rgb2gray(I);
[rows cols] = size(Igray);
%% Dilate and Erode Image in order to remove noise
Idilate = Igray;
for i = 1:rows
for j = 2:cols-1
temp = max(Igray(i,j-1), Igray(i,j));
Idilate(i,j) = max(temp, Igray(i,j+1));
end
end
I = Idilate;
figure(2);
imshow(Igray);
figure(3);
title('Dilated Image')
imshow(Idilate);
figure(4);
imshow(I);
difference = 0;
sum = 0;
total_sum = 0;
difference = uint32(difference);
%% PROCESS EDGES IN HORIZONTAL DIRECTION
disp('Processing Edges Horizontally...');
max_horz = 0;
maximum = 0;
for i = 2:cols
sum = 0;
for j = 2:rows
if(I(j, i) > I(j-1, i))
difference = uint32(I(j, i) - I(j-1, i));
else
difference = uint32(I(j-1, i) - I(j, i));
end
if(difference > 20)
sum = sum + difference;
end
end
horz1(i) = sum;
% Find Peak Value
if(sum > maximum)
max_horz = i;
maximum = sum;
end
total_sum = total_sum + sum;
end
average = total_sum / cols;
figure(5);
% Plot the Histogram for analysis
subplot(3,1,1);
plot (horz1);
title('Horizontal Edge Processing Histogram');
xlabel('Column Number ->');
ylabel('Difference ->');
%% Smoothen the Horizontal Histogram by applying Low Pass Filter
sum = 0;
horz = horz1;
for i = 21:(cols-21)
sum = 0;
for j = (i-20):(i+20)
sum = sum + horz1(j);
end
horz(i) = sum / 41;
end
subplot(3,1,2);
plot (horz);
title('Histogram after passing through Low Pass Filter');
xlabel('Column Number ->');
ylabel('Difference ->');
%% Filter out Horizontal Histogram Values by applying Dynamic Threshold
disp('Filter out Horizontal Histogram...');
for i = 1:cols
if(horz(i) < average)
horz(i) = 0;
for j = 1:rows
I(j, i) = 0;
end
end
end
subplot(3,1,3);
plot (horz);
title('Histogram after Filtering');
xlabel('Column Number ->');
ylabel('Difference ->');
%% PROCESS EDGES IN VERTICAL DIRECTION
difference = 0;
total_sum = 0;
difference = uint32(difference);
disp('Processing Edges Vertically...');
maximum = 0;
max_vert = 0;
for i = 2:rows
sum = 0;
for j = 2:cols %cols
if(I(i, j) > I(i, j-1))
difference = uint32(I(i, j) - I(i, j-1));
end
if(I(i, j) <= I(i, j-1))
difference = uint32(I(i, j-1) - I(i, j));
end
if(difference > 20)
sum = sum + difference;
end
end
vert1(i) = sum;
%% Find Peak in Vertical Histogram
if(sum > maximum)
max_vert = i;
maximum = sum;
end
total_sum = total_sum + sum;
end
average = total_sum / rows;
figure(6)
subplot(3,1,1);
plot (vert1);
title('Vertical Edge Processing Histogram');
xlabel('Row Number ->');
ylabel('Difference ->');
%% Smoothen the Vertical Histogram by applying Low Pass Filter
disp('Passing Vertical Histogram through Low Pass Filter...');
sum = 0;
vert = vert1;
for i = 21:(rows-21)
sum = 0;
for j = (i-20):(i+20)
sum = sum + vert1(j);
end
vert(i) = sum / 41;
end
subplot(3,1,2);
plot (vert);
title('Histogram after passing through Low Pass Filter');
xlabel('Row Number ->');
ylabel('Difference ->');
%% Filter out Vertical Histogram Values by applying Dynamic Threshold
disp('Filter out Vertical Histogram...');
for i = 1:rows
if(vert(i) < average)
vert(i) = 0;
for j = 1:cols
I(i, j) = 0;
end
end
end
subplot(3,1,3);
plot (vert);
title('Histogram after Filtering');
xlabel('Row Number ->');
ylabel('Difference ->');
figure(7), imshow(I);
%% Find Probable candidates for Number Plate
j = 1;
for i = 2:cols-2
if(horz(i) ~= 0 && horz(i-1) == 0 && horz(i+1) == 0)
column(j) = i;
column(j+1) = i;
j = j + 2;
elseif((horz(i) ~= 0 && horz(i-1) == 0) || (horz(i) ~= 0 && horz(i+1) == 0))
column(j) = i;
j = j+1;
end
end
j = 1;
for i = 2:rows-2
if(vert(i) ~= 0 && vert(i-1) == 0 && vert(i+1) == 0)
row(j) = i;
row(j+1) = i;
j = j + 2;
elseif((vert(i) ~= 0 && vert(i-1) == 0) || (vert(i) ~= 0 && vert(i+1) == 0))
row(j) = i;
j = j+1;
end
end
[temp column_size] = size (column);
if(mod(column_size, 2))
column(column_size+1) = cols;
end
[temp row_size] = size (row);
if(mod(row_size, 2))
row(row_size+1) = rows;
end
%% Region of Interest Extraction
%Check each probable candidate
for i = 1:2:row_size
for j = 1:2:column_size
% If it is not the most probable region remove it from image
if(~((max_horz >= column(j) && max_horz <= column(j+1)) && (max_vert >=row(i) && max_vert <= row(i+1))))
%This loop is only for displaying proper output to User
for m = row(i):row(i+1)
for n = column(j):column(j+1)
I(m, n) = 0;
end
end
end
end
end
figure(8), imshow(I);
imshow(I);
SOURCE CODE FOR GESTURE RECOGNITION USING MATLAB IMAGE PROCESSING
function gesturerecognisition(redThresh, greenThresh, blueThresh, numFrame)
warning('off','vision:transition:usesOldCoordinates');
if nargin < 1
redThresh = 0.22;
greenThresh = 0.14;
blueThresh = 0.18;
numFrame = 1000;
end
cam = imaqhwinfo;
cameraName = char(cam.InstalledAdaptors(end));
cameraInfo = imaqhwinfo(cameraName);
cameraId = cameraInfo.DeviceInfo.DeviceID(end);
cameraFormat = char(cameraInfo.DeviceInfo.SupportedFormats(end));
jRobot = java.awt.Robot;
vidDevice = imaq.VideoDevice(cameraName, cameraId, cameraFormat, ...
'ReturnedColorSpace', 'RGB');
vidInfo = imaqhwinfo(vidDevice);
screenSize = get(0,'ScreenSize');
hblob = vision.BlobAnalysis('AreaOutputPort', false, ...
'CentroidOutputPort', true, ...
'BoundingBoxOutputPort', true', ...
'MaximumBlobArea', 3000, ...
'MinimumBlobArea', 100, ...
'MaximumCount', 3);
hshapeinsBox = vision.ShapeInserter('BorderColorSource', 'Input port', ...
'Fill', true, ...
'FillColorSource', 'Input port', ...
'Opacity', 0.4);
hVideoIn = vision.VideoPlayer('Name', 'Final Video', ...
'Position', [100 100 vidInfo.MaxWidth+20 vidInfo.MaxHeight+30]);
nFrame = 0;
lCount = 0; rCount = 0; dCount = 0;
sureEvent = 5;
iPos = vidInfo.MaxWidth/2;
while (nFrame < numFrame)
rgbFrame = step(vidDevice);
rgbFrame = flipdim(rgbFrame,2);
diffFrameRed = imsubtract(rgbFrame(:,:,1), rgb2gray(rgbFrame));
binFrameRed = im2bw(diffFrameRed, redThresh);
[centroidRed, bboxRed] = step(hblob, binFrameRed);
diffFrameGreen = imsubtract(rgbFrame(:,:,2), rgb2gray(rgbFrame));
binFrameGreen = im2bw(diffFrameGreen, greenThresh);
[centroidGreen, bboxGreen] = step(hblob, binFrameGreen);
diffFrameBlue = imsubtract(rgbFrame(:,:,3), rgb2gray(rgbFrame));
binFrameBlue = im2bw(diffFrameBlue, blueThresh);
[~, bboxBlue] = step(hblob, binFrameBlue);
if length(bboxRed(:,1)) == 1
jRobot.mouseMove(1.5*centroidRed(:,1)*screenSize(3)/vidInfo.MaxWidth, 1.5*centroidRed(:,2)*screenSize(4)/vidInfo.MaxHeight);
end
if ~isempty(bboxBlue(:,1))
if length(bboxBlue(:,1)) == 1
lCount = lCount + 1;
if lCount == sureEvent
jRobot.mousePress(16);
pause(0.1);
jRobot.mouseRelease(16);
end
elseif length(bboxBlue(:,1)) == 2
rCount = rCount + 1;
if rCount == sureEvent
jRobot.mousePress(4);
pause(0.1);
jRobot.mouseRelease(4);
end
elseif length(bboxBlue(:,1)) == 3
dCount = dCount + 1;
if dCount == sureEvent
jRobot.mousePress(16);
pause(0.1);
jRobot.mouseRelease(16);
pause(0.2);
jRobot.mousePress(16);
pause(0.1);
jRobot.mouseRelease(16);
end
end
else
lCount = 0; rCount = 0; dCount = 0;
end
if ~isempty(bboxGreen(:,1))
if (mean(centroidGreen(:,2)) - iPos) < -2
jRobot.mouseWheel(-1);
elseif (mean(centroidGreen(:,2)) - iPos) > 2
jRobot.mouseWheel(1);
end
iPos = mean(centroidGreen(:,2));
end
vidIn = step(hshapeinsBox, rgbFrame, bboxRed,single([1 0 0]));
vidIn = step(hshapeinsBox, vidIn, bboxGreen,single([0 1 0]));
vidIn = step(hshapeinsBox, vidIn, bboxBlue,single([0 0 1]));
step(hVideoIn, vidIn);
nFrame = nFrame+1;
end
release(hVideoIn);
release(vidDevice);
clc;
end
warning('off','vision:transition:usesOldCoordinates');
if nargin < 1
redThresh = 0.22;
greenThresh = 0.14;
blueThresh = 0.18;
numFrame = 1000;
end
cam = imaqhwinfo;
cameraName = char(cam.InstalledAdaptors(end));
cameraInfo = imaqhwinfo(cameraName);
cameraId = cameraInfo.DeviceInfo.DeviceID(end);
cameraFormat = char(cameraInfo.DeviceInfo.SupportedFormats(end));
jRobot = java.awt.Robot;
vidDevice = imaq.VideoDevice(cameraName, cameraId, cameraFormat, ...
'ReturnedColorSpace', 'RGB');
vidInfo = imaqhwinfo(vidDevice);
screenSize = get(0,'ScreenSize');
hblob = vision.BlobAnalysis('AreaOutputPort', false, ...
'CentroidOutputPort', true, ...
'BoundingBoxOutputPort', true', ...
'MaximumBlobArea', 3000, ...
'MinimumBlobArea', 100, ...
'MaximumCount', 3);
hshapeinsBox = vision.ShapeInserter('BorderColorSource', 'Input port', ...
'Fill', true, ...
'FillColorSource', 'Input port', ...
'Opacity', 0.4);
hVideoIn = vision.VideoPlayer('Name', 'Final Video', ...
'Position', [100 100 vidInfo.MaxWidth+20 vidInfo.MaxHeight+30]);
nFrame = 0;
lCount = 0; rCount = 0; dCount = 0;
sureEvent = 5;
iPos = vidInfo.MaxWidth/2;
while (nFrame < numFrame)
rgbFrame = step(vidDevice);
rgbFrame = flipdim(rgbFrame,2);
diffFrameRed = imsubtract(rgbFrame(:,:,1), rgb2gray(rgbFrame));
binFrameRed = im2bw(diffFrameRed, redThresh);
[centroidRed, bboxRed] = step(hblob, binFrameRed);
diffFrameGreen = imsubtract(rgbFrame(:,:,2), rgb2gray(rgbFrame));
binFrameGreen = im2bw(diffFrameGreen, greenThresh);
[centroidGreen, bboxGreen] = step(hblob, binFrameGreen);
diffFrameBlue = imsubtract(rgbFrame(:,:,3), rgb2gray(rgbFrame));
binFrameBlue = im2bw(diffFrameBlue, blueThresh);
[~, bboxBlue] = step(hblob, binFrameBlue);
if length(bboxRed(:,1)) == 1
jRobot.mouseMove(1.5*centroidRed(:,1)*screenSize(3)/vidInfo.MaxWidth, 1.5*centroidRed(:,2)*screenSize(4)/vidInfo.MaxHeight);
end
if ~isempty(bboxBlue(:,1))
if length(bboxBlue(:,1)) == 1
lCount = lCount + 1;
if lCount == sureEvent
jRobot.mousePress(16);
pause(0.1);
jRobot.mouseRelease(16);
end
elseif length(bboxBlue(:,1)) == 2
rCount = rCount + 1;
if rCount == sureEvent
jRobot.mousePress(4);
pause(0.1);
jRobot.mouseRelease(4);
end
elseif length(bboxBlue(:,1)) == 3
dCount = dCount + 1;
if dCount == sureEvent
jRobot.mousePress(16);
pause(0.1);
jRobot.mouseRelease(16);
pause(0.2);
jRobot.mousePress(16);
pause(0.1);
jRobot.mouseRelease(16);
end
end
else
lCount = 0; rCount = 0; dCount = 0;
end
if ~isempty(bboxGreen(:,1))
if (mean(centroidGreen(:,2)) - iPos) < -2
jRobot.mouseWheel(-1);
elseif (mean(centroidGreen(:,2)) - iPos) > 2
jRobot.mouseWheel(1);
end
iPos = mean(centroidGreen(:,2));
end
vidIn = step(hshapeinsBox, rgbFrame, bboxRed,single([1 0 0]));
vidIn = step(hshapeinsBox, vidIn, bboxGreen,single([0 1 0]));
vidIn = step(hshapeinsBox, vidIn, bboxBlue,single([0 0 1]));
step(hVideoIn, vidIn);
nFrame = nFrame+1;
end
release(hVideoIn);
release(vidDevice);
clc;
end
SOURCE CODE FOR REAL TIME FACE DETECTION USING IMAGE PROCESSING MATLAB
function varargout = testing(varargin)
% TESTING MATLAB code for testing.fig
% TESTING, by itself, creates a new TESTING or raises the existing
% singleton*.
%
% H = TESTING returns the handle to a new TESTING or the handle to
% the existing singleton*.
%
% TESTING('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TESTING.M with the given input arguments.
%
% TESTING('Property','Value',...) creates a new TESTING or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before testing_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to testing_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help testing
% Last Modified by GUIDE v2.5 20-Aug-2013 16:34:04
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @testing_OpeningFcn, ...
'gui_OutputFcn', @testing_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before testing is made visible.
function testing_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to testing (see VARARGIN)
% Choose default command line output for testing
handles.output = hObject;
axes(handles.axes1);
imshow('blank.jpg');
axis off;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes testing wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = testing_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in start.
function start_Callback(hObject, eventdata, handles)
% hObject handle to start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.vid = videoinput('winvideo' , 1, 'YUY2_640X480');
%preview(handles.vid);
guidata(hObject, handles);
% --- Executes on button press in face.
function face_Callback(hObject, eventdata, handles)
% hObject handle to face (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%handles.vid = videoinput('winvideo' , 1, 'YUY2_640X480');
triggerconfig(handles.vid ,'manual');
set(handles.vid, 'TriggerRepeat',inf);
set(handles.vid, 'FramesPerTrigger',1);
handles.vid.ReturnedColorspace = 'rgb';
handles.vid.Timeout = 5;
start(handles.vid);
while(1)
facedetector = vision.CascadeObjectDetector;
trigger(handles.vid);
handles.im = getdata(handles.vid, 1);
bbox = step(facedetector, handles.im);
hello = insertObjectAnnotation(handles.im,'rectangle',bbox,'Face');
imshow(hello);
end
guidata(hObject, handles);
% --- Executes on button press in stop.
function stop_Callback(hObject, eventdata, handles)
% hObject handle to stop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = hObject;
stop(handles.vid),clear handles.vid %, ,delete(handles.vid)
guidata(hObject, handles);
% --- Executes on button press in eyes.
function eyes_Callback(hObject, eventdata, handles)
% hObject handle to eyes (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
triggerconfig(handles.vid ,'manual');
set(handles.vid, 'TriggerRepeat',inf);
set(handles.vid, 'FramesPerTrigger',1);
handles.vid.ReturnedColorspace = 'rgb';
handles.vid.Timeout = 2;
start(handles.vid);
while(1)
bodyDetector = vision.CascadeObjectDetector('EyePairBig');
bodyDetector.MinSize = [11 45];
%bodyDetector.ScaleFactor = 1.05;
trigger(handles.vid);
handles.im = getdata(handles.vid, 1);
bbox = step(bodyDetector, handles.im);
hello = insertObjectAnnotation(handles.im,'rectangle',bbox,'EYE');
imshow(hello);
end
guidata(hObject, handles);
% --- Executes on button press in upperbody.
function upperbody_Callback(hObject, eventdata, handles)
% hObject handle to upperbody (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
triggerconfig(handles.vid ,'manual');
set(handles.vid, 'TriggerRepeat',inf);
set(handles.vid, 'FramesPerTrigger',1);
handles.vid.ReturnedColorspace = 'rgb';
handles.vid.Timeout = 5;
start(handles.vid);
while(1)
bodyDetector = vision.CascadeObjectDetector('UpperBody');
bodyDetector.MinSize = [60 60];
bodyDetector.ScaleFactor = 1.05;
trigger(handles.vid);
handles.im = getdata(handles.vid, 1);
bbox = step(bodyDetector, handles.im);
hello = insertObjectAnnotation(handles.im,'rectangle',bbox,'UpperBody');
imshow(hello);
end
guidata(hObject, handles);
% TESTING MATLAB code for testing.fig
% TESTING, by itself, creates a new TESTING or raises the existing
% singleton*.
%
% H = TESTING returns the handle to a new TESTING or the handle to
% the existing singleton*.
%
% TESTING('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TESTING.M with the given input arguments.
%
% TESTING('Property','Value',...) creates a new TESTING or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before testing_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to testing_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help testing
% Last Modified by GUIDE v2.5 20-Aug-2013 16:34:04
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @testing_OpeningFcn, ...
'gui_OutputFcn', @testing_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before testing is made visible.
function testing_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to testing (see VARARGIN)
% Choose default command line output for testing
handles.output = hObject;
axes(handles.axes1);
imshow('blank.jpg');
axis off;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes testing wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = testing_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in start.
function start_Callback(hObject, eventdata, handles)
% hObject handle to start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.vid = videoinput('winvideo' , 1, 'YUY2_640X480');
%preview(handles.vid);
guidata(hObject, handles);
% --- Executes on button press in face.
function face_Callback(hObject, eventdata, handles)
% hObject handle to face (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%handles.vid = videoinput('winvideo' , 1, 'YUY2_640X480');
triggerconfig(handles.vid ,'manual');
set(handles.vid, 'TriggerRepeat',inf);
set(handles.vid, 'FramesPerTrigger',1);
handles.vid.ReturnedColorspace = 'rgb';
handles.vid.Timeout = 5;
start(handles.vid);
while(1)
facedetector = vision.CascadeObjectDetector;
trigger(handles.vid);
handles.im = getdata(handles.vid, 1);
bbox = step(facedetector, handles.im);
hello = insertObjectAnnotation(handles.im,'rectangle',bbox,'Face');
imshow(hello);
end
guidata(hObject, handles);
% --- Executes on button press in stop.
function stop_Callback(hObject, eventdata, handles)
% hObject handle to stop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = hObject;
stop(handles.vid),clear handles.vid %, ,delete(handles.vid)
guidata(hObject, handles);
% --- Executes on button press in eyes.
function eyes_Callback(hObject, eventdata, handles)
% hObject handle to eyes (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
triggerconfig(handles.vid ,'manual');
set(handles.vid, 'TriggerRepeat',inf);
set(handles.vid, 'FramesPerTrigger',1);
handles.vid.ReturnedColorspace = 'rgb';
handles.vid.Timeout = 2;
start(handles.vid);
while(1)
bodyDetector = vision.CascadeObjectDetector('EyePairBig');
bodyDetector.MinSize = [11 45];
%bodyDetector.ScaleFactor = 1.05;
trigger(handles.vid);
handles.im = getdata(handles.vid, 1);
bbox = step(bodyDetector, handles.im);
hello = insertObjectAnnotation(handles.im,'rectangle',bbox,'EYE');
imshow(hello);
end
guidata(hObject, handles);
% --- Executes on button press in upperbody.
function upperbody_Callback(hObject, eventdata, handles)
% hObject handle to upperbody (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
triggerconfig(handles.vid ,'manual');
set(handles.vid, 'TriggerRepeat',inf);
set(handles.vid, 'FramesPerTrigger',1);
handles.vid.ReturnedColorspace = 'rgb';
handles.vid.Timeout = 5;
start(handles.vid);
while(1)
bodyDetector = vision.CascadeObjectDetector('UpperBody');
bodyDetector.MinSize = [60 60];
bodyDetector.ScaleFactor = 1.05;
trigger(handles.vid);
handles.im = getdata(handles.vid, 1);
bbox = step(bodyDetector, handles.im);
hello = insertObjectAnnotation(handles.im,'rectangle',bbox,'UpperBody');
imshow(hello);
end
guidata(hObject, handles);
Saturday, 11 March 2017
SOLAR INVERTER
WHAT IS AN INVERTER ?
1.A inverter is a device which converts the direct current into an alternating one.
2.Inveter simply serve the purpose to convert the power just as a transformer does for ac to ac conversion.
3.Inverter doesn't produce any power the power is provided by dc source in its input terminals.
4.A inverter can be rotatary or static one.
5.Rotatary connects to equipment having mechanical elements while static corresponds to elctronic circuitory.
INPUT VOLTAGE IN A INVERTER
A inverter requires a stable dc power source capable of supplying enough current for the intended power demands of the system.
Input voltage actually depends on the design and purpose of the inverter.
examples such as :-
12vdc for small consumers
24v,36v,48v dc for common standards home energy systems
300v to 400v dc when power is from photovoltaic solar panels.
OUTPUT WAVEFORM
An inverter has the ability to produce square wave,modified sine wave ,pulsed sine wave,pulse width modulated wave or sine wave depending on the circuit design.
square wave- It's a non-sinusoidal periodic waveform which can be represented as a infinite summation of sinusoidal waves.It produces harmonics and is generally unsuitable for sensitive electronics equipments.
DUTY CYCLE - it corresponds to the fraction of time for which pulse is activated.
duty cycle = active time / total time for one period
eg. For a square wave duty cycle is 50%.
OUTPUT CONVERSION
A inverter actually converts the dc electricity from the sources like fuel cells or batteries.
1.Batteries are connected in series in order to increase the amount of voltage.
2.Batteries are connected in parallel in order to increase the ampere hour rating.
PROJECTS FOR FINAL YEAR { ELECTRICAL ENGINEERING } MATLAB BASED
1.Grid connected Solar Inverter
2.Modelling and circuit based simulation of photovoltaic array
3.Create a fault on transmission line
4.Smart Grid
5.Modelling and simulation of 5 phase permanent magnet synchronous motor using sliding controller
1.Grid connected Solar Inverter
2.Modelling and circuit based simulation of photovoltaic array
3.Create a fault on transmission line
4.Smart Grid
5.Modelling and simulation of 5 phase permanent magnet synchronous motor using sliding controller
Saturday, 4 March 2017
EASY SYNTAX BASED MATLAB QUESTIONS
2. To calculate the limit lim x -- 2+ [ (x+3/x+4) ]
3. To generate a set of uniformly spaced points for 0 ≤ x ≤ 10 you can write:
6. To add a title to a graph, the correct command is:
7. To plot a curve as a red dotted line, the correct command is:
8. To create a symbolic function f(t) = sin(t) the best command to use is:
27. To plot a log-log plot, the correct command is:
1. We use MATLAB to
solve an equation 2x + 3 = 0. What is the correct function to call and
what is the syntax:
(a) find(‘2 * x +
3’)
(b) roots(‘2 * x +
3’)
(c) solve(‘2 * x +
3’)
(d) solve(‘2 * x + 3’, 0)
2. To calculate the limit lim x -- 2+ [ (x+3/x+4) ]
the correct MATLAB call
is:
(a) limit((x +
3)/(x – 4), 2, +)
(b) limit((x +
3)/(x – 4)), 2,+
(c) limit((x +
3)/(x – 4), 2, ‘right’)
(d) limit((x + 3)/(x – 4),
2), right
3. To generate a set of uniformly spaced points for 0 ≤ x ≤ 10 you can write:
(a) x =
linspace(0:10);
(b) x =
linspace(0:0.1:10);
(c) x =
linspace(0, 10, ‘u’);
(d) x = linspace(0, 10);
4. You want to plot two
curves y1 and y2 against x. To plot y1 as a red
lineand y2 as a blue line, the correct command is:
(a) plot(x, y1,
‘r’, x, y2, ‘b’)
(b) plot(x, y1,
‘r’, y2, ‘b’)
(c) plot(x, y1,
“r”, y2, “b”)
(d) plot(x, y1, x, y2),
color(‘r’, ‘b’)
5. You want to plot a
curve as a dashed blue line. The correct command is:
(a) plot(x, y,
‘b–’)
(b) plot(x, y,
‘b–’)
(c) plot(x, y, ‘b’,
‘–’)
6. To add a title to a graph, the correct command is:
(a) plot(x, y,
‘title–>‘Plot of Sin(x)’)
(b) plot(x, y,
‘Plot of Sin(x)’)
(c) plot(x, y),
title(‘Plot of Sin(x)’)
(d) plot(x, y), Title(‘Plot
of Sin(x)’)
7. To plot a curve as a red dotted line, the correct command is:
(a) plot(x, y,
‘r’, ‘:’)
(b) plot(x, y,
‘r:’)
(c) plot(x, y, ‘r.’)
8. To create a symbolic function f(t) = sin(t) the best command to use is:
(a) syms t; f =
sin(t);
(b) syms t; f =
sin(‘t’);
(c) syms t; f =
‘sin(t)’;
(d) a or c
9. To plot a symbolic
function f you call:
(a) quickplot( f )
(b) symplot( f )
(c) ezplot( f )
(d) plot( f,
‘symbolic’)
10. You want to use ezplot
to generate a graph of a function f and its second derivative on the same
graph. The correct command is:
(a) ezplot( f,
diff( f, 2))
(b) subplot(1, 2, 1);
ezplot( f ) subplot(1, 2, 2); ezplot(diff( f, 2))
(c) ezplot( f );
hold on ezplot(diff( f, 2))
(d) ezplot( f );
hold; ezplot(diff( f, 2));
11. You want to use ezplot
to generate a graph of a function f and its second
derivative in
side-by-side plots. The correct command is:
(a) subplot(1, 2, 1);
ezplot( f ) subplot(1, 2, 2); ezplot(diff( f, 2))
(b) ezplot(subplot(1, f
), subplot(2, diff( f, 2))
(c) ezplot( f );
hold on ezplot(diff( f, 2))
12. You have created a
symbolic function f. To display its third derivative, you
can write:
(a) f’’’’
(b) f’’’’ or
diff( f, 3)
(c) derivative( f,
3)
(d) diff( f, 3)
13. The subplot command
(a) Allows you to
generate several plots contained in the same figure.
(b) Allows you to plot
multiple curves on the same graph.
(c) MATLAB does not have
a subplot command.
14. Calling subplot(m,
n, p)
(a) Divides a figure
into an array of plots with m rows and n columns,
putting the current plot
at pane p.
(b) Plots curve n against
m in pane p.
(c) Plots curve p at
location (row, column) = (m, n)
(d) MATLAB does not have
a subplot command.
15. If A is a
column vector, we can create the transpose or row vector B by writing:
(a) B =
transpose(A)
(b) B = A’
(c) B = t(A)
(d) B = trans(A)
16. Suppose that x =
7 and y = –3. The statement x ~= y in MATLAB will generate:
(a) ans = 1
(b) ans = 0
(c) ans = –1
(d) An error
17. To enter the
elements 1 –2 3 7 in a column vector, we type:
(a) [1: –2:3:7]
(b) [1, –2,3,7]
(c) [ 1; –2; 3; 7]
(d) [1 –2 3 7]
18. To compute the
square of a vector f of data, write:
(a) sqr( f )
(b) f. ^ 2
(c) f ^ 2
(d) square( f )
19. To generate the
fourth order Taylor expansion of a function f about the
origin, use:
(a) Taylor( f, 4)
(b) taylor( f, 4)
(c) taylor( f ),
terms(‘4’)
(d) taylor, f, 4
20. A function is
defined as f = a * x ^ 2 – 2. The command solve( f,
a) yields:
(a) 2/a
(b) 2/x
(c) –2/x
(d) An error: rhs must be specified.
21. A variable called y
has one row and 11 columns. If we type size(y) MATLAB returns:
(a) 11
(b) 1 11
(c) 11 1
(d) (1, 11)
22. To implement a for
loop which ranges over 1 ≤ x ≤ 5 in increments of 0.5
the best command is:
(a) for i = 1, 5,
0.5
(b) for i =
1:0.5:5
(c) for loop i =
1, 5, 0.5
(d) loop i =
1:0.5:5 do
23. A function y =
exp(-2*x) is defined numerically
for some data range x. It can be entered using:
(a) y = exp(–x)
* exp(–x)
(b) y = sqr(exp(–x))
(c) y = exp(–x).
* exp(–x)
(d) y =
sqrt(exp(–x))
24. To find the largest
value in a column vector x, type:
(a) max(x)
(b) maximum(x)
(c) largest(x)
25. The labels used by
MATLAB on an x–y plot are specified with:
(a) The labels command.
(b) The xlabel
and ylabel command.
(c) The label command
(d) The text command
26. To specify the
domain and range used in an x–y plot where a <=x <=
b, c <=y
<= d
(a) axis([a b c d ])
(b) axis(a b c d )
(c) axis([a, b,
c, d ])
(d) axis a, b, c, d
27. To plot a log-log plot, the correct command is:
(a) plot(x, y,
‘log-log’)
(b) loglog(x, y)
(c) log(x, y)
(d) logplot(x, y)
28. When solving a
differential equation using MATLAB, the dsolve command expects the user to
indicate a second derivative of y = f(x) by typing:
(a) y’’
(b) diff(y, 2)
(c) D ^ 2y
(d) D2y
(e) D(Dy)
29. To find a solution
of
Dy/dt+ 2y =
0
The best syntax to use
in MATLAB is:
(a) diff(‘y’ + 2
* y = 0’)
(b) dsolve(‘Dy +
2 * y’)
(c) dsolve(‘Dy +
2 * y = 0’)
(d) diff(Dy + 2y)
30. Who
invented MATLAB and when ?
a.Cleve Moler (1987)
b.Jack Little (1992)
c.Cleve Moler (1985)
d.John Little (1987)
Subscribe to:
Posts (Atom)