Skip to content

Commit 0e2bbbc

Browse files
committed
Modify ByteConversion
1 parent eb11fc4 commit 0e2bbbc

38 files changed

+153
-109
lines changed

app/src/main/java/com/orbbec/orbbecsdkexamples/activity/AdvancedHdrActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void onDeviceAttach(DeviceList deviceList) {
7979
mHdrConfig.setGain1(16);
8080
mHdrConfig.setExposure2(1);
8181
mHdrConfig.setGain2(16);
82-
mDevice.setPropertyValueDataType(DeviceProperty.OB_STRUCT_DEPTH_HDR_CONFIG, mHdrConfig, mHdrConfig.BYTES());
82+
mDevice.setPropertyValueDataType(DeviceProperty.OB_STRUCT_DEPTH_HDR_CONFIG, mHdrConfig);
8383

8484
// 6.Create HdrMerge post processor
8585
mHdrFilter = new HdrMerge();
@@ -169,7 +169,7 @@ protected void onStop() {
169169

170170
if (mDevice != null) {
171171
mHdrConfig.setEnable((byte) 0);
172-
mDevice.setPropertyValueDataType(DeviceProperty.OB_STRUCT_DEPTH_HDR_CONFIG, mHdrConfig, mHdrConfig.BYTES());
172+
mDevice.setPropertyValueDataType(DeviceProperty.OB_STRUCT_DEPTH_HDR_CONFIG, mHdrConfig);
173173
mDevice.close();
174174
}
175175
} catch (Exception e) {

obsensor_jni/src/main/java/com/orbbec/obsensor/AccelStreamProfile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public IMUSampleRate getSampleRate() {
6464
public AccelIntrinsic getIntrinsic() {
6565
throwInitializeException();
6666
AccelIntrinsic intrinsic = new AccelIntrinsic();
67-
nGetIntrinsic(mHandle, intrinsic.BYTES());
67+
nGetIntrinsic(mHandle, intrinsic.getBytes());
6868
boolean result = intrinsic.parseBytes();
6969
if (!result) {
7070
throw new OBException("getIntrinsic parse bytes error!");
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.orbbec.obsensor;
22

33
public interface ByteConversion {
4-
// 解析字节数组的方法
4+
byte[] getBytes();
5+
6+
// Parse Byte Arrays
57
default boolean parseBytes() {
6-
// 默认实现:返回 false 或抛出异常
78
throw new UnsupportedOperationException("parseBytes not implemented");
89
}
910

10-
// 包装字节数组的方法
11-
default boolean wrapBytes(byte[] bytes) {
12-
// 默认实现:返回空字节数组或抛出异常
11+
// Wrap Byte Arrays
12+
default boolean wrapBytes() {
1313
throw new UnsupportedOperationException("wrapBytes not implemented");
1414
}
1515
}

obsensor_jni/src/main/java/com/orbbec/obsensor/CameraParamList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public CameraParam getCameraParam(int index) {
4848
throwInitializeException();
4949

5050
CameraParam params = new CameraParam();
51-
nGetCameraParam(mHandle, index, params.BYTES());
51+
nGetCameraParam(mHandle, index, params.getBytes());
5252
if (params.parseBytes()) {
5353
return params;
5454
}

obsensor_jni/src/main/java/com/orbbec/obsensor/CoordinateTransformHelper.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public static boolean is3dTo3d(CalibrationParam calibrationParam,
3535
Point3f sourcePoint3f,
3636
SensorType sourceType, SensorType targetType,
3737
Point3f targetPoint3f) {
38-
return nIs3dTo3d(calibrationParam.BYTES(), sourcePoint3f.BYTES(),
38+
return nIs3dTo3d(calibrationParam.getBytes(), sourcePoint3f.getBytes(),
3939
sourceType.value(), targetType.value(),
40-
targetPoint3f.BYTES());
40+
targetPoint3f.getBytes());
4141
}
4242

4343
/**
@@ -66,10 +66,10 @@ public static boolean is2dTo3d(CalibrationParam calibrationParam,
6666
float sourceDepthPixel,
6767
SensorType sourceType, SensorType targetType,
6868
Point3f targetPoint3f) {
69-
return nIs2dTo3d(calibrationParam.BYTES(), sourcePoint2f.BYTES(),
69+
return nIs2dTo3d(calibrationParam.getBytes(), sourcePoint2f.getBytes(),
7070
sourceDepthPixel,
7171
sourceType.value(), targetType.value(),
72-
targetPoint3f.BYTES());
72+
targetPoint3f.getBytes());
7373
}
7474

7575
/**
@@ -98,10 +98,10 @@ public static boolean is2dTo3dUndistortion(CalibrationParam calibrationParam,
9898
float sourceDepthPixel,
9999
SensorType sourceType, SensorType targetType,
100100
Point3f targetPoint3f) {
101-
return nIs2dTo3dUndistortion(calibrationParam.BYTES(), sourcePoint2f.BYTES(),
101+
return nIs2dTo3dUndistortion(calibrationParam.getBytes(), sourcePoint2f.getBytes(),
102102
sourceDepthPixel,
103103
sourceType.value(), targetType.value(),
104-
targetPoint3f.BYTES());
104+
targetPoint3f.getBytes());
105105
}
106106

107107
/**
@@ -127,10 +127,10 @@ public static boolean is3dTo2d(CalibrationParam calibrationParam,
127127
Point3f sourcePoint3f,
128128
SensorType sourceType, SensorType targetType,
129129
Point2f targetPoint2f) {
130-
return nIs3dTo2d(calibrationParam.BYTES(),
131-
sourcePoint3f.BYTES(),
130+
return nIs3dTo2d(calibrationParam.getBytes(),
131+
sourcePoint3f.getBytes(),
132132
sourceType.value(), targetType.value(),
133-
targetPoint2f.BYTES());
133+
targetPoint2f.getBytes());
134134
}
135135

136136
/**
@@ -159,11 +159,11 @@ public static boolean is2dTo2d(CalibrationParam calibrationParam,
159159
float sourceDepthPixel,
160160
SensorType sourceType, SensorType targetType,
161161
Point2f targetPoint2f) {
162-
return nIs2dTo2d(calibrationParam.BYTES(),
163-
sourcePoint2f.BYTES(),
162+
return nIs2dTo2d(calibrationParam.getBytes(),
163+
sourcePoint2f.getBytes(),
164164
sourceDepthPixel,
165165
sourceType.value(), targetType.value(),
166-
targetPoint2f.BYTES());
166+
targetPoint2f.getBytes());
167167
}
168168

169169
/**
@@ -218,7 +218,7 @@ public static boolean initXYTables(CalibrationParam calibrationParam,
218218
SensorType sensorType,
219219
float[] data, long size,
220220
XYTables xyTables) {
221-
return nInitXYTables(calibrationParam.BYTES(), sensorType.value(),
221+
return nInitXYTables(calibrationParam.getBytes(), sensorType.value(),
222222
data, size, xyTables.getHandle());
223223
}
224224

@@ -250,12 +250,12 @@ public static void depthToRgbdPointcloud(XYTables xyTables, byte[] depthImageDat
250250
* \endif
251251
*/
252252
public static boolean transformation3dto3d(Point3f sourcePoint3f, Extrinsic extrinsic, Point3f targetPoint3f) {
253-
if (!sourcePoint3f.wrapBytes(sourcePoint3f.BYTES())) {
253+
if (!sourcePoint3f.wrapBytes()) {
254254
Log.w(TAG, "transformation3dto3d: sourcePoint3f wrap bytes error!");
255255
return false;
256256
}
257257

258-
if (!nTransformation3dto3d(sourcePoint3f.BYTES(), extrinsic.BYTES(), targetPoint3f.BYTES())) {
258+
if (!nTransformation3dto3d(sourcePoint3f.getBytes(), extrinsic.getBytes(), targetPoint3f.getBytes())) {
259259
Log.w(TAG, "transformation3dto3d: Transformation failed!");
260260
return false;
261261
}
@@ -293,12 +293,12 @@ public static boolean transformation3dto3d(Point3f sourcePoint3f, Extrinsic extr
293293
*/
294294
public static boolean transformation2dto3d(Point2f sourcePoint2f, float sourceDepthPixel, CameraIntrinsic sourceIntrinsic,
295295
Extrinsic extrinsic, Point3f targetPoint3f) {
296-
if (!sourcePoint2f.wrapBytes(sourcePoint2f.BYTES())) {
296+
if (!sourcePoint2f.wrapBytes()) {
297297
Log.w(TAG, "transformation2dto3d: sourcePoint2f wrap bytes error!");
298298
return false;
299299
}
300300

301-
if (!nTransformation2dto3d(sourcePoint2f.BYTES(), sourceDepthPixel, sourceIntrinsic.BYTES(), extrinsic.BYTES(), targetPoint3f.BYTES())) {
301+
if (!nTransformation2dto3d(sourcePoint2f.getBytes(), sourceDepthPixel, sourceIntrinsic.getBytes(), extrinsic.getBytes(), targetPoint3f.getBytes())) {
302302
Log.w(TAG, "transformation2dto3d: Transformation failed!");
303303
return false;
304304
}
@@ -336,12 +336,12 @@ public static boolean transformation2dto3d(Point2f sourcePoint2f, float sourceDe
336336
*/
337337
public static boolean transformation3dto2d(Point3f sourcePoint3f, CameraIntrinsic targetIntrinsic, CameraDistortion targetDistortion,
338338
Extrinsic extrinsic, Point2f targetPoint2f) {
339-
if (!sourcePoint3f.wrapBytes(sourcePoint3f.BYTES())) {
339+
if (!sourcePoint3f.wrapBytes()) {
340340
Log.w(TAG, "transformation3dto2d: sourcePoint3f wrap bytes error!");
341341
return false;
342342
}
343343

344-
if (!nTransformation3dto2d(sourcePoint3f.BYTES(), targetIntrinsic.BYTES(), targetDistortion.BYTES(), extrinsic.BYTES(), targetPoint2f.BYTES())) {
344+
if (!nTransformation3dto2d(sourcePoint3f.getBytes(), targetIntrinsic.getBytes(), targetDistortion.getBytes(), extrinsic.getBytes(), targetPoint2f.getBytes())) {
345345
Log.w(TAG, "transformation3dto2d: Transformation failed!");
346346
return false;
347347
}
@@ -387,13 +387,13 @@ public static boolean transformation2dto2d(Point2f sourcePoint2f, float sourceDe
387387
CameraIntrinsic sourceIntrinsic, CameraDistortion sourceDistortion,
388388
CameraIntrinsic targetIntrinsic, CameraDistortion targetDistortion,
389389
Extrinsic extrinsic, Point2f targetPoint2f) {
390-
if (!sourcePoint2f.wrapBytes(sourcePoint2f.BYTES())) {
390+
if (!sourcePoint2f.wrapBytes()) {
391391
Log.w(TAG, "transformation2dto2d: sourcePoint2f wrap bytes error!");
392392
return false;
393393
}
394394

395-
if (!nTransformation2dto2d(sourcePoint2f.BYTES(), sourceDepthPixel, sourceIntrinsic.BYTES(), sourceDistortion.BYTES(),
396-
targetIntrinsic.BYTES(), targetDistortion.BYTES(), extrinsic.BYTES(), targetPoint2f.BYTES())) {
395+
if (!nTransformation2dto2d(sourcePoint2f.getBytes(), sourceDepthPixel, sourceIntrinsic.getBytes(), sourceDistortion.getBytes(),
396+
targetIntrinsic.getBytes(), targetDistortion.getBytes(), extrinsic.getBytes(), targetPoint2f.getBytes())) {
397397
Log.w(TAG, "transformation2dto2d: Transformation failed!");
398398
return false;
399399
}

obsensor_jni/src/main/java/com/orbbec/obsensor/DecimationFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public short getScaleValue() {
6262
public Uint8PropertyRange getScaleRange() {
6363
throwInitializeException();
6464
Uint8PropertyRange scaleRange = new Uint8PropertyRange();
65-
nGetScaleRange(mHandle, scaleRange.BYTES());
65+
nGetScaleRange(mHandle, scaleRange.getBytes());
6666
boolean result = scaleRange.parseBytes();
6767
if (!result) {
6868
throw new OBException("getScaleRange parse bytes error!");

obsensor_jni/src/main/java/com/orbbec/obsensor/Device.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ public void setPropertyValueF(DeviceProperty property, float value) {
259259
* @throws OBException 当待设置的数据结构封装出错时
260260
* \endif
261261
*/
262-
public void setPropertyValueDataType(DeviceProperty property, ByteConversion dataType, byte[] data) {
262+
public void setPropertyValueDataType(DeviceProperty property, ByteConversion dataType) {
263263
throwInitializeException();
264-
boolean result = dataType.wrapBytes(data);
264+
boolean result = dataType.wrapBytes();
265265
if (result) {
266-
nSetPropertyValueDataType(mHandle, property.value(), data);
266+
nSetPropertyValueDataType(mHandle, property.value(), dataType.getBytes());
267267
} else {
268268
throw new OBException(property + " wrap bytes error!");
269269
}
@@ -688,7 +688,7 @@ public DeviceTemperature getDeviceTemperature() {
688688
throwInitializeException();
689689
DeviceTemperature temperature = new DeviceTemperature();
690690
if (isPropertySupported(DeviceProperty.OB_STRUCT_DEVICE_TEMPERATURE, PermissionType.OB_PERMISSION_READ)) {
691-
getPropertyValueDataType(DeviceProperty.OB_STRUCT_DEVICE_TEMPERATURE, temperature, temperature.BYTES());
691+
getPropertyValueDataType(DeviceProperty.OB_STRUCT_DEVICE_TEMPERATURE, temperature, temperature.getBytes());
692692
} else {
693693
throw new OBException("Getting device temperature is unsupported!");
694694
}
@@ -749,8 +749,8 @@ public void triggerCapture() {
749749
*/
750750
public void setTimestampResetConfig(DeviceTimestampResetConfig config) {
751751
throwInitializeException();
752-
if (config.wrapBytes(config.BYTES())) {
753-
nSetTimestampResetConfig(mHandle, config.BYTES());
752+
if (config.wrapBytes()) {
753+
nSetTimestampResetConfig(mHandle, config.getBytes());
754754
}
755755
}
756756

@@ -767,7 +767,7 @@ public void setTimestampResetConfig(DeviceTimestampResetConfig config) {
767767
public DeviceTimestampResetConfig getTimestampResetConfig() {
768768
throwInitializeException();
769769
DeviceTimestampResetConfig config = new DeviceTimestampResetConfig();
770-
nGetTimestampResetConfig(mHandle, config.BYTES());
770+
nGetTimestampResetConfig(mHandle, config.getBytes());
771771
if (config.parseBytes()) {
772772
return config;
773773
}
@@ -921,7 +921,7 @@ public List<DepthWorkMode> getDepthWorkModeList() {
921921
private NetIpConfig getNetworkConfig() {
922922
throwInitializeException();
923923
NetIpConfig config = new NetIpConfig();
924-
nGetNetIpConfig(mHandle, config.BYTES());
924+
nGetNetIpConfig(mHandle, config.getBytes());
925925
if (config.parseBytes()) {
926926
return config;
927927
}
@@ -939,8 +939,8 @@ private NetIpConfig getNetworkConfig() {
939939
*/
940940
private void setNetworkConfig(NetIpConfig config) {
941941
throwInitializeException();
942-
if (config.wrapBytes(config.BYTES())) {
943-
nSetNetworkConfig(mHandle, config.BYTES());
942+
if (config.wrapBytes()) {
943+
nSetNetworkConfig(mHandle, config.getBytes());
944944
}
945945
}
946946

@@ -957,7 +957,7 @@ private void setNetworkConfig(NetIpConfig config) {
957957
public MultiDeviceSyncConfig getMultiDeviceSyncConfig() {
958958
throwInitializeException();
959959
MultiDeviceSyncConfig config = new MultiDeviceSyncConfig();
960-
nGetMultiDeviceSyncConfig(mHandle, config.BYTES());
960+
nGetMultiDeviceSyncConfig(mHandle, config.getBytes());
961961
if (config.parseBytes()) {
962962
return config;
963963
}
@@ -977,8 +977,8 @@ public MultiDeviceSyncConfig getMultiDeviceSyncConfig() {
977977
*/
978978
public void setMultiDeviceSyncConfig(MultiDeviceSyncConfig deviceSyncConfig) {
979979
throwInitializeException();
980-
if (deviceSyncConfig.wrapBytes(deviceSyncConfig.BYTES())) {
981-
nSetMultiDeviceSyncConfig(mHandle, deviceSyncConfig.BYTES());
980+
if (deviceSyncConfig.wrapBytes()) {
981+
nSetMultiDeviceSyncConfig(mHandle, deviceSyncConfig.getBytes());
982982
}
983983
}
984984

@@ -1102,7 +1102,7 @@ public String getExtensionInfo(String infoKey) {
11021102
public void setHdrConfig(HdrConfig config) {
11031103
throwInitializeException();
11041104
if (isPropertySupported(DeviceProperty.OB_STRUCT_DEPTH_HDR_CONFIG, PermissionType.OB_PERMISSION_WRITE)) {
1105-
setPropertyValueDataType(DeviceProperty.OB_STRUCT_DEPTH_HDR_CONFIG, config, config.BYTES());
1105+
setPropertyValueDataType(DeviceProperty.OB_STRUCT_DEPTH_HDR_CONFIG, config);
11061106
} else {
11071107
throw new OBException("Setting device hdr config is unsupported!");
11081108
}
@@ -1123,7 +1123,7 @@ public HdrConfig getHdrConfig() {
11231123
throwInitializeException();
11241124
HdrConfig hdrConfig = new HdrConfig();
11251125
if (isPropertySupported(DeviceProperty.OB_STRUCT_DEPTH_HDR_CONFIG, PermissionType.OB_PERMISSION_READ)) {
1126-
getPropertyValueDataType(DeviceProperty.OB_STRUCT_DEPTH_HDR_CONFIG, hdrConfig, hdrConfig.BYTES());
1126+
getPropertyValueDataType(DeviceProperty.OB_STRUCT_DEPTH_HDR_CONFIG, hdrConfig, hdrConfig.getBytes());
11271127
return hdrConfig;
11281128
} else {
11291129
throw new OBException("Getting device hdr config is unsupported!");

obsensor_jni/src/main/java/com/orbbec/obsensor/EdgeNoiseRemovalFilter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public EdgeNoiseRemovalFilter() {
2828
*/
2929
public void setFilterParams(EdgeNoiseRemovalFilterParams params) {
3030
throwInitializeException();
31-
nSetFilterParams(mHandle, params.BYTES());
31+
nSetFilterParams(mHandle, params.getBytes());
3232
}
3333

3434
/**
@@ -41,7 +41,7 @@ public void setFilterParams(EdgeNoiseRemovalFilterParams params) {
4141
public EdgeNoiseRemovalFilterParams getFilterParams() {
4242
throwInitializeException();
4343
EdgeNoiseRemovalFilterParams params = new EdgeNoiseRemovalFilterParams();
44-
nGetFilterParams(mHandle, params.BYTES());
44+
nGetFilterParams(mHandle, params.getBytes());
4545
boolean result = params.parseBytes();
4646
if (!result) {
4747
throw new OBException("getFilterParams parse bytes error!");
@@ -63,7 +63,7 @@ public EdgeNoiseRemovalFilterParams getFilterParams() {
6363
public Uint16PropertyRange getMarginLeftThRange() {
6464
throwInitializeException();
6565
Uint16PropertyRange marginLeftThRange = new Uint16PropertyRange();
66-
nGetMarginLeftThRange(mHandle, marginLeftThRange.BYTES());
66+
nGetMarginLeftThRange(mHandle, marginLeftThRange.getBytes());
6767
boolean result = marginLeftThRange.parseBytes();
6868
if (!result) {
6969
throw new OBException("getMarginLeftThRange parse bytes error!");
@@ -85,7 +85,7 @@ public Uint16PropertyRange getMarginLeftThRange() {
8585
public Uint16PropertyRange getMarginRightThRange() {
8686
throwInitializeException();
8787
Uint16PropertyRange marginRightThRange = new Uint16PropertyRange();
88-
nGetMarginRightThRange(mHandle, marginRightThRange.BYTES());
88+
nGetMarginRightThRange(mHandle, marginRightThRange.getBytes());
8989
boolean result = marginRightThRange.parseBytes();
9090
if (!result) {
9191
throw new OBException("getMarginRightThRange parse bytes error!");
@@ -107,7 +107,7 @@ public Uint16PropertyRange getMarginRightThRange() {
107107
public Uint16PropertyRange getMarginTopThRange() {
108108
throwInitializeException();
109109
Uint16PropertyRange marginTopThRange = new Uint16PropertyRange();
110-
nGetMarginTopThRange(mHandle, marginTopThRange.BYTES());
110+
nGetMarginTopThRange(mHandle, marginTopThRange.getBytes());
111111
boolean result = marginTopThRange.parseBytes();
112112
if (!result) {
113113
throw new OBException("getMarginTopThRange parse bytes error!");
@@ -129,7 +129,7 @@ public Uint16PropertyRange getMarginTopThRange() {
129129
public Uint16PropertyRange getMarginBottomThRange() {
130130
throwInitializeException();
131131
Uint16PropertyRange marginBottomThRange = new Uint16PropertyRange();
132-
nGetMarginBottomThRange(mHandle, marginBottomThRange.BYTES());
132+
nGetMarginBottomThRange(mHandle, marginBottomThRange.getBytes());
133133
boolean result = marginBottomThRange.parseBytes();
134134
if (!result) {
135135
throw new OBException("getMarginBottomThRange parse bytes error!");

obsensor_jni/src/main/java/com/orbbec/obsensor/GyroStreamProfile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public IMUSampleRate getSampleRate() {
6464
public GyroIntrinsic getIntrinsic() {
6565
throwInitializeException();
6666
GyroIntrinsic intrinsic = new GyroIntrinsic();
67-
nGetIntrinsic(mHandle, intrinsic.BYTES());
67+
nGetIntrinsic(mHandle, intrinsic.getBytes());
6868
boolean result = intrinsic.parseBytes();
6969
if (!result) {
7070
throw new OBException("getIntrinsic parse bytes error!");

obsensor_jni/src/main/java/com/orbbec/obsensor/NoiseRemovalFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public NoiseRemovalFilterParams getFilterParams() {
7171
public Uint16PropertyRange getDispDiffRange() {
7272
throwInitializeException();
7373
Uint16PropertyRange dispDiffRange = new Uint16PropertyRange();
74-
nGetDispDiffRange(mHandle, dispDiffRange.BYTES());
74+
nGetDispDiffRange(mHandle, dispDiffRange.getBytes());
7575
boolean result = dispDiffRange.parseBytes();
7676
if (!result) {
7777
throw new OBException("getDispDiffRange parse bytes error!");
@@ -93,7 +93,7 @@ public Uint16PropertyRange getDispDiffRange() {
9393
public Uint16PropertyRange getMaxSizeRange() {
9494
throwInitializeException();
9595
Uint16PropertyRange maxSizeRange = new Uint16PropertyRange();
96-
nGetMaxSizeRange(mHandle, maxSizeRange.BYTES());
96+
nGetMaxSizeRange(mHandle, maxSizeRange.getBytes());
9797
boolean result = maxSizeRange.parseBytes();
9898
if (!result) {
9999
throw new OBException("getMaxSizeRange parse bytes error!");

0 commit comments

Comments
 (0)