NaturalIntelligence / imglab

To speedup and simplify image labeling/ annotation process with multiple supported formats.
https://solothought.com/imglab/
MIT License
988 stars 611 forks source link

Bug: Mouse coordinates are wrong when zoomed in/out #104

Closed amitguptagwl closed 6 years ago

amitguptagwl commented 6 years ago

About One of the contributors has discovered a bug in PR #95 which was raised to fix the issue #52. When a user zoom in/out the image, the function to get mouse coordinates return wrong value. Hence a feature point gets drawn on wrong position.

To Reproduce Steps to reproduce the behavior:

  1. Add a shape.
  2. Add a point
  3. Zoom In/out
  4. Add a new point

Screenshots imglab-zoom-biug

Console Errors No console error

Device detail All

Watch for changes, or Bookmark for easy discovery. Fund this project for new features and maintenance. [Showcase] your project with us by raising an issue

amitguptagwl commented 6 years ago

@Alvin-Voo in case if you wanna check.

alvinvoo commented 6 years ago

@amitguptagwl Alright let me look at it

amitguptagwl commented 6 years ago

Thanks

alextychan commented 6 years ago

I have found the cause of the bug and have fixed it in my local branch. Just waiting for my copy-paste functionality be approved before I push the fix.

The problem was caused when the zoom icon is pressed, the image size is scaled up, but the canvas svg still maintained the original image size.

The solution was to rescale the points to fit the image as if image scale never changed.

alvinvoo commented 6 years ago

@alextychan Alright thanks man. Let @amitguptagwl review your PR first, just let me know again if you guys need my help.

amitguptagwl commented 6 years ago

Thanks @alextychan and @Alvin-Voo .

amitguptagwl commented 6 years ago

@alextychan I hope you're taking care of it.

alextychan commented 6 years ago

I am currently looking into it. I found an interesting bug back when #52 was implemented. It's reproducible by following these steps:

1) Create a shape when the zoom is 100% 2) Zoom out -> 50% 3) Move the shape

Result: Shape proportion is distorted and the location of the shape is changed. Expected result: Shape should be proportionate to the image size and the location of the shape should not change.

I have been trying to find out what's the cause and I am burning my brain cells on this.

amitguptagwl commented 6 years ago

Oh. I even found that it is happening on all the zoom level. However I din't see any issue with size and shape but only with the position. Most probably both issues are related.

amitguptagwl commented 6 years ago
  1. if a shape is moved in same zoom level, then there is no issue.
  2. if a shape is created on 100% zoom then we move it on 90%, it takes distance and shape relevant 90%. Now if we zoom back to 100% it doesn't change the size and location
alvinvoo commented 6 years ago

Yes, I see it too. zoom -> move shape -> zoom again, the shape will jump. My guess is that something to do with wrong scaling, because after moving will have new positions. I am occupied with something now, but I could look at it maybe tomorrow or Saturday. Sorry guys.

alextychan commented 6 years ago

Solved and closed.