Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1.  
  2. import cv2
  3. import numpy
  4.  
  5. # 加载图像并显示
  6.  
  7.  
  8. if __name__ == '__main__':
  9.     # Read image
  10.     image = cv2.imread( "/Users/laichian/Desktop/Computer_Vision/homework-3-MattLai-master/PKLot/parking1b/sunny/2013-02-22/2013-02-22_06_05_00.jpg",0)
  11.  
  12.     # Select ROI
  13.     #r = cv2.selectROI(image)
  14.  
  15.     # Crop image
  16.     #imCrop = image[int(r[1]):int(r[1] + r[3]), int(r[0]):int(r[0] + r[2])]
  17.  
  18.     # Display cropped image
  19.     #cv2.imshow("Image", imCrop)
  20.     #cv2.waitKey(0)
  21.  
  22. #rect: (453,369), (543,386), (573,334), (446,304)
  23. #rect: (278,90), (349,97), (364,65), (287,51)
  24.  
  25. #x="502" y="348" w="61" h="130"
  26.  
  27.     cv2.rectangle(image, (453, 369), (573, 334), 3) #12
  28.     cv2.imshow("Canvas", image) #13
  29.     cv2.waitKey(0)
  30.  
  31.  
  32. #crop_img = image[369:334,453:573] # Crop from x, y, w, h -> 502, 348, 61, 130
  33. # NOTE: its img[y: y + h, x: x + w] and *not* img[x: x + w, y: y + h]
  34. #cv2.imshow("cropped", crop_img)
  35. #cv2.waitKey(0)
  36.  
  37. #mouth = image[85:250, 85:220]
  38. #看上去,numpy的数组切片只需要提供高度区间和宽度区间即可。事实上也确实是这样。
  39. #上面的语句表示提取矩形区域(左上角坐标(85,85),右下角坐标(220,250))的图像。
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement