Skip to content

Advanced usage

hn-88 edited this page Jul 30, 2024 · 16 revisions

Keyboard shortcuts

The keyboard shortcuts available are listed at the bottom of the readme.

Command-line support and image sequences

Starting with version 3.10, command-line arguments are supported - exactly three file paths should be supplied, in the correct order - ini file first, the input path next, and output path third. This enables image sequences also to be used for input or output, if arguments are supplied in the correct syntax.

Examples:

ocvwarp.exe "c:\Downloads\ocvwarp.ini" "c:\Downloads\input.mp4" "c:\Downloads\output.mp4" 
"OCVWarp-3.10-x64Win10" OCVWarp.ini "C:\Users\user\Downloads\img%03d.jpg" "C:\Users\user\Downloads\imgW%03d.jpg"
(works if fourcc is set to mjpe in the ini file - and in this case, would work if fourcc is set to NULL too, since input is also a frame sequence)

Caveats for image sequences

Starting with version 4.00, image sequences are supported via the UI also. Just choose one file of the image sequence, and OCVWarp will automatically create the required syntax like img_%02d.jpg for files like img_00.jpg, img_01.jpg, img_02.jpg, etc. But the automatic syntax change in OCVWarp only supports image sequences with zero-padded numbering - only sequences like img_%02d.jpg and not those like img_%2d.jpg.

If the image sequence has missing files, or the sequence is not numbered with single number increments, the program is likely to fail. In general, the formats supported by OpenCV's VideoCapture class should be OK when supplied as command-line arguments.

Single image files would work, if both input and output have similar filename patterns.

./ocvwarp OCVWarp.ini hanu0018.jpg hanuW.jpg
# does not work, OpenCV error, 
# error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): hanuW.jpg

./ocvwarp OCVWarp.ini hanu0018.jpg hanuW0018.jpg
# this works fine when FOURCC is set to NULL in the ini file.

Cloud usage

Command-line support enables the use of OCVWarp on headless virtual machines, cloud VMs, for example even on Google Cloud Shell . Just note that in the case of cloud shell, you will need to install the dependencies like

sudo apt install libopencv-dev

every time you start up the shell, since the VMs don't persist on logging out. Also note that in the case of cloud shell, the full path may need to be given in case the input and output paths are not in the same directory - shortcuts like ~ for home directory etc. cannot be used.

Codecs and formats

The possible fourcc values (indicating output codecs) are listed at fourcc.txt. Not all fourccs are supported on all containers (formats). For example, XVID is poorly supported on .mov files. And so on. Since ffmpeg is used by the backend, ffmpeg -formats will give you some idea of the supported formats, if you have ffmpeg installed. The OpenCV documentation also points to this page for a list of codecs and fourcc's (Archived page) when using ffmpeg as backend.

The Matroska container (.mkv) generally supports most codecs or fourccs.

Some known good combinations are
.avi with XVID - widely compatible
.mp4 with H264 - better quality for smaller file size
.mov with MJPEG - large file with high quality

Or you can just choose NULL in the ini file for the fourcc, the output file will then have the same fourcc as the input file.

Audio dubbing

Currently, OCVWarp does not support audio. The output video will not have an audio stream. You can dub audio using many tools like ffmpeg

Angles used for mapping

The current angles used are such that during the Fisheye to Equirectangular (360) conversion, the 0 to 90 degrees comes at the right extreme of the image, as shown using Paul's fulldome test pattern below - the fulldome test pattern

Paul's fulldome test pattern

is mapped to the Equirectangular image below by transform type 3 when anglex and angley are set to zero:

Paul's fulldome test pattern after transform type 3

Unfortunately, doing the reverse transform using transform type 1, again with anglex=angley=0, results in an image which is left-right mirrored as below. Probably this is an issue and must be fixed.

Paul's fulldome test pattern after transform type 3 and then transform 1