提交 727a64b8 编写于 作者: F feilong

add ball

上级 755d2af3
......@@ -3,4 +3,4 @@
"author": "huanhuilong",
"source": "install.md",
"notebook_enable": true
}
\ No newline at end of file
}
\ No newline at end of file
......@@ -22,7 +22,6 @@ if __name__ == '__main__':
for i in range(-1, 4):
# TODO(You): 请在此实现代码
cv2.imwrite("continue_ball.jpg", img)
cv2.imshow("continue_ball", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
......@@ -30,6 +29,31 @@ if __name__ == '__main__':
请实现粘贴足球部分的代码。
## template
```python
import cv2
import numpy as np
if __name__ == '__main__':
img = cv2.imread('ball.jpg', cv2.IMREAD_COLOR)
start = [493, 594]
end = [112, 213]
ball = img[start[0]:start[1], end[0]:end[1]]
x_step = 101
y_step = 10
for i in range(-1, 4):
x_offset = x_step*i
y_offset = y_step*i
img[start[0]-y_offset:start[1]-y_offset,
end[0]+x_offset:end[1]+x_offset] = ball
cv2.imshow("continue_ball", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
```
## 答案
```python
......
......@@ -14,7 +14,6 @@ if __name__ == '__main__':
img[start[0]-y_offset:start[1]-y_offset,
end[0]+x_offset:end[1]+x_offset] = ball
cv2.imwrite("continue_ball.jpg", img)
cv2.imshow("continue_ball", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册