Forum

Author Topic: manual input/edit Camera position parameters into PhotoScan?  (Read 25378 times)

an198317

  • Newbie
  • *
  • Posts: 42
    • View Profile
manual input/edit Camera position parameters into PhotoScan?
« on: January 23, 2013, 02:25:09 AM »
Hello there,

Our lab bought the PhotoScan Pro for our project and we love this software a lot!

For our project, we mounted 18 cameras (9 cameras per row and 2 rows) on a flat panel above a table in the growth chamber. We have plants on the table so 18 cameras can be controlled taking photos of those plants at the same time every couple of hours. Eventually, we want to make 3D models of plants on the table using every 18 photos from those 18 cameras, and then we can do some measurements like plant leave length and width, etc from 3D models.

We have our own coordinate system built for the entire system, so we know the exact locations of each camera. So I am wondering is there any way that we can input camera position information like X, Y, Z, Omega, Phi, Kappa back into PhotoScan? So this way we can use these information to make a 3D model and extract more information from the model.

I do see the camera position output containing these information automatically built by PhotoScan Pro. But we want to use our own camera position parameters for more information.

Thanks for your help! I am looking forward to hearing about the solution.
Nan

RalfH

  • Sr. Member
  • ****
  • Posts: 344
    • View Profile
Re: manual input/edit Camera position parameters into PhotoScan?
« Reply #1 on: January 23, 2013, 04:15:17 PM »
XYZ are easy; the other parameters are quite tricky to measure with the necessary accuracy. If you are using the pro version, you should be able to feed only the positions into PhotoScan and let the software figure out the rotation paramters. In the standard version you have to import the full information; at least I haven't found a way to import only the positions.

You might be able to develop a workaround by aligning the cameras in PhotoScan, export cameras, scale and rotate the r11, r12, r13, X, r21, r22, r23, Y, r31, r32, r33, Z data to fit your local coordinate system and then import cameras with the modified parameters. If your setup stays unchanged, you'd only have to do this once.

