图片坐标和数组下标是相反的,坐标原点位于左上角

 1 import numpy as np
 2 import cv2
 3 
 4 height, width = 150, 200
 5 img = np.zeros((height, width, 3), np.uint8)
 6 img[:, :] = [255, 255, 255]
 7 
 8 # Pixel position to draw at
 9 row, col = 20, 100
10 
11 # Draw a square with position 20, 100 as the top left corner
12 for i in range(row, 30):
13     for j in range(col, 110):
14         img[i, j] = [0, 0, 255]
15 
16 # Will the following draw a circle at (20, 100)?
17 # Ans: No. It will draw at row index 100 and column index 20.
18 cv2.circle(img,(row, col), 5, (0,255,0), -1)
19 
20 cv2.imwrite("square_circle_opencv.jpg", img)

 opencv图片坐标和数组下标

 

相关文章:

  • 2021-06-28
  • 2021-12-29
  • 2021-11-25
  • 2021-11-12
  • 2022-12-23
  • 2022-01-22
  • 2021-10-01
  • 2021-11-17
猜你喜欢
  • 2022-12-23
  • 2022-01-20
  • 2022-12-23
  • 2022-01-28
  • 2021-08-13
  • 2021-11-05
  • 2021-11-19
相关资源
相似解决方案