Hello everyone. I am doing a project on object tracking. Therefore I have used SiamMask from arcgis.learn module. I have installed the python API version through command prompt. But I have encountered a problem as there is a numpy function in the module which has been depreciated. I cannot change the code in the module nor download the library locally through github. Github folder does not have setup.py file. Please give a solution which is solvable in jupyter notebook.
CODE:
import cv2
from arcgis.learn import SiamMask
import numpy as np
import torch
ot = SiamMask()
cap = cv2.VideoCapture("Office.mp4")
# Read all frames and store them in a list
frames = []
while True:
ret, frame = cap.read()
if ret is False:
break
frames.append(frame)
# Initialize the bounding box coordinates (x, y, width, height)
x = 100
y = 100
w = 50
h = 80
# Initialize the track with the given coordinates
state = ot.init(frames[0], [[x, y, w, h]])
frame_id = 0
while frame_id < len(frames):
frame = frames[frame_id]
state = ot.update(frame) # Update the track location in the frame
for track in state:
mask = track.mask
frame[:, :, 2] = (mask > 0) * 255 + (mask == 0) * frame[:, :, 2]
cv2.polylines(frame, [np.int0(track.location).reshape((-1, 1, 2))], True, (0, 255, 0), 2)
cv2.imshow('frame', frame)
key = cv2.waitKey(1)
if key & 0xFF == ord('q'):
break
# Use the frame number (frame_id) to advance to the next frame
frame_id += 1
cap.release()
cv2.destroyAllWindows()
ERROR:
Hello,
Would it be possible to get further detail on what you are trying to detect within the video? It could be a case that a different workflow might provide the best outcome.
Many thanks,
David
@Ha1 What is the version of arcgis python api installed? What command have you used for installation? If possible, also provide the video to reproduce the issue