problem in connecting with webcam and re

2 次查看(过去 30 天)
I use this code to take a picture but the picture is very eliminate.but also when I use this command "preview(cam)" on time image is good. what is the problem with the picture?the code is below
cam=videoinput('winvideo' , 2);
set(cam.source , 'Brightness' , 240);
pic=getsnapshot(cam);
  4 个评论
Walter Roberson
Walter Roberson 2013-11-2
I would not assume that the default video format is RGB. You should find out which formats your camera can return, and select one specifically. Then if necessary, convert colorspaces into something you can display. If the video format is grayscale, make sure you have a grayscale colormap active when you display it.
Behrad kiani
Behrad kiani 2013-11-3
imaqhwinfo('winvideo' , 2)
ans =
DefaultFormat: 'YUY2_160x120'
DeviceFileSupported: 0
DeviceName: 'A4TECH USB2.0 PC Camera'
DeviceID: 2
ObjectConstructor: 'videoinput('winvideo', 2)'
SupportedFormats: {1x5 cell}
>> cam = videoinput('winvideo') >> imaqhwinfo(cam)
ans =
AdaptorName: 'winvideo'
DeviceName: 'Integrated Webcam'
MaxHeight: 720
MaxWidth: 1280
NativeDataType: 'uint8'
TotalSources: 1
VendorDriverDescription: 'Windows WDM Compatible Driver'
VendorDriverVersion: 'DirectX 9.0'

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2013-11-3
Do you have a weird colormap applied? Is the camera running in monochrome mode? Your videoinput() code doesn't look like mine. Mine looks like:
% Initialize Logitech webcam
vidobj = videoinput('winvideo', 1, 'RGB24_640x480');
if ~isempty(vidobj)
src = getselectedsource(vidobj);
vidobj.FramesPerTrigger = 1;
axes(handles.axesImage);
hImage = findobj(handles.axesImage, 'Type', 'image');
preview(vidobj, hImage);
% src.ZoomMode = 'manual';
% Turn on the live video preview. Display the bounding box over it if there is one selected.
TurnOnLiveVideo(handles); % My own function
end
Are you sure you're supposed to be using camera #2? Why did you not specify an operation mode, such as 'RGB24_640x480', for the video?
  9 个评论
Walter Roberson
Walter Roberson 2013-11-3
The comments in the link I posted show how to get the YUY2 space converted to RGB.

请先登录,再进行评论。

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by