def transform_detection(p0,detections,detect_thresh):
    """Convert the result of the detection from a cropped part 
    of image to the original image coordinates.

    Parameters
    ----------
    p0 : tuple
        The top-left point used for cropping the image (x,y)
    detections : list
        A list of lists for the detections in the cropped frame as it is the 
        output from the detection network. The list has the following
        shape [top-left point, bottom-right point,probabilty, class id]
    detect_thresh : float
        The minimum probability to consider a detection result from Yolo
        model ok. 

    Returns
    -------
    list
        The same detection list as the input but with moving 
        the coordinates to the original frame of coordinates
        before cropping.
    """

    output = []
    for detection in detections:
        if detection[2]>detect_thresh:
            output.append( [(p0[0]+detection[0][0],p0[1]+detection[0][1]),
                            (p0[0]+detection[1][0],p0[1]+detection[1][1]),
                            detection[2], detection[3]])
    
    return output