Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. img = cv2.imread(path, -1)
  2. eye = img[349:307, 410:383]
  3. img[30:180, 91:256] = eye
  4.  
  5. Traceback (most recent call last):
  6. File "test.py", line 13, in <module>
  7. img[30:180, 91:256] = eye
  8. ValueError: could not broadcast input array from shape (0,0,3) into shape (150,165,3)
  9.  
  10. ValueError: could not broadcast input array from shape (0,0,3) into shape (150,165,3)
  11.  
  12. In [8]: import cv2
  13. ...: fn=r'D:DocumentsDesktop1.jpg'
  14. ...: img=cv2.imread(fn, -1)
  15. ...: roi=img[200:400, 200:300]
  16.  
  17. In [9]: roi.shape
  18. Out[9]: (200, 100, 3)
  19.  
  20. In [10]: img2=img.copy()
  21.  
  22. In [11]: img2[:roi.shape[0], :roi.shape[1]]=roi
  23.  
  24. In [12]: cv2.imshow('img', img)
  25. ...: cv2.imshow('roi', roi)
  26. ...: cv2.imshow('img2', img2)
  27. ...: cv2.waitKey(0)
  28. ...: cv2.destroyAllWindows()
  29.  
  30. In [13]: img2[:100, :100]=roi
  31. ---------------------------------------------------------------------------
  32. ValueError Traceback (most recent call last)
  33. <ipython-input-13-85de95cf3ded> in <module>()
  34. ----> 1 img2[:100, :100]=roi
  35.  
  36. ValueError: could not broadcast input array from shape (200,100,3) into shape (100,100,3)
  37.  
  38. img[349:307, 410:383]
  39.  
  40. img[307,349, 383:413]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement