Create equirectangle Panorama from gear 360 images

Hello,
i am wondering if it is posible to transform raw images from a gear 360 camera like this (https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQp8hXHFrU_wwNbxZnbctW4amgx2vezzH7ekqB8VWO9XXzDkhgm) to a projected equirectangular image (Panorama).

As far as i understand the math behind it, it is a kind of “simple” translation function. Each pixel (x,y) in the source image is transferd to a new u,v position in the output image.

Because of static mounting of the lenses one function should fit to all gear 360 cameras. So, i am really not good in math and i only understand a little of the gmic syntax…

Am i right would this be possible with gmic?
Has someone a ready function or a hint where to find a transformation formular for my aim?

There are other possibilities like hugin, but i think gmic would be a lot easy once prepared a script.

Greetings

Ludger

Yes that’s certainly possible, see for example this post about re-projection

Do you have any information about the maths involved? Otherwise working that out could take a while…

Edit: I should add that a larger/clearer example input image would help!

I found this: Converting dual fisheye images into a spherical (equirectangular) projection which describes the nececarry steps, but i am not able to translate this to a formula and also no to code this in a gmic script.

But this seems to be the right direction.

Ludger

Given I know almost nothing about optics this is tricky for me. For now I can give a very basic example of fisheye to rectilinear (deliberately with no trig reductions):

example_unfisheye :
-local.
  100%,100%,1,3,0 -sh. 0
  -f. "
    init(H=h/2;W=w/2;F=H/1.5);
    X=x-W;Y=y-H;
    D=sqrt(X*X+Y*Y);
    T=atan2(Y,X);
    A=atan(D/F);
    R=2*F*sin(A/2);
    i(#-2,x,y,0,1)=R*sin(T)+H;
    R*cos(T)+W
  "
-rm. -warp.. .,0,2 -rm.
-endlocal

The idea is much as you suggest; build a map of source pixel (x,y) locations for each output location (x,y). The -warp command uses that map to actually ‘pull’ the pixels in.

Maths wise this is assuming an ‘equisolid’ lens, where distance from the centre of your fisheye image (i.e. radius) is defined as r = 2f * sin (angle from optical axis/2). In the example that’s used to work out the original angle from the axis, then remap to a ‘normal’ rectilinear r = f * tan (angle). (Edit: actually it’s the backwards transform - this is just how my brain works!)

Clearly this isn’t enough explanation for either the G’MIC commands or the maths. I hope to have time to do more with it later, but can’t promise anything :anguished:

1 Like

Not to detract from GMIC at all, but given the lens is fixed (correct?), you can probably script this in hugin very easily.

I bet if you uploaded a sample, you’d have several solutions :wink:

The script from @garagecoder is a very good base to start from.
I made a quick test which is shown here: https://youtu.be/Ozl_MX5ze3Y

The first shown image is the expected result, the second the source image, the third the result from the script.

As you see in the first source image the two lenses are fix focus lenses with a field of view of 195°.

Thanks

Diving deeper into gmic…

So, i found that @garagecoder made a perfect script to deal with one fish eye. The syntax of scripting such complex equotations is still hard to read for me. But i am trying expand the given code to my needs.

Thanks