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

1 次查看(过去 30 天)
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 中查找有关 Licensing on Cloud Platforms 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by