alicevision / Meshroom

3D Reconstruction Software
http://alicevision.org
Other
10.93k stars 1.07k forks source link

[question]How to use the ImportKnownPoses node? #2158

Open handrianj opened 11 months ago

handrianj commented 11 months ago

Describe the problem I would need an example of where and how to plugin the ImportFromKnownPoses format and a sample of XML/JSON used in the KnownPosesData.

I tried to set up the node as follows but I'm not sure if it's correct.

If it's correct can you provide a sample of the expected json file for the KnowPosesData file please?

Screenshots Capture

Desktop (please complete the following and other pertinent information):

natowi commented 11 months ago

Option 1:
Do a default reconstruction. The StructureFromMotion SfM file has the data you are looking for. (cameras.sfm file)

Meshroom uses this rotation format: https://github.com/alicevision/meshroom/issues/300#issuecomment-573386855

https://github.com/alicevision/AliceVision/blob/3e4f31ad9de2ad1f024011fb1917906c175c3b99/src/software/convert/main_importKnownPoses.cpp

Option 2: The Agisoft Cameras Export XML format seems to be supported from what I see. Agisoft reference can be found here https://www.agisoft.com/forum/index.php?topic=1557.0

<?xml version="1.0" encoding="UTF-8"?>
<document version="1.2.0">
  <chunk>
    <sensors>
      <sensor id="0" label="iPhone 7 (3.99 mm)" type="frame">
        <resolution width="4032" height="3024"/>
        <property name="pixel_width" value="0.001223312039889568"/>
        <property name="pixel_height" value="0.001223312039889568"/>
        <property name="focal_length" value="3.9900000000000002"/>
        <property name="fixed" value="false"/>
        <calibration type="frame" class="adjusted">
          <resolution width="4032" height="3024"/>
          <fx>3261.6371538043468</fx>
          <fy>3261.6371538043468</fy>
          <cx>2016</cx>
          <cy>1512</cy>
        </calibration>
      </sensor>
    </sensors>
    <cameras>
      <camera id="0" label="IMG_1024.JPG" sensor_id="0" enabled="true">
        <transform>9.9990957130907576e-001 1.3495301151825133e-003 1.3380133518341587e-002 -5.1572033080923844e-005 -1.3435753650299783e-003 9.9999899433359063e-001 -4.5402317761030815e-004 1.6145857830320931e-004 -1.3380732780341933e-002 4.3600490311265192e-004 9.9991037892902457e-001 2.0136876999787284e-005 0.0000000000000000e+000 0.0000000000000000e+000 0.0000000000000000e+000 1.0000000000000000e+000</transform>
        <orientation>6</orientation>
        <reference x="-119.615883333333" y="37.723294444444399" z="1224.42424242424" enabled="true"/>
      </camera>
      <camera id="1" label="IMG_1025.JPG" sensor_id="0" enabled="true">
        <transform>9.9736872890996220e-001 7.2029603734097919e-002 -8.2069957009286744e-003 5.7994504487395987e-003 -6.9266435834908990e-002 9.8022733063134870e-001 1.8535517567650794e-001 -4.6384937779366919e-001 2.1395781342467241e-002 -1.8429898662024574e-001 9.8263732071985532e-001 3.1995791087047212e-002 0.0000000000000000e+000 0.0000000000000000e+000 0.0000000000000000e+000 1.0000000000000000e+000</transform>
        <orientation>6</orientation>
        <reference x="-119.615905555556" y="37.723280555555597" z="1223.82051282051" enabled="true"/>
      </camera>
      <camera id="2" label="IMG_1026.JPG" sensor_id="0" enabled="true">
        <transform>9.9361809714114879e-001 1.1190085107153604e-001 1.4187197153371398e-002 -1.8669048493305723e-002 -1.0929980786179165e-001 9.2409378304769318e-001 3.6620244692516529e-001 -1.0213047440695029e+000 2.7868064787102548e-002 -3.6541603640517611e-001 9.3042704781350427e-001 9.2816145104142073e-002 0.0000000000000000e+000 0.0000000000000000e+000 0.0000000000000000e+000 1.0000000000000000e+000</transform>
        <orientation>6</orientation>
        <reference x="-119.615913888889" y="37.723280555555597" z="1224.6835443038001" enabled="true"/>
      </camera>
    </cameras>
    <transform>
      <rotation>3.0330319744236212e-001 9.1766764760573760e-001 -2.5669682304031638e-001 -2.5736571204699177e-001 -1.8048456563240375e-001 -9.4930933411139873e-001 -9.1748027808982602e-001 3.5399351703983878e-001 1.8143464170323462e-001</rotation>
      <translation>-2.4967346519396263e+006 -4.3922117944052164e+006 3.8819453005004991e+006</translation>
      <scale>2.9954298547676830e+000</scale>
    </transform>
    <reference>GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9102"]],AUTHORITY["EPSG","4326"]]</reference>
    <region>
      <center>2.0030653442140944e-001 9.2571194515947239e-002 2.4428729169135881e+000</center>
      <size>4.5543568611145018e+000 2.7544041633605958e+000 2.5712667465209957e+000</size>
      <R>-8.6359655005735125e-001 5.1394590253089373e-002 -5.0155717004321454e-001 -3.5381381321654193e-002 -9.9851611181001321e-001 -4.1397250048584702e-002 -5.0294050998583595e-001 -1.8004736835910536e-002 8.6413348093142250e-001</R>
    </region>
    <settings>
      <property name="accuracy_tiepoints" value="1"/>
      <property name="accuracy_cameras" value="10"/>
      <property name="accuracy_cameras_ypr" value="2"/>
      <property name="accuracy_markers" value="0.0050000000000000001"/>
      <property name="accuracy_scalebars" value="0.001"/>
      <property name="accuracy_projections" value="0.10000000000000001"/>
    </settings>
  </chunk>
