fisheyegl icon indicating copy to clipboard operation
fisheyegl copied to clipboard

port over to OpenCV?

Open oneshell opened this issue 5 years ago • 2 comments

The live demo is fantastic, thanks for making this available.

I am trying to understand the math/algorithm going on behind the scenes. I want to calibrate a Raspberry Pi wide FOV camera using your approach, then use these lens parameters in an OpenCV loop to dewarp a video stream.

Your live demo does everything I want in terms of finding the parameters, now I'm struggling with how to apply this to a video feed in OpenCV.

Could you point me in the right direction?

Thanks,

oneshell avatar Sep 12 '19 15:09 oneshell

Hi, @oneshell - sorry, saw your email but was a bit busy yesterday. Glad to answer here!

The issue is that we are doing this via WebGL, so the conversion is done via a shader. We feed the variables in here:

https://github.com/jywarren/fisheyegl/blob/89d28f0dee943681192a708b59c076e3d5854652/src/fisheyegl.js#L257-L259

These are applied in the shaders:

https://github.com/jywarren/fisheyegl/blob/89d28f0dee943681192a708b59c076e3d5854652/src/shaders/fragment.glfs.js#L14-L25

However, I believe they are determining the geometry of a GL surface, rather than doing this per pixel (in a GL paradigm rather than a pixel mapper). GL isn't my strong suit, and I am not very familiar with OpenCV, but here are some resources that may help you use the parameters in OpenCV:

  • https://hackaday.io/project/12384-autofan-automated-control-of-air-flow/log/41862-correcting-for-lens-distortions
  • https://stackoverflow.com/questions/26602981/correct-barrel-distortion-in-opencv-manually-without-chessboard-image
  • https://answers.opencv.org/question/6332/lens-distortion-equation-changed-reference-please/

I'm not sure if they use the same model, but perhaps there is some way to convert and use the parameters in whatever model they are using?

Sorry I'm not more helpful!

jywarren avatar Sep 12 '19 18:09 jywarren

same problem here...

I would love to have a port to open-cv

guilhermecgs avatar Dec 12 '22 14:12 guilhermecgs