spmallick / learnopencv

Learn OpenCV : C++ and Python Examples
https://www.learnopencv.com/
21.38k stars 11.63k forks source link

Optical-Flow-in-OpenCV #632

Open niu1970 opened 2 years ago

niu1970 commented 2 years ago

(yolov5) C:\Users\renfang\Desktop\基于视频的车辆转弯安全提醒方案\Optical-Flow-in-OpenCV>python demo.py --algorithm lucaskanade --video_path videos\people.mp4 Traceback (most recent call last): File "demo.py", line 38, in main() File "demo.py", line 24, in main lucas_kanade_method(video_path) File "C:\Users\renfang\Desktop\基于视频的车辆转弯安全提醒方案\Optical-Flow-in-OpenCV\algorithms\lucas_kanade.py", line 33, in lucas_kanade_method good_new = p1[st == 1] TypeError: 'NoneType' object is not subscriptable

metro-smiles commented 2 years ago

This is perhaps happening because the corner detector was not able to track the keypoints (corners) in the new image. Hence, p1 came out to be None. You should handle this case by using try/Except.

Souleymane0511 commented 2 years ago

I saw your article in website:[https://learnopencv.com/optical-flow-in-opencv/#disqus_thread] DenseOpticalFlow , there is a special image in the part of algorithm visualization of Dense Optical Flow, which used lines to draw optical flow. I don't know whether can you see this image or not. And the code in your personal website can not get this image. can you answer my question? Thank you!