Forum

Author Topic: Waving a white flag  (Read 3213 times)

mks_gis

  • Newbie
  • *
  • Posts: 43
    • View Profile
Waving a white flag
« on: June 08, 2022, 05:52:10 PM »
Hi,

 When adding markers, if a markers are placed you get an automatically aligned blue flag on the other images it appears on. They still need to be checked, but are often ok, making the process less manually intensive.

 When loading a GCP file and placing a marker the flags never turn blue, they are white, and not used in processing. You need to click on every white flag to turn it green. Now, you can add points, rename them to match your markers, and then load the coordinates later, but that's cumbersome. Is there a way to turn the white flags blue, mirroring the add points workflow? I ask this before I spend time coding some python to turn flags green.

Cheers
M.

JMR

  • Hero Member
  • *****
  • Posts: 504
    • View Profile
Re: Waving a white flag
« Reply #1 on: June 08, 2022, 09:38:55 PM »
I'm not sure I'm understanding you well. I guess you are not fully understanding the different methods to add a control point to the chunk. Place marker vs add marker. Also I wonder if you know that naming markers the same as the gcps in the file is not as critical as it may appear.
Of course there is no need for coding for turning white flags into green, and even if it was doable, I guess it would be hardly acceptable. Green flags are marker projections placed by the user on a given pixel location very consciously, nothing to be automated.
Blue flags are projections placed by the software based on previous user input that have same value for calculations as green ones, (all blue flags need to be inspected by the user if only one is found to be off its expected location in some instance), and white flags are projections suggested by the software by projecting a ray from the 3d point location to the camera center, they play no role in calculations.

José Martínez
Geobit & Accupixel
Metashape traning

mks_gis

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Waving a white flag
« Reply #2 on: June 09, 2022, 12:41:49 PM »
Thanks for the response

To clarify, green marker=user placed, blue marker=system placed, both used in processing, white marker=system placed but not used in processing, that's understood. I also understand I need to check all blue flags, as mentioned in the OP.

Correct me if I'm wrong, Add Marker adds a marker and works out the projections on the other images, Place marker adds it in 2D on that image only.

Not sure what you mean about the names not being important, please clarify. I need to match the names to update the coordinates from the GCP file. (That's a minor issue, as you can edit the GCP csv to match the labels, i.e. "point 1".)

At the moment you have two workflows as I see it, and my question is if they can be merged, as both are cumbersome in their own way.

WF1 - using add markers: Add marker by right clicking on each marker once, move a few blue flags, check the others and leave them if good enough. Then load GCP file with matching names to update the coordinates of the markers to the GCP. Issues are that you need to find each GCP, not always easy on e.g. glacial rubble.

WF2 - using a GCP file: Load GCP file, some white flags pop up, if you fix about 4 in place and Update Transform all other GCP are roughly located, which is better in terms of finding them. After manually updating a couple of markers each the others show up in the right place, but need to be clicked on to turn green. With several markers on several images each that's a lot of clicking.

So my question is, can you use the gcp workflow and get blue flags, best of both worlds.

This is not a big issue, but I'm trying to find the most efficient way of marking GCP, just tired of clicking markers, either way.



Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14943
    • View Profile
Re: Waving a white flag
« Reply #3 on: June 09, 2022, 06:39:57 PM »
Hello Martin,

The following code should create marker projections (blue flags) on the images, based on the marker 3D location, which can be defined either by the reference coordinates only, or by other manually placed projections:

Code: [Select]
import Metashape
chunk = Metashape.app.document.chunk #active chunk
for marker in chunk.markers:
if not marker.position:
continue
point = marker.position
for camera in [c for c in chunk.cameras if c.transform and c.type == Metashape.Camera.Type.Regular]:
if camera in marker.projections.keys():
continue #skip existing projections              
x, y = camera.project(point)
if not(x) or not(y):
continue
if (0 <= x < camera.sensor.width) and (0 <= y < camera.sensor.height):
marker.projections[camera] = Metashape.Marker.Projection(Metashape.Vector([x,y]), False)
print("Script finished")

Is it what you are looking for?

« Last Edit: June 09, 2022, 06:55:23 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

JMR

  • Hero Member
  • *****
  • Posts: 504
    • View Profile
Re: Waving a white flag
« Reply #4 on: June 09, 2022, 09:19:57 PM »
Quote
Not sure what you mean about the names not being important, please clarify. I need to match the names to update the coordinates from the GCP file. (That's a minor issue, as you can edit the GCP csv to match the labels, i.e. "point 1".)
In the import reference dialogue there is a checkbox that "ignore labels", try it and you will understand. Metashape manages to match markers and ground points on its own (obviously it can fail if points distribution is too much regular making several matches plausible)
Also you may need to see if by enabling "refine markers" under tools menu, you get the boost you want for your workflow. (also needs some user care, that is why it is not enabled by default)
Best regards,

José Martínez
Geobit & Accupixel
Metashape traning
« Last Edit: June 10, 2022, 12:02:55 PM by JMR »

DayGeckoArt

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: Waving a white flag
« Reply #5 on: June 10, 2022, 11:00:04 AM »
GCPs do turn blue if the program is confident about their locations. You may have to place quite a few before some start turning blue

mks_gis

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Waving a white flag
« Reply #6 on: June 10, 2022, 12:55:52 PM »
Exactly what I was looking for, thanks Alexey

Hello Martin,

The following code should create marker projections (blue flags) on the images, based on the marker 3D location, which can be defined either by the reference coordinates only, or by other manually placed projections:

Code: [Select]
import Metashape
chunk = Metashape.app.document.chunk #active chunk
for marker in chunk.markers:
if not marker.position:
continue
point = marker.position
for camera in [c for c in chunk.cameras if c.transform and c.type == Metashape.Camera.Type.Regular]:
if camera in marker.projections.keys():
continue #skip existing projections              
x, y = camera.project(point)
if not(x) or not(y):
continue
if (0 <= x < camera.sensor.width) and (0 <= y < camera.sensor.height):
marker.projections[camera] = Metashape.Marker.Projection(Metashape.Vector([x,y]), False)
print("Script finished")

Is it what you are looking for?

mks_gis

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Waving a white flag
« Reply #7 on: June 10, 2022, 01:20:45 PM »
Refine markers does indeed work for this workflow, white flags turn blue as an image is loaded after the initial points are manually defined, thanks.

Quote
Not sure what you mean about the names not being important, please clarify. I need to match the names to update the coordinates from the GCP file. (That's a minor issue, as you can edit the GCP csv to match the labels, i.e. "point 1".)
In the import reference dialogue there is a checkbox that "ignore labels", try it and you will understand. Metashape manages to match markers and ground points on its own (obviously it can fail if points distribution is too much regular making several matches plausible)
Also you may need to see if by enabling "refine markers" under tools menu, you get the boost you want for your workflow. (also needs some user care, that is why it is not enabled by default)
Best regards,

José Martínez
Geobit & Accupixel
Metashape traning