Computing optical flow features over 1000 image frames in matlab, gives out of memory error

1 view (last 30 days)
I am trying to use Horn-schnuck method for computing optical flow features for 1000 frames using matlab ,i have kept all the 1000 frames in a single folder. But the problem with computing the optical flow is, when i call the particular Optical flow function after reading a 1000 frames using for loop, matlab gives an out of memory error.
But it works well well with 50 images at a time. But the resulting variable is about 400mb in size.
I cannot even concatenate two consecutive feature variables,workspace cannot even load 2 features at a time, i am in a hurry to compute optical flow for all the thousand gray scale images. But unluckily i cannot even compute it for 100 frames.
Is there any way to compute optical flow over 1000 frames with less space complexity in matlab?
Or whether i should use any other API?
The code i use for Computing Optical flow in matlab over 1000 frames is given below
for i = 1:1000 f1 = strcat('C:\Users\JoKeR\Desktop\input\masks\ucsd\ped1\train001\',num2str(i),'.png'); im1 = imread(f1); X(:,:,1)=im1; for j = i : 1000
f2 = strcat('C:\Users\JoKeR\Desktop\input\masks\ucsd\ped1\train001\',num2str(j),'.png');
im2 = imread(f2);
X(:,:,2)=im2;
[Vx Vy] = OpticalFlow(X,1,3);
tempX{i,j}=Vx;
tempY{i,j}=Vy;
end
end
for i = 1:1000 for j = 1:i-1
tempX{i,j}=tempX{j,i};
tempY{i,j}=tempY{j,i};
end
end
Is the loop correct? or something has to be dealt with the loop, if somebody could help with this optical flow computation it will be grateful
Thanks in advance

Answers (0)

Community Treasure Hunt

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

Start Hunting!