我正在对低分辨率视频(30 FPS)进行实时运动跟踪,并且无法将边界框坐标打印到计算机集群(SLURM)中输出的TXT或CSV文件中。
当前,我依靠外壳并将值打印到终端,并将其输出保存为TXT。但是,我想扩大此过程并移至计算机集群。
cnts = imutils.grab_contours(cnts)
a = []
# loop over the contours
for c in cnts:
# if the contour is too small, ignore it
if cv2.contourArea(c) < args["min_area"]:
continue
# compute the bounding box for the contour, draw it on the frame,
# and update the text
(x, y, w, h) = cv2.boundingRect(c)
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
text = "Occupied"
x1 = w/2
y1 = h/2
cx = x+x1
cy = y+y1
a.append([cx,cy])
print(len(a)-1, a)
我在终端中收到正确的输出,但是无法正确地将其写入TXT或CSV文件。