gpt4 book ai didi

opencv - 使用 OpenCV 可以实现画中画吗?

转载 作者:太空宇宙 更新时间:2023-11-03 22:01:52 25 4
gpt4 key购买 nike

我想在较大的图像之上添加较小的图像(最终用于视频源上的画中画)。我可以通过遍历大图像中的相关数据属性并添加小图像中的像素来实现。但是有没有更简单更整洁的方法呢?我正在使用 EMGU。

我的想法是在与小图像大小相同的大图像中定义一个 ROI。将大图像设置为与小图像相等,然后简单地删除 ROI。即在伪代码中:

Large.ROI = rectangle defined by small image;

Large = Small;

Large.ROI = Rectangle.Empty;

但是这不起作用,大图像也没有改变。任何建议将不胜感激。

大图:
Large Image

小图:
Small Image

期望的结果:
Desired Result

最佳答案

如果您使用 C++ API,则以下代码片段应该有效:

cv::Mat big;
cv::Mat small;

// Define roi area (it has small image dimensions).
cv::Rect roi = cv::Rect(50,50, small.cols, small.rows);

// Take a sub-view of the large image
cv::Mat subView = big(roi);

// Copy contents of the small image to large
small.copyTo(subView);

注意不要超出大图像的尺寸。

关于opencv - 使用 OpenCV 可以实现画中画吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6378543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com