在关于reshape()函数的numpy手册中,它说
>>> a = np.zeros((10, 2))
# A transpose make the array non-contiguous
>>> b = a.T
# Taking a view makes it possible to modify the shape without modifying the
# initial object.
>>> c = b.view()
>>> c.shape = (20)
AttributeError: incompatible shape for a non-contiguous array
Run Code Online (Sandbox Code Playgroud)
我的问题是:
c.shape = (20)抛出错误incompatible shape for a non-contiguous array?感谢您的回答!
我在这里使用选择性搜索:http://koen.me/research/selectivesearch/
这给出了一个对象可能存在的感兴趣区域.我想进行一些处理并仅保留一些区域,然后删除重复的边界框以获得最终整齐的边界框集合.为了丢弃不需要/重复的边界框区域,我使用grouprectanglesopencv 的功能进行修剪.
一旦我从上面链接中的"选择性搜索算法"中获取Matlab中的有趣区域,我将结果保存在一个.mat文件中,然后在python程序中检索它们,如下所示:
import scipy.io as sio
inboxes = sio.loadmat('C:\\PATH_TO_MATFILE.mat')
candidates = np.array(inboxes['boxes'])
# candidates is 4 x N array with each row describing a bounding box like this:
# [rowBegin colBegin rowEnd colEnd]
# Now I will process the candidates and retain only those regions that are interesting
found = [] # This is the list in which I will retain what's interesting
for win in candidates:
# doing some processing …Run Code Online (Sandbox Code Playgroud)