Fisheye 235° to equirectangular

A plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.
jumpjack
Posts: 61
Joined: 2010-12-10T05:29:16-07:00
Authentication code: 8675308

Fisheye 235° to equirectangular

Post by jumpjack » 2017-04-20T13:00:58-07:00

How can I convert a fisheye picture with FOV=235° into an equirectangular projection?

Bonzo
Posts: 2970
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Fisheye 235° to equirectangular

Post by Bonzo » 2017-04-20T13:16:03-07:00

You could try one of fmw42's scripts; for instance this one: http://www.fmwconcepts.com/imagemagick/ ... /index.php

jumpjack
Posts: 61
Joined: 2010-12-10T05:29:16-07:00
Authentication code: 8675308

Re: Fisheye 235° to equirectangular

Post by jumpjack » 2017-04-20T13:29:46-07:00

It looks interesting, but how can I run it in Windows?

Bonzo
Posts: 2970
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Fisheye 235° to equirectangular

Post by Bonzo » 2017-04-20T13:38:56-07:00

Windows 10 has a developer mode where you can run bash but I tried one of fmw42's scripts before and it came up with errors. I think it is for basic bash commands only.

Install Cygwin which might work and there are some instructions in snibgo's site: http://im.snibgo.com/cygwin.htm

Find some other software to do the job.

jumpjack
Posts: 61
Joined: 2010-12-10T05:29:16-07:00
Authentication code: 8675308

Re: Fisheye 235° to equirectangular

Post by jumpjack » 2017-04-20T13:48:27-07:00

