Need help to resolve error related to physical memory
조회 수: 5 (최근 30일)
이전 댓글 표시
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
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
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);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!