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

Fix lots of georeferencer issues #47141

Merged
merged 35 commits into from
Feb 9, 2022
Merged

Conversation

nyalldawson
Copy link
Collaborator

Before trying to fix the mess that has gotten into, we need a good test suite...!

@roya0045
Copy link
Contributor

roya0045 commented Feb 2, 2022

Unsure if this can be helpful but there were some exchanges on #46415

The renaming of things is welcome.

@nyalldawson nyalldawson changed the title Start on test suite for georeferencer Fix lots of georeferencer issues Feb 3, 2022
@nyalldawson nyalldawson added backport release-3_22 Regression Something which used to work, but doesn't anymore labels Feb 3, 2022
@nyalldawson
Copy link
Collaborator Author

@roya0045 @gioman I'd love testing of this branch and confirmation that you don't see any remaining issues (aside from those described in #46941)

The size of these changes makes me nervous, but at the same time the georeferencer is quite broken in master/3.22 so we don't have any choice but to merge and backport and hope that we can test sufficiently prior to release...!

@gioman
Copy link
Contributor

gioman commented Feb 3, 2022

@nyalldawson I tested the windows artifact. The georef operation seems to get stuck (progress bar moves, but like 1% every 5 minutes) and GCP points are a no show in georef map window:

image

I'm using the data and configs from here #46901 (comment)

A few days back I tested the artifact for a now closed patch #46524 (comment) and worked ok (even if I understand that was not the right fix).

@gioman
Copy link
Contributor

gioman commented Feb 3, 2022

@nyalldawson GCP did show up when I double clicked somwhere in the GCP table, but that made the image to georef disappear

image

@nyalldawson
Copy link
Collaborator Author

@gioman I suspect the points file there is invalid, and has map coordinates for the raster instead of pixels. Creation of the gcp file is fixed here, but I'm not sure we can "auto repair" invalid ones...

@gioman
Copy link
Contributor

gioman commented Feb 3, 2022

@nyalldawson ok, I'll try with another dataset.

@nyalldawson
Copy link
Collaborator Author

@gioman

It's always possible that I've made the wrong choice here, and that we should be storing the source coordinates instead of pixels in the gcp file! I'm not sure what the original intention was, but we always interpret these values as pixels and the heading states "pixelX" so that's why I went that way.

But maybe the heading is what's wrong... 😳

Thinking about a future time when we support vector file georeferencing, it no longer would make sense to use pixels here.

So in short... I'm 50/50, and would value any insights anyone has!

@gioman
Copy link
Contributor

gioman commented Feb 3, 2022

@nyalldawson tested again from scratch. The operation seems to work ok. Anyway I have a few observations I will leave here. As a start;

I georeferenced a jpg using a project that had CRS 3763 and picking the GCP on the canvas. In georef configs I choose 3763 as target CRS. The output is added to QGIS with "unknown" CRS (but in the right place).

@gioman
Copy link
Contributor

gioman commented Feb 3, 2022

@nyalldawson tested again from scratch. The operation seems to work ok. Anyway I have a few observations I will leave here. As a start;

I georeferenced a jpg using a project that had CRS 3763 and picking the GCP on the canvas. In georef configs I choose 3763 as target CRS. The output is added to QGIS with "unknown" CRS (but in the right place)

@nyalldawson after all this seems to be the only outstanding issue. I tried also to georef to WGS84 and the resulting layer shows with "invalid" projection.

@roya0045
Copy link
Contributor

roya0045 commented Feb 3, 2022

@gioman

It's always possible that I've made the wrong choice here, and that we should be storing the source coordinates instead of pixels in the gcp file! I'm not sure what the original intention was, but we always interpret these values as pixels and the heading states "pixelX" so that's why I went that way.

But maybe the heading is what's wrong... 😳

Thinking about a future time when we support vector file georeferencing, it no longer would make sense to use pixels here.

So in short... I'm 50/50, and would value any insights anyone has!

IMO the coordinates should be the good things to store, as ungeoreferenced images also have their own 'coordinates' and the pixel values are quite specific to a file, but the intent is to move one point to another and from one projection to another. The pixels are just where the point is for a given raster. I could see uses where there is a single gcp files to georeference multiple images, even if the points are out of the image the transformation should still be usable. IE if you have a lot of overlapping images, do a few generic points and then use the same gcps to georeference everything (if they are already georeferenced, from a non-referenced state this wouldn't work).

But as long as it works fine I don't mind it. But I agree that the requirement of this requires juggling with a lot of 'domains' which can be confusing (raster pixels, pts crs, origin, destinations, destination crs, etc.)

@roya0045
Copy link
Contributor

roya0045 commented Feb 3, 2022

@gioman Thanks for testing! I wouldn't have much time at work or out of it to test it in depth as you did, even with a few days of delay.

@nyalldawson
Copy link
Collaborator Author

@roya0045

IMO the coordinates should be the good things to store

I think I'm leaning that way too (especially given the future vector consideration).

If we go that we we'll definitely need to fix the headers of the .points files though, as they are misleading right now. I'll see what's involved in making this switch tomorrow (and will also re-test with the raster/points from that ticket as a result)

@roya0045
Copy link
Contributor

roya0045 commented Feb 3, 2022

@roya0045

IMO the coordinates should be the good things to store

I think I'm leaning that way too (especially given the future vector consideration).

If we go that we we'll definitely need to fix the headers of the .points files though, as they are misleading right now. I'll see what's involved in making this switch tomorrow (and will also re-test with the raster/points from that ticket as a result)

👍 Sure, let me know if I can be of assistance, though it might not be too timely.

@nyalldawson
Copy link
Collaborator Author

@gioman @roya0045

I've re-worked this so that we ALWAYS use source coordinates when saving/loading gcp points files. This fixes the issue described in #46901 (that file works without issue now).

I'd love some more testing of this branch before we merge, if you've time!

(Also added a bunch of extra paper cut fixes to this branch, tests, cleaner code, ...)

@roya0045
Copy link
Contributor

roya0045 commented Feb 8, 2022

I'll try to do some tests later today, thanks for doing this!

@gioman
Copy link
Contributor

gioman commented Feb 8, 2022

@nyalldawson I see weird things.

First case, canvas is in 3857, georef configured to 3763. The destination Y parameter shows with no decimals, double clicking on its cell a lot more show up (but really, on a projected CRS how many are used?), then when moving the focus the value change to one expressed in scientific notation

Recording.6.mp4

When canvas is in 4326, georef configured to 3763, the dest x/y values are in a projected crs(?), then if clicking in a cell of the gcp table values change to geographic, but only for dest x.

Recording.7.mp4

@roya0045
Copy link
Contributor

roya0045 commented Feb 8, 2022

First case, canvas is in 3857, georef configured to 3763. The destination Y parameter shows with no decimals, double clicking on its cell a lot more show up (but really, on a projected CRS how many are used?), then when moving the focus the value change to one expressed in scientific notation

I think this is out of scope for the fix, the table should still use the default Qt number formatting. What matters is if the numbers are good.

Here is what I was expecting to test when I had the time:

  • Mixing projected and geographic coords in the input pts
  • Moving points on the canvas (with the same or a different origin crs)
  • georefercing an already georeferenced image
  • Change the destination crs to validate reprojection
  • (Maybe ) load a gcp file

@gioman
Copy link
Contributor

gioman commented Feb 8, 2022

I think this is out of scope for the fix

maybe, but is totally confusing,

raster file name for these and not the output raster file name

The GCPs relate specifically to the ORIGINAL image, not the warped
output exported after georeferencing. If we use the output file
name for the .points file then when THIS georeferenced output is
loaded into the georeferencer we get misleading location of
source GCP points, as the pixel coordinates are from the ORIGINAL
image, not the warped one.
from class which stores graphical item representing point
This is too fragile, there's too many different situations which
should lead us to invalidate the cached point which are not
being caught.
points instead of always using source pixel row/columns

The "always use pixels" approach does not work well when a source
image already has some georeferencing information attached.

Also add tests for this, and fix loading of "enabled" status for
points when loading points from a file
enabled

And partially fix this functionality when using an already
georeferenced image (not fully)
@roya0045
Copy link
Contributor

roya0045 commented Feb 9, 2022

@nyalldawson Did my tests, everything seemed ok, even with a projected dataset.

@nyalldawson
Copy link
Collaborator Author

Thanks @roya0045 !

@gioman

I see weird things.

These aren't directly impacted by the changes in this PR, but should be fixed by #46941
I'd suggest we get this part merged first and then #46941 can be reworked on top of master to fix those issues, with appropriate tests added to suit...

@roya0045
Copy link
Contributor

roya0045 commented Feb 9, 2022

I'm curious to see how much rework will be needed in 46941 & #41386 🤣

Nyall I know you had interest in 41386, let me do the cleanup and you can take over after if you want, no use in having you do some work I could be doing (albeit slower) during the freeze. Other than reworking the dwg importer I didn't find any easy bugs I could fix quickly and willingly at the moment, so I wouldn't mind updating my things in my free-time.

@nyalldawson nyalldawson merged commit c5ca66d into qgis:master Feb 9, 2022
@nyalldawson nyalldawson deleted the georef_test branch February 9, 2022 19:26
@nyalldawson
Copy link
Collaborator Author

Merged for wider testing

@nyalldawson
Copy link
Collaborator Author

@gioman

I see weird things.

These should all be fixed by #47279

@gioman
Copy link
Contributor

gioman commented Feb 10, 2022

These should all be fixed by #47279

@nyalldawson confirmed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants