File: lucy.py

package info (click to toggle)
mayavi2 4.8.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 21,892 kB
  • sloc: python: 49,447; javascript: 32,885; makefile: 129; fortran: 60
file content (42 lines) | stat: -rw-r--r-- 1,073 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Viewing Stanford 3D Scanning Repository lucy model
"""
# Copyright (c) 2014-2020, Enthought, Inc.
# Standard library imports
import os
from os.path import join

# Enthought library imports
from mayavi import mlab

### Download the lucy data, if not already on disk ############################
if not os.path.exists('lucy.tar.gz'):
    # Download the data
    try:
        from urllib import urlopen
    except ImportError:
        from urllib.request import urlopen
    print("Downloading lucy model, Please Wait (307MB)")
    opener = urlopen(
            'http://graphics.stanford.edu/data/3Dscanrep/lucy.tar.gz')
    open('lucy.tar.gz', 'wb').write(opener.read())

# Extract the data
import tarfile
lucy_tar_file = tarfile.open('lucy.tar.gz')
try:
    os.mkdir('lucy_data')
except:
    pass
lucy_tar_file.extractall('lucy_data')
lucy_tar_file.close()

# Path to the lucy ply file
lucy_ply_file = join('lucy_data', 'lucy.ply')

# Render the lucy ply file
mlab.pipeline.surface(mlab.pipeline.open(lucy_ply_file))
mlab.show()

import shutil
shutil.rmtree('lucy_data')