Armandpl / skyline

code I wrote to win the 2023 Renault Digital 1/10th roborace
https://twitter.com/armand_dpl/status/1670922434445291521
4 stars 1 forks source link

calibrate camera #16

Closed Armandpl closed 1 year ago

Armandpl commented 1 year ago
Armandpl commented 1 year ago

I think the reason why the sim and actual cam look different is the lens distortion and maybe difference in extrinsinc parameters. put the sim camera and real car on the track at roughly the same position and compare the images

Armandpl commented 1 year ago

actually I could also measure lens distortion and then distort the sim image lmao maybe that's better, it removes one step in the inference pipeline

Armandpl commented 1 year ago

i dont understand why we estimate K when calibrating? isn't it just defined by the focal length when skew is null? is it only useful when there is skew? or do camera have small variation in focal length? do the calibration and see what's in the estimated K

Armandpl commented 1 year ago

understand how jetcam works, how are images resized, how does the fact that I can set any framerate works? can the cam do any framerate?

Armandpl commented 1 year ago

digging

Armandpl commented 1 year ago

quick calib gave this matrix for the camera from 640x480 images:

array([[269.24624039,   0.        , 345.9362606 ],
       [  0.        , 357.38497645, 256.33152125],
       [  0.        ,   0.        ,   1.        ]])

F(mm) = F(pixels) SensorWidth(mm) / ImageWidth (pixel) F_x (mm) = 269 3.691 / 640 = 1.55 mm F_y (mm) = 357 * 2.813 / 480 = 2.09 mm

doesn't seem to match 0.87 from the datasheet? Ok so it's because the calibration process can't guess the scale of things so the units don't matter. We can specify the sides of the squares if we want translation and rotation vectors to mean anything.

Armandpl commented 1 year ago

Ok so I'm starting to have a plan to match sim images and real images:

Armandpl commented 1 year ago

According to v4l2-ctl --list-formats these are the available modes for my imx219 camera:

ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'RG10'
        Name        : 10-bit Bayer RGRG/GBGB
                Size: Discrete 3264x2464
                        Interval: Discrete 0.048s (21.000 fps)
                Size: Discrete 3264x1848
                        Interval: Discrete 0.036s (28.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1640x1232
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.017s (60.000 fps)

gst_argus on the other hand lists the following modes:

GST_ARGUS: 3264 x 2464 FR = 21,000000 fps Duration = 47619048 ; Analog Gain range min 1,000000, max 10,625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 3264 x 1848 FR = 28,000001 fps Duration = 35714284 ; Analog Gain range min 1,000000, max 10,625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1920 x 1080 FR = 29,999999 fps Duration = 33333334 ; Analog Gain range min 1,000000, max 10,625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1640 x 1232 FR = 29,999999 fps Duration = 33333334 ; Analog Gain range min 1,000000, max 10,625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 59,999999 fps Duration = 16666667 ; Analog Gain range min 1,000000, max 10,625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 120,000005 fps Duration = 8333333 ; Analog Gain range min 1,000000, max 10,625000; Exposure Range min 13000, max 683709000;

I am tempted to use 1280x720 because it is the smallest resolution and I'm going to resize to 224x224 so might as well save some bandwith, however:

Armandpl commented 1 year ago

alright alright I got it:

Armandpl commented 1 year ago

ok so the values given by v4l seem to be the oned we should look at, I can't actually start the cam at e.g 120 fps. but the modes specified by v4l all seem to work the nvargus modes also don't match what's actually running? e.g if I ask for 720p 60 fps it is going to say 720p 120fps but then only actually provides 60fps

it also look like cv2 or gstreamer is able to change the framerate from 60 to whatever

Armandpl commented 1 year ago

ok so turns out there is a fisheye lens in cycles in blender, can use that instead of distorting the image after generating?

Action plan:

Armandpl commented 1 year ago

update update:

Armandpl commented 1 year ago

right right looks like i can distort the sim images w/ the fisheye calibration coeffs! and it matches the sim match_sim only issue now is the distorted image doesn't span the whole real image. why is that the case?

Armandpl commented 1 year ago

contexte et problèmes pour poser des questions à des gens:

Armandpl commented 1 year ago

try cropping, training network, deploying