AdamSpannbauer / python_video_stab

A Python package to stabilize videos using OpenCV

Home Page:https://adamspannbauer.github.io/python_video_stab/html/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Command Line Parameters vs. Python Interface

SBCV opened this issue · comments

Hey,
is there a specific reason why some parameters of the "stabilize" method (like smoothing_window) aren't accessible from the command line?
On the contrary, it would be also nice to have a progress bar, when calling "stabilize(...)" using the VidStab class.

Cheers
Sebastian

Hi @SBCV,

I agree that adding some more parameters to the CLI would be a better design. I created it overly basic for the sake of simplicity, but it is lacking some options that would be helpful.

As for the progress bar, you should see a progress bar if you run a python script that contains a call to stabilize (see below). Is your request more specifically to see the progress bar if running Python code via REPL or are you not seeing progress in cases like the example below?

~/Documents/github/python_video_stab $ python visual_inspection_tests.py 
Stabilizing |████████████████████████████████| 100%

Hey,
thank you for the quick reply.

I used Pycharm to execute VidStab. Unfortunately, the Pycharm console does not show the progress bar. But the progress bar appears when I call the script from command line.
A bit strange, but obviously some Pycharm related issue. Thank you.

Since running the main python file from command line shows the progress bar, I think it is not that bad, that the parameters aren't accessible from the command line.

Best regards

@SBCV to show the progress bar when using Run or Debug in PyCharm you can set the Emulate terminal in output console. This option is found in under Run-> Edit Configurations.... Below shows the options window and the resulting output (progress bar is written to stderr which causes the red text).

image

I've added additional options to CLI in branch cli_consistency#65. Kept original CLI args at same positions and added new options to end.

usage: python -m vidstab [-h] -i INPUT -o OUTPUT [-p PLAYBACK] [-k KEYPOINTMETHOD]
                   [-s SMOOTHWINDOW] [-m MAXFRAMES] [-b BORDERTYPE]
                   [-z BORDERSIZE] [-l LAYERFRAMES]

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        Path to input video to stabilize.
  -o OUTPUT, --output OUTPUT
                        Path to save stabilized video.
  -p PLAYBACK, --playback PLAYBACK
                        Should stabilization be played to screen? (y/n)
  -k KEYPOINTMETHOD, --keyPointMethod KEYPOINTMETHOD
                        Name of keypoint detector to use.
  -s SMOOTHWINDOW, --smoothWindow SMOOTHWINDOW
                        Smoothing window to use while smoothing frame
                        transforms.
  -m MAXFRAMES, --maxFrames MAXFRAMES
                        Max frames to process in video. Negative values will
                        not apply limit.
  -b BORDERTYPE, --borderType BORDERTYPE
                        How to fill in empty border caused by frame shifting.
                        Options: ['black', 'reflect', 'replicate']
  -z BORDERSIZE, --borderSize BORDERSIZE
                        If positive, borderType is added equal to borderSize.
                        If negative, cropping is applied. If 'auto', auto
                        sizing is used to fit transformations.
  -l LAYERFRAMES, --layerFrames LAYERFRAMES
                        Should frame layering effect be applied to output
                        video? (y/n)

Wow. Just wow.
Perfect! Thank you!

Final update

Tests passed, branch merged, & updated version released to PyPi.

Upgrade should now be available via (updated CLI available in vidstab >= 1.5.6):

pip install --upgrade vidstab