1 package com.intel.realsense.camera;
3 import android.content.Context;
4 import android.content.Intent;
5 import android.content.SharedPreferences;
6 import android.graphics.Color;
7 import android.graphics.Rect;
8 import android.os.Bundle;
9 import androidx.appcompat.app.AppCompatActivity;
10 import android.util.Pair;
11 import android.view.View;
12 import android.view.ViewGroup;
13 import android.view.WindowManager;
14 import android.widget.RelativeLayout;
15 import android.widget.TextView;
22 import java.util.HashMap;
26 private static final String TAG =
"librs camera pb";
41 protected void onCreate(Bundle savedInstanceState) {
42 super.onCreate(savedInstanceState);
43 setContentView(
R.layout.activity_playback);
44 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
46 mGLSurfaceView = findViewById(
R.id.playbackGlSurfaceView);
47 m3dButton = findViewById(
R.id.playback_3d_button);
48 m3dButton.setOnClickListener(
new View.OnClickListener() {
50 public void onClick(View
view) {
51 mGLSurfaceView.setVisibility(View.GONE);
52 mGLSurfaceView.
clear();
55 m3dButton.setTextColor(mShow3D ?
Color.YELLOW :
Color.WHITE);
56 mGLSurfaceView.setVisibility(View.VISIBLE);
57 SharedPreferences sharedPref = getSharedPreferences(getString(
R.string.app_settings), Context.MODE_PRIVATE);
58 SharedPreferences.Editor editor = sharedPref.edit();
59 editor.putBoolean(getString(
R.string.show_3d), mShow3D);
63 SharedPreferences sharedPref = getSharedPreferences(getString(
R.string.app_settings), Context.MODE_PRIVATE);
64 mShow3D = sharedPref.getBoolean(getString(
R.string.show_3d),
false);
65 m3dButton.setTextColor(mShow3D ?
Color.YELLOW :
Color.WHITE);
72 if(mFilePath == null){
74 intent.putExtra(getString(
R.string.browse_folder), getString(
R.string.realsense_folder) + File.separator +
"video");
75 startActivityForResult(intent, OPEN_FILE_REQUEST_CODE);
86 public void onFrameset(
FrameSet frameSet) {
88 mGLSurfaceView.
upload(frameSet);
89 Map<Integer, Pair<String, Rect>> rects = mGLSurfaceView.
getRectangles();
94 mGLSurfaceView.
clear();
96 }
catch (Exception
e) {
108 if(mStreamer != null)
110 if(mGLSurfaceView != null)
111 mGLSurfaceView.
clear();
116 super.onActivityResult(requestCode, resultCode, data);
117 if (requestCode == OPEN_FILE_REQUEST_CODE && resultCode == RESULT_OK) {
119 mFilePath = data.getStringExtra(getString(
R.string.intent_extra_file_path));
123 Intent intent =
new Intent();
124 setResult(RESULT_OK, intent);
131 super.onSaveInstanceState(outState);
132 outState.putString(FILE_PATH_KEY, mFilePath);
137 super.onRestoreInstanceState(savedInstanceState);
138 mFilePath = savedInstanceState.getString(FILE_PATH_KEY);
141 private synchronized Map<Integer, TextView>
createLabels(Map<Integer, Pair<String, Rect>> rects){
144 mLabels =
new HashMap<>();
146 final RelativeLayout rl = findViewById(
R.id.labels_layout);
147 for(Map.Entry<Integer, Pair<String, Rect>>
e : rects.entrySet()){
148 TextView tv =
new TextView(getApplicationContext());
149 ViewGroup.LayoutParams lp =
new RelativeLayout.LayoutParams(
150 ViewGroup.LayoutParams.WRAP_CONTENT,
151 ViewGroup.LayoutParams.WRAP_CONTENT);
152 tv.setLayoutParams(lp);
153 tv.setTextColor(
Color.parseColor(
"#ffffff"));
156 mLabels.put(
e.getKey(), tv);
161 private void printLables(
final Map<Integer, Pair<String, Rect>> rects){
164 final Map<Integer, String> lables =
new HashMap<>();
167 for(Map.Entry<Integer, Pair<String, Rect>>
e : rects.entrySet()){
168 lables.put(
e.getKey(),
e.getValue().first);
171 runOnUiThread(
new Runnable() {
174 for(Map.Entry<Integer,TextView>
e : mLabels.entrySet()){
175 Integer
uid =
e.getKey();
176 if(rects.get(uid) == null)
178 Rect
r = rects.get(uid).second;
179 TextView tv =
e.getValue();
182 tv.setText(lables.get(uid));
190 for(Map.Entry<Integer, TextView>
label : mLabels.entrySet())
191 label.getValue().setVisibility(View.GONE);
Map< Integer, TextView > mLabels
uvc_xu_option< int > super
void onActivityResult(int requestCode, int resultCode, Intent data)
void onRestoreInstanceState(final Bundle savedInstanceState)
void onCreate(Bundle savedInstanceState)
void enableDeviceFromFile(String filePath)
::std_msgs::String_< std::allocator< void > > String
void onSaveInstanceState(final Bundle outState)
static final String FILE_PATH_KEY
static final int OPEN_FILE_REQUEST_CODE
def run(include_folder_path, addon_folder_path)
void printLables(final Map< Integer, Pair< String, Rect >> rects)
GLuint GLsizei const GLchar * label
GLRsSurfaceView mGLSurfaceView
synchronized void start()
synchronized Map< Integer, TextView > createLabels(Map< Integer, Pair< String, Rect >> rects)