感兴趣的区域 opencv python [英] Region of Interest opencv python

查看:33
本文介绍了感兴趣的区域 opencv python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 opencv python 获取图像区域 (ROI).使用的opencv版本是2.4.3.但是,当我尝试调用 API 时

I am trying to get a region of an image (ROI) using opencv python. The version of opencv used is 2.4.3. However when I try to call the API

cv2.SetImageROI

它返回这个错误

AttributeError: 'module' object has no attribute 'SetImageROI'

另外在检查文档时似乎表明这个 api 是一个遗留的 python 函数.http://docs.opencv.org/2.4.3/search.html?q=setimageroi

Also on checking the documentation it seems to suggest this api is a legacy python function. http://docs.opencv.org/2.4.3/search.html?q=setimageroi

我不知道如何在 python 中使用当前版本的 opencv 来获得 ROI.有人可以建议如何解决这个问题吗?

I am not sure how to go about getting the ROI using this current version of opencv in python. Could some one please suggest how to go about this?

谢谢

推荐答案

好的,进一步分析发现cv2既然已经支持numpy数组结构,就不再需要任何API,整个图片就可以了在数组本身中操作.例如:

Okay, On further analysis realized that the cv2 since it has been supporting numpy array structure, there is no longer any need for a API, the entire image can be manipulated in the array itself. eg:

img = cv2.imread('image.png')
img = img[c1:c1+25,r1:r1+25]

这里c1是左侧列像素位置,r1是对应的行位置.并且 img 现在将像素内指定的图像作为 ROI.

Here c1 is the left side column pixel location, and r1 is the corresponding row location. And img now has the image specified within the pixels as the ROI.

在这里很好地解释了,How to copy a image region usingpython中的opencv?

这篇关于感兴趣的区域 opencv python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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