Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user change photo labels (and update Container.item_label) at the same time. #76

Open
HowcanoeWang opened this issue Feb 1, 2023 Discussed in #75 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@HowcanoeWang
Copy link
Member

Discussed in #75

Originally posted by youngdjn February 1, 2023
This is potentially a Python newbie issue -- apologies if so.

I am trying to change the labels of the photos (Photo.label) in my project, but this does not propagate to downstream places where I think the photo label is (should be?) used.

For example using this project, if I run:

import easyidp as idp
from pathlib import Path
msproj = Path("/path/to/project/example-multifolder.psx")
ms = idp.Metashape(msproj, chunk_id=0)
ms.photos[57].label

I get '100MEDIA-DJI_0165'

Then I attempt to rename them:

for i in range(len(ms.photos)):
    ms.photos[i].label = "newlabel" + str(i) 
ms.photos[57].label

and I get 'newlabel57'.

But then I run back projection

img_dict_ms = roi.back2raw(ms)
img_dict_ms

And the labels in the returned dict are the original ones:

{'1': {'100MEDIA-DJI_0165': array([[4741.6161679 ,  684.46603374],
         [4735.11907978,  712.14368673],
         [4718.00310275,  728.6865289 ],
         [4722.27333877,  728.17479155],
         ...

And also when running show_roi_on_img() it only works when I reference the photos by their original labels, like:

ms.show_roi_on_img(img_dict_ms, "1", "100MEDIA-DJI_0165")

and it doesn't work when I run:

ms.show_roi_on_img(img_dict_ms, "1", "newlabel57")

Can you suggest a way to fully change the labels?

The reason for this request is that I am trying to give the photos more meaningful labels so that I can more easily link the photo labels to the original photo files.

@HowcanoeWang HowcanoeWang added the enhancement New feature or request label Feb 1, 2023
@HowcanoeWang HowcanoeWang added this to the 2.0.0 milestone Feb 1, 2023
@HowcanoeWang HowcanoeWang self-assigned this Feb 1, 2023
@illrayy
Copy link

illrayy commented Feb 4, 2023

You are changing the "ms.photos.label". However, when using the roi.back2raw() function, the parameter passed is "ms.photos.item_label", which is a dictionary, different from "ms.photos.label"
So to change the labels correctly, you need to modify the "ms.photos.item_label", here's my practice

new_dic = {}
for i in range(len(ms.photos)):
new_key = "newlabel_" + str(i)
new_dic[new_key] = i
ms.photos.item_label = new_dic

Notes

  1. After using roi.back2raw(),modifications will be stored in the *.psx file, which is irreversible, so please make a backup of the *.psx file.
  2. I only modifed the "ms.photos.item_label", the "ms.photos.label", "ms.photos.label" hasn't changed. So you may need to re-read the *.psx file after saving it, or do what you did with "ms.photos.label" at the same time. But as I practice, it doesn't matter whether I do that or not.

@HowcanoeWang
Copy link
Member Author

You are changing the "ms.photos.label". However, when using the roi.back2raw() function, the parameter passed is "ms.photos.item_label", which is a dictionary, different from "ms.photos.label" So to change the labels correctly, you need to modify the "ms.photos.item_label", here's my practice

new_dic = {} for i in range(len(ms.photos)): new_key = "newlabel_" + str(i) new_dic[new_key] = i ms.photos.item_label = new_dic

Notes

  1. After using roi.back2raw(),modifications will be stored in the *.psx file, which is irreversible, so please make a backup of the *.psx file.
  2. I only modifed the "ms.photos.item_label", the "ms.photos.label", "ms.photos.label" hasn't changed. So you may need to re-read the *.psx file after saving it, or do what you did with "ms.photos.label" at the same time. But as I practice, it doesn't matter whether I do that or not.

Please refer to this comment: #75 (comment)

Actually, EasyIDP only reads the *.psx files and unable to change that file. You may need to rename the labels every time you load that project.

@HowcanoeWang HowcanoeWang modified the milestones: 2.0.0, 2.1.0, 2.0.1 May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

2 participants