RAPP Platform API
 All Classes Namespaces Files Functions Variables Typedefs
FaceDetection.py
Go to the documentation of this file.
1 from RappCloud.Objects import (
2  File,
3  Payload)
4 
5 from Cloud import (
6  CloudMsg,
7  CloudRequest,
8  CloudResponse)
9 
10 
11 class FaceDetection(CloudMsg):
12  """ Face Detection CloudMsg object"""
13 
14  class Request(CloudRequest):
15  """ Face Detection Cloud Request object. FaceDetection.Request """
16  def __init__(self, **kwargs):
17  """!
18  Constructor
19 
20  @param **kwargs - Keyword arguments. Apply values to the request attributes.
21  - @ref imageFilepath
22  - @ref fast
23  """
24 
25  ## File path to the image to load. This is the image to perform
26  # face-detection on.
27  self.imageFilepath = ''
28  ## If true, detection will take less time but it will be less
29  # accurate
30  self.fast = False
31  # Apply passed keyword arguments to the Request object.
32  super(FaceDetection.Request, self).__init__(**kwargs)
33 
34 
35  def make_payload(self):
36  """ Create and return the Payload of the Request. """
37  return Payload(fast=self.fast)
38 
39  def make_files(self):
40  """ Create and return Array of File objects of the Request. """
41  return [File(self.imageFilepath, postfield='file')]
42 
43 
44  class Response(CloudResponse):
45  """ Face Detection Cloud Response object. FaceDetection.Response """
46  def __init__(self, **kwargs):
47  """!
48  Constructor
49 
50  @param **kwargs - Keyword arguments. Apply values to the request attributes.
51  - @ref error
52  - @ref faces
53  """
54 
55  ## Error message
56  self.error = ''
57  ## Detected faces. Array of face objects. TODO create face object.
58  self.faces = []
59  ## Apply passed keyword arguments to the Request object.
60  super(FaceDetection.Response, self).__init__(**kwargs)
61 
62 
63  def __init__(self, **kwargs):
64  """!
65  Constructor
66 
67  @param **kwargs - Keyword arguments. Apply values to the request attributes.
68  - @ref Request.fast
69  - @ref Request.imageFilepath
70  """
71 
72  # Create and hold the Request object for this CloudMsg
74  # Create and hold the Response object for this CloudMsg
76  super(FaceDetection, self).__init__(svcname='face_detection', **kwargs)
77 
78 
fast
If true, detection will take less time but it will be less accurate.