Forum

Author Topic: Issues with importing bundler.out alignment  (Read 20093 times)

badger

  • Newbie
  • *
  • Posts: 20
    • View Profile
Issues with importing bundler.out alignment
« on: December 12, 2016, 04:01:08 PM »
Hello,

I'm trying to import scene and mesh from RealityCapture, to take advantage of the great texturing capabilities of Photoscan. The scene is exported from RC in bundler format but when importing in Photoscan, the mesh is translated on the z axis with respect to the cameras (see attached screenshot).

I imported the same mesh and the same bundler.out with meshlab and the alignment shows correct there, therefore it is not a problem on the export side, but Photoscan is rendering a translated mesh, or translated camera positions.

Any suggestion how this could be fixed on my side, or any hope to get a patch for this ?

thank you in advance

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15168
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #1 on: December 12, 2016, 04:06:15 PM »
Hello badger,

If you can send the bundler file, PhotoScan project in PSZ format (I assume only added camera instances will be sufficient) and mesh file to be imported to support@agisoft.com, we'll check that.
Best regards,
Alexey Pasumansky,
Agisoft LLC

badger

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #2 on: December 12, 2016, 04:33:43 PM »
thank you. I'll sent everything via WeTransfer.

Do you also need the photographs ?

badger

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #3 on: December 12, 2016, 04:41:00 PM »
by eyeballing the alignment it looks a bit offset also along the X and Y axes. Not as much as the Z axis.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15168
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #4 on: December 12, 2016, 04:46:10 PM »
Hello badger,

The images are not required.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15168
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #5 on: December 13, 2016, 06:54:16 PM »
Hello badger,

Can you also send the list of files that you are using for Meshlab import? We are trying to open the mesh with the bundler file there, but it keeps crashing.

Also please specify which edition of PhotoScan you are using.
« Last Edit: December 13, 2016, 09:25:58 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

badger

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #6 on: December 14, 2016, 02:25:11 PM »
Hello badger,

Can you also send the list of files that you are using for Meshlab import? We are trying to open the mesh with the bundler file there, but it keeps crashing.

Also please specify which edition of PhotoScan you are using.

hello,

I'm using Photoscan 1.2.6

I sent the list of photos yesterday, but pathnames need to be adjusted to your testing environment, otherwise meshlab crashes because it does not find the photos.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15168
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #7 on: December 14, 2016, 02:51:57 PM »
Hello badger,

Is it Standard or Professional edition?

I think we have found what's the problem with bundler.out import. To avoid coordinate overflow (internal coordinates of the chunk) PhotoScan is translating the point of origin for the imported cameras.

I'll try to send you back the project where the camera positions are aligned with mesh (planning to do that with Python script).
Best regards,
Alexey Pasumansky,
Agisoft LLC

badger

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #8 on: December 14, 2016, 08:40:26 PM »
Hello badger,

Is it Standard or Professional edition?

I think we have found what's the problem with bundler.out import. To avoid coordinate overflow (internal coordinates of the chunk) PhotoScan is translating the point of origin for the imported cameras.

I'll try to send you back the project where the camera positions are aligned with mesh (planning to do that with Python script).

It's standard edition, for the time being. And thanks for the explanation. Would you be so kind to give details about the translation of the PoO, so that would be possible to compensate it ?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15168
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #9 on: December 14, 2016, 09:23:41 PM »
Hello badger,

It's just a translation, all the rotations are kept, so the shift would be the same for each camera, meaning that you can compare the last column in 4x4 matrix of camera.transform (as it kept in the project xml, for example) with the corresponding camera center from the bundler file.

To calculate the camera center from bundler out you need to use the following:
Code: [Select]
center = - R.t() * translationHere R is 3x3 rotation matrix from bundler file and translation: three-component vector form the same file. R.t() means that matrix is transposed.
Best regards,
Alexey Pasumansky,
Agisoft LLC

