Custom Export Scripting

Hey Guys,

I want to edit the calibration.xml file in the RC-Folder adding a custom export format.

The Export Format should export the TiePoints of each image and the corresponding Image Name, but you can only export the Image Index.

Code:

    <format id="{00000000-0000-0000-0000-000000000003}"
                    mask="*.lst"
                    desc="Tie Points Real Coordinates in Pixels"
                    writer="cvs"
                    undistortImages="never"
                    exportImages="never"
                    requires="component">
            <body>
                    # Tie Points Real Coordinates Data Export in Pixels
   
                    $ExportPoints(
                            Point index: $(index)
                            $ExportTrack(
                                    Image index: $(imageIndex)
                                    Feature index: $(featureIndex)
                                    Real X [Pixel]: $((x + 0.5) * width)
                                    Real Y [Pixel]: $((y + 0.5) * height)
                           
                            # Export Image Name
                                    $ExportCameras($(imageName))
                            )
                    )                        
            </body>
    </format>

In the Help Sections of RC I found the $ExportCameras Function where you can export the $imageName but it exports all image names and thats not what I want.

Can you help me please?

Thanks
Julian

Hello @StuEv
I suppose you don’t need to create the own export. Can you check the COLMAP export if this is what you need? There in the Images.txt section you can export cameras with their indexes and also tie points for each camera.

$ExportCameras(
    $[a]$(index+1) $QuaternionFromMatrix(R00,-R02,R01,R10,-R12,R11,R20,-R22,R21,$(qw:g) $(qx:g) $(qy:g) $(qz:g)) $(tx:g) $(ty:g) $(tz:g) $(cameraIndex+1) $(imageName)$(imageExt)$[b]$[n]
    $ExportTiePoints("",0,999999,
        $[a]$(x*scale+width*0.5) $(y*scale+height*0.5) $(pointIndex+1) $[b]
    )$Strip(1)
    $[n]
))

Just remove the quaternion matrix.

Hey @OndrejTrhan

I searched everywhere but there is no export option fpr colmap and if I try your code, then the $ExportTiePoints function is not found. Can you help me? Where is it located?

OK, I am sorry for that. COLMAP export is planned for next releases. Instead, can you try to add this script to the calibration.xml file if it works for you?

	<format id="{280B11A4-F9A3-47D1-AE58-C0DEA33487D8}" mask="*.txt" descID="9001" desc="TiePoints Text Format" writer="cvs" undistortImages="always" exportImages="0" requires="component">
		<body>The files are in the same folder.$[b]
$WriteFile("Images.txt",
$[a]$ExportPoints(
    Point index: $(index)
    $ExportTrack(
        Image index: $(imageIndex)
        Feature index: $(featureIndex)
        Real X [Pixel]: $((x + 0.5) * width)
        Real Y [Pixel]: $((y + 0.5) * height)
        $ExportCamera(cameraIndex,ImageName: $(imageName)$(imageExt))
    )
)$[b]$[n]
)
</body>
    </format>

Hey @OndrejTrhan it works!!! my god I spend so much time with this thanks.

I have one more Question it seems like some features have the same “feature Index”:


				Point index: 0
				
					Image index: 0
					Feature index: 940
					Real X [Pixel]: 2975.213370323181
					Real Y [Pixel]: 756.0130627155304
					ImageName: 1.JPG
				
					Image index: 4
					Feature index: 994
					Real X [Pixel]: 2830.730699300766
					Real Y [Pixel]: 3006.320393562317
					ImageName: 5.JPG
				
					Image index: 1
					Feature index: 952
					Real X [Pixel]: 2906.399903297424
					Real Y [Pixel]: 1319.910706579685
					ImageName: 2.JPG
				
					Image index: 2
					Feature index: 940
					Real X [Pixel]: 2879.564208984375
					Real Y [Pixel]: 1881.819028228521
					ImageName: 3.JPG
				
					Image index: 3
					Feature index: 820
					Real X [Pixel]: 2853.721924424171
					Real Y [Pixel]: 2446.360100358725
					ImageName: 4.JPG

shouldn’t be every feature code unique?

And do you know if it is possible to convert the image coordinates to milimeters and with the Principal Point as the Center?

And do you know if there is a function to export also the camera name?

Thanks a lot!

Feature is basically tie point and the same can be visible from more cameras (and basically needs to be visible).

It is possible, you just need to know the pixel size and provide some corrections to the equation.

Image name is basically a camera name for this case.

@OndrejTrhan Hey, no i mean the Camera Model which took the pictures like “Sony alpha 28mm” or “DJI Mavic 3 10mm”

Probably this will work like that:

ExportCameraModels - this function exports all types of camera models used to take photos and laser scans.

**Syntax:**

$ExportCameraModels( noParametersJustAnyText )

**Available variable:**

cameraModel - a camera model

**Example:**

$ExportCameraModels( Camera model: $(cameraModel) )

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.