-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Optical flow python example will cause an error src.empty() in function 'cvtColor' when the video ends #21223
Description
https://github.com/opencv/opencv/blob/master/samples/python/tutorial_code/video/optical_flow/optical_flow.py

Traceback (most recent call last):
File "optical_flow.py", line 37, in
frame_gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
cv2.error: OpenCV(4.5.3) /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-req-build-ucsrqn3m/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
https://github.com/opencv/opencv/blob/master/samples/python/tutorial_code/video/optical_flow/optical_flow_dense.py

This problem occurs when the video is read to the last frame
Traceback (most recent call last):
File "optical_flow_dense.py", line 10, in
next = cv.cvtColor(frame2,cv.COLOR_BGR2GRAY)
cv2.error: OpenCV(4.5.3) /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-req-build-ucsrqn3m/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
System information (version)
- OpenCV => ❔
- Operating System / Platform => ❔
- Compiler => ❔
Detailed description
Steps to reproduce
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues,
forum.opencv.org, Stack Overflow, etc and have not found solution - I updated to latest OpenCV version and the issue is still there
- There is reproducer code and related data files: videos, images, onnx, etc