Forum

Author Topic: Remove the marker with projection value less than 3 and error(pix)  (Read 1903 times)

ankit.chaurasia

  • Newbie
  • *
  • Posts: 8
    • View Profile
Hi

I am new to photoscan scripting. I had written the script to add markers from csv with #camera_label #marker_label  #px_x #px_y #world_x #world_y #altitude columns

Following is the code:
Code: [Select]
import csv
import PhotoScan

def read_marker(path_to_marker_file,chunk=None):
    marker_list = list(csv.DictReader(open(path_to_marker_file)))
    number_of_cameras = len(marker_list)
    j = 0
    while (j < number_of_cameras):
        title = list(marker_list[j].keys())
        camera_name = marker_list[j]["camera_label"]
        marker_name = marker_list[j]["marker_label"]
        x = float(marker_list[j]["px_x"])
        y = float(marker_list[j]["px_y"])
        cx = float(marker_list[j]["world_x"])
        cy = float(marker_list[j]["world_y"])
        cz = float(marker_list[j]["altitude"])
        photos_total = len(chunk.cameras)  # number of photos in chunk
        flag = 0

        for i in range(0, photos_total):
            if chunk.cameras[i].label == camera_name:
                for marker in chunk.markers:  # searching for the marker (comparing with all the marker labels in chunk)
                    if marker.label == marker_name:
                        marker.projections[chunk.cameras[i]] = (x, y)  # setting up marker projection of the correct photo)
                        flag = 1
                        break

                if not flag:
                    marker = chunk.addMarker()
                    marker.label = marker_name
                    marker.projections[chunk.cameras[i]] = (x, y)

                marker.reference.location = PhotoScan.Vector([cx, cy, cz])
                break

        chunk.updateTransform()
        j=j+1



if __name__=="__main__":
    doc = PhotoScan.app.document
    chunk = doc.chunk

    path = PhotoScan.app.getOpenFileName("Specify the path to the file:")
    read_marker(path,chunk)

So, I wanted to remove the markers in the image with projections less than 3 and error(pix) greater 0.5 by my script. If I do it manually, the processing time decreases drastically.

Please do help me with this scripting!