Reputation: 1056
I would like to scan my picture with a rectangle (openCV and python). This rectangle has to go all over the image.
I proceed like this but it doesn't work at all. My rectangle has a size of 20
for i in range(0,height):
for j in range(0,width):
pt1=(0+i,0+j)
pt2=(20+i,20+j)
point.append([pt1,pt2])
cv2.rectangle(res,pt1,pt2,(255,0,0))
I know it seems to be simple but I don't have any ideas how to proceed.
Thank you!
Upvotes: 0
Views: 1307
Reputation: 824
Currently your rectangle has no fixed size. Shouldn't it be:
pt1 = (i, j)
pt2 = (pt1.x+20, pt1.y+20)
And additionally you might want to check that the rectangle does not overlap your image.
Upvotes: 3