for line, images_files in zip(lines, image_list):
info = line.split(',')
image_index = [int(info[0])]
box_coordiante1 = [info[2]]
box_coordiante2 = [info[3]]
box_coordiante3 = [info[4]]
box_coordiante4 = [info[5]]
prev_image_num = 1
for image_number in image_index: #### read each other image_number
if prev_image_num != image_number: # if read 11111 but appear different number such as 2, 3 and ect
prev_image_num = image_number # the different number becomes pre_image_num(it was 1)
#box_coordinate = [] # empty box_coordinate
#box_coordinate.append(info[2:6])
#print box_coordinate
# box_coordinate.append() #insert 2 to 6 axis
rect = plt.Rectangle((int(box_coordiante1), int(box_coordiante2)), int(box_coordiante3), int(box_coordiante4), linewidth=1, edgecolor='r', facecolor='none')
ax.add_patch(rect)
im = cv2.imread(images_files)
im = im[:, :, (2, 1, 0)]
# # Display the image
plt.imshow(im)
plt.draw()
plt.pause(0.1)
plt.cla()
我应该在每张照片上画盒子。 为了在每张照片上显示方框, 我想收集盒子的位置并在同一时间显示它们。 所以我使用了一种方法使用LIST来plt.Rectanle 但它说“TypeError:int()参数必须是字符串或数字,而不是'list'” 还有其他方法吗?
答案 0 :(得分:1)
嗯,我刚刚做了。我不知道这是否是你想要的。
subnet
答案 1 :(得分:0)
我对Python不是很熟悉,但似乎你想要变量image_index
和box_coordinateN
中的普通数字。看起来你正在为它们分配单元素数组。尝试更改:
image_index = [int(info[0])] // list containing one element: int(info[0])
box_coordiante1 = [info[2]]
box_coordiante2 = [info[3]]
box_coordiante3 = [info[4]]
box_coordiante4 = [info[5]]
为:
image_index = int(info[0]) // number: int(info[0])
box_coordiante1 = info[2]
box_coordiante2 = info[3]
box_coordiante3 = info[4]
box_coordiante4 = info[5]
答案 2 :(得分:0)
上面的答案是粗心草率和错误的 Python。
必须改写并更正如下:
x = 10
y = 10
a = []
for unit in range(x):
a.append(0)
for unit in range(y):
print(a)