News for hackers. Stuff that matters.
Re:Mrcal – Camera Calibrations and More by syntaxing on Tuesday March 02, 2021 @11:25AM (#26316986)
This is awesome, it always bothered me that if you wanted to calibrate a camera, 99.9999% of the websites or tutorials you search for is using OpenCV or Matlab...
Re:Mrcal – Camera Calibrations and More by kristopolous on Tuesday March 02, 2021 @12:17PM (#26317654)
it's worth noting there's pretty trivial ffmpeg solutions with the lenscorrection filter for people who don't need any accuracy and just want to stop looking like a distorted alien. (https://www.danielplayfaircal.com/blogging/ffmpeg/lensfun/v3...)

Dima's solutions in mrcal are way more accurate and can even accommodate manufacturing imperfections with localized warping and other less-than-perfect real world realities but for the times such things don't matter (like say correcting a webcam for your zoom calls instead of, say, landing on mars), there's always lenscorrection.

If you're trying to set up a really basic pipeline for lens correction (more like adjustment) in linux that works with the web browser and apps here's a gross simplification

1. create a virtual v4l device with the v4l2loopback module, set exclusive_caps=1 (example: modprobe v4l2loopback devices=1 exclusive_caps=1)

2. Do something like ffmpeg -i /dev/video0 -vf "lenscorrection=cx=0.5:cy=0.5:k1=-0.015:k2=-0.072" -f v4l2 /dev/video2 where the first argument is the real video and the second is the virtual (do v4l2-ctl --list-devices) to see the devices

3. Point teams or whatever to the virtual device, /dev/video2 in this example.

You can use this same trick to force resolutions, compression ratios, rotate and mirror webcams - it's pretty useful.