Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Requirement:
~~~~~~~~~~~~
You have to install:
- OpenAlea
- VPlants
- mayavi2

Reference:
Expand Down
244 changes: 244 additions & 0 deletions example/ScanAlea-Maize.ipynb

Large diffs are not rendered by default.

39 changes: 24 additions & 15 deletions example/ScanAlea.ipynb

Large diffs are not rendered by default.

286 changes: 286 additions & 0 deletions example/canopy.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
# package installation
packages= packages,
package_dir= package_dir,
share_dirs = {'share':'share'},

zip_safe= False,

Expand Down
2 changes: 1 addition & 1 deletion src/scanalea/codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ def read(fname, split=True):

from scanalea import ply, vtk
register('vtk', vtk.VtkCodec)
register('ply', ply.PlyCodec)
register('ply', ply.PlyCodecVTK)

6 changes: 3 additions & 3 deletions src/scanalea/ply.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,16 @@ def write(self,fname,scene):
f.close()

class PlyCodecVTK(PlyCodec):
def read(self,fname):
def read(self,fname, **kwds):
""" read a ply file """
try:
from mayavi.sources.poly_data_reader import PolyDataReader
except:
from enthought.mayavi.sources.poly_data_reader import PolyDataReader

my_reader = PolyDataReader()
return generic_vtk_read(my_reader,fname)
return generic_vtk_read(my_reader,fname,**kwds)


codec = PlyCodec()
codec = PlyCodecVTK()
sg.SceneFactory.get().registerCodec(codec)
2 changes: 1 addition & 1 deletion src/scanalea/vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#from openalea.plantgl.ext import color
import numpy as np

def generic_vtk_read(reader, fname, split=True):
def generic_vtk_read(reader, fname, split=True,**kwds):

r = reader
r.initialize(fname)
Expand Down
44 changes: 42 additions & 2 deletions test/test1.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,49 @@
from openalea.deploy.shared_data import shared_data
from vpltkdisplay import *
from IPython.display import display
from openalea.plantgl.all import *
import scanalea
from scanalea import segmentation as seg
from scanalea.codecs import read, ply
import numpy as np
from openalea.core.path import path
import pandas

def normalised(shape, translation=(0,0,0), color=(60,150,80) ):
bc=BBoxComputer(Discretizer())
shape.apply(bc)
bbox = bc.boundingbox
gi = shape.geometry
X,Y=bbox.getXRange(), bbox.getYRange()
scale = max(X,Y)
gi=Scaled((1./scale,1./scale,1./scale),gi)
return Shape(Translated(translation,gi),Material(color))

def test_simple():
data = path(scanalea.__path__[0])/'..'/'..'

def test_ply():
fn = '/media/pradal/DONNEES/pradal/data/plantscan/663_4_tp/FourTPsec_20130326_3199_663_res1280_full_vh_smoothed_textured.ply'
scene = read(fn)
geometry = scene[0]

def test_full():
data = path(scanalea.__path__[0])/'..'/'..'
datadir = data/'share'/'INRIA_maize'/'finemesh'
files =datadir.glob('*.ply')

report = pd.read_csv(datadir/'report.txt',
sep=' *',
header=None,
names=['Date', 'num'],
infer_datetime_format=True)

report =report.sort('Date')
# bad option to do the trick...
def fun(x):
return [f for f in files if ('_'+str(x)+'_') in f][0]
report['filename'] = report['num'].map(fun)

scenes = [read(fn) for fn in report['filename']]
shapes = [normalised(scenes[xx][0], (xx/5,xx%5.,0), (xx*10,80,(xx*30)%255)) for xx in range(len(scenes))]

scene = Scene(shapes)
return scene