Comments (31)
@Vedhus I don't know, its should work maybe the syntax is different but you should find way to get the same using python.
Any way I figure out that in digital camera matrix (computer graphics like openGL/UnrealEngine) the pixel ratio equals to 1 because there is no physical distortion like in real life camera, this means that getting the intrinsic matrix is simple,no calibration operation needed :
Intrinsic Matrix:
K = [[f, 0, Cu],
[0, f, Cv],
[0, 0, 1 ]]
fx=fy=f=imageWidth /(2 * tan(CameraFOV * Ο / 360))
Cu=image horizontal center = imageWidth/2
Cv=image vertical center = imageHight/2
Enjoy .
from unrealcv.
@Vedhus I don't know, its should work maybe the syntax is different but you should find way to get the same using python.
Any way I figure out that in digital camera matrix (computer graphics like openGL/UnrealEngine) the pixel ratio equals to 1 because there is no physical distortion like in real life camera, this means that getting the intrinsic matrix is simple,no calibration operation needed :
Intrinsic Matrix:
K = [[f, 0, Cu],
[0, f, Cv],
[0, 0, 1 ]]fx=fy=f=imageWidth /(2 * tan(CameraFOV * Ο / 360))
Cu=image horizontal center = imageWidth/2
Cv=image vertical center = imageHight/2Enjoy .
The focal length you calculate here is measured in pixel, but how can I get the focal length measured in real-world units(mm)? I can't find the sensor size of the default camera in the unreal engine.
Without the real focal length, how can I reproject the point into 3D world coordinates?
from unrealcv.
Hi @edz-o thanks for the reply
According to your formula the k matrix comes out to be
K = [320 0 320
0 320 240
0 0 1]
The depth to point cloud conversion using this intrinsic matrix is very distorted. Previously for opengl to camera matrix conversion i have used this https://strawlab.org/2011/11/05/augmented-reality-with-OpenGL. i wanted to access the OpenGL projection matrix to convert to the Hz intrinsic matrix.
from unrealcv.
I have a quick note: the posted distance-to-image plane function does not seem to be correct; it actually computes the distance to the camera along the viewing direction (i.e. distance to image plane + focal depth).
The correct equation on line 8 should, imo, read
PlaneDepth = (PointDepth-1) / (1 + (DistanceFromCenter / f)**2)**(0.5)
However, for single-image reconstruction purposes it seems to work as it should π I guess this is more of a semantic note, in that it does not compute the distance to the image plane, but rather to the Z plane in the camera's reference system.
from unrealcv.
Hi,
@debadeepta
We guess the cause is that the depth image obtained by vget /camera/0/depth
is the distance from the scene to the camera center, you may convert it to the distance to image plane using this function.
from unrealcv.
For future reference, I got confused with the calculation/application of the location and rotation, because they do not follow the axes lay-out I was expecting. The translation axes for a non-rotated camera are given with the x axis into the scene, the y axis to the right and the z axis to the top (left-handed, for some reason?). I was expecting it to be z axis into the scene, x axis to the right and y axis to the bottom, as you do when projecting points onto an image plane.
By setting location = [location[1],-location[2],location[0]], the rest of my code ran as expected.
from unrealcv.
anyone faced: LogUnrealCV:Warning: error Argument Invalid
when calling vget /camera/0/proj_matrix
?
from unrealcv.
Hi, @dineshreddy91
This is an unfinished feature and I am working on it.
The camera matrix for FOV 90 is fixed, I need to ask my co-author for the exact value.
from unrealcv.
@qiuwch thanks for the reply. can you provide the projection matrix for FOV 90. i wanted to test the odometry and am stuck without the intrinsic matrix of the camera.
from unrealcv.
Hi, @dineshreddy91
The focal length f = W / 2 / tan(FOV/2) = W/2, where W is the width of the image which is 640 px here. And the pixels are square.
from unrealcv.
@dineshreddy91 If this is not what you are looking for, then I need to spend one or two days to read Unreal Engine's code to find what is the correct answer.
from unrealcv.
from unrealcv.
Using the K matrix above I am getting a really distorted point cloud as well. See attached image. It is a view into the room in RealisticRendering binary example. The depth image converted to point cloud using K above makes the scene 'cave-in' towards the center. I think we need the camera distortion model and coefficients to properly project. Is anyone else having the same experience?
from unrealcv.
Thank you! I didn't realize the depth image was in ray-distance form. Your function works great. Just a small nitpick: 'f' is undefined in your function. Ideally should be an argument to it.
Many thanks!
from unrealcv.
Could we add this to the plugin?
from unrealcv.
@bhack I am willing to finish the uncompleted vget /camera/[id]/proj_matrix
. I am working on #60 and it is almost finished. This will be my next step. If anyone has already done this and can make a pull request, that would be best.
@debadeepta I think the distance to the image plane is a much natural definition for depth. The ray-distance should at least be clearly documented, this is our fault. I am thinking to provide both these two types of depth, but not sure how to call them, depth
and ray_distance
?
from unrealcv.
Hi, @DonnEssime
@edz-o is travelling these days, I will ask him to follow up this issue when he is back.
from unrealcv.
Hi, @DonnEssime
You are right, this function computes the distance to the camera plane, i.e. the Z plane.
from unrealcv.
@edgarriba as of the current version 0.3.10, the function vget /camera/0/proj_matrix
is incomplete. It just contains a couple lines of commented out code and returns FExecStatus::InvalidArgument
.
from unrealcv.
CameraMatrix = IntrinsicMatrix * ExtrinsicMatrix
Where ExtrinsicMatrix = RotationMatrix|TranslationMatrix(aKa position)
For C++ users :
ProjectionMatrix projMatrix = client.simGetCameraInfo("0").proj_mat;
VectorMath::Matrix3x3f rotationMatrix = client.simGetCameraInfo("0").pose.orientation.toRotationMatrix();
VectorMath::Vector3f cameraPosition = client.simGetCameraInfo("0").pose.position;
from unrealcv.
@stavBodik is the projMatrix the IntrinsicMatrix?
from unrealcv.
@Vedhus No, The projection matrix is the camera matrix.
from unrealcv.
@stavBodik thanks, do you know if I can use the camera matrix directly with the cv2.reprojectImageTo3D?
from unrealcv.
@Vedhus "In computer vision a camera matrix or projection matrix is a matrix which describes the mapping of a pinhole camera from 3D points in the world to 2D points in an image.Β " I never tried but this matrix should help you to do the reverse operation if you know the depth/distance from the camera to each pixel.
from unrealcv.
@stavBodik Thanks, last question. Does this work with the python client as well?
proj = client.simGetCameraInfo("0").proj_mat
from unrealcv.
@stavBodik Thanks! Do you know why the projection matrix is 4x4 and not 3x4? Because the Intrisic matrix is 3x3 and extrinsic matrix is 3x4.
from unrealcv.
Some calibration software provides a 4x4 matrix, which adds an extra row to preserve the z-coordinate. In this case, just drop the last row to get a 3x4 matrix.
http://ksimek.github.io/2012/08/14/decompose/
from unrealcv.
@whatseven, Are you able to get information from specific camera in Python wrapper? It looks like we are not able to attain information in Python environment.,..Here are others' experience.
from unrealcv.
thanks
from unrealcv.
Is anyone else also getting this format of Projection Matrix? It seems wrong, I have no idea why I am getting this. I expected to get a matrix in this format:
ProjectionMatrix { 'matrix': [ [ 0.0,
1.0,
0.0,
0.0],
[ 0.0,
0.0,
-1.7777777910232544,
0.0],
[ 0.0,
0.0,
0.0,
10.0],
[ -1.0,
0.0,
0.0,
0.0]]}
from unrealcv.
Is anyone else also getting this format of Projection Matrix? It seems wrong, I have no idea why I am getting this. I expected to get a matrix in this format: ProjectionMatrix { 'matrix': [ [ 0.0, 1.0, 0.0, 0.0], [ 0.0, 0.0, -1.7777777910232544, 0.0], [ 0.0, 0.0, 0.0, 10.0], [ -1.0, 0.0, 0.0, 0.0]]}
Hi I got the same Projection matrix when I tried to get the camera information of the AIRSIM simulator by using client.simGetCameraInfo("0") in python.
from unrealcv.
Related Issues (20)
- Problems detecting the position of the cameras, using Unreal engine 4.27 HOT 1
- Lighting needs to be rebuilt
- Assertion Error When Launching a Packaged Game for PlayerController
- Reflection Material Reflects Annotation in Lit Mode
- How to convert the depth into disparity? HOT 5
- New viewmode for albedo
- Dynamic camera position not reflecting HOT 1
- Getting vertex position of skeletal mesh HOT 2
- Can't Build for UE4.27 on Ubuntu HOT 1
- What are the internal parameters of FunsionCamSensor HOT 1
- Unrecognized image file extension for "npy" HOT 1
- ζ ζ³θΏζ₯ε°οΌ'localhost', 9000οΌ HOT 4
- deadlock of Euler Angle
- error Can not find a handler for URI 'vget /camera/0/lit' HOT 2
- Can you add support for Unreal Engine 5.3 or higher? HOT 2
- UE5.2 Missing Headers for unrealcv 5.2 Branch HOT 1
- The photos taken by ue5.2 lit are blurry HOT 2
- Could not be compiled. Try rebuilding from source manually HOT 5
- Rendered depth is inconsistent wrt visualized one HOT 2
- Some error when run vget /unrealcv/status HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unrealcv.