Exemple #1
0
 def get_distribution(self, save=True, force_computation=False):
     """ Distribution of the frame, computed if needed, can be slow. """
     if force_computation or not self._distribution:
         distribution = ShapeDistribution.compute(self.pointcloud)
         if save:
             self._distribution = distribution
             self.save()
         return distribution
     else:
         return self._distribution
Exemple #2
0
 def get_distribution(self, save=True, force_computation=False):
     """ Distribution of the frame, computed if needed, can be slow. """
     if force_computation or not self._distribution:
         distribution = ShapeDistribution.compute(self.pointcloud)
         if save:
             self._distribution = distribution
             self.save()
         return distribution
     else:
         return self._distribution
Exemple #3
0
    def setUp(self):
        """ Run before starting testing. """
        # TODO : use fixtures
        test_model = SketchupModel()
        test_model.google_id = "test1"
        test_model.tags = ["tag1", "tag2"]
        test_model.title = "title1"
        test_model.text = "Description of 'title1' SketchupModel."
        test_model.mesh = file("sketchup_models/fixtures/mesh_can.tri").read()
        test_model.save()

        self.test_model = SketchupModel.find_google_id("test1")
        self.view = PartialView(model=self.test_model, theta=0.0, phi=0.0)
        self.distribution = ShapeDistribution.compute(self.view.pointcloud)
Exemple #4
0
    def setUp(self):
        """ Run before starting testing. """
        # TODO : use fixtures
        test_model = SketchupModel()
        test_model.google_id = "test1"
        test_model.tags = ["tag1", "tag2"]
        test_model.title = "title1"
        test_model.text = "Description of 'title1' SketchupModel."
        test_model.mesh = file("sketchup_models/fixtures/mesh_can.tri").read()
        test_model.save()

        self.test_model = SketchupModel.find_google_id("test1")
        self.view = PartialView(model=self.test_model, theta=0.0, phi=0.0)
        self.distribution = ShapeDistribution.compute(self.view.pointcloud)
Exemple #5
0
 def identify_with_proba(self, data):
     """ Return the category of the Pointcloud or Distribution object. """
     if not self.dict_categories:
         raise IndexError("Identifier is empty.")
     if len(self.dict_categories) == 1:
         #  Only 1 category return it directly
         return (self.dict_categories.keys()[0], 1.0)
     if type(data) is PointCloud:
         data = ShapeDistribution.compute(data)
     if type(data) is ShapeDistribution:
         data = data.as_numpy_array
     result_proba = None
     try:
         result_proba = self.classifier.decision_function(data)
     except AttributeError:
         pass
     try:
         result_idx = int(self.classifier.predict(data)[0])
         result_name = self.dict_categories.keys()[result_idx]
     except ValueError:
         result_name = 'Unknown'
     return (result_name, result_proba)
Exemple #6
0
 def identify_with_proba(self, data):
     """ Return the category of the Pointcloud or Distribution object. """
     if not self.dict_categories:
         raise IndexError("Identifier is empty.")
     if len(self.dict_categories) == 1:
         #  Only 1 category return it directly
         return (self.dict_categories.keys()[0], 1.0)
     if type(data) is PointCloud:
         data = ShapeDistribution.compute(data)
     if type(data) is ShapeDistribution:
         data = data.as_numpy_array
     result_proba = None
     try:
         result_proba = self.classifier.decision_function(data)
     except AttributeError:
         pass
     try:
         result_idx = int(self.classifier.predict(data)[0])
         result_name = self.dict_categories.keys()[result_idx]
     except ValueError:
         result_name = 'Unknown'
     return (result_name, result_proba)
Exemple #7
0
 def distribution(self):
     if not self._distribution:
         self._distribution = ShapeDistribution.compute(self.pointcloud)
     return self._distribution
Exemple #8
0
 def distribution(self):
     if not self._distribution:
         self._distribution = ShapeDistribution.compute(self.pointcloud)
     return self._distribution
Exemple #9
0
from sketchup_models.models import SketchupModel
from partial_view.models import PartialView
from shape_distribution.models import ShapeDistribution
from common.libs.libpydescriptors import Distribution

model = SketchupModel.objects.all()[0]
view = PartialView.compute_view( model, 0.0, 0.0 )
dis = ShapeDistribution.compute( view.pointcloud )