If you manage to do this, I would be very interested in "borrowing" your workflow (haven't been able to figure out how to rotate the r data).
« Last Edit: January 23, 2013, 04:17:00 PM by RalfH »

an198317

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: manual input/edit Camera position parameters into PhotoScan?
« Reply #2 on: January 23, 2013, 09:45:58 PM »
RalfH,

Thanks for your detailed information. We are using PhotoScan Pro version. It seems like there is a way to import modified camera position and rotation parameters. We do want to import X, Y, Z, Omega, Phi and Kappa into PhotoScan. So can you let me know where I can find function to do this step?

And yes, our setup never changes, so I assumed I only need import modified parameters once. But I read through manual and just couldn't find it. Maybe I was looking at the wrong place. I will really appreciate your help if you can enlighten me on this.

I will be very glad to share the approach to measure those parameters once I test my theory.

Thanks!
Nan
« Last Edit: January 23, 2013, 09:48:08 PM by an198317 »

Kiesel

  • Sr. Member
  • ****
  • Posts: 332
    • View Profile
Re: manual input/edit Camera position parameters into PhotoScan?
« Reply #3 on: January 24, 2013, 12:12:33 AM »
Nan,

I'm not sure that I fully understand what do you mean with "But we want to use our own camera position parameters for more information." What do you mean with more information?
But isn't it possible to mark some GCPs or Coded Targets in your own coordinate system and let Photoscan do the rest?
Otherwise I think there might be an answer in http://www.agisoft.ru/forum/index.php?topic=834.msg3921#msg3921 or Alexey will help you.

Karsten

an198317

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: manual input/edit Camera position parameters into PhotoScan?
« Reply #4 on: January 24, 2013, 12:29:01 AM »
Karsten,

I haven't finished reading the post you attached. The reason we want to use our own coordinates is because we need do some biological measurement like plant leave length and width. The camera position in the Agisoft is relative position. I assume, if we can import our own coordinates, then I can do these measurements from the 3D model, using reasonable units (cm, inch, etc). Right now, we can't do measurement based on the original camera coordinates.

I've seen people talking about using GCPs or GPS for aerial photography. But our setup is different, which is no GPS information we can use. If we use GCPs, I assume I have to do this over and over again for different models. The 3D model will be built hourly based on 18 photos per hour.

So I thought, since the cameras never move, I can do external calibration one time at the beginning, then we can use the same camera position over and over again.

Does this make sense to you? I am looking forward to hearing from Alexey to help me. Thanks you guys a lot!!

Nan

RalfH

  • Sr. Member
  • ****
  • Posts: 344
    • View Profile
Re: manual input/edit Camera position parameters into PhotoScan?
« Reply #5 on: January 24, 2013, 12:13:37 PM »
Nan,

I only have the standard version of PhotoScan but looked through the pro manual. There are two ways to do what you want to do:

(1) Measure and import camera parameters - you need XYZ as well as all the r11, r12... rotation parameters, put them into a PhotoScan structure xml file and then import them (tools > import > import cameras). This is probably tricky as it is very difficult to measure the rotation parameters exactly.

(2) Use your camera positions as "ground" control points for georeferencing (In the end, PhotoScan simply needs a number of points for which it knows the positions in the desired coordinate system, no matter if they are ground points or camera positions) - you only need the XYZ positions, no rotation, put them in a csv file described elsewhere in this forum (e.g. http://www.agisoft.ru/forum/index.php?topic=562.msg2492#msg2492) and import them (see page 32 of the 0.9.0 pro manual). It's the easier and probably (as you don't have to measure rotation) less error-prone option. Camera rotation will be determined by PhotoScan during image alignment, and after having done this once you can export cameras (which now have XYZ as well as rotation paramteres) to a file which you can re-use for every set of images taken with your setup.

P.S.: By the way, how do you measure camera positions, and how accurate are your measurements?
« Last Edit: January 24, 2013, 11:33:30 PM by RalfH »

an198317

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: manual input/edit Camera position parameters into PhotoScan?
« Reply #6 on: January 29, 2013, 09:43:22 AM »
Thanks for your detailed information, RalfH. And sorry to get back to you late.

After studying what you mentioned the xml file format, the only xml format I can find is the output from the tools> export > export cameras... Is this the xml format you mentioned?

If so, I checked the content in this xml file. The calibration part is the internal camera calibration parameters like focal length, principle point, etc. So is the "Transform" section is the external calibration?

I compared values with the Omega, Phi, Kappa output values, I assume in the Transform section, the value order is r11, r12, r13, x, r21, r22, r23, y, r31, r32, r33, z.

So do you think this is the right assumption just by looking at values? I can't see any values for rotation angles Omega, Phi, Kappa.

P.S. RalfH, we are taking photos of different known objects using this 18-camera setup, and we have written a program to do external measurement. This still is a on-going process. Once we get this step done, I can share what I got.

Thanks for helping!

Nan

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14971
    • View Profile
Re: manual input/edit Camera position parameters into PhotoScan?
« Reply #7 on: January 29, 2013, 01:39:03 PM »
Hello Nan,

If I understand your task correctly there is a recommended way provided that camera positions will not move.

Camera coordinates could be imported to the Ground Control pane so you'll be able to have your model referenced in the same coordinate system.
For better accuracy control you can also have some coded targets printed and placed around the object.

Another point is to reconstruct good textured object at first and export .xml file with camera positions and calibration data. After that you'll be able to import this file to PhotoScan and reconstruct the object of interest using previously acquired data.
But please note that camera export + import could be only used if camera relative positions do not change during the whole capturing set, focal length could not be also changed.

Best regards,
Alexey Pasumansky,
Agisoft LLC

RalfH

  • Sr. Member
  • ****
  • Posts: 344
    • View Profile
Re: manual input/edit Camera position parameters into PhotoScan?
« Reply #8 on: January 29, 2013, 05:34:16 PM »
Hello Nan,

yes, you interpreted the numbers in the "transform" section more or less correctly, but note that some of the r parameters have a changed sign. The order of parameters seems to be the following:
r11
-r21
-r31
X
r12
-r22
-r32
Y
r13
-r23
-r33
Z

Omega, Phi and Kappa are not saved in the XML file. But as Alexey also says, it would be easier to just work with the positions as ground control data and perhaps add some markers for the establishment of the xml file.

an198317

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: manual input/edit Camera position parameters into PhotoScan?
« Reply #9 on: January 30, 2013, 10:33:13 AM »
Hi Alexey and RalfH,

Thanks again for your detailed information. It's hugely helpful to me, and I really appreciate you guys' fast response. And thanks RalfH for your rotation matrix info, that makes sense to me now.

As Alexey mentioned, yes, once the cameras are mounted above the table, all of the cameras will only be controlled to shoot photos by computer hourly. No position, aperture, focal length, shutter speed changes at all. We had made this plan from the day one.

The reason I am not sure about the ground control method you guys keep talking about is this study is different than the typical remote sensing studies I did in the past: we have to utilize FOV of each camera very well, so no empty space of table can be seen from any of those cameras. And the plants will be moved randomly to make sure every single plant will have the same chance to gain equal light and air flow, etc. So if I make any markers on the tray of plants, the markers positions will be changed from time to time. This is why I am not sure ground control method works. Please enlighten me if my understanding about ground control is not right.

After thinking through, we came up a plan to test camera position import. Right now there are two cameras on the both ends of one row are not perfectly leveled: Phi values are 5.065235 and -4.045621 (Omega and Kappa values are very close to zero). Since there is no way I can input Omega, Phi, Kappa back to XML file, I will modify those two Phi values close to zero and then back calculate rotation matrix  using original Omega and Kappa values and modified Phi values. Then put matrix along with xyz into the XML and import back to PhotoScan using Import Cameras.

So my question is will PhotoScan use this new camera position XML file to correct those two cameras on the both ends. And after importing this XML file, should I redo the workflow again to make a new 3d model?

Now the 3D model with cameras can show those two cameras are not perfectly flat. So I am curious about after redoing this, will those two cameras' position be changed according to the Phi values I modified?

Sorry about my long reply! Any input will be hugely helpful. If this setup can be done, the huge part of this project is fixed by PhotoScan.

Thanks!
Nan

RalfH

  • Sr. Member
  • ****
  • Posts: 344
    • View Profile
Re: manual input/edit Camera position parameters into PhotoScan?
« Reply #10 on: January 30, 2013, 11:15:11 AM »
Hello Nan,

even if all your field of view is covered by plants during the research phase, you can use markers on the empty (or better, filled with something structured) tray in the setup phase. It would probably improve precision. I think using the camera positions could be sufficient, but even in that case, using some markers or some object of known dimensions may be useful to check the precision.

As for the other question: if you are able to compute the r parameters from the Omega, Phi, Kappa parameters and then use them together with the XYZ values in the cameras xml file, PhotoScan will use these values to build the model. I believe that all parameters have to be VERY precise and accurate, otherwise PhotoScan will probably not be able to build a model or there will be errors in the model.

P.S.: I created the images attached to the post http://www.agisoft.ru/forum/index.php?topic=964.0 by manually editing a camera xml file and importing it into PhotoScan.
« Last Edit: January 30, 2013, 04:41:15 PM by RalfH »