Unable to allocate memory for an incoming image frame. Use IMAQMEM to modify the frame memory limit.

5 views (last 30 days)
hi,
i try to run my detection of blue code,it was running before but now it showing this errors:
Error in imaqdevice/getsnapshot (line 63)
[snapshot, metadata] = getsnapshot(imaqgate('privateGetField', obj, 'uddobject'));
Error in Blu (line 28)
data = getsnapshot(vid);
Error using imaqdevice/getsnapshot (line 65)
A timeout occurred during GETSNAPSHOT.
Error in Blu (line 28)
data = getsnapshot(vid);
my code is:
clc;
clear all;
close all;
vid = videoinput('winvideo',1, 'YUY2_160x120');
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb');
vid.FrameGrabInterval = 1;
start(vid)
%-------------------------------Variable-----------------------------------------------------%
count_b = 1;
vbt_1_b = 1;
count_2_b =1;
while(vid.FramesAcquired<=1000)
data = getsnapshot(vid);
[row col cc] = size(data);
%----------------------------------------------Blue Detection--------------------------------------------%
diff_im_b = imsubtract(data(:,:,3), rgb2gray(data));
diff_im_b = medfilt2(diff_im_b, [3 3]);
diff_im_b = im2bw(diff_im_b,0.15);
diff_im_b = bwareaopen(diff_im_b,300);
bw_b = bwlabel(diff_im_b, 8);
status{count_b} = regionprops(bw_b, 'BoundingBox', 'Centroid');
% Display the image
imshow(data);
hold on
x_b = length(status{count_b});
for n=1:x_b
rectangle('position',[status{count_b}(n).BoundingBox],'edgecolor','r');
plot( status{count_b}(n,1).Centroid(1,1),status{count_b}(n,1).Centroid(1,2),'+');
end
hold off
x_b = status{1,count_b};
if(~isempty(x_b))
vbt(vbt_1_b) = status{1,count_b}.Centroid(1,1);
if(vbt_1_b > 1)
a_b =vbt(vbt_1_b-1);
b_b= vbt(vbt_1_b);
if(a_b>b_b)
count_2_b = count_2_b +1;
if (count_2_b == 8)
fprintf('5')
count_2_b = 0;
end
end
if(a_b<b_b)
count_2_b = count_2_b - 1;
if (count_2_b == 1)
fprintf('4')
end
end
end
vbt_1_b = vbt_1_b+1;
end
count_b = count_b + 1;
end
stop(vid);
flushdata(vid);

Answers (0)

Community Treasure Hunt

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

Start Hunting!