在 cv2 python 中克隆图像 [英] Clone an image in cv2 python

查看:58
本文介绍了在 cv2 python 中克隆图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 opencv 的新手,这里有一个问题,与 cpp 中的 cv::clone() 作用相同的 python 函数是什么?我只是尝试通过

I'm new to opencv, here is a question, what is the python function which act the same as cv::clone() in cpp? I just try to get a rect by

    rectImg = img[10:20, 10:20]

但是当我在上面画一条线时,我发现这条线同时出现在 img 和 rectImage 上,所以,我该如何完成?

but when I draw a line on it ,I find the line appear both on img and the rectImage,so , how can I get this done?

推荐答案

第一个答案是正确的,但您说您使用的是 cv2,它本质上使用 numpy 数组.因此,要制作一个完全不同的myImage"副本:

The first answer is correct but you say that you are using cv2 which inherently uses numpy arrays. So, to make a complete different copy of say "myImage":

newImage = myImage.copy()

以上就够了.无需导入 numpy.

The above is enough. No need to import numpy.

这篇关于在 cv2 python 中克隆图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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