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.
saveas doesn't work with pcshow when running the background with parfeval?
1 view (last 30 days)
Show older comments
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!
Answers (1)
ag
on 24 Sep 2024
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!
0 Comments
See Also
Categories
Find more on Licensing on Cloud Platforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!