Forum

Author Topic: Import OPK from ASCII file and convert them to YPR  (Read 10170 times)

adams

  • Newbie
  • *
  • Posts: 1
    • View Profile
Import OPK from ASCII file and convert them to YPR
« on: September 19, 2016, 02:40:12 PM »
Hello,

Is it possible to import OPK from ASCII file, and then convert them to Yaw,Pitch, Roll   using script below:

Code: [Select]
#to convert opk into ypr
yaw, pitch, roll = PhotoScan.utils.mat2ypr(PhotoScan.utils.opk2mat(PhotoScan.Vector((omega, phi, kappa))).t())

I have no idea how to import OPK from ASCII file (ID, X, Y, Z, omega, phi kappa) without numpy...

I count on your support



Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15086
    • View Profile
Re: Import OPK from ASCII file and convert them to YPR
« Reply #1 on: September 19, 2016, 05:46:27 PM »
Hello adams,

You can use the following function Python function from the Console pane to load the reference data using OPK data:
PhotoScan.app.document.chunk.importCameras(path = "d:/file.txt", format = "opk")
Best regards,
Alexey Pasumansky,
Agisoft LLC

Juilson

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Import OPK from ASCII file and convert them to YPR
« Reply #2 on: October 17, 2016, 04:20:59 PM »
Hi!

I'm trying to "reread" an OPK file generated from Photoscan in order to refine my matches.
I have though no clue how to call the function mentioned above. Could you please give us some more detail on it?

Best regads
Juilson

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15086
    • View Profile
Re: Import OPK from ASCII file and convert them to YPR
« Reply #3 on: October 17, 2016, 05:57:17 PM »
Hello Juilson,

At the moment, .importCameras() Python API function assumes that each line contains the following information in the same order:
Code: [Select]
camera_label x-coord y-coord z-coord omega phi kappaPhotoScan cameras export in OPK format also generates rotation matrix elements that need to be removed.
Best regards,
Alexey Pasumansky,
Agisoft LLC

PK_2509

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Import OPK from ASCII file and convert them to YPR
« Reply #4 on: November 02, 2016, 08:49:21 PM »
Hello Alexey,

I have an additional question.

My ASCII file has the format you provided. When I import the file from the Console pane, I don´t get an error.
I have tested to import a xml file and it works perfect.

Also I don´t found the format "opk" for importCameras in the Python API.

What am I doing wrong?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15086
    • View Profile
Re: Import OPK from ASCII file and convert them to YPR
« Reply #5 on: November 04, 2016, 06:18:41 PM »
Hello PK_2509,

Do the camera labels in the active chunk correspond to the camera names in opk text file? Please check that in the project the extension is the same in the camera labels (*.tiff).
Best regards,
Alexey Pasumansky,
Agisoft LLC

PK_2509

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Import OPK from ASCII file and convert them to YPR
« Reply #6 on: November 04, 2016, 08:07:07 PM »
Hello Alexey,

yes the camera labels in the active chunk correspond to the camera names in opk text file.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15086
    • View Profile
Re: Import OPK from ASCII file and convert them to YPR
« Reply #7 on: November 05, 2016, 07:50:44 PM »
Hello PK_2509,

You need to use "space" delimiter, as it seems that you have "tab" in your input file.
Best regards,
Alexey Pasumansky,
Agisoft LLC

PK_2509

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Import OPK from ASCII file and convert them to YPR
« Reply #8 on: November 07, 2016, 06:46:23 PM »
Hello Alexey,

thank you for your advise. Everthing works perfect now.

Best regards

lfreguete

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Import OPK from ASCII file and convert them to YPR
« Reply #9 on: June 24, 2021, 11:06:54 PM »
Good afternoon, Mr. Pasumansky.
I was able to run this function, but when I try to check what are the current camera rotation values, the values are the same of before.
If in my Reference Panel I have values of pitch,Yas and roll and try to import the opk file, after running the camera.reference.rotation, the variables are still in YPR.

How can I convert my opk to the YPR?

Hello adams,

You can use the following function Python function from the Console pane to load the reference data using OPK data:
PhotoScan.app.document.chunk.importCameras(path = "d:/file.txt", format = "opk")

lfreguete

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Import OPK from ASCII file and convert them to YPR
« Reply #10 on: June 25, 2021, 08:15:02 PM »
I would like to add that the imported camera coordinates are in a specific crs. Does importCamera take that in consideration?
« Last Edit: June 26, 2021, 01:31:05 AM by lfreguete »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15086
    • View Profile
Re: Import OPK from ASCII file and convert them to YPR
« Reply #11 on: July 01, 2021, 12:52:19 AM »
Hello lfreguete,

Can you please show a few lines related to the camera data being imported in the format that you are trying to use on input?

To switch the angle convention used (without re-calculation applied):
Code: [Select]
chunk.euler_angles = Metashape.EulerAngles.EulerAnglesOPK
Best regards,
Alexey Pasumansky,
Agisoft LLC