视频中的移动物体上覆盖图像(Argumented Reality / OpenCv) [英] Overlay Image on moving object in Video (Argumented Reality / OpenCv)

查看:261
本文介绍了视频中的移动物体上覆盖图像(Argumented Reality / OpenCv)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 FFmpeg 通过此命令覆盖图像/表情符号视频 -

  -  i+ inputfilePath +-filter_complex+[0] [1] overlay = enable ='between(t,+ startTime +,+ endTime +)'[v1]+ - map [v0] -map 0:a+ OutputfilePath; 

但以上命令只覆盖影片并保持静止。



Instagram Snapchat 中,有新的



这里是链接



可以通过 FFmpeg



我认为拥有 OPENCV 论证现实知识的人可以帮助这个。它是安静的,类似于 AR ,因为我们需要移动/放大表情符号我们想要的视频/现场凸轮。

解决方案

根据重叠规范:
https:// ffmpeg.org/ffmpeg-filters.html#overlay-1



当您指定时间间隔时,只会在该时间间隔发生:



例如,要启用10秒至3分钟的模糊滤镜(smartblur):

  smartblur = enable ='between(t,10,3 * 60)'

需要做的是在特定坐标上覆盖图像,例如在固定的x和y处的以下内容:

  ffmpeg -i rtsp :// [host]:[port] -i x.png -filter_complex'overlay = 10:main_h-overlay_h-10'http:// [host]:[post] /output.ogg 

现在的想法是根据当前帧计算这些坐标e的视频和力过滤器在每个帧上使用改变的坐标。
例如基于时间:
FFmpeg从一个像素坐标移动到另一个像素坐标

  ffmpeg -i bg.mp4 -i fg.mkv -filter_complex \ 
[0:v] [1:v] overlay = enable ='between =(t,10,20)':x = 720 + t * 28:y = t * 10 [out] \
-map[out]output.mkv

或使用其他一些表达式:
http://ffmpeg.org/ffmpeg-utils.html#Expression - 评估



不幸的是,在使用猫移动他的头部或绘制x和y笔的有限表达式之前,需要找到一个公式。它可以是时间上的线性,三角函数或其他依赖关系:

  x = sin(t)

随着自由移动,并不总是可能。



要更精确找到一个对象坐标来叠加一些应该可能提供自己的过滤器(ffmpeg是开源的)类似于overlay:
https://github.com/FFmpeg/FFmpeg/blob/master/libavfilter/vf_overlay.c



根据外部文件计算x和y(如果它是一个静态视频,可以一次转储所有x和y)或执行某些图像处理以查找特定区域。



希望它会给你一个想法和方向移动到。
这是非常有趣的功能。


I am using FFmpeg to overlay image/emoji on video by this command -

"-i "+inputfilePath+" -filter_complex "+"[0][1]overlay=enable='between(t,"+startTime+","+endTime+")'[v1]"+" -map [v0] -map 0:a "+OutputfilePath;  

But above command only overlay image over video and stays still.

In Instagram and Snapchat there is New pin feature. I want exactly same ,eg blur on moving faces or as in below videos -

Here is link.

Is it possible via FFmpeg?

I think someone with OPENCV or Argumented Reality knowledge can help in this. It is quiet similar to AR as we need to move/zoom emoji exactly where we want to on video/live cam.

解决方案

Based on overlay specification: https://ffmpeg.org/ffmpeg-filters.html#overlay-1

when you specify time interval it will happen only at that time interval:

For example, to enable a blur filter (smartblur) from 10 seconds to 3 minutes:

smartblur = enable='between(t,10,3*60)'

What you need to do is to overlay an image at specific coordinates, for example the following at fixed x and y:

ffmpeg -i rtsp://[host]:[port] -i x.png -filter_complex 'overlay=10:main_h-overlay_h-10' http://[host]:[post]/output.ogg

Now the idea is to calculate those coordinates based on the current frame of the video and force filter to use changed coordinates on every frame. For example based on time: FFmpeg move overlay from one pixel coordinate to another

ffmpeg -i bg.mp4 -i fg.mkv -filter_complex \
"[0:v][1:v]overlay=enable='between=(t,10,20)':x=720+t*28:y=t*10[out]" \
-map "[out]" output.mkv

Or using some other expressions: http://ffmpeg.org/ffmpeg-utils.html#Expression-Evaluation

Unfortunately this will require to find a formula before using those limited expressions of cat moving his head or drawing a pen for x and y. It can be linear, trigonometric or other dependency from time:

x=sin(t)

With the free move it is not always possible.

To be more precise of finding an object coordinates to overlay something it should be possible to provide your own filter(ffmpeg is open sourced) similar to overlay: https://github.com/FFmpeg/FFmpeg/blob/master/libavfilter/vf_overlay.c

Calculating x and y either based on external file(where you can dump all x and y for all times if it is a static video) or do some image processing to find specific region.

Hopefully it will give you an idea and direction to move to. It's very interesting feature.

这篇关于视频中的移动物体上覆盖图像(Argumented Reality / OpenCv)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