I'm studying "Generic Mapping Tools" (GMT), Flexify Plugin, NASA G.projector, Marzipano tool,... but still can't figure out how to get what I need. :-(

User avatar
fmw42
Posts: 24004
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fisheye 235° to equirectangular

Post by fmw42 » 2017-04-20T14:00:03-07:00

Please identify your IM version and platform when asking questions on this forum.

Please post an example input and output image (to some free hosting service and put the URLs here). Also post any links to the camera/lens system being used.

I suspect you might want my script at http://www.fmwconcepts.com/imagemagick/ ... /index.php, which allows large FOV. The last example shows the equivalent Imagemagick commands to achieve most of what my script does and they can be run individually in Windows. See http://www.imagemagick.org/Usage/windows/ for any potential Windows vs Unix syntax issues with Imagemagick.

My scripts only run in Unix-like environments. So on Windows you would need to install Cygwin or try Windows 10.

jumpjack
Posts: 61
Joined: 2010-12-10T05:29:16-07:00
Authentication code: 8675308

Re: Fisheye 235° to equirectangular

Post by jumpjack » 2017-04-21T01:22:17-07:00

SED converter is not working on my system (Win7), it complains about some "garbage" being present in cim.txt.
I'll try with manual conversion described in last example.

snibgo
Posts: 10831
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Fisheye 235° to equirectangular

Post by snibgo » 2017-04-21T03:31:12-07:00

On my Windows 8.1 computer, with Cygwin, Fred's fisheye2pano script, example 1...

Code: Select all

bash fisheye2pano -v -90,52.5 -h 211.5 -f angle testimage2.jpg out.png
... runs with no problem, and makes the expected output.
snibgo's IM pages: im.snibgo.com

jumpjack
Posts: 61
Joined: 2010-12-10T05:29:16-07:00
Authentication code: 8675308

Re: Fisheye 235° to equirectangular

Post by jumpjack » 2018-07-15T13:48:07-07:00

I installed Linux inside Windows 10, so now I can run BASH; I copied the script directly inside Imagemagick folder, together with test image, but if I run this commmand:

Code: Select all

bash fisheye2pano -v -90,52.5 -h 211.5 -f angle test.jpg out.png
I get these errors:

Code: Select all

fisheye2pano: line 197: -h}: command not found
fisheye2pano: line 294: [: too many arguments
fisheye2pano: line 302: [: too many arguments
fisheye2pano: line 303: [: too many arguments
fisheye2pano: line 304: [: too many arguments
fisheye2pano: line 229: [: too many arguments
fisheye2pano: line 278: [: too many arguments
fisheye2pano: line 286: [: too many arguments
fisheye2pano: line 229: [: too many arguments
fisheye2pano: line 411: convert: command not found

--- FILE test.jpg DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---


basename $PROGNAME:
sed: can't read dirname $PROGNAME/basename $PROGNAME: No such file or directory
Line 197 is:

Code: Select all

PROGNAME=`type $0 | awk `{print $3}``  # search for executable on path

User avatar
fmw42
Posts: 24004
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fisheye 235° to equirectangular

Post by fmw42 » 2018-07-15T14:04:33-07:00

There is no "-h}" at that line in my script! Not sure what is going on. But I would suggest you test with a simple ImageMagick command line first. If that works, then try one of my simpler scripts such as 2colorthresh. But be sure you have followed my Pointers For Use on my home page at my like below. Also be sure you have all the Unix commands, such as bc, expr, type, sed, tr, etc.

I do not think you needed to install a separate Linux. Windows 10 comes with its own Unix. See the notes on my home page and especially, http://www.howtogeek.com/249966/how-to- ... indows-10/

Are you calling the script and the images from a Linux terminal or from a Windows CMD window?

jumpjack
Posts: 61
Joined: 2010-12-10T05:29:16-07:00
Authentication code: 8675308

Re: Fisheye 235° to equirectangular

Post by jumpjack » 2018-07-16T01:20:48-07:00

fmw42 wrote:
2018-07-15T14:04:33-07:00
There is no "-h}" at that line in my script!
I know, i pasted the line in my post... but it's what the command prompt says.
It also says another weird thing:

Code: Select all

--- FILE test.jpg DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---
This is not true, it's a regular JPG image which opens fine in Windows image viewer.
But this could mean my environment is not properly configured.
Not sure what is going on. But I would suggest you test with a simple ImageMagick command line first. If that works, then try one of my simpler scripts such as 2colorthresh. But be sure you have followed my Pointers For Use on my home page at my like below. Also be sure you have all the Unix commands, such as bc, expr, type, sed, tr, etc.
I'll try.
I do not think you needed to install a separate Linux. Windows 10 comes with its own Unix.
Yes I read so, but just typing "bash" in ALT+R window or in CMD window resulted in an error message redirecting to Windows Store to download Linux, so I did that.
See the notes on my home page and especially, http://www.howtogeek.com/249966/how-to- ... indows-10/
Yes, this is what I did.
Are you calling the script and the images from a Linux terminal or from a Windows CMD window?
From Windows CMD window.
But I don't know what happens when calling bash from inside CMD window: does bash use current DOS folder as its current folder or as its home folder? How do I make a Windows folder directly accessible to bash?

User avatar
fmw42
Posts: 24004
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fisheye 235° to equirectangular

Post by fmw42 » 2018-07-16T10:00:57-07:00

You must call the script from a Linux window, not a Windows DOS CMD window. If the script errors earlier in the argument parsing, then it may fail later with other messages about not being able to read the input image. So I would not worry about the second message. You need to run the script from a proper Linux terminal and then see if you get the -h error, which is not at the line you mention, but in the argument parsing.

Sorry I am not Windows (Unix) user, so cannot advise. But you should read more about the Windows built in Linux and how to get to its terminal window.

jumpjack
Posts: 61
Joined: 2010-12-10T05:29:16-07:00
Authentication code: 8675308

Re: Fisheye 235° to equirectangular

Post by jumpjack » 2018-07-16T12:07:30-07:00

It looks like your scripts cannot directly be used in Windows bash, they need a little tuning: when calling ImageMagick executables, script must use syntax ./FILENAME.exe rather than just the filename, and script itself must end by ".sh".

Apart from this, one version of your script which I have had characters ' and ` messed up; I downloaded it again and now they are ok.

But that's not enough:
running this command from command prompt:

Code: Select all

bash fisheye2pano_win.sh -v -90,52.5 -h 211.5 -f angle test.jpg out.png
results in these errors:

Code: Select all

line 197: type: fisheye2pano_win.sh: not found
dirname: missing operand
Try 'dirname --help' for more information.
basename: missing operand
Try 'basename --help' for more information.
fisheye2pano_win.sh: line 301: bc: command not found
fisheye2pano_win.sh: line 302: bc: command not found
fisheye2pano_win.sh: line 303: bc: command not found
fisheye2pano_win.sh: line 304: [: -eq: unary operator expected
fisheye2pano_win.sh: line 305: [: -eq: unary operator expected
fisheye2pano_win.sh: line 306: [: -eq: unary operator expected
fisheye2pano_win.sh: line 287: bc: command not found
fisheye2pano_win.sh: line 288: [: -eq: unary operator expected
fisheye2pano_win.sh: line 452: bc: command not found
fisheye2pano_win.sh: line 452: [: -eq: unary operator expected
fisheye2pano_win.sh: line 479: bc: command not found
fisheye2pano_win.sh: line 479: [: -eq: unary operator expected
Mogrify/Image/.[fisheye2pano_430.mpc]: 1 of 2, 100% complete
A little less errors appear if I run bash and then I run:

Code: Select all

fisheye2pano_win.sh -v -90,52.5 -h 211.5 -f angle test.jpg out.png

Code: Select all

line 197: type: fisheye2pano_win.sh: not found
fisheye2pano_win.sh: line 301: bc: command not found
fisheye2pano_win.sh: line 302: bc: command not found
fisheye2pano_win.sh: line 303: bc: command not found
fisheye2pano_win.sh: line 304: [: -eq: unary operator expected
fisheye2pano_win.sh: line 305: [: -eq: unary operator expected
fisheye2pano_win.sh: line 306: [: -eq: unary operator expected
fisheye2pano_win.sh: line 287: bc: command not found
fisheye2pano_win.sh: line 288: [: -eq: unary operator expected
fisheye2pano_win.sh: line 452: bc: command not found
fisheye2pano_win.sh: line 452: [: -eq: unary operator expected
fisheye2pano_win.sh: line 479: bc: command not found
fisheye2pano_win.sh: line 479: [: -eq: unary operator expected
But it looks like they are jut warnings, because then the scripts starts processing:

Code: Select all

Mogrify/Image/.[fisheye2pano_430.mpc]: 1 of 2, 100% complete
image[]: 1 of 1621, 00% complete
At the end of the processing I eventually get the equirectangular image. I have yet to test if I can properly view it in some SW, but in the meantime I have a question: is it possible for the script to add to the final image the exif data needed by Facebook (and I guess other platforms and tools) to recognize it as a panoramic photo? (called "spherical photo)
https://developers.google.com/streetvie ... l-metadata
https://developers.facebook.com/docs/gr ... nce/photo/

Second question:
which are the correct parameters to use to convert a 235° fisheyes photo into equirectangular? I don't see any "235" in the commandline I used (copied from this thread).

User avatar
fmw42
Posts: 24004
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fisheye 235° to equirectangular

Post by fmw42 » 2018-07-16T12:27:52-07:00

Adding .exe is not correct for Linux.

To get rid of those issue, you need to follow the directions on my home page to put the path to the scripts into your PATH environment variable. Without doing that, the script cannot use the unix type command to find the script. As you found out, those are warnings. That also allows you to run the script without using bash and from any directory. The other issue is that you need to be sure that your Windows 10 unix has all the unix tools it needs. It seems that you do not have the unix calculator, bc, installed. This was also noted on my home page about using Windows 10 unix.

Please read my home page carefully about the Pointers for Use and the Windows 10 installation notes.

ImageMagick does not have tools to add XMP or EXIF meta data. Any EXIF data would need to be added perhaps by EXIFTOOL. I am not sure it can write XMP data.

See the -h argument for the angular coverage in degrees of your fisheye. See my examples for other types of fisheye views and angular coverage.

jumpjack
Posts: 61
Joined: 2010-12-10T05:29:16-07:00
Authentication code: 8675308

Re: Fisheye 235° to equirectangular

Post by jumpjack » 2018-07-16T12:30:49-07:00

I have the windows versione of ImageMagick, it uses .exe files.

So bc command is not necessary for a proper output?

What about this error?
[: -eq: unary operator expected

Post Reply