</document>

I updated the wiki https://github.com/alicevision/Meshroom/wiki/Using-known-camera-positions

rammalali commented 11 months ago

Option 1: Do a default reconstruction. The StructureFromMotion SfM file has the data you are looking for. (cameras.sfm file)

Meshroom uses this rotation format: #300 (comment)

https://github.com/alicevision/AliceVision/blob/3e4f31ad9de2ad1f024011fb1917906c175c3b99/src/software/convert/main_importKnownPoses.cpp

Option 2: The Agisoft Cameras Export XML format seems to be supported from what I see. Agisoft reference can be found here https://www.agisoft.com/forum/index.php?topic=1557.0

<?xml version="1.0" encoding="UTF-8"?>
<document version="1.2.0">
  <chunk>
    <sensors>
      <sensor id="0" label="iPhone 7 (3.99 mm)" type="frame">
        <resolution width="4032" height="3024"/>
        <property name="pixel_width" value="0.001223312039889568"/>
        <property name="pixel_height" value="0.001223312039889568"/>
        <property name="focal_length" value="3.9900000000000002"/>
        <property name="fixed" value="false"/>
        <calibration type="frame" class="adjusted">
          <resolution width="4032" height="3024"/>
          <fx>3261.6371538043468</fx>
          <fy>3261.6371538043468</fy>
          <cx>2016</cx>
          <cy>1512</cy>
        </calibration>
      </sensor>
    </sensors>
    <cameras>
      <camera id="0" label="IMG_1024.JPG" sensor_id="0" enabled="true">
        <transform>9.9990957130907576e-001 1.3495301151825133e-003 1.3380133518341587e-002 -5.1572033080923844e-005 -1.3435753650299783e-003 9.9999899433359063e-001 -4.5402317761030815e-004 1.6145857830320931e-004 -1.3380732780341933e-002 4.3600490311265192e-004 9.9991037892902457e-001 2.0136876999787284e-005 0.0000000000000000e+000 0.0000000000000000e+000 0.0000000000000000e+000 1.0000000000000000e+000</transform>
        <orientation>6</orientation>
        <reference x="-119.615883333333" y="37.723294444444399" z="1224.42424242424" enabled="true"/>
      </camera>
      <camera id="1" label="IMG_1025.JPG" sensor_id="0" enabled="true">
        <transform>9.9736872890996220e-001 7.2029603734097919e-002 -8.2069957009286744e-003 5.7994504487395987e-003 -6.9266435834908990e-002 9.8022733063134870e-001 1.8535517567650794e-001 -4.6384937779366919e-001 2.1395781342467241e-002 -1.8429898662024574e-001 9.8263732071985532e-001 3.1995791087047212e-002 0.0000000000000000e+000 0.0000000000000000e+000 0.0000000000000000e+000 1.0000000000000000e+000</transform>
        <orientation>6</orientation>
        <reference x="-119.615905555556" y="37.723280555555597" z="1223.82051282051" enabled="true"/>
      </camera>
      <camera id="2" label="IMG_1026.JPG" sensor_id="0" enabled="true">
        <transform>9.9361809714114879e-001 1.1190085107153604e-001 1.4187197153371398e-002 -1.8669048493305723e-002 -1.0929980786179165e-001 9.2409378304769318e-001 3.6620244692516529e-001 -1.0213047440695029e+000 2.7868064787102548e-002 -3.6541603640517611e-001 9.3042704781350427e-001 9.2816145104142073e-002 0.0000000000000000e+000 0.0000000000000000e+000 0.0000000000000000e+000 1.0000000000000000e+000</transform>
        <orientation>6</orientation>
        <reference x="-119.615913888889" y="37.723280555555597" z="1224.6835443038001" enabled="true"/>
      </camera>
    </cameras>
    <transform>
      <rotation>3.0330319744236212e-001 9.1766764760573760e-001 -2.5669682304031638e-001 -2.5736571204699177e-001 -1.8048456563240375e-001 -9.4930933411139873e-001 -9.1748027808982602e-001 3.5399351703983878e-001 1.8143464170323462e-001</rotation>
      <translation>-2.4967346519396263e+006 -4.3922117944052164e+006 3.8819453005004991e+006</translation>
      <scale>2.9954298547676830e+000</scale>
    </transform>
    <reference>GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9102"]],AUTHORITY["EPSG","4326"]]</reference>
    <region>
      <center>2.0030653442140944e-001 9.2571194515947239e-002 2.4428729169135881e+000</center>
      <size>4.5543568611145018e+000 2.7544041633605958e+000 2.5712667465209957e+000</size>
      <R>-8.6359655005735125e-001 5.1394590253089373e-002 -5.0155717004321454e-001 -3.5381381321654193e-002 -9.9851611181001321e-001 -4.1397250048584702e-002 -5.0294050998583595e-001 -1.8004736835910536e-002 8.6413348093142250e-001</R>
    </region>
    <settings>
      <property name="accuracy_tiepoints" value="1"/>
      <property name="accuracy_cameras" value="10"/>
      <property name="accuracy_cameras_ypr" value="2"/>
      <property name="accuracy_markers" value="0.0050000000000000001"/>
      <property name="accuracy_scalebars" value="0.001"/>
      <property name="accuracy_projections" value="0.10000000000000001"/>
    </settings>
  </chunk>
