Forum

Author Topic: Filtering Tie Points  (Read 6475 times)

claranine

  • Newbie
  • *
  • Posts: 14
    • View Profile
Filtering Tie Points
« on: August 09, 2016, 10:59:54 AM »
Hi all,
 
I'm looking for a way to programatically filter tie points prior to building a sparse/dense point cloud. I have looked through the Python API and I currently don't understand where tie points are stored once photos have been aligned.

Is there a way to identify tie points present in a photo and sort them by distance from centre of the image or colour of pixels under each point? Ideally I'd like to be able to programatically select tie points that are near the edges of a photo and call something like cropSelectedPoints() to remove them before resetting + re-aligning the photos, optimising cameras and generating the dense point cloud.

Thanks,

J

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14853
    • View Profile
Re: Filtering Tie Points
« Reply #1 on: August 09, 2016, 03:28:27 PM »
Hello claranine,

The following script removes (marks as invalid) all the tie points that are farther than 1500 pixels from the image center:

Code: [Select]
import PhotoScan

chunk = PhotoScan.app.document.chunk
point_cloud = chunk.point_cloud
projections = point_cloud.projections
points = point_cloud.points
npoints = len(points)
tracks = point_cloud.tracks

THRESHOLD = 1500

for camera in chunk.cameras:
center = PhotoScan.Vector([camera.sensor.width/2, camera.sensor.height/2])

point_index = 0
for proj in projections[camera]:
track_id = proj.track_id
if (proj.coord - center).norm() > THRESHOLD:
while point_index < npoints and points[point_index].track_id < track_id:
point_index += 1
if point_index < npoints and points[point_index].track_id == track_id:
if not points[point_index].valid:
continue

points[point_index].valid = False

print("Finished")
Best regards,
Alexey Pasumansky,
Agisoft LLC

claranine

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Filtering Tie Points
« Reply #2 on: August 10, 2016, 06:50:16 AM »
Hi Alexey,

Thanks for your reply, this is exactly what I was looking for however when I run the script the point index appears to go out of bounds and I get the error "can't run script - Index error: index out of range". I also don't see a reference to "proj" in the 1.2.5 Python API reference, is there an updated version somewhere?

A bit of context: the tie points I'm trying to filter out belong to the background which are causing PhotoScan to align photos incorrectly. I would like to filter these out and tell PhotoScan to consider the tie points closer to the centre of the image (where the object of the image is) before deciding which ones to use.

Could you tell me a bit about how PhotoScan determines which Tie Points to use? The script you gave me invalidates all tie points more than a specific distance from the center of the image which is great however when I do the inverse (set tie points inside 1500 pixels to valid), I notice that the tie points in the viewer are still gray (being unused?).

Thanks again,

J
« Last Edit: August 10, 2016, 06:58:22 AM by claranine »

MeHoo

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: Filtering Tie Points
« Reply #3 on: August 13, 2016, 07:07:05 PM »
I am unsure how all of this works, but this has me wondering.. do the tie points have a quality assigned to them like the estimating image quality does for images as a whole?  I'd love to be able to filter my blurrier sections of my photos based on a percentage of "better" to "worse" in each image.

ie: if I could take an image with say 500 tie points, build the range of quality between the min/max points and then say, deleted all that fail to meet at least 30% quality, I can see that being useful.

I am totally guessing here, and this might already exist.. Just happened across this post and that thought came to mind.

Yoann Courtois

  • Sr. Member
  • ****
  • Posts: 316
  • Engineer in Geodesy, Cartography and Surveying
    • View Profile
Re: Filtering Tie Points
« Reply #4 on: July 12, 2017, 07:31:47 PM »
Hi !

May somebody tell me what is the new (PhotoScan 1.3) python code to remove (set as invalid) a group of tie points which have been selected using a script.
In simple words, how to transcript "press delete on the keyboard" in a script  ::)

Thanks in advance !
Regards
--
Yoann COURTOIS
R&D Engineer in photogrammetric process and mobile application
Lyon, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14853
    • View Profile
Re: Filtering Tie Points
« Reply #5 on: July 12, 2017, 07:58:00 PM »
Hello Yoann,

It should be chunk.point_cloud.removeSelectedPoints()
Best regards,
Alexey Pasumansky,
Agisoft LLC

Yoann Courtois

  • Sr. Member
  • ****
  • Posts: 316
  • Engineer in Geodesy, Cartography and Surveying
    • View Profile
Re: Filtering Tie Points
« Reply #6 on: July 13, 2017, 10:18:57 AM »
It works well
Thanks a lot !
--
Yoann COURTOIS
R&D Engineer in photogrammetric process and mobile application
Lyon, FRANCE
--