1 package com.intel.realsense.camera;
3 import android.util.Log;
14 import java.util.HashMap;
16 import java.util.concurrent.atomic.AtomicLongArray;
19 private static final String TAG =
"librs camera streamer";
22 private Map<Integer, Statistics>
mStreamsMap =
new HashMap<>();
23 private Map<Integer, Statistics>
mLastFrames =
new HashMap<>();
54 public void onFrame(
Frame f) {
58 if (!mLastFrames.containsKey(
profile.getUniqueId()))
60 if (mLastFrames.get(uid).mFrameNumber != fn) {
73 mStreamsMap.get(uid).mFrameNumber = fn;
75 mStreamsMap.get(uid).mSWTimestamp = System.currentTimeMillis();
76 mStreamsMap.get(uid).onFrame(f);
77 mLastFrames.put(uid, mStreamsMap.get(uid).clone());
80 mStreamsMap.get(uid).kick();
91 for(Map.Entry
e : mStreamsMap.entrySet()){
132 }
catch (CloneNotSupportedException
e) {
139 mStartTime = mBaseTime = System.currentTimeMillis();
140 mFirstFrameLatency = 0;
152 long curr = System.currentTimeMillis();
153 int diffInSeconds = (int) ((curr - mStartTime) * 0.001);
154 String hwTimestampAsString =
String.format(
"%.3f", mHWTimestamp);
156 "\nFrame Rate: " + mFps +
157 "\nFrame Count: " + mTotalFrameCount +
158 "\nFrame Number: " + mFrameNumber +
159 "\nFrame Loss: " + mFrameLoss +
160 "\nHW timestamp: " + hwTimestampAsString +
161 "\nSW timestamp: " + mSWTimestamp +
162 "\nRun Time: " + diffInSeconds +
" [sec]" +
163 "\nEmitter Mode: " + mEmitter +
167 public synchronized void kick(){
168 long curr = System.currentTimeMillis();
169 float diffInSeconds = (float) ((curr - mBaseTime) * 0.001);
170 if(diffInSeconds > 2){
171 mFps = mFrameCount / diffInSeconds;
180 long curr = System.currentTimeMillis();
181 float diffInSeconds = (float) ((curr - mBaseTime) * 0.001);
182 if(mFirstFrameLatency == 0){
186 if(diffInSeconds > 2){
187 mFps = mFrameCount / diffInSeconds;
194 Statistics mLastFrame = mLastFrames.get(streamProfile.getUniqueId());
195 mHWTimestampDiff = mHWTimestamp - mLastFrame.
mHWTimestamp;
196 mSWTimestampDiff = mSWTimestamp - mLastFrame.
mSWTimestamp;
201 String hwTimestampAsString =
String.format(
"%.3f", mHWTimestamp);
202 String hwTimestampDiffAsString =
String.format(
"%.3f", mHWTimestampDiff);
207 mRequestedFps +
", " +
208 mFrameNumber +
", " +
209 hwTimestampAsString +
", " +
210 hwTimestampDiffAsString +
", " +
211 mSWTimestamp +
", " +
212 mSWTimestampDiff +
", " +
213 mAutoExposureMode +
", " +
219 Log.i(DATA_LOG_TAG, data);
::rosgraph_msgs::Log_< std::allocator< void > > Log
uvc_xu_option< int > super
GLuint const GLchar * name
long getMetadata(FrameMetadata type)
::std_msgs::String_< std::allocator< void > > String
static final String DATA_LOG_TAG
void initStream(StreamProfile profile)
GLint GLint GLsizei GLint GLenum format
Map< Integer, Statistics > mStreamsMap
boolean is(Extension extension)
void foreach(FrameCallback callback)
void onFrameset(FrameSet frames)
FrameCallback mFrameCallback
Map< Integer, Statistics > mLastFrames
synchronized void onFrame(Frame f)
boolean supportsMetadata(FrameMetadata type)
StreamProfile getProfile()