Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. try:
  2. scale = yPosEnd/height
  3. dim = (int(height*scale), int(width*scale))
  4. resized = cv2.resize(img1, dim, interpolation=cv2.INTER_AREA)
  5. resized_height, resized_width, resized_depth = resized.shape
  6. roi = vis[int(yPos - resized_height / 2):int(yPos - resized_height / 2 + resized_height ), int(xPos - resized_width / 2):int(xPos - resized_width / 2 + resized_width)]
  7.  
  8. img2gray = cv2.cvtColor(resized,cv2.COLOR_BGR2GRAY)
  9. ret, mask2 = cv2.threshold(img2gray,240,255,cv2.THRESH_BINARY)
  10. mask2_inv = cv2.bitwise_not(mask2)
  11.  
  12. img1_bg = cv2.bitwise_and(roi,roi,mask = mask2)
  13. img2_fg = cv2.bitwise_and(resized,resized,mask = mask2_inv)
  14.  
  15. dst = cv2.add(img1_bg,img2_fg)
  16.  
  17. vis[int(yPos - resized_height / 2):int(yPos - resized_height / 2 + resized_height ), int(xPos - resized_width / 2):int(xPos - resized_width / 2 + resized_width)] = dst
  18. lista_obserwowanych.append(newtw)
  19. except:
  20. print track_box
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement