我在这里使用选择性搜索: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) 尝试将横向图像旋转为纵向时,应用旋转后,我无法在图像上绘制.
img1 = cv2.imread('a.jpg')
cv2.circle(img1, tuple([10,10]),radius = 3, color = (255,0,0))
Run Code Online (Sandbox Code Playgroud)
工作良好.
然后我尝试:
img2 = np.rot90(img1,3)
cv2.circle(img2, tuple([10,10]),radius = 3, color = (255,0,0))
Run Code Online (Sandbox Code Playgroud)
我收到错误:
TypeError: Layout of the output array img is incompatible with cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels)
Run Code Online (Sandbox Code Playgroud)
看着type(img2)和img2.dtype它似乎相同IMG1.尺寸看起来也很好(前两个尺寸翻转,第三个尺寸保持"3")
顺便说一句:这似乎有效.(为什么?):
img2 = np.rot90(img1,3)
img3 = img2.copy()
cv2.circle(img3, tuple([10,10]),radius = 3, color = (255,0,0))
Run Code Online (Sandbox Code Playgroud)