# 画矩形

```python
import cv2
imgpath = 'd:/img.png'
x,y,x1,y1 = 641,165,752,278

img = cv2.imread(imgpath)
img.shape
linet = cv2.LINE_4
img = cv2.rectangle(img, (x, y), (x1, y1), (0, 0, 255), linet,2)
cv2.imshow('name', img)
cv2.waitKey()
cv2.destroyAllWindows()
```

![originimg](https://250664616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M88QQGIp-pdjQKnp4a4%2Fuploads%2Fgit-blob-18a9ed2fc67a37b85681bfea7e27d8edcb3563b2%2Fimg.png?alt=media) ![originimg1](https://250664616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M88QQGIp-pdjQKnp4a4%2Fuploads%2Fgit-blob-3c8283cef820013b927441945870f39a12a17410%2Fimg1.png?alt=media)
