Rendering video from a log file using Python and OpenCV

I am supposed to render a video based on an offline log file. To be more precise, I have to process this log file and print the frame with the boxes, object identifiers and the direction of the car. Log file is composed of: cam_id frame timestamp category lat lon geohash speed yaw obj_id x y w h. I have also a .mp4 file of the video. Al in all, I have to be able to display the video with the information on the log.

Any ideas?
When I run the code below, it is creating bounding boxes somewhere at the top left of the window(all of them) instead of creating them properly for every obj_id.

def creating_boxes(cap):
import cv2

video_resolution = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)),
                    int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)))
reference_x, reference_y = [r // 2 for r in video_resolution]

while cap.isOpened():
    file = open('log.in', 'r')
    data = file.readlines()
    file.close()

    ret, frame = cap.read()

    if ret:
        #cv.line(frame, (reference_x, 0), (reference_x, reference_y), (255, 0, 0), 2, 4)
        #cv.line(frame, (0, reference_y), (video_resolution[0], reference_y), (255, 0, 0), 2, 4)

        for line in data:
            cam_id, frame1, timestamp, category, lat, lon, geohash, speed, yaw, obj_id, x, y, w, h = line.split()
             cv2.rectangle(frame, (int(float(x)), int(float(y))), (int(float(x + w)), int(float(y + h))), (255, 0, 0), 1)
            #cv2.rectangle(frame, (int(-25.6890869140625), int(19.63014030456543)), (int(-25.6890869140625 + 203), int(19.63014030456543 + 178)), (255, 0, 0), 2)
            #cv.rectangle(frame, (int(-25.6890869140625), int(19.63014030456543) - 10), (int(-25.6890869140625) + 10 * len(str(obj_id)), int(19.63014030456543)), (255, 0, 0), -1)
            #cv.putText(frame, str(obj_id), (int(float(x)), int(float(y))), cv.FONT_HERSHEY_SCRIPT_SIMPLEX, .5, (255, 255, 255))
        cv2.imshow('Frame', frame)
        cv2.waitKey(1)
    else:
        print("Can't receive frame (stream end?). Exiting ...")
        break

        print(f"Iteration {i} completed")

def main():
import cv2

cap = cv2.VideoCapture('20939.mp4')
print(f"{cap.get(cv2.CAP_PROP_FRAME_WIDTH)}x{cap.get(cv2.CAP_PROP_FRAME_HEIGHT)}")

cv2.namedWindow("Frame", cv2.WINDOW_NORMAL)
cv2.resizeWindow("Frame", (1920, 1080))

if not cap.isOpened():
    print("An error occured while trying to open a video or file")

creating_boxes(cap)

cap.release()
cv2.destroyAllWindows()

if name == “main”:
main()

welcome.

what information is missing that anyone would need to help you?

are you aware that python code can be debugged?

I see you use negative values - ie. -25.

Maybe log uses different coordinates - ie. like in chars with (0,0) in the middle of image/screen and with negative values y below point 0.
But opencv has (0,0) in top left corner of image/screen. And positive values y below 0

You may have to recalculate coordinates.
At start you can try to add to every point

x = x + image_width//2
y = y + image_height//2

or for negative y below 0

x = x + image_width//2
y = -y + image_height//2

in your code it can be even

x = x + reference_x
y = y + reference_y

or for negative y below 0

x = x + reference_x
y = -y + reference_y