Commit e36e815c authored by Wei Guan's avatar Wei Guan Committed by Commit Bot

Indicate what types of perception were run in a perception sample.

Currently all available perception results are added to the perception
sample as entities. When there are no entities, we dont know if there
were no entities detected, or no detections were run at all.

BUG=872764

Change-Id: I18d4b0f1a0e285f030e5d6f64a4c62c0dc23ae07
Reviewed-on: https://chromium-review.googlesource.com/1169311Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Commit-Queue: Wei Guan <weigua@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582994}
parent 77c6418c
......@@ -224,6 +224,16 @@ message FramePerception {
// Human presence detection results for a video frame.
optional VideoHumanPresenceDetection video_human_presence_detection = 7;
enum PerceptionType {
UNKNOWN_TYPE = 0;
FACE_DETECTION = 1;
MOTION_DETECTION = 2;
PERSON_DETECTION = 3;
}
// Indicates what types of frame perception were run.
repeated PerceptionType perception_types = 8;
}
// Detection of human presence close to the camera.
......
......@@ -285,6 +285,21 @@ std::unique_ptr<Distance> DistanceProtoToIdl(const mri::Distance& distance) {
return distance_result;
}
FramePerceptionType FramePerceptionTypeProtoToIdl(int type) {
switch (type) {
case mri::FramePerception::UNKNOWN_TYPE:
return FRAME_PERCEPTION_TYPE_UNKNOWN_TYPE;
case mri::FramePerception::FACE_DETECTION:
return FRAME_PERCEPTION_TYPE_FACE_DETECTION;
case mri::FramePerception::PERSON_DETECTION:
return FRAME_PERCEPTION_TYPE_PERSON_DETECTION;
case mri::FramePerception::MOTION_DETECTION:
return FRAME_PERCEPTION_TYPE_MOTION_DETECTION;
}
NOTREACHED() << "Unknown frame perception type: " << type;
return FRAME_PERCEPTION_TYPE_UNKNOWN_TYPE;
}
EntityType EntityTypeProtoToIdl(const mri::Entity& entity) {
if (entity.has_type()) {
switch (entity.type()) {
......@@ -379,6 +394,14 @@ FramePerception FramePerceptionProtoToIdl(
VideoHumanPresenceDetectionProtoToIdl(
frame_perception.video_human_presence_detection());
}
if (frame_perception.perception_types_size() > 0) {
frame_perception_result.frame_perception_types =
std::make_unique<std::vector<FramePerceptionType>>();
for (const auto& type : frame_perception.perception_types()) {
frame_perception_result.frame_perception_types->emplace_back(
FramePerceptionTypeProtoToIdl(type));
}
}
return frame_perception_result;
}
......
......@@ -161,6 +161,13 @@ void InitializeFakeFramePerception(const int index,
detection->set_motion_detected_likelihood(0.2);
detection->set_light_condition(mri::VideoHumanPresenceDetection::BLACK_FRAME);
detection->set_light_condition_likelihood(0.3);
// Add fake frame perception types.
frame_perception->add_perception_types(mri::FramePerception::FACE_DETECTION);
frame_perception->add_perception_types(
mri::FramePerception::PERSON_DETECTION);
frame_perception->add_perception_types(
mri::FramePerception::MOTION_DETECTION);
}
std::unique_ptr<media_perception::Point> MakePointIdl(float x, float y) {
......@@ -269,6 +276,15 @@ void ValidateFramePerceptionResult(
media_perception::LIGHT_CONDITION_BLACK_FRAME);
ASSERT_TRUE(detection_result->light_condition_likelihood);
EXPECT_EQ(*detection_result->light_condition_likelihood, 0.3);
// Validate frame perception types.
ASSERT_EQ(3u, frame_perception_result.frame_perception_types->size());
EXPECT_EQ(frame_perception_result.frame_perception_types->at(0),
media_perception::FRAME_PERCEPTION_TYPE_FACE_DETECTION);
EXPECT_EQ(frame_perception_result.frame_perception_types->at(1),
media_perception::FRAME_PERCEPTION_TYPE_PERSON_DETECTION);
EXPECT_EQ(frame_perception_result.frame_perception_types->at(2),
media_perception::FRAME_PERCEPTION_TYPE_MOTION_DETECTION);
}
void ValidateAudioPerceptionResult(
......
......@@ -232,6 +232,13 @@ namespace mediaPerceptionPrivate {
LABELED_REGION
};
enum FramePerceptionType {
UNKNOWN_TYPE,
FACE_DETECTION,
PERSON_DETECTION,
MOTION_DETECTION
};
dictionary Entity {
// A unique id associated with the detected entity, which can be used to
// track the entity over time.
......@@ -320,6 +327,9 @@ namespace mediaPerceptionPrivate {
// Human presence detection results for a video frame.
VideoHumanPresenceDetection? videoHumanPresenceDetection;
// Indicates what types of frame perception were run.
FramePerceptionType[]? framePerceptionTypes;
};
// An estimate of the direction that the sound is coming from.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment