Project import generated by Copybara.

GitOrigin-RevId: ea8d45731f5a052f79745e35bfd8240d6ac568d2
This commit is contained in:
MediaPipe Team
2020-12-16 00:05:25 -05:00
committed by chuoling
parent 38be2ec58f
commit 39309bedba
109 changed files with 5803 additions and 1500 deletions
@@ -56,8 +56,10 @@ public class MainActivity extends com.google.mediapipe.apps.basic.MainActivity {
} catch (NameNotFoundException e) {
Log.e(TAG, "Cannot find application info: " + e);
}
// Get allowed object category.
String categoryName = applicationInfo.metaData.getString("categoryName");
// Get maximum allowed number of objects.
int maxNumObjects = applicationInfo.metaData.getInt("maxNumObjects");
float[] modelScale = parseFloatArrayFromString(
applicationInfo.metaData.getString("modelScale"));
float[] modelTransform = parseFloatArrayFromString(
@@ -70,6 +72,7 @@ public class MainActivity extends com.google.mediapipe.apps.basic.MainActivity {
inputSidePackets.put("obj_texture", packetCreator.createRgbaImageFrame(objTexture));
inputSidePackets.put("box_texture", packetCreator.createRgbaImageFrame(boxTexture));
inputSidePackets.put("allowed_labels", packetCreator.createString(categoryName));
inputSidePackets.put("max_num_objects", packetCreator.createInt32(maxNumObjects));
inputSidePackets.put("model_scale", packetCreator.createFloat32Array(modelScale));
inputSidePackets.put("model_transformation", packetCreator.createFloat32Array(modelTransform));
processor.setInputSidePackets(inputSidePackets);
@@ -118,8 +121,8 @@ public class MainActivity extends com.google.mediapipe.apps.basic.MainActivity {
} catch (RuntimeException e) {
Log.e(
TAG,
"MediaPipeException encountered adding packets to width and height"
+ " input streams.");
"MediaPipeException encountered adding packets to input_width and input_height"
+ " input streams.", e);
}
widthPacket.release();
heightPacket.release();
@@ -8,6 +8,7 @@
<application>
<meta-data android:name="categoryName" android:value="Camera"/>
<meta-data android:name="maxNumObjects" android:value="5"/>
<meta-data android:name="modelScale" android:value="250, 250, 250"/>
<meta-data android:name="modelTransformation" android:value="1.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
@@ -8,6 +8,7 @@
<application>
<meta-data android:name="categoryName" android:value="Chair"/>
<meta-data android:name="maxNumObjects" android:value="5"/>
<meta-data android:name="modelScale" android:value="0.1, 0.05, 0.1"/>
<meta-data android:name="modelTransformation" android:value="1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, -10.0,
@@ -8,6 +8,7 @@
<application>
<meta-data android:name="categoryName" android:value="Coffee cup,Mug"/>
<meta-data android:name="maxNumObjects" android:value="5"/>
<meta-data android:name="modelScale" android:value="500, 500, 500"/>
<meta-data android:name="modelTransformation" android:value="1.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, -0.001,
@@ -8,6 +8,7 @@
<application>
<meta-data android:name="categoryName" android:value="Footwear"/>
<meta-data android:name="maxNumObjects" android:value="5"/>
<meta-data android:name="modelScale" android:value="0.25, 0.25, 0.12"/>
<meta-data android:name="modelTransformation" android:value="1.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
@@ -52,8 +52,9 @@ mediapipe::Status KinematicPathSolver::AddObservation(int position,
}
}
double delta_degs = (Median(raw_positions_at_time_) - current_position_px_) /
pixels_per_degree_;
int filtered_position = Median(raw_positions_at_time_);
double delta_degs =
(filtered_position - current_position_px_) / pixels_per_degree_;
// If the motion is smaller than the min_motion_to_reframe and camera is
// stationary, don't use the update.
@@ -68,14 +69,14 @@ mediapipe::Status KinematicPathSolver::AddObservation(int position,
} else if (delta_degs > 0) {
// Apply new position, less the reframe window size.
target_position_px_ =
position - pixels_per_degree_ * options_.reframe_window();
filtered_position - pixels_per_degree_ * options_.reframe_window();
delta_degs =
(target_position_px_ - current_position_px_) / pixels_per_degree_;
motion_state_ = true;
} else {
// Apply new position, plus the reframe window size.
target_position_px_ =
position + pixels_per_degree_ * options_.reframe_window();
filtered_position + pixels_per_degree_ * options_.reframe_window();
delta_degs =
(target_position_px_ - current_position_px_) / pixels_per_degree_;
motion_state_ = true;