I want to convert point (i.e 622,622) coordinates to other dimensional coordinates (622*1186) Using OpenCV. i.e I currently plotted the data at Image Size 640 * 640.
Now I want to plot it at 622*1186 Image size. I want to know the formula so that I can convert them. I am working with OpenCV.
Ok, So I am answering my own Question!
The formula to convert the point (x, y) from the original size (width_original, height_original) to a new size (width_new, height_new) is:
x_new = x * width_new / width_original
y_new = y * height_new / height_original
So, in the above case:
x_new = 622 * 1186 / 640 = 622 * 1186 / 640 = 1176.25
y_new = 622 * 1186 / 640 = 622 * 1186 / 640 = 1176.25
So the new coordinates of the point would be (1176.25, 1176.25) in the 622 x 1186 image.
I am trying to estimate a gues for the intrinsic matrix, K, of a DJI Phantom 4 drone. I know that the form of this matrix is:
but i cant seem to get the units right. Looking up the specs at https://www.dji.com/phantom-4/info#specs I find that the focal length is 8.88 (dosnt say units...) and the image dimensions are 4000x3000. WHat would K look like with these?
*PS, I am scaling down the images so they are smaller. Will this effect the K matrix I should use for openCV?
The page the OP linked to lists a FOV of 94 degrees. With an image width of 4000 pixels this corresponds to a focal length of
f = (4000 / 2) pixels / tan(94 / 2 degrees) = 1865 pixels
Absent any other calibration data, one should therefore use an estimated camera matrix of the form:
K = [ [1865, 0 , 2000],
[0 , 1865, 1500],
[0 , 0 , 1 ] ]
OP, you may have confused the specs of the P4 and the P4Pro, which have different sensors and lenses. The P4Pro, not the P4, has a focal length of 8.8mm. The P4 has a focal length of 3.61mm.
If you are indeed using images from a P4, Francesco's answer is correct.
However, if you are actually using images from a P4Pro, you need to use these values:
f = (4864 / 2) pixels / tan(84 / 2 degrees) = 2701 pixels
K = [ [2701, 0 , 2432],
[0 , 2701, 1824],
[0 , 0 , 1 ] ]
For future reference for anyone that may find this answer, here are the relevant specs for the P4 and P4Pro sensors/lenses:
Phantom 4:
Sensor size: 1/2.3" (6.17mm x 4.55mm)
Focal length (actual): 3.61mm
Focal length (35mm equivalent): 20mm
FOV: 94°
Image size: 4000×3000 pixels
Video frame size
UHD: 4096×2160 pixels
4K: 3840×2160 pixels
2.7K: 2704×1520 pixels
FHD: 1920×1080 pixels
HD: 1280×720 pixels
Phantom 4 Pro:
Sensor size: 1" (12.8mm x 9.6mm)
Focal length (actual): 8.88mm
Focal length (35mm equivalent): 24mm
FOV: 84°
Image size
3:2 aspect ratio: 5472×3648 pixels
4:3 aspect ratio: 4864×3648 pixels
16:9 aspect ratio: 5472×3078 pixels
Video frame size
C4K: 4096×2160 pixels
4K: 3840×2160 pixels
2.7K: 2720×1530 pixels
FHD: 1920×1080 pixels
HD: 1280×720 pixels
I think it is much better to work from the focal length in mm
https://www.dxomark.com/Cameras/DJI/Phantom4-Pro---Specifications
For P4 Pro:
13.2 x 8.8 so pixel size is = 0.00241 or 2.41 um focal length is 8.8mm
so focal length in pixel = 8.8 / 0.00241 = 3684.6 pixels
Incidentally in the image metadata, there is a field:
CalibratedFocalLength 3666.666504 (use exiftool to find it) so I think K should be
K = [ [3666.6, 0 , 2432],
[0 , 3666.6, 1824],
[0 , 0 , 1 ] ]
If 110 X 110 dimension, editor generates pixel by pixel (COL X ROW) rgb color code starting from 0 to 109.
Example :
px0=,,,,,,,,,,,,e6ebf8,c6d1ef,b6c3eb,9fb1e5,a0b2e5,a1b3e6,8ba1df,869fdf,87a0e0,88a0df,8ba0e0,8da2e2,8ea3e2,8fa3e2,92a7e6,93a8e6,93a8e4,97abe8,9baaeb,9baaeb,9caaeb,9caaeb,9dabec,9eabed,9eaded,9dafed,9ab0e9,9aafe5,9cb2e6,9dafe1,9eafde,9eaed9,a0add7,a3add8,a2b2dd,a2b2df,a3b3e1,a4b4e1,a6b6e4,a7b8e4,a8b9e5,a9bae6,aeb9e6,afbae7,afbae8,afbbec,afbdf0,abbaf0,abbaf1,a9baf1,abbdf1,a7b9eb,a2b4e6,99aade,92a4d7,8ea0d1,8898cc,8898cb,8a99cb,8d9bcd,919ecf,909dcf,8d9bcc,8b99ca,8896c7,8693c4,8591c2,8391c0,8795c4,8c99c9,909ecd,93a0d0,95a3d2,99a6d7,99a7d6,97a6d4,98a6d7,96a3d4,92a0d1,909dcc,a1aad2,9aa4cb,959ec7,acb3d0,bdc2d8,e2e4ed,,,,,,,,,,,,|px1=,,,,,,,,,dce2f4,abbae6,8298da,7b93d9,7d95db,7f97dd,8098de,829add,839bde,839bde,849ddd,859ede,87a0e0,8ba0e0,8a9fdf,8ea3e2,90a2e2,8da0dd,9aadea,99ace7,96a9e3,a5b3eb,a1aee6,9eace4,99a6de,a1afe7,a1aee6,a0aee6,9eade4,92a5da,8b9ccd,8698c5,8490bb,737da2,7880a2,8286a4,888ba7,8990ac,8d96b2,949db9,969fbb,9ba4c0,9da6c2,,,,,,,,,|px2=,,,,,,,
and so on until px109