2012-02-20 83 views
1

我在运行MATLAB这个代码,但它返回一个青色帧getsnapshot返回青色屏幕

obj = videoinput('winvideo', 1); 

% Select the source to use for acquisition. 
set(obj, 'SelectedSourceName', 'input1') 

% View the properties for the selected video source object. 
src_obj = getselectedsource(obj); 
get(src_obj) 

% Acquire and display a single image frame. 
frame = getsnapshot(obj); 
image(frame); 

% Remove video input object from memory. 
delete(obj); 

但预览视频效果很好。 getsnapshot output

回答

1

在第二行中添加obj.ReturnedColorSpace = 'rgb';范围解决它。

1

也许问题是输入到image命令。

尝试运行

class(frame) 
max(frame(:)) 
min(frame(:)) 

,并查看结果是什么。

Double值应为[0-1]之间,而uint8应在[0-255].

+0

'ans = uint8 ans = 136 ans = 18' – Maysam 2012-02-20 19:51:32