Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try:
- scale = yPosEnd/height
- dim = (int(height*scale), int(width*scale))
- resized = cv2.resize(img1, dim, interpolation=cv2.INTER_AREA)
- resized_height, resized_width, resized_depth = resized.shape
- 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)]
- img2gray = cv2.cvtColor(resized,cv2.COLOR_BGR2GRAY)
- ret, mask2 = cv2.threshold(img2gray,240,255,cv2.THRESH_BINARY)
- mask2_inv = cv2.bitwise_not(mask2)
- img1_bg = cv2.bitwise_and(roi,roi,mask = mask2)
- img2_fg = cv2.bitwise_and(resized,resized,mask = mask2_inv)
- dst = cv2.add(img1_bg,img2_fg)
- 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
- lista_obserwowanych.append(newtw)
- except:
- print track_box
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement