# Compute world and image coordinates with exported intrinsic and extrinsic camera parameters

**URL:** <https://forums.unrealengine.com/t/compute-world-and-image-coordinates-with-exported-intrinsic-and-extrinsic-camera-parameters/1219134>\
**Category:** Photogrammetry\
**Tags:** realityscan\
**Created:** [July 4, 2023, 12:18pm UTC](https://forums.unrealengine.com/t/compute-world-and-image-coordinates-with-exported-intrinsic-and-extrinsic-camera-parameters/1219134 "2023-07-04T12:18:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![schmilor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@schmilor](https://forums.unrealengine.com/u/schmilor)\
**Post date:** [July 4, 2023, 12:18pm UTC](https://forums.unrealengine.com/t/compute-world-and-image-coordinates-with-exported-intrinsic-and-extrinsic-camera-parameters/1219134/1 "2023-07-04T12:18:50Z")

</div>

Hi,

For visualization of the reality capture workflow, I wanted to visualize the mapping of the e.g. a control point marked on the image into 3d space and then backward into another image. So the basic photogrammetry I class exercise.  
For that I have a small dataset and exported the internal and external camera parameters for my own calculation (or for the students then later)  
Unfortunately, I’m not able to manage to compute it from the given parameters.

Right now I just have exported the normal parameter set:

> name,x,y,alt,heading,pitch,roll,f,px,py,k1,k2,k3,k4,t1,t2

But will add the image width and height later like described here: [Post 1](https://forums.unrealengine.com/t/include-image-px-width-and-height-in-the-internal-external-camera-parameters-csv-export/712520/2)

I similar post like [Post 2](https://forums.unrealengine.com/t/calculating-camera-fustrum-based-of-camera-alignment-export-options/712145/5) and [Post 3](https://forums.unrealengine.com/t/what-is-the-logic-of-camera-rotation-in-internal-external-camera-parameters-csv/710458/4) but some of the images are dead or the links broken.

Can someone, maybe @OndrejTrhan himself give me a short hint of how to compute world coordinate from a pixel coordinate, with the exported camera parameters and also back. I’m especially confused by the 35mm equivalent focal length and the principle point (which seems to be an offset from the center of the image, so [imageWidth/2, ImageHeight/2]

> cameraPosition = [x,y, alt; % Camera position in the world coordinate system
> 
> cameraOrientation = eul2rotm([heading,pitch,roll], ‘XYZ’); % Camera orientation as a rotation matrix
> 
> % Compute the extrinsic matrix (Rt)  
> R = cameraOrientation;  
> t = -R \* cameraPosition;  
> Rt = [R, t]
> 
> % compute intrinsic matrix  
> fx = focalLength; ?? what unit  
> fy = focalLength; ?? what unit
> 
> K = [fx, 0, cx;  
> 0, fy, cy;  
> 0, 0, 1];  
> Kinv = inv(K);
> 
> pixelCoords = [u; v; 1]; % Homogeneous coordinates of the pixel  
> normalizedCoords = Kinv \* pixelCoords;
> 
> worldCoords = Rt\normalizedCoords;  
> worldCoords = worldCoords(1:3) / worldCoords(4);

I think that the first two steps (intrinsic and extrinsic matrix calculation is faulty, but I cannot see where…

---

<div class="post-metadata">

**Author:** ![OndrejTrhan](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ondrejtrhan/32/906565_2.png) [@OndrejTrhan](https://forums.unrealengine.com/u/OndrejTrhan)\
**Post date:** [July 11, 2023, 9:20am UTC](https://forums.unrealengine.com/t/compute-world-and-image-coordinates-with-exported-intrinsic-and-extrinsic-camera-parameters/1219134/2 "2023-07-11T09:20:58Z")

</div>

Hi [schmilor](https://forums.unrealengine.com/u/schmilor), this could be helpful for you: [RealityCapture XMP Camera Math](https://forums.unrealengine.com/t/realitycapture-xmp-camera-math/682564)

---

<div class="post-metadata">

**Author:** ![brizzle1834](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@brizzle1834](https://forums.unrealengine.com/u/brizzle1834)\
**Post date:** [October 17, 2024, 10:52am UTC](https://forums.unrealengine.com/t/compute-world-and-image-coordinates-with-exported-intrinsic-and-extrinsic-camera-parameters/1219134/3 "2024-10-17T10:52:47Z")

</div>

@schmilor Did you manage to compute this?
