def moveWindow(image, winWidth, winHeight):
height, width = image.shape[:2]
i_heiht = False
for i in range(0, height, 50):
if i + winHeight > height:
i_heiht = True
for j in range(0, width, 10):
showRecImage = image.copy()
if i + winHeight > height and j + winWidth > width:
moveRoi = image[i:height, j: width]
cv2.rectangle(showRecImage,(j, i), (width,height), (0, 0, 255), 1)
print("111")
break
elif j + winWidth > width:
moveRoi = image[i:winHeight + i, j: width]
cv2.rectangle(showRecImage, (j, i), ( width, winHeight + i), (0, 0, 255), 1)
print("222")
break
elif i + winHeight > height:
moveRoi = image[i: height , j: winWidth + j]
cv2.rectangle(showRecImage, (j, i), (winWidth + j, height), (0, 0, 255), 1)
print("333")
else:
moveRoi = image[i: winHeight+i, j: winWidth+j]
cv2.rectangle(showRecImage, (j, i), (winHeight+j, winWidth+i), (0, 0, 255), 1)
print("444")
print("i", i)
cv2.imshow("image", showRecImage)
cv2.waitKey(10)
if i_heiht:
break
if __name__ == "__main__":
image = cv2.imread("src.jpg")
# cv2.imshow("image", image)
# cv2.waitKey()
if image is None:
print("No images")
else:
moveWindow(image, 800, 800)