Kamis, 04 April 2013

Menampilkan webcam di matlab

Langkah Awal :

1. Buat "pushbottom"
2. Buat "axes"
3. Ketikkan script ini di bawahnya script "pushbottom" :
                    %% inisialisasi objek
                    caminf = imaqhwinfo;
                    mycam = char(caminf.InstalledAdaptors(end));
                    mycaminfo = imaqhwinfo(mycam);
                    resolution = char(mycaminfo.DeviceInfo.SupportedFormats(end));
                    vd = videoinput(mycam, 1, resolution);
                    -------------------------------------------------------------                  
               %% Previewing video
   untitled3
   vidRes = get(vd, 'VideoResolution');
   nBands = get(vd, 'NumberOfBands');
   hImage = image(zeros(vidRes(2), vidRes(1), nBands)) ;
   preview(vd, hImage);

4. Save.
5. Siap di jalankan

6. NB : untitle3 adalah nama m-file yang ingin digunakan.

1 komentar:

  1. ketika saya running ini yang muncul gan,,

    form1
    Error using end
    Incorrect cell or structure reference involving "end".
    Most likely cause is a reference to multiple elements of a
    cell or structure followed by additional subscript or
    structure references.

    Error in form1>pushbutton1_Callback (line 89)
    resolution =
    char(mycaminfo.DeviceInfo.SupportedFormats(end));

    Error in gui_mainfcn (line 95)
    feval(varargin{:});

    Error in form1 (line 42)
    gui_mainfcn(gui_State, varargin{:});

    Error in
    @(hObject,eventdata)form1('pushbutton1_Callback',hObject,eventdata,guidata(hObject))


    Error while evaluating uicontrol Callback

    mohon petunjuk

    BalasHapus