OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Private API for communicating with and receiving real-time media perception |
| 6 // information from an computer vision + machine intelligence binary. |
| 7 [platforms=("chromeos"), |
| 8 implemented_in = "extensions/browser/api/media_perception_private/media_percept
ion_private_api.h"] |
| 9 |
| 10 namespace mediaPerceptionPrivate { |
| 11 enum Status { |
| 12 // An error occurred that needs to be propagated to the frontend. |
| 13 ERROR, |
| 14 |
| 15 // Unable to reach media analysis process. |
| 16 TIMEOUT, |
| 17 |
| 18 // Media analytics process waiting to be started. |
| 19 UNINITIALIZED, |
| 20 |
| 21 // Analysis process running but not recieving frames. |
| 22 STARTED, |
| 23 |
| 24 // Analysis process running and injesting frames. |
| 25 RUNNING, |
| 26 |
| 27 // Analysis process ready to be set to state RUNNING. |
| 28 SUSPENDED |
| 29 }; |
| 30 |
| 31 // The system and configuration state of the analysis process and v4lplugin. |
| 32 dictionary State { |
| 33 Status? status; |
| 34 // Optionally add device context to setState command for starting |
| 35 // media analytics process, so that the media analytics process can |
| 36 // better select the right video device to open. |
| 37 DOMString? deviceContext; |
| 38 }; |
| 39 |
| 40 dictionary Point { |
| 41 // x represents the horizontal distance from the top left corner of the |
| 42 // image to the point. |
| 43 double? x; |
| 44 // y represents the vertical distance from the top left corner of the |
| 45 // image to the point. |
| 46 double? y; |
| 47 }; |
| 48 |
| 49 dictionary BoundingBox { |
| 50 // Specifies whether the points are normalized to the size of the image. |
| 51 // If not set, the points are not normalized. |
| 52 boolean? normalized; |
| 53 // The two points that define the corners of a bounding box. |
| 54 Point? topLeft; |
| 55 Point? bottomRight; |
| 56 }; |
| 57 |
| 58 enum EntityType { |
| 59 UNSPECIFIED, |
| 60 FACE, |
| 61 PERSON |
| 62 }; |
| 63 |
| 64 dictionary Entity { |
| 65 // A unique id associated with the detected entity, which can be used to |
| 66 // track the entity over time. |
| 67 long? id; |
| 68 |
| 69 EntityType? type; |
| 70 |
| 71 // Minimum box which captures entire detected entity. |
| 72 BoundingBox? boundingBox; |
| 73 |
| 74 // A value for the quality of this detection. |
| 75 double? confidence; |
| 76 }; |
| 77 |
| 78 // The set of computer vision metadata for an image frame. |
| 79 dictionary FramePerception { |
| 80 long? frameId; |
| 81 |
| 82 long? frameWidthInPx; |
| 83 long? frameHeightInPx; |
| 84 // The timestamp associated with the frame (when its recieved by the |
| 85 // analysis process). |
| 86 double? timestamp; |
| 87 |
| 88 // The list of entities detected in this frame. |
| 89 Entity[]? entities; |
| 90 }; |
| 91 |
| 92 dictionary MediaPerception { |
| 93 // The timestamp attached with when this data originated from the analysis |
| 94 // process. |
| 95 double? timestamp; |
| 96 // An array of framePerceptions, often just one. |
| 97 FramePerception[]? framePerceptions; |
| 98 }; |
| 99 |
| 100 // TODO(lasoren): Change this interface based on the compressed images coming |
| 101 // from the media analytics process. |
| 102 dictionary ImageFrame { |
| 103 long? width; |
| 104 long? height; |
| 105 // colorspace is defined in the same way as SimpleImage::ColorSpace. |
| 106 long? colorspace; |
| 107 // By default, 1 channel means Grayscale, 2 channels meangs Grayscale + Alph
a, |
| 108 // 3 channels means RGB, and 4 channels means RGBA. |
| 109 long? channels; |
| 110 // TODO(lasoren): Add compression format marker. |
| 111 // The bytes of the image frame. |
| 112 ArrayBuffer? frame; |
| 113 }; |
| 114 |
| 115 dictionary PerceptionSample { |
| 116 // The video analytics FramePerception for the associated image frame |
| 117 // data. |
| 118 FramePerception? framePerception; |
| 119 // The image frame data for the associated FramePerception object. |
| 120 ImageFrame? imageFrame; |
| 121 }; |
| 122 |
| 123 dictionary Diagnostics { |
| 124 // A buffer of image frames and the associated video analytics to be sent |
| 125 // for diagnostics (when a user reports malfunction). |
| 126 PerceptionSample[]? perceptionSamples; |
| 127 }; |
| 128 |
| 129 callback StateCallback = void(State state); |
| 130 |
| 131 callback DiagnosticsCallback = void(Diagnostics diagnostics); |
| 132 |
| 133 interface Functions { |
| 134 // Get the status of the media perception process. |
| 135 // |callback| : The current State of the system. |
| 136 static void getState(StateCallback callback); |
| 137 |
| 138 // Set the desired state of the system. |
| 139 // |state| : A dictionary with the desired new state. |
| 140 // |callback| : The State of the system after setting it. Verifies that |
| 141 // the state was set as desired. |
| 142 static void setState(State state, StateCallback callback); |
| 143 |
| 144 // Get a diagnostics buffer out of the video analytics process. |
| 145 // |callback| : Returns a Diagnostics dictionary object which |
| 146 // contains image frame data and associated detections to be logged. |
| 147 static void getDiagnostics(DiagnosticsCallback callback); |
| 148 }; |
| 149 |
| 150 interface Events { |
| 151 // Fired when the analysis process has passed back to Chrome the current |
| 152 // mediaPerception information. |
| 153 // |mediaPerception| : The dictionary which contains a dump of everything |
| 154 // the analysis process has detected or determined from the incoming media |
| 155 // streams. |
| 156 static void onMediaPerception(MediaPerception mediaPerception); |
| 157 }; |
| 158 }; |
OLD | NEW |