badger

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #10 on: December 16, 2016, 12:52:28 PM »
Hi Alexey,

I think it's fair to thank you guys also publicly, on the forum. A very top level customer support.

keep it  ;)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15168
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #11 on: March 14, 2017, 01:08:07 PM »
Here's the script for those, who has the similar issue. I think that in the next update (version 1.3.1) we'll change the internal representation a little, so that the import could work without any corrections using scripting.

Code: [Select]
import PhotoScan

doc = PhotoScan.app.document
chunk = doc.chunk
path = PhotoScan.app.getOpenFileName("Specify bundler.out file used:")
file = open(path, "rt")

coords = list()

line = file.readline()
line = file.readline()
for i in range(0, len(chunk.cameras)):
    line = file.readline()
    line = file.readline()
    line = file.readline()
    line = file.readline()
    line = file.readline()
    x, y, z = line.split()
    coords.append(PhotoScan.Vector([float(x), float(y), float(z)]))

T = chunk.cameras[i].transform

###for version 1.3:
        R = chunk.cameras[i].transform.rotation() * PhotoScan.Matrix.Diag([1,-1,-1]) #for version 1.3
###end of code for version 1.3

###for version 1.2:
#R = PhotoScan.Matrix([[T[0,0], T[0,1], T[0,2]],
# [T[1,0], T[1,1], T[1,2]],
# [T[2,0], T[2,1], T[2,2]]])
#R = R * PhotoScan.Matrix.Diag([1,-1,-1]) #for version 1.2
###end of code for version 1.2

    v = (-1) * R * coords[-1]

chunk.cameras[i].transform = PhotoScan.Matrix([[T[0,0], T[0,1], T[0,2], v.x],
[T[1,0], T[1,1], T[1,2], v.y],
[T[2,0], T[2,1], T[2,2], v.z],
[0, 0, 0, 1]])

file.close()

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

jsloat

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #12 on: May 24, 2017, 09:25:27 PM »
I really appreciate the example plug-in to import Bundler files from Reality Capture. (I learn a lot from such examples)

As others have no doubt discovered, it is unlikely to work "out of the box" on substantial files like I've been trying.
I'm trying to use it to convert a Bundler file with 3500 cameras and it keeps crashing.

After wrestling to try to get it working for a day, my debugging shows that the format of the bundler.out
file being created in the Current Beta 1.0 version of Reality Capture has several complicating factors.

The first was ensuring that values that have exponential notation from RC, get wrapped in a Float() call to handle that.

The second was that in the case where PhotoScan didn't align certain images, there will be no transform to stuff the position data into so watch for that. If you simply skip those then you'll likely be stuffing position data into a non-corresponding image/camera.

The 3rd issue is that (at least in my case) the line record structure of the file is rather inconsistent.
For much of my Bundler file, the 3x3 transform matrix has a triplet per line, (which the plug-in tries to skip
using readline() but part way through reading the bundler file, I start encountering lines where all 9 transform values are on a single line, and elsewhere I get as many as 13 values per line, which makes the parsing logic much more complicated than this plug-in (skipping fixed numbers of lines) will handle.

My plan is to try exporting from Reality Capture in another format such as Maya and rewrite a version of this plug-in to parse that file format (hoping it is a bit more of a structured record file format ).

(Will share if I get that working)

-Jay-

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15168
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #13 on: May 24, 2017, 09:32:40 PM »
Hello Jay,

Latest version of PhotoScan (1.3.2) should be able to import bundler.out file without any shift, so the script would be no longer needed.
Best regards,
Alexey Pasumansky,
Agisoft LLC

risu

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Issues with importing bundler.out alignment
« Reply #14 on: July 22, 2017, 08:06:24 PM »
I'm having issues getting RC bundler file into latest Photoscan.

When I try it, I just get generic error "Can't import cameras: <filename>"

I'm using PS Standard, 1.3.2 build 4205 and RC 1.0.2.2600 Steam