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

3 vues (au cours des 30 derniers jours)
PietroMaggi
PietroMaggi le 16 Sep 2024
Réponse apportée : ag le 24 Sep 2024
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 commentaire
PietroMaggi
PietroMaggi le 16 Sep 2024
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.

Connectez-vous pour commenter.

Réponses (1)

ag
ag le 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!

Catégories

En savoir plus sur Licensing on Cloud Platforms dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by