用图像替换检测到的对象(imageProcessing) [英] Replacing detected object in a frame with an image.(imageProcessing)

查看:169
本文介绍了用图像替换检测到的对象(imageProcessing)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

概述:



我正在开展视频制作项目。我使用的技术有:imageMagick,php,ffmpeg。



当前状态



目前,该项目能够使用图像和文本创建视频,并且几乎没有基本的转换。我正在做的是使用imagemagick使用输入图像(在其中具有过渡效果)来创建gif,然后将所有gifs转换为视频,并将视频连接在一起。



下一步移动(我的问题):



我现在已经把它提升到了一个新的水平。所以,我所拥有的是一个视频(1920x1080),其中有一些白框(1280x720),每帧都保持不变。我想用一些我想使用的图像(1280x720)替换出现在视频某些帧中的那些白框。请看这里的图像,你会得到一个想法:这些只是我的视频的两帧。如果您可以仔细看到图像正在移动(白色空间不是常数)。







期望:



用我自己的形象填满这些空白空间。如果只有一个框架,我可以使用ffmpeg来覆盖图像的确切的宽度和高度。但是这里的白色空间不是固定的,并且在所有的帧中都保持不变,并且有很多帧。所以,我正在寻找类似opencv或其他一些技术,可用于视频或一组帧中的对象检测,并将检测到的区域替换为其他图像。


$ b $我只需要一个脚踢。所以,如果有人已经在这样的工作,只是建议我可以使用什么技术。感谢提前。

解决方案

这一切都取决于你可以假定的:



如果您可以放心地假设矩形的边界不会被遮挡(隐藏),您可以尝试找到图像中的边缘(如OpenCV的Canny边缘),然后查找矩形(形成扭曲矩形的拐角或非常受欢迎的Hough Lines)。



如果您要查找的矩形始终是白色的,您可以在像HSV这样的颜色空间中对图像进行阈值来寻找最大值(在VV〜亮度中的V),然后在二进制图像中进行矩形搜索。



如果您的角落被遮挡,有时您必须对图像进行一些调整,例如形态操作(增长和收缩二进制阈值图像),然后Hough Lines可以做到这一点。



请注意,这个答案假设一旦知道矩形在哪里, 你完成了,你只需要覆盖使用自定义内容的矩形。
我也不检查任何时间 - 连续性:您的视频帧可能会基于矩形的逐帧外观跳转。你必须包括一些关于以前职位的知识。


Overview:

I am working on a video creation project. The technology I am using are: imageMagick, php, ffmpeg.

Current Status:

Currently the project is able to create videos using images and texts and few basic transitions. The way I am doing it is using imagemagick to create gif using input images(with transition effects in them) and then converting all gifs to videos and atlast concatenating the video together.

Next Move (My question):

I am now set to take it to the next level. So, what I am having is a video(1920x1080) with some white frames(1280x720) that keeps shifting in each frame. I want to replace those white frames appearing in some frames of the video with some images(1280x720) that I wish to use. Please see the image here and you will get an idea: These are just two frames from my video. If you can see carefully the images are shifting(white space is not constant).

Expectation:

So, I want to fill those white space with one of my own image. If the case would have been for only one frame I could have used ffmpeg to overlay image on the exact width and height. But here the white space is not fixed and keeps shifting in all the frames and there are a lot of frames. So, I am looking for something like opencv or some other technology that can be used for object detection in a video or in a set of frames and replace the detected area with some other image.

I just need a kick. So, if anyone has already worked on something like this just suggest me what technology can I use. Thanks in advance.

解决方案

It all depends on exactly what you can assume :

If you can safely assume that your rectangle's boundary is never occluded (hidden) somehow, you can try finding the edges in your image (like OpenCV's Canny edge) and then look for rectangular shape (corners forming a warped rectangle, or the very popular Hough Lines).

If the rectangle you're looking for is always white, you can threshold the image in a colorspace like HSV to look for maximum value (the V in HSV ~ brightness) then rectangular shape search in a binary image.

If your corners are occluded sometimes you'll have to do some tweaking with your image, like morphological operations ("grow and contract" binary thresholded image), then Hough Lines could do the trick.

Note that this answer assumes that once you know where the rectangle is, "you're done", and you just have to overwrite the rectangle with custom content. I also do not check for any time-continuity : you video frame might jump around based on the frame-by-frame appearance of rectangle. You'd have to include some knowledge about previous positions.

这篇关于用图像替换检测到的对象(imageProcessing)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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