简体   繁体   English

带有 cv2 的运动图像

[英]moving image with cv2

I applied the image to the background, but I can't figure out how to move it around.我将图像应用于背景,但我不知道如何移动它。

That's more or less what it looks like:这或多或少是这样的:

在此处输入图像描述

This is my code (I take it from here ):这是我的代码(我从这里获取):

# GUI
background = cv2.imread('BG2.png')
overlay = cv2.imread('beacon.png')
rows,cols,channels = overlay.shape
overlay=cv2.addWeighted(background[250:250+rows, 0:0+cols],0.5,overlay,0.5,0)
background[250:250+rows, 0:0+cols ] = overlay

# Display the image
cv2.imshow("Composited image", background)
cv2.waitKey(0)

I would like to be able to move the dot in real time, but I can't change its position.我希望能够实时移动点,但我无法更改它的 position。

Just overlaying the images took me a while.只是叠加图像花了我一段时间。 I checked the code from these topics before, but none worked:我之前检查了这些主题的代码,但没有一个有效:

  1. Tkinter, overlay foreground image on top of a background image with transparency Tkinter,将前景图像叠加在具有透明度的背景图像之上

  2. How to merge a transparent png image with another image using PIL 如何使用 PIL 将透明 png 图像与另一个图像合并

  3. How do I generate circular thumbnails with PIL? 如何使用 PIL 生成圆形缩略图?

If you want to carry out image transformations only by means of cv2, use affine transformations: cv2.warpAffine如果只想通过 cv2 进行图像变换,请使用仿射变换: cv2.warpAffine

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM