Forum

Poll

Is there any API can export matches? Or Is there any easier way to implement this ?

yes
0 (0%)
no
0 (0%)
unclear
1 (100%)

Total Members Voted: 1

Author Topic: exportMatches using Python Script API?  (Read 8763 times)

jason.liu

  • Newbie
  • *
  • Posts: 13
    • View Profile
exportMatches using Python Script API?
« on: November 16, 2015, 01:06:44 PM »
Hi,

Can we export feature matches using Python script API?

By feature matches I mean some feature point (x1,y1) on image 1 is matching (x2,y2) on image 2, like what's showing in Agisoft in the attached screenshot. The information is obviously stored somewhere in memory, but we just cannot find any means to extract it.

Thank you very much in advance.

Jason

jason.liu

  • Newbie
  • *
  • Posts: 13
    • View Profile
exportMatches using Python Script API?
« Reply #1 on: December 02, 2015, 04:45:11 AM »
Hi,

Is there any way to export matches (as orima format, for example) using Python Script API? I could not find an exportMatches function for a Chunk in the API doc.

Thanks very much in advance.

Regards
Jason

chaoer

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: exportMatches using Python Script API?
« Reply #2 on: February 29, 2016, 01:08:03 PM »
Hi, jason.liu.

I also stuck by this problem.
There is a menu in version1.1.6 that can export the matches.
But I cann't find a Python API.
Did you find a solution yet?

chaoer

  • Newbie
  • *
  • Posts: 11
    • View Profile
Export Matches
« Reply #3 on: February 29, 2016, 04:15:49 PM »
Hi there,

I find that thers is a menu in PS.(version greater than v1.1.0), which can export matches.
And I wonder is there any Python API to export matches(in patb format)?

I finished this work use script as follows:
(Note: this scirpt do not take the distortation into consiseration AND it just export to the PATB format!!!)
And I wonder is there any easier way to  export matches?

Code: [Select]
import PhotoScan
import os

print("Export Matches to PTAB...")

doc = PhotoScan.app.document
chunk = doc.chunk

point_cloud = chunk.point_cloud
point_proj = point_cloud.projections

#Opens save-to dialog box
path = PhotoScan.app.getExistingDirectory("Specify the output folder for PATB:")
filepath = path + "\\" + chunk.label + ".ptb"
print("Export to:\n{}".format(filepath))

fileMatches = open(filepath, "wt")

# loop on every camera of the image block
for i in range(0, len(chunk.cameras)):

photo1 = chunk.cameras[i]
if not photo1.transform:
continue

foc = int(photo1.photo.meta["Exif/FocalLength"]) * 1.0

cali1 = photo1.sensor.calibration
cx =  cali1.cx
cy =  cali1.cy
pixelsizeX = photo1.sensor.pixel_size[0]
pixelsizeY = photo1.sensor.pixel_size[1]

fileMatches.write(" " * 5 + photo1.label + "{:15.3f}".format(foc)  + "{:>10}".format(0) + "\n")

for matches in point_proj[photo1]:
key = matches.track_id
u = matches.coord[0]
v = matches.coord[1]

u = (u - cx) * pixelsizeX
v = (v - cy) * pixelsizeY
fileMatches.write("{:>15}".format(key) + "{:15.3f}".format(u) + " {:15.3f}".format(v)  + "{:>15}".format(0) + "\n")

fileMatches.write("{:>15}".format(-99) + "\n")

fileMatches.close()
print("Finished!")

Best Regards.
Chaoer.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15177
    • View Profile
Re: exportMatches using Python Script API?
« Reply #4 on: July 04, 2016, 05:18:32 PM »
Sorry for the late reply.

chunk.exportMatches() is already available in Python API.
Best regards,
Alexey Pasumansky,
Agisoft LLC

dcsa

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: exportMatches using Python Script API?
« Reply #5 on: August 16, 2017, 02:15:19 PM »
Hi,

Please, can you show me the script to export matches in an especific format (ORIMA)?

I don't know how to use parameter "format".
"chunk.exportMatches(matchesPath)" works for me, but i want to do something like: "chunk.exportMatches(matchesPath,format=PhotoScan.MatchesFormatORIMA,precision=4,export_points=True,export_markers=False,use_labels=True)", and it doesn't work...

Thank you for your time

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15177
    • View Profile
Re: exportMatches using Python Script API?
« Reply #6 on: August 16, 2017, 04:46:01 PM »
Hello delcampoana,

What happens when you run this code, does PhotoScan simply crash in the latest version?
Best regards,
Alexey Pasumansky,
Agisoft LLC

dcsa

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: exportMatches using Python Script API?
« Reply #7 on: August 16, 2017, 05:32:16 PM »
Yes it is

"chunk.exportMatches(matchesPath,format=MatchesFormatORIMA,precision=4,export_points=True,export_markers=False,use_labels=True)" ends with: NameError: name 'MatchesFormatORIMA' is not defined

"chunk.exportMatches(matchesPath,format=PhotoScan.MatchesFormatORIMA,precision=4,export_points=True,export_markers=False,use_labels=True)" ends with: Agisoft Crash Reporter
This is the beginning:
ARB_texture_non_power_of_two: Yes
ARB_vertex_buffer_object: Yes
OpenGLMaxTextureSize: 16384
OpenGLRenderer: GeForce GTX 960M/PCIe/SSE2
OpenGLStereo: No
OpenGLVendor: NVIDIA Corporation
OpenGLVersion: 4.5.0 NVIDIA 369.09
ProductName: PhotoScan Pro
System: Windows 64bit
SystemMemory: 15.9 GB
Throttleable: 1
URL:
Vendor: Agisoft
Version: 1.3.2.4205

With ...
Everything what i have test doesn't work for me

Thank you Alexey

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15177
    • View Profile
Re: exportMatches using Python Script API?
« Reply #8 on: August 23, 2017, 01:33:29 PM »
The issue with Python function exportMatches() will be fixed in the next version update.
Best regards,
Alexey Pasumansky,
Agisoft LLC

dcsa

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: exportMatches using Python Script API?
« Reply #9 on: August 23, 2017, 01:41:00 PM »
Thank you so much Alexey