Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
No high res. live image from logitech C250 webcam in Matlab

Subject: No high res. live image from logitech C250 webcam in Matlab

From: FMC

Date: 22 Aug, 2010 21:48:08

Message: 1 of 2

I recently purchased a Logitech C250 webcam and my Matlab (2007a) code to acquire live images does not work correctly with this C250 webcam. I have been using a Logitech Fusion QuickCam (and other makes of cameras) with this same Matlab code for a couple of years without problems. With the C250, everything works fine if I use lower image resolutions of 'I420_160x120', 'I420_176x144', 'RGB24_160x120' and 'RGB24_176x144'. If I use higher resolutions, I can get a live video feed the first time I 'grab', but after I 'snap' and then try to 'grab' again, I get a black image and no live display (although the webcam green light goes on indicating it is capturing). If I unplug the webcam USB cable and then plug it back in again, I get a live image feed the first time I 'grab'. However, once I 'snap' and then try to 'grab' again, I again get no live video image. If I then select one of the smaller
image format above, I get a live feed on the next 'grab'. The Logitech webcam software works fine with low and high resolution images. However, it too won't recover a live feed after I 'snap' in my Matlab code until I unplug and plug in the camera again. Logitech tech-support kindly sent me a new C250 thinking it might be a problem with the first C250. Now I have two C250's that behave the same way. The behavior is the same on two different computers. I worked through the 'preview.m' function to try to diagnose where the the problem is, and it seems that the ZZZUpdatePreviewFcn simply never gets invoked. It appears that the C250 is doing something different from the Fusion QuickCam and with the higher resolution image formats that means Matlab doesn't recognize the live image feed. I have tried reducing the frame rate, and several different code variation in the 'snap' function, but they
all behave the same way.

I implemented an UpdatePreviewWindowFcn to show the live image myself using:

setappdata(hImage, 'UpdatePreviewWindowFcn', @video_preview_fcn);

... and ...

function video_preview_fcn(obj, event, himage)
% get the current image
im = event.Data;
set(himage, 'CData', im, 'EraseMode', 'none');
% Complete pending drawing events
drawnow

...but this has exactly the same effect; ivideo_preview_fcn gets called with the low resolution images, but is not called with the high resolution images.

What actually causes the UpdatePreviewWindowFcn to be invoked? For some reason this is not being invoked with the regular preview.m function or with my own UpdatePreviewWindowFcn with the higher resolution images. It's almost as though the camera trigger is not being detected by Matlab with the higher resolution images. Is anyone else using a Logitech C250 with Matlab? I have posted a message on the Logitech forum to ask there as well.

Anybody have any ideas?
 

Subject: No high res. live image from logitech C250 webcam in Matlab

From: muhammad Raza

Date: 20 Feb, 2011 03:38:23

Message: 2 of 2

I am getting the below mentioned problem,
please comment.....

regards
Raza
"FMC " <fmc210@gmail.com> wrote in message <i4s5uo$ht1$1@fred.mathworks.com>...
> I recently purchased a Logitech C250 webcam and my Matlab (2007a) code to acquire live images does not work correctly with this C250 webcam. I have been using a Logitech Fusion QuickCam (and other makes of cameras) with this same Matlab code for a couple of years without problems. With the C250, everything works fine if I use lower image resolutions of 'I420_160x120', 'I420_176x144', 'RGB24_160x120' and 'RGB24_176x144'. If I use higher resolutions, I can get a live video feed the first time I 'grab', but after I 'snap' and then try to 'grab' again, I get a black image and no live display (although the webcam green light goes on indicating it is capturing). If I unplug the webcam USB cable and then plug it back in again, I get a live image feed the first time I 'grab'. However, once I 'snap' and then try to 'grab' again, I again get no live video image. If I then select one of the
smaller
> image format above, I get a live feed on the next 'grab'. The Logitech webcam software works fine with low and high resolution images. However, it too won't recover a live feed after I 'snap' in my Matlab code until I unplug and plug in the camera again. Logitech tech-support kindly sent me a new C250 thinking it might be a problem with the first C250. Now I have two C250's that behave the same way. The behavior is the same on two different computers. I worked through the 'preview.m' function to try to diagnose where the the problem is, and it seems that the ZZZUpdatePreviewFcn simply never gets invoked. It appears that the C250 is doing something different from the Fusion QuickCam and with the higher resolution image formats that means Matlab doesn't recognize the live image feed. I have tried reducing the frame rate, and several different code variation in the 'snap' function, but
they
> all behave the same way.
>
> I implemented an UpdatePreviewWindowFcn to show the live image myself using:
>
> setappdata(hImage, 'UpdatePreviewWindowFcn', @video_preview_fcn);
>
> ... and ...
>
> function video_preview_fcn(obj, event, himage)
> % get the current image
> im = event.Data;
> set(himage, 'CData', im, 'EraseMode', 'none');
> % Complete pending drawing events
> drawnow
>
> ...but this has exactly the same effect; ivideo_preview_fcn gets called with the low resolution images, but is not called with the high resolution images.
>
> What actually causes the UpdatePreviewWindowFcn to be invoked? For some reason this is not being invoked with the regular preview.m function or with my own UpdatePreviewWindowFcn with the higher resolution images. It's almost as though the camera trigger is not being detected by Matlab with the higher resolution images. Is anyone else using a Logitech C250 with Matlab? I have posted a message on the Logitech forum to ask there as well.
>
> Anybody have any ideas?
>

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us