saveas doesn't work with pcshow when running the background with parfeval?

조회 수: 5 (최근 30일)
PietroMaggi
PietroMaggi 2024년 9월 16일
답변: ag 2024년 9월 24일
I'm looking to save point cloud images to a file in the background using the parfeval method of parallel operations, a representative example below:
for i = 1:5
p = parfeval(@saveFig, 0);
wait(p);
rgbImage = imread("MyPointCloud.png");
imshow(rgbImage)
end
function saveFig()
saveas(pcshow(rand(1000, 3)), "MyPointCloud.png");
end
Running the above script results in a File "MyPointCloud.png" does not exist error. However, if I run this same code by calling the function directly instead of using parfeval it works fine. Additionally, this parfeval method works if I use a simple "plot" function instead of pcshow, as shown here:
function saveFig()
saveas(plot(rand(100, 1)), "MyPointCloud.png");
end
What is it about pcshow that it isn't able to be saved in the background? Are there any workarounds? Thanks!
  댓글 수: 1
PietroMaggi
PietroMaggi 2024년 9월 16일
fwiw, obviously the above example doesn't make good use of paralellization; in my actual code, there are other operations running in place of "wait(p)", and waiting for the figure the generate and save on the main thread takes too much time.

댓글을 달려면 로그인하십시오.

답변 (1개)

ag
ag 2024년 9월 24일
Dear PietroMaggi,
I understand that you are encountering the error message: "File 'MyPointCloud.png' does not exist" while running the provided script. It seems this issue is related to the "imread" function rather than "parfeval."
To resolve this, please ensure that the "MyPointCloud.png" image file is located in the same directory as the script. Once confirmed, try running the script again.
Alternatively, you can add the folder containing "MyPointCloud.png" to the search path. To do this, navigate to the folder in MATLAB, right-click, and select "Add to Path" -> "Selected Folders and Subfolders."
Hope this helps!

카테고리

Help CenterFile Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by