def check_file_type()

in threedod/benchmark_scripts/show_3d_bbox_annotation.py [0:0]


def check_file_type(file):
    file_type = None
    cmd = f'head -n 30 {file}'
    try:
        p = subprocess.Popen(cmd, shell=True,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.STDOUT)
        res = [i.strip() for i in p.stdout.readlines()]
    except Exception:
        return file_type
    for i in res:
        try:
            line = i.decode("utf-8")
        except Exception:
            pass
        else:
            if "element face" in line:
                face_count = int(line.split(" ")[-1])
                if face_count == 0:
                    file_type = "pcd"
                else:
                    file_type = "mesh"
                break
    return file_type