From: eduardo on
Hi forum!

As I said in the subject of my post I want to process in real time the images that are being grabbed by my webcam. I did this in c++ using the openCV library but now I want to do this in Matlab. In this link ( http://www.mathworks.com/support/solutions/en/data/1-1CBPW/index.html ) I learned how to do a GUI and show the frames that are being acquired. But how can I process and show the result each of them in the GUI?
How can I get each frame matrix (using this code or another one! )in order to make them available to the processing toolbox?
(I´m supposing that I will have to use also the image processing toolbox to process each image coming from the cam, am I wrong?) .

I googled a lot and so far I didn´find anything useful !
Hope you can point me on the right way :D

Best regards and thanks for all,

Eduardo
From: Morten on
Hey
I hope this will help

Matlab code:
vid = videoinput('winvideo',1)
preview(vid)

while 1

% takes a snapshot at the current time
i = getsnapshot(vid);
% converts the image to grayscale
gray = mat2gray(i);

% display grayscale image
figure(2)
imshow(gray)

% You can also display black/white image by
% Finds a threshold
threshold = graythresh(gray);
% you can set the threshold manually. [value: 0-1]
bw = im2bw(gray, threshold);

% Before uncommenting the sentence below, comment "imshow(gray)"
%imshow(bw)

end
From: Morten on
"Morten " <mortenvestboe(a)hotmail.com> wrote in message <hruhi4$fki$1(a)fred.mathworks.com>...
> Hey
> I hope this will help
>
> Matlab code:
> vid = videoinput('winvideo',1)
> preview(vid)
>
> while 1
>
> % takes a snapshot at the current time
> i = getsnapshot(vid);
> % converts the image to grayscale
> gray = mat2gray(i);
>
> % display grayscale image
> figure(2)
> imshow(gray)
>
> % You can also display black/white image by
> % Finds a threshold
> threshold = graythresh(gray);
> % you can set the threshold manually. [value: 0-1]
> bw = im2bw(gray, threshold);
>
> % Before uncommenting the sentence below, comment "imshow(gray)"
> %imshow(bw)
>
> end



i will try again

Matlab code:
vid = videoinput('winvideo',1)
preview(vid)

while 1

% takes a snapshot at the current time
i = getsnapshot(vid);
% converts the image to grayscale
gray = rgb2gray(i);

% display grayscale image
figure(2)
imshow(gray)

% You can also display black/white image by
% Finds a threshold
threshold = graythresh(gray);
% you can set the threshold manually. [value: 0-1]
bw = im2bw(gray, threshold);

% Before uncommenting the sentence below, comment "imshow(gray)"
%imshow(bw)

end
From: Morten on
"Morten " <mortenvestboe(a)hotmail.com> wrote in message <hruhi4$fki$1(a)fred.mathworks.com>...
> Hey
> I hope this will help
>
> Matlab code:
> vid = videoinput('winvideo',1)
> preview(vid)
>
> while 1
>
> % takes a snapshot at the current time
> i = getsnapshot(vid);
> % converts the image to grayscale
> gray = mat2gray(i);
>
> % display grayscale image
> figure(2)
> imshow(gray)
>
> % You can also display black/white image by
> % Finds a threshold
> threshold = graythresh(gray);
> % you can set the threshold manually. [value: 0-1]
> bw = im2bw(gray, threshold);
>
> % Before uncommenting the sentence below, comment "imshow(gray)"
> %imshow(bw)
>
> end



i will try again

Matlab code:
vid = videoinput('winvideo',1)
preview(vid)

while 1

% takes a snapshot at the current time
i = getsnapshot(vid);
% converts the image to grayscale
gray = rgb2gray(i);

% display grayscale image
figure(2)
imshow(gray)

% You can also display black/white image by
% Finds a threshold
threshold = graythresh(gray);
% you can set the threshold manually. [value: 0-1]
bw = im2bw(gray, threshold);

% Before uncommenting the sentence below, comment "imshow(gray)"
%imshow(bw)

end
From: Mark Jones on
eduardo wrote:
> Hi forum!
>
> As I said in the subject of my post I want to process in real time the
> images that are being grabbed by my webcam. I did this in c++ using the
> openCV library but now I want to do this in Matlab. In this link (
> http://www.mathworks.com/support/solutions/en/data/1-1CBPW/index.html )
> I learned how to do a GUI and show the frames that are being acquired.
> But how can I process and show the result each of them in the GUI?
> How can I get each frame matrix (using this code or another one! )in
> order to make them available to the processing toolbox? (I´m supposing
> that I will have to use also the image processing toolbox to process
> each image coming from the cam, am I wrong?) .
>
> I googled a lot and so far I didn´find anything useful !
> Hope you can point me on the right way :D
>
> Best regards and thanks for all,
>
> Eduardo

Hi Eduardo,

I think you will find a good example of a custom preview here:

http://www.mathworks.com/access/helpdesk/help/toolbox/imaq/f11-74309.html#f11-76067

However, you may wish to use GETDATA and a FramesAcquiredFcn callback to
get your data, modify it, and set the CData of an IMAGE object instead
of using the PREVIEW function.

Mark