moviepy
moviepy copied to clipboard
Headblur example (still) does not work
Expected Behavior
Running the example script headblur.py
, provided necessarily packages have been installed and necessary files are saved, should work.
Actual Behavior
Running the script errors, firstly with a trivial import error, then with a (afaik) non-trivial error:
cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'blur'
> Overload resolution failed:
> - Can't parse 'ksize'. Sequence item with index 0 has a wrong type
> - Can't parse 'ksize'. Sequence item with index 0 has a wrong type
Steps to Reproduce the Problem
[from project root]
- Firstly fix the missing imports by adding
from moviepy.editor import VideoFileClip, vfx
toexamples/headblur.py
(or changingfrom moviepy import *
tofrom moviepy.editor import *
) - Uncomment the line
manual_tracking(clip, fps=6, savefile="blurred_trajectory.txt")
- Run the code, do the clicking
- Observe the error (which repeats re-running the code after re-commenting out the
manual_tracking
line):
.../venv38/lib/python3.8/site-packages/moviepy/video/fx/headblur.py", line 44, in fl
blurred = cv2.blur(orig, (r_blur, r_blur))
cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'blur'
> Overload resolution failed:
> - Can't parse 'ksize'. Sequence item with index 0 has a wrong type
> - Can't parse 'ksize'. Sequence item with index 0 has a wrong type
Note: the variable r_blur
is a float, if I replace that with int(r_blur)
, I get the below error instead:
..../venv38/lib/python3.8/site-packages/moviepy/video/fx/headblur.py", line 45, in fl
im[y1:y2, x1:x2] = mask * blurred + (1 - mask) * orig
ValueError: assignment destination is read-only
Specifications
- Python Version: 3.8
- Moviepy Version: 2.0.0.dev2 (same issue with v1.0.3)
- Platform Name: ubuntu
- Platform Version: 20.04
- opencv-python==4.5.5.64
For clarity: I started trying to use the headblur script from the docs ( https://zulko.github.io/moviepy/examples/headblur.html ), but moved to using the updated version on master branch ( https://github.com/Zulko/moviepy/blob/master/examples/headblur.py ), as I saw issues had been raised & closed regarding the doc version.
This issue relates to the updated instructions on master branch