// Scilab Computer Vision Module
// Copyright (C) 2017 - Scilab Enterprises
scicv_Init();
f=figure('figure_position',[400,50],'figure_size',[640,480],'auto_resize','on','background',[33],'figure_name','Graphic window number %d','dockable','off','infobar_visible','off','toolbar_visible','off','menubar_visible','off','default_axes','on','visible','off');
//////////
handles.dummy = 0;
handles.abrir=uicontrol(f,'unit','normalized','BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.2932692,0.2857143,0.1282051,0.1292517],'Relief','default','SliderStep',[0.01,0.1],'String','UnName1','Style','pushbutton','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','abrir','Callback','abrir_callback(handles)')
f.visible = "on";
//////////
// Callbacks are defined as below. Please do not delete the comments as it will be used in coming version
//////////
function abrir_callback(handles)
//Write your callback for abrir here
videoCapture = new_VideoCapture(0);
if ~VideoCapture_isOpened(videoCapture)
messagebox("Cannot open capture device #0. Please plug a camera.", ..
"sciCV - Video capture demo");
return
end
f = scf();
toolbar(f.figure_id, "off");
demo_viewCode("video_capture.dem.sce");
clsf = new_CascadeClassifier();
CascadeClassifier_load(clsf, "data/haarcascades/haarcascade_frontalface_alt.xml");
h_checkbox = uicontrol(f, "style", "checkbox", "string", "fotopal", ..
"backgroundColor", [1,1,1], "position", [10,20,150,20]);
while is_handle_valid(f)
[ret, frame] = VideoCapture_read(videoCapture);
if ret then
if h_checkbox.value == 1 then
faces = CascadeClassifier_detectMultiScale(clsf, frame, 1.3, 2, CV_HAAR_SCALE_IMAGE, [10 10]);
for i=1:size(faces)
face = faces(i);
leftTopPt = [face(1), face(2)];
rightBottomPt = [face(1)+face(4), face(2)+face(3)];
rectangle(frame, leftTopPt, rightBottomPt, [0, 255, 0], 2, 8, 0);
end
end
if is_handle_valid(f) then
matplot(frame);
// This GUI file is generated by guibuilder version 4.2.1
//////////
end
delete_Mat(frame);
else
break
end
end
VideoCapture_release(videoCapture);
//graphicwindows("video_capture.dem.sce");
endfunction
// video capture from the camera
Opcion dos
// Scilab Computer Vision Module
// Copyright (C) 2017 - Scilab Enterprises
scicv_Init();
// video capture from the camera
videoCapture = new_VideoCapture(0);
if ~VideoCapture_isOpened(videoCapture)
messagebox("Cannot open capture device #0. Please plug a camera.", ..
"sciCV - Video capture demo");
return
end
f = scf();
toolbar(f.figure_id, "off");
demo_viewCode("video_capture.dem.sce");
clsf = new_CascadeClassifier();
CascadeClassifier_load(clsf, "data/haarcascades/haarcascade_frontalface_alt.xml");
h_checkbox = uicontrol(f, "style", "checkbox", "string", "export to", ..
"backgroundColor", [1,1,1], "position", [10,20,150,20]);
while is_handle_valid(f)
[ret, frame] = VideoCapture_read(videoCapture);
if ret then
if h_checkbox.value == 1 then
faces = CascadeClassifier_detectMultiScale(clsf, frame, 1.3, 2, CV_HAAR_SCALE_IMAGE, [10 10]);
for i=1:size(faces)
face = faces(i);
leftTopPt = [face(1), face(2)];
rightBottomPt = [face(1)+face(4), face(2)+face(3)];
rectangle(frame, leftTopPt, rightBottomPt, [0, 255, 0], 2, 8, 0);
end
end
if is_handle_valid(f) then
matplot(frame);
end
delete_Mat(frame);
else
break
end
end
VideoCapture_release(videoCapture);Opcion tres
////////////////////////////////////////////////////////////
// IPCV - Scilab Image Processing and Computer Vision toolbox
// Copyright (C) 2017 Tan Chin Luh
////////////////////////////////////////////////////////////
function demo_webcam()
re = messagebox("Make sure you have a supported webcam connected", "WebCam Demo", "info", ["Continue" "Stop"], "modal")
if re ==1 then
avicloseall();
n = camopen(0);
while(1)
im = camread(n); //get a frame
br = imdisplay(im,'Press anykey to exit');
if br == -1
break
end
end
//xs2png(im,'foo.png');
avicloseall();
imdestroyall
messagebox("Thanks!", "End of demo", "info", "Done", "modal") ;
else
messagebox("Exit Demo Now", "User Interruption", "warning", "Done", "modal") ;
end
endfunction
// ====================================================================
demo_webcam();
//clear demo_webcam;
// ====================================================================
No hay comentarios.:
Publicar un comentario