フィルターのクリア

Need help to resolve error related to physical memory

11 ビュー (過去 30 日間)
Raushan
Raushan 2023 年 5 月 30 日
コメント済み: Walter Roberson 2023 年 5 月 31 日
Hello guys,
Hope you all are doing great. I am facing an error when I run the following code in Matlab. There is only one drive on my computer "c" and there is enough memory (more than 300gb) in it. Earlier matlab was not giving this error, but I don't understand why it is giving this error now.
Can anyone please help me to resolve this error. I would be thankful to you.
Here are my script
outdir = 'C:\Users\newfolder';
outprefix1 = "pic1_"; %string, not character vector!
img_suffix = ".tiff";
vid1 = videoinput('gentl', 1, 'Mono8');
src1 = getselectedsource(vid1);
vid1.FramesPerTrigger = 10;
vid1.ROIPosition = [2462 1092 415 1553];
vidlist = [vid1];
start(vidlist);
filename = 'C:\usuarios\abc_Graphs.xls';
framecount = 0;
counter=0;
while true
framecount = 1 + framecount ;
counter = counter +1;
pause(1800); %After every 900sec
img=getdata(vid1);
for i = 1:10
outname1 = fullfile(outdir, outprefix1 + counter + "_" + i + img_suffix);
imwrite(img(:,:,:,i), outname1);
end
start(vidlist);
if isfile(filename)
break
end
end
stop(vidlist);
Also, here are the error that I got while running this script
>> tencontinuousshot_code
Warning: The ROIPosition property was modified by the device.
Error event occurred at 14:14:34 for video input object: Mono8-gentl-1.
Unable to allocate memory for an incoming image frame due to insufficient free physical memory.
Unable to allocate memory for an incoming image frame due to insufficient free physical memory.
Error in tencontinuousshot_code (line 18)
pause(1800); %After every 900se
  4 件のコメント
Raushan
Raushan 2023 年 5 月 30 日
Hello
can anyone of you please give some suggestion to resolve the above error without upgrading the RAM. Is it possible to use the drive space while saving the images. I am saving the images on Desktop and I have only one drive "c" on my computer having 300 gb Free space.
I looked at some online siurces too it seems people use following line of ciode to resolve it, but I am having one doubt if I use the below lines of code in my script then whether I will lost the image every time when it capture or it will be saved in my computer.
imaqmex('feature','-limitPhysicalMemoryUsage',false);
flushdata(vid1);
Please help me to clear this.
Thank you
Walter Roberson
Walter Roberson 2023 年 5 月 31 日
Do the imaqmex('feature','-limitPhysicalMemoryUsage',false); once at the beginning, not within the loop.
I would suggest that you consider using backgroundPool or (if necessary) parpool and parfeval or parfeval . You would read the data in the main worker, and use parfeval() to queue writing to the disk. You might not gain any peformance past 3-ish simultaneous writers to the same drive, but it is typically possible to improve performance by spreading the work out to drives that are on different controllers.

サインインしてコメントする。

回答 (1 件)

Diwakar Diwakar
Diwakar Diwakar 2023 年 5 月 30 日
This code seems to be capturing video frames using a video input device and saving them as individual images.
The error message shows that your system does not have enough free physical memory to allocate for incoming image frames. This could be due to various reasons, such as running multiple memory-intensive processes or having limited RAM. To resolve this issue, you can try closing other applications or processes consuming a significant amount of memory to free up resources.
and your code:
outdir = 'C:\Users\newfolder';
outprefix1 = "pic1_"; % string, not character vector!
img_suffix = ".tiff";
vid1 = videoinput('gentl', 1, 'Mono8');
src1 = getselectedsource(vid1);
vid1.FramesPerTrigger = 10;
vid1.ROIPosition = [2462 1092 415 1553];
vidlist = [vid1];
start(vidlist);
filename = 'C:\usuarios\abc_Graphs.xls';
framecount = 0;
counter = 0;
while true
framecount = framecount + 1;
counter = counter + 1;
pause(1800); % After every 900 sec
img = getdata(vid1);
for i = 1:10
outname1 = fullfile(outdir, outprefix1 + string(counter) + "_" + string(i) + img_suffix);
imwrite(img(:, :, :, i), outname1);
end
start(vidlist);
if isfile(filename)
break;
end
end
stop(vidlist);

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by