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

Save x,y coordinates of the landmarks #5

Closed
jankaWIS opened this issue Apr 27, 2021 · 8 comments
Closed

Save x,y coordinates of the landmarks #5

jankaWIS opened this issue Apr 27, 2021 · 8 comments

Comments

@jankaWIS
Copy link

Hi, first of all, it's an amazing project of yours. I was reading your documentation and you write there that the user should be also able to upload the (x,y) coordinates of the landmark points. I have not found the option in your GUI. Is it already implemented? And more importantly, would it be possible to add a button for exporting the points into a txt file?
Thanks a lot.

@ddowd97
Copy link
Owner

ddowd97 commented Apr 27, 2021

Hello, thanks for your interest in this project!

the user should be also able to upload the (x,y) coordinates of the landmark points. I have not found the option in your GUI. Is it already implemented?

When you download this repository, it comes with an Images_Points folder that will store whatever this program works with (if this folder gets deleted or moved, it is remade on startup). Currently, if you want to upload a points list, it must be done manually by placing a correctly named text file into Images_Points. Below is an example of an image and it's corresponding text file (with points):

Dog1.jpg
Dog1-jpg.txt

There is no way of doing this with the GUI currently, but since I have been slowly working on a larger update for the project, I may consider adding that to the list of things to do.

would it be possible to add a button for exporting the points into a txt file?

PIM automatically creates and updates text files in Images_Points as points are placed on images in the GUI, so unless I am misunderstanding what you mean, there is no need for a button like this. :)

@jankaWIS
Copy link
Author

Hi @ddowd97, thanks a lot for your answer. I somehow missed this folder :). No, you didn't miss anything, it was exactly about getting the points out and back in, if the only thing needed is to have them in the directory and get them from there, then it's perfect. I understood that you have to manually locate the files which you want to add.

@jankaWIS
Copy link
Author

Hi @ddowd97 once again, I have now checked it out and I have some issues with it. When you say correctly named, it does not mean (at least in my case) that the name is the same as the picture name. When I tried putting the dog picture together with the txt file into the Image_Points, it did not recognised it. I had to manually rename the file to janka-jpg.txt which was the name when I started clicking randomly. It always puts janka followed by the ending. It never takes the image name, is it a bug?

Then I have another question. If I put two images and marked the points, only one coordinates were saved, ie. only one file was created. My feeling is that it's because of the aforementioned issue, ie. that both are created but one is being overwritten by the other since they have the same name (since the name of the image does not matter and they're the same, ie. png or jpg). Is it the case? If not, how can I load/add/export them separately?
Thanks.

@jankaWIS jankaWIS reopened this Apr 29, 2021
@ddowd97
Copy link
Owner

ddowd97 commented Apr 29, 2021

Hello again!

Regarding your first point:

When PIM creates text files for your images, it will always use the format [filename]-[extension].txt to play nicely with images that share the same filename but have different extensions. This is why Dog1.jpg is paired with Dog1-jpg.txt, for example.
If I understand what you're saying, you are:

  1. Placing "Dog1.jpg" and "Dog1-jpg.txt" into Images_Points
  2. Starting PIM
  3. Loading "Dog1.jpg"
  4. Observing that there are no points on the image
  5. Observing that a new text file named "janka-jpg.txt" has been created in Images_Points
  6. Observing that any placed points inside "Dog1.jpg" are written to "janka-jpg.txt" instead of "Dog1-jpg.txt"

If this is the case, then yes, this is unexpected behavior. Would I be wrong in assuming that your machine is named "janka" since that is a part of your GitHub username? If so, what is the OS that you are running PIM on? I have not been able to test this program on Mac/Linux for any incompatibilities or unexpected file behavior, so there may be an issue with the following line:

self.startingImageName = re.search('(?<=[/])[^/]+(?=[.])', self.startingImagePath).group()

Regarding your second point:

If you are loading two separate image sources (e.g. Dog1.jpg and Dog2.jpg), then again yes, this is unexpected behavior for what appears to be the same reason as the aforementioned issue.

I will have to look more into this later today - thank you for bringing this issue to my attention.
Can you provide me with the full filepath you are using so that I can test this on my end?
Example: C:\Users\xzomb\PycharmProjects\Personal\Morphing\Morphing\Images_Points

@ddowd97
Copy link
Owner

ddowd97 commented Apr 30, 2021

Following up.

When this project began in early 2019 - when I was first learning Python - I wrote my own regex implementation for catching file names since I didn't know much about the os library. After two years, I believe you have identified an issue with this implemention where, if a file path contains a period before the filename, the regex will trip earlier than intended.

Example:
/Users/janka.test/etc/PIM/Images_Points/Test.jpg → the file name becomes janka instead of Test

I have created a hotfixed release to hopefully correct this issue - you can find that release here. My development branch is messy right now so I can't deploy these changes to the repository, but this hotfix will be included in the next feature update and onwards.

Please let me know if I hit the nail on the head with this analysis and the program works as intended for you.
If not, then as I said before, please provide me details regarding the OS you are using as well as the full file path in use. :)

@jankaWIS
Copy link
Author

Yes, indeed you did (or at least I think so). This was on my computer at work and for some reason, we have there a folder named name.domain and yes, the name there is janka :) (not a coincidence). So I guess what happens is exactly what you describe. I have also Mac and Linux if you'd want to test it there, I can do that. But I think that you hit the nail on the head precisely.

I will have a look, hopefully later today, and let you know.

@jankaWIS
Copy link
Author

jankaWIS commented May 2, 2021

I have another issue, I guess very related, this time on Mac. If I load images on Mac, the corresponding files with coordinates which are created are called Images_Points\image-png.txt and the folder Images_Points is not being created. My guess is / and \ in the path. Because if I have a file called Images_Points\image-png.txt, the marks are being loaded. So to sum up -- the folder is not created and probably naming issues with \ and /.

@ddowd97
Copy link
Owner

ddowd97 commented May 2, 2021

And here I thought I had a working project! ;)
I have created another hotfixed release here. You are correct in that this bug is due to how operating systems handle directories (I believe Windows may be unique in using the backslash). Although I do not have access to Mac/Linux on a VM currently, I believe this fix will do the trick. Thanks for the bug report, and again, please let me know if you encounter any other issues.

@jankaWIS jankaWIS closed this as completed May 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants