视频稳像学习笔记

举报
风吹稻花香 发表于 2022/01/22 22:25:32 2022/01/22
【摘要】 https://github.com/AdamSpannbauer/python_video_stab 也有运行代码 https://github.com/abhiTronix/vidgear # import required librariesfrom vidgear.gears import VideoGearimpor...

https://github.com/AdamSpannbauer/python_video_stab

也有运行代码

https://github.com/abhiTronix/vidgear


  
  1. # import required libraries
  2. from vidgear.gears import VideoGear
  3. import numpy as np
  4. import cv2
  5. # open any valid video stream with stabilization enabled(`stabilize = True`)
  6. stream_stab = VideoGear(source = "test.mp4", stabilize = True).start()
  7. # open same stream without stabilization for comparison
  8. stream_org = VideoGear(source = "test.mp4").start()
  9. # loop over
  10. while True:
  11. # read stabilized frames
  12. frame_stab = stream_stab.read()
  13. # check for stabilized frame if Nonetype
  14. if frame_stab is None:
  15. break
  16. # read un-stabilized frame
  17. frame_org = stream_org.read()
  18. # concatenate both frames
  19. output_frame = np.concatenate((frame_org, frame_stab), axis=1)
  20. # put text over concatenated frame
  21. cv2.putText(
  22. output_frame, "Before", (10, output_frame.shape[0] - 10), cv2.FONT_HERSHEY_SIMPLEX,
  23. 0.6, (0, 255, 0), 2,
  24. )
  25. cv2.putText(
  26. output_frame, "After", (output_frame.shape[1] // 2 + 10, output_frame.shape[0] - 10),
  27. cv2.FONT_HERSHEY_SIMPLEX,
  28. 0.6, (0, 255, 0), 2,
  29. )
  30. # Show output window
  31. cv2.imshow("Stabilized Frame", output_frame)
  32. # check for 'q' key if pressed
  33. key = cv2.waitKey(1) & 0xFF
  34. if key == ord("q"):
  35. break
  36. # close output window
  37. cv2.destroyAllWindows()
  38. # safely close both video streams
  39. stream_org.stop()
  40. stream_stab.stop()

c++ opencv的:

https://github.com/Lakshya-Kejriwal/Real-Time-Video-Stabilization

c的,需要自己编译,需要ffmpeg,能处理视频

https://github.com/georgmartius/vid.stab

Using default values:

ffmpeg -i input.mp4 -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 out_stabilized.mp4
 

Note the use of the ffmpeg's unsharp filter which is always recommended.

Zooming-in a bit more and load transform data from a given file:

ffmpeg -i input.mp4 -vf vidstabtransform=zoom=5:input="mytransforms.trf" out_stabilized.mp4
 

Smoothening the video even more:

ffmpeg -i input.mp4 -vf vidstabtransform=smoothing=30:input="mytransforms.trf" out_stabilized.mp4
 

文章来源: blog.csdn.net,作者:AI视觉网奇,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/jacke121/article/details/109789501

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。