Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I can not draw the rectangles with the for loop.

I set up an np.array and was able to print all the elements in python console.

a =np.array([[1,2,3,4],[3,4,4,5],[5,6,7,8],[9,9,9,9]])
for (x,y,x1,y1)in a:
   print(x,y,x1,y1)

image description

When I set up the for loop to draw the rectangles I get the last one in the array draw on image.

rect = np.array([[14,137,80,166],[14,174,80,204],[14,214,80,244],[14,252,80,282],
[14,290,80,320],[14,328,80,358],[14,366,80,396],[14,402,80,432]])

for (x1,y1,x2,y2)in rect:
  #Create the basic black image
  mask = np.zeros(blur.shape[:2], dtype="uint8")
  cv2.rectangle(mask,(x1,y1),(x2,y2), (COLOR_WHITE), -1)

image description

Any help greatly appreciated. Thanks.

I can not draw the rectangles with the for loop.

I set up an np.array and was able to print all the elements in python console.

a =np.array([[1,2,3,4],[3,4,4,5],[5,6,7,8],[9,9,9,9]])
for (x,y,x1,y1)in a:
   print(x,y,x1,y1)

image description

When I set up the for loop to draw the rectangles I get the last one in the array draw on image.

rect = np.array([[14,137,80,166],[14,174,80,204],[14,214,80,244],[14,252,80,282],
[14,290,80,320],[14,328,80,358],[14,366,80,396],[14,402,80,432]])

for (x1,y1,x2,y2)in rect:
  #Create the basic black image
  mask = np.zeros(blur.shape[:2], dtype="uint8")
  cv2.rectangle(mask,(x1,y1),(x2,y2), (COLOR_WHITE), -1)

image description

Any help greatly appreciated. Thanks.

I can not draw the rectangles with the for loop.

I set up an np.array and was able to print all the elements in python console.

a =np.array([[1,2,3,4],[3,4,4,5],[5,6,7,8],[9,9,9,9]])
=np.array([[14,137,80,166],[14,174,80,204],[14,214,80,244],[14,252,80,282],
[14,290,80,320],[14,328,80,358],[14,366,80,396],[14,402,80,432]])
for (x,y,x1,y1)in (x1,y1,x2,y2)in a:
   print(x,y,x1,y1)
print(x1,y1,x2,y2)

image description

When I set up the for loop to draw the rectangles I get the last one in the array draw on image.

rect = np.array([[14,137,80,166],[14,174,80,204],[14,214,80,244],[14,252,80,282],
[14,290,80,320],[14,328,80,358],[14,366,80,396],[14,402,80,432]])

for (x1,y1,x2,y2)in rect:
  #Create the basic black image
  mask = np.zeros(blur.shape[:2], dtype="uint8")
  cv2.rectangle(mask,(x1,y1),(x2,y2), (COLOR_WHITE), -1)

image description

Any help greatly appreciated. Thanks.