herrDeng網內搜尋

自訂搜尋

Ads

2022年11月14日 星期一

opencv python用selectROI與12星座截圖

 
 python code如下:
  1. print('利用cv2.selectROI來取圖')
  2.  
  3. import cv2
  4.  
  5. for i in range(1,13):
  6. im=cv2.imread('0.png')
  7. # print(im.shape)
  8. r=cv2.selectROI('roi', im )
  9. # print(r)
  10. # print(type(r))
  11. x,y,w,h=r
  12. im2=im[y:y+h, x:x+w]
  13. im2=cv2.resize(im2, (im2.shape[1]*2, im2.shape[0]*2), 4)
  14. cv2.imshow('select'+str(i), im2)
  15. cv2.imwrite(str(i)+'.png', im2)
  16. cv2.waitKey(0)
  17. cv2.destroyAllWindows()

沒有留言:

Related Posts Plugin for WordPress, Blogger...

熱門文章