Skip to content

Commit c2724ac

Browse files
Merge pull request #32 from MobileRoboticsSkoltech/remote_extension
Add exposure time reporting to remote feature
2 parents 0cfcde3 + 8d623bc commit c2724ac

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

api_client/basic_example.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ def main():
1010
remote = RemoteControl(HOST)
1111
print("Connected")
1212

13-
accel_data, gyro_data, magnetic_data = remote.get_imu(10000, True, False, True)
14-
print("Magnetometer data length: %d" % len(magnetic_data))
15-
with open("magnetic.csv", "w+") as imu_file:
16-
imu_file.writelines(magnetic_data)
13+
#print("Magnetometer data length: %d" % len(magnetic_data))
14+
#with open("magnetic.csv", "w+") as imu_file:
15+
# imu_file.writelines(magnetic_data)
1716

18-
phase, duration = remote.start_video()
19-
print("%d %f" % (phase, duration))
17+
phase, duration, exp_time = remote.start_video()
18+
print("%d %f" % (exp_time, duration))
2019
time.sleep(5)
2120
remote.stop_video()
2221

api_client/src/RemoteControl.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
BUFFER_SIZE = 4096
77
PROPS_PATH = '../app/src/main/assets/server_config.properties'
88
SUPPORTED_SERVER_VERSIONS = [
9-
'v.0.1'
9+
'v.0.1.1'
1010
]
1111
NUM_SENSORS = 3
1212

@@ -81,7 +81,7 @@ def get_imu(self, duration_ms, want_accel, want_gyro, want_magnetic):
8181
def start_video(self):
8282
"""
8383
Starts video recording and receives phase and duration info
84-
:return: Tuple (phase, average duration) - all in nanoseconds
84+
:return: Tuple (phase, average duration, exposure time) - all in nanoseconds
8585
"""
8686
status, socket_file = self._send_and_get_response_status(
8787
self.props['VIDEO_START_REQUEST']
@@ -94,8 +94,11 @@ def start_video(self):
9494
line = socket_file.readline()
9595
avg_duration_ns = float(line)
9696

97+
line = socket_file.readline()
98+
exposure_time = int(line)
99+
97100
socket_file.readline()
98-
return phase_ns, avg_duration_ns
101+
return phase_ns, avg_duration_ns, exposure_time
99102

100103
def stop_video(self):
101104
"""

app/src/main/assets/server_config.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
RPC_PORT=6969
2-
SERVER_VERSION=v.0.1
2+
SERVER_VERSION=v.0.1.1
33
VIDEO_START_REQUEST=video_start
44
VIDEO_STOP_REQUEST=video_stop
55
GET_VIDEO_REQUEST=get_video

app/src/main/java/net/sourceforge/opencamera/sensorlogging/VideoFrameInfo.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package net.sourceforge.opencamera.sensorlogging;
22

3-
import android.content.Context;
43
import android.graphics.Bitmap;
54
import android.graphics.Matrix;
65
import android.util.Log;
@@ -11,6 +10,7 @@
1110
import net.sourceforge.opencamera.StorageUtils;
1211
import net.sourceforge.opencamera.StorageUtilsWrapper;
1312
import net.sourceforge.opencamera.cameracontroller.YuvImageUtils;
13+
import net.sourceforge.opencamera.preview.Preview;
1414

1515
import java.io.BufferedWriter;
1616
import java.io.Closeable;
@@ -47,7 +47,7 @@ public class VideoFrameInfo implements Closeable {
4747
private final ExtendedAppInterface mAppInterface;
4848
private final BufferedWriter mFrameBufferedWriter;
4949
private final boolean mShouldSaveFrames;
50-
private final Context mContext;
50+
private final MainActivity mContext;
5151
private final YuvImageUtils mYuvUtils;
5252
private final BlockingQueue<VideoPhaseInfo> mPhaseInfoReporter;
5353
private final List<Long> durationsNs;
@@ -102,8 +102,14 @@ public void submitProcessFrame(long timestamp) {
102102
mLastTimestamp = timestamp;
103103
} else if (mFrameNumber == PHASE_CALC_N_FRAMES) {
104104
// Should report phase
105+
Preview preview = mContext.getPreview();
106+
107+
long exposureTime = 0;
108+
if(preview.getCameraController().captureResultHasExposureTime() ) {
109+
exposureTime = preview.getCameraController().captureResultExposureTime();
110+
}
105111
mPhaseInfoReporter.add(
106-
new VideoPhaseInfo(timestamp, durationsNs)
112+
new VideoPhaseInfo(timestamp, durationsNs, exposureTime)
107113
);
108114
}
109115

app/src/main/java/net/sourceforge/opencamera/sensorlogging/VideoPhaseInfo.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
public class VideoPhaseInfo {
88
private final long mVideoPhaseNs;
99
private final double mAvgDurationNs;
10+
private final long mExposureTime;
11+
1012

1113
private static double mean(List<Long> numList) {
1214
double sum = 0;
@@ -16,9 +18,10 @@ private static double mean(List<Long> numList) {
1618
return sum / numList.size();
1719
}
1820

19-
public VideoPhaseInfo(long videoPhaseNs, List<Long> frameDurations) {
21+
public VideoPhaseInfo(long videoPhaseNs, List<Long> frameDurations, long exposureTime) {
2022
this.mVideoPhaseNs = videoPhaseNs;
2123
this.mAvgDurationNs = mean(frameDurations);
24+
this.mExposureTime = exposureTime;
2225
}
2326

2427
public long getVideoPhaseNs() {
@@ -29,9 +32,11 @@ public double getAvgDurationNs() {
2932
return mAvgDurationNs;
3033
}
3134

35+
public long getExposureTime() { return mExposureTime; }
36+
3237
@NonNull
3338
@Override
3439
public String toString() {
35-
return mVideoPhaseNs + "\n" + mAvgDurationNs + "\n";
40+
return mVideoPhaseNs + "\n" + mAvgDurationNs + "\n" + mExposureTime + "\n";
3641
}
3742
}

0 commit comments

Comments
 (0)