コード例 #1
0
from utils import ProgressBar
path.append(os.path.join(os.path.dirname(__file__), ".."))
from src.utility.SetupUtility import SetupUtility

if __name__ == "__main__":
    # setting the default header, else the server does not allow the download
    opener = build_opener()
    opener.addheaders = [('User-agent', 'Mozilla/5.0')]
    install_opener(opener)

    # set the download directory relative to this one
    current_dir = os.path.dirname(os.path.abspath(__file__))
    pix3d_dir = os.path.join(current_dir, "..", "resources", "pix3d")

    if not os.path.exists(pix3d_dir):
        os.makedirs(pix3d_dir)

    # download the zip file, which contains all the obj files. Size ~3.5 GB
    print("Download the zip file, may take a while:")
    pix3d_url = "http://pix3d.csail.mit.edu/data/pix3d.zip"
    zip_file_path = os.path.join(pix3d_dir, "pix3d.zip")
    urlretrieve(pix3d_url, zip_file_path, ProgressBar())

    # unzip the zip file
    print("Unzip the zip file.")
    SetupUtility.extract_file(pix3d_dir, zip_file_path)

    os.remove(zip_file_path)
    shutil.rmtree(os.path.join(pix3d_dir, "img"))
    shutil.rmtree(os.path.join(pix3d_dir, "mask"))
コード例 #2
0
                    downloaded = block_num * block_size
                    if downloaded < total_size:
                        self.pbar.update(downloaded)
                    else:
                        self.pbar.finish()

            print("Downloading blender from " + url)
            file_tmp = urlretrieve(url, None, DownloadProgressBar())[0]
        except ImportError:
            print("Progressbar for downloading, can only be shown, "
                  "when the python package \"progressbar\" is installed")
            file_tmp = urlretrieve(url, None)[0]

        if platform == "linux" or platform == "linux2":
            if version_info.major == 3:
                SetupUtility.extract_file(blender_install_path, file_tmp,
                                          "TAR")
            else:
                with contextlib.closing(lzma.LZMAFile(file_tmp)) as xz:
                    with tarfile.open(fileobj=xz) as f:
                        f.extractall(blender_install_path)
        elif platform == "darwin":
            if not os.path.exists(blender_install_path):
                os.makedirs(blender_install_path)
            os.rename(
                file_tmp,
                os.path.join(blender_install_path, blender_version + ".dmg"))
            # installing the blender app by mounting it and extracting the information
            subprocess.Popen([
                "hdiutil attach {}".format(
                    os.path.join(blender_install_path,
                                 blender_version + ".dmg"))
コード例 #3
0
    ikea_dir = os.path.join(current_dir, "..", "resources", "IKEA")

    if not os.path.exists(ikea_dir):
        os.makedirs(ikea_dir)

    # download the zip file, which contains all the model files.
    print("Downloading the zip file (166mb)...")
    ikea_url = "http://ikea.csail.mit.edu/zip/IKEA_models.zip"
    zip_file_path = os.path.join(ikea_dir, "IKEA_models.zip")
    urlretrieve(ikea_url, zip_file_path)
    print("Download complete.")

    # unzip the zip file
    print("Unzipping the zip file...")
    ikea_dir = os.path.join(ikea_dir, "IKEA")
    SetupUtility.extract_file(ikea_dir, zip_file_path)
    os.remove(zip_file_path)

    subprocess.call("chmod -R a+rw *", shell=True, cwd=ikea_dir)

    print("The IKEA dataset has some weird bugs, these are fixed now.")
    if os.path.exists(os.path.join(ikea_dir, "IKEA_bed_BEDDINGE")):
        shutil.rmtree(os.path.join(ikea_dir, "IKEA_bed_BEDDINGE"))

    nils_folder = os.path.join(ikea_dir, "IKEA_chair_NILS")
    if os.path.exists(nils_folder):
        shutil.rmtree(nils_folder)

    # delete all no double .obj
    for folder in glob.glob(os.path.join(ikea_dir, "*")):
        no_jitter_folders = glob.glob(os.path.join(folder, "nojitter*"))
コード例 #4
0
    opener = build_opener()
    opener.addheaders = [('User-agent', 'Mozilla/5.0')]
    install_opener(opener)

    # set the download directory relative to this one
    current_dir = os.path.dirname(os.path.abspath(__file__))
    scenenet_dir = os.path.join(current_dir, "..", "resources", "scenenet")

    if not os.path.exists(scenenet_dir):
        os.makedirs(scenenet_dir)

    # download the zip file, which contains all the obj files
    print("Download the zip file, may take a while:")
    scenenet_url = "https://bitbucket.org/robotvault/downloadscenenet/get/cfe5ab85ddcc.zip"
    zip_file_path = os.path.join(scenenet_dir, "scene_net.zip")
    urlretrieve(scenenet_url, zip_file_path)

    # unzip the zip file
    print("Unzip the zip file.")
    SetupUtility.extract_file(scenenet_dir, zip_file_path)

    os.remove(zip_file_path)
    os.rename(
        os.path.join(scenenet_dir, "robotvault-downloadscenenet-cfe5ab85ddcc"),
        os.path.join(scenenet_dir, "SceneNetData"))

    print(
        "Please also download the texture library from here: http://tinyurl.com/zpc9ppb"
    )
    print("This is a google drive folder downloading via script is tedious.")