I have done object detection on my video data using trackers such as CSRT, KCF and got the detection part.I have ground truth coordinates (x,y) values for few frames from the original video which would be something like this.
this is the snapshot from the detected video
I have the x and y co-ords (which is x2,y2 in first image) for original video. Now I have a situation to measure the 2D distance between the ground truth and detected contact points, and for this i need to get the co-ords for the detected video. In simple words, I want to get the center value of the bounding box atleast for few frames from the detected video i.e(x1,y1) as shown in the second image.
# loop over frames from the video stream
while True:
# grab the current frame, then handle if we are using a
# VideoStream or VideoCapture object
frame = vs.read()
frame = frame[1] if args.get("video", False) else frame
# check to see if we have reached the end of the stream
if frame is None:
break
# resize the frame (so we can process it faster) and grab the
# frame dimensions
frame = imutils.resize(frame, width=720)
(H, W) = frame.shape[:2]
#init BB = initial bounding box
# check to see if we are currently tracking an object
if initBB is not None:
# grab the new bounding box coordinates of the object
(success, box) = tracker.update(frame)
# check to see if the tracking was a success
if success:
(x, y, w, h) = [int(v) for v in box]
cv2.rectangle(frame, (x, y), (x + w, y + h),
(0, 255, 0), 2)
I don't know if I was clear enough to convey my problem, but please ask if anymore info is required and someone help me over here. This is so important for me. Thank you
x_center, y_center = x + 0.5 * w, y + 0.5 * h
. $\endgroup$(x, y)
coordinates in the overall image relative to the image origin (probably bottom left). $\endgroup$frame
, the actual origin depends on the way the tracker was trained/set-up. $\endgroup$