</document>

I updated the wiki https://github.com/alicevision/Meshroom/wiki/Using-known-camera-positions

Hello, is there any example for JSON format, Im getting a fatal error in the node ImportKnownPoses, unspecified file>(1): expected key string

natowi commented 11 months ago

You are right. It does not work properly. Hard for me to test without known poses that differ from the default reconstruction.

--

Run a default reconstruction with images. The resulting cameras.sfm in the StructureFromMotion folder can be used as template

yan892 commented 9 months ago

Hello. I also wanted to try the ImportKnownPoses node. So far I have read the wiki and some posts about it. I tried it with the mini6 test dataset from Alicevision. I have determined the camera positions with the default pipeline. To see what output the ImportKnownPoses node has in the first place, I separated the nodes that come after it from it and passed its output to a ConvertSfMFormat node so that it would output an .sfm file for me to compare. If I use an .sfm file for the camera positions and give it to the ImportKnownPoses node, it is ignored. In the .sfm file from the ConvertSfMFormat node are then only the views and intrinsics from the CameraInit node. If I use a .json file for the camera positions, I also get the error from @rammalali [fatal] (1): expected key string. What is the reason for this? And what goes into the camera positions file anyway? I know you are supposed to compare the file from the StructureFromMotion node with the one from the CameraInit node. But does "version" and "views" come in as well? I also used the ConvertSfMFormat node to convert the output from the StructureFromMotion node to a .json file and then give that to the ImportKnownPoses node, but the error still comes up.

zhanglq2024 commented 8 months ago

Sorry, Still confused about this feature, I get a bunch of drone images captured by DJI devices, they have position and yaw-roll-pich, I should have be able to set the prior position and rotaion, also set the accuracy (i.e. sigma in ceres or information matrix in g2o), but it seems this app doesn't provide any convinient way to do this.

rammalali commented 8 months ago

Sorry, Still confused about this feature, I get a bunch of drone images captured by DJI devices, they have position and yaw-roll-pich, I should have be able to set the prior position and rotaion, also set the accuracy (i.e. sigma in ceres or information matrix in g2o), but it seems this app doesn't provide any convinient way to do this.

I actually tried many ways to do this and didn't find any solution, even with other apps there still no solution for this.

zhanglq2024 commented 8 months ago

@rammalali I think metashape/photoscan and DJI Terra are pretty good options, but the downside of them is that neither of them are open sourced.