[go: up one dir, main page]

0% found this document useful (0 votes)
36 views2 pages

If ... Return End

This document contains code for capturing video from a webcam or other video input device, displaying the live video feed, capturing snapshots, converting images to grayscale, applying thresholding, and loading external images. The code selects a video input device, captures video frames, displays the live video feed, saves snapshots, converts images to grayscale, thresholds the grayscale images based on a slider value, and loads external images for processing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

If ... Return End

This document contains code for capturing video from a webcam or other video input device, displaying the live video feed, capturing snapshots, converting images to grayscale, applying thresholding, and loading external images. The code selects a video input device, captures video frames, displays the live video feed, saves snapshots, converts images to grayscale, thresholds the grayscale images based on a slider value, and loads external images for processing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

movegui(hObject, 'center');

-----------------------------------------------------------
IAHI= imaqhwinfo;
IA= (IAHI.InstalledAdaptors);
D= menu ('select Video Input Device',IA);

if isempty(IA)||D==0
msgbox({'you don''t have any Video Input Installed Adaptors!',...
'please try again select Adaptors properly.'})
return
end

IA= char(IA);
IA= IA(D,:);
IA(IA==' ')=[];
x= imaqhwinfo(IA);

try
DeviceID= menu('Select Device ID',x.DeviceIDs);
F= x.Deviceinfo(DeviceID).SupportedFormats;
nF= menu('Select Format',F);
Format =F(nF);
catch
warndlg({'Try Another Device or ID';...
'you Don''t Have Installed This Device (VideoInputDevice)'})
return
end

VidObj=VideoInput(IA,DeviceID,Format);
handles.VidObj=VidObj;
vidRes = get(handles.VidObj,'VideoResolution');
nBands = get(handles,VidObj,'NumberOfBands');

axes(handles.axes1)
hImage= image(zeros(vidRes(2),vidRes(1),nBands));
preview(handles.VidObj,hImage)
set(VidObj,'returnnedcolorspace','rgb');
guidata(hObject,handles);
----------------------------------------------------------------
try
delete(handles,VidObj)
catch
end

axes(handles.axes1)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])

cla (handles.axes2,'reset');
cla (handles.axes3,'reset');

----------------------------------------------------------------
try
VidObj=handles.VidObj;
i= getsnapshot(VidObj);

axes(handles.axes2)
imshow(i);
imwrite(i(['image','.jpg']))
catch
end
------------------------------------------------------------------------------------------------------------------------------------------
gambar = handles.data1;
gr = rgb2gray(gambar);
axes(handles.axes3);
imshow(gr);
handles.data2= gr;
guidata(hObject,handles);

------------------------------------------------------------------------------------------------------------------------------------------
gr= handles.data2;
value= get(handles.slider1,'value');
thresh= imcomplement (im2bw(gr,value/255));
axes(handles.axes3);
imshow(thresh);
handles.data3= thresh;
guidata(hObject,handles);
set(handles.edit1,'string',value)

------------------------------------------------------------------------------------------------------------------------------------------
[name_file,name_path]=uigetfile(...
{'*.bmp;*.jpg;*.tif','Files of type (*.bmp,*.jpg*.tif)';
'*.bmp','File Bitmap (*.bmp)';...
'*.jpg','File Jpeg (*.jpg)';
'*.tif','File Tif (*.tif)';
'*.*','All Files (*.*)'},...
'Open Image');

if ~isequal (name_file,0)
handles.data1= imread(fullfile(name_path,name_file));
guidata(hObject,handles);
axes(handles.axes1);
imshow(handles.data1);
else
return
end

------------------------------------------------------------------------------------------------------------------------------------------

You might also like