Skip to content

Commit a459700

Browse files
authored
Merge pull request #14 from IntelRealSense/v0.13.0
V0.13.0
2 parents 2e3f6c2 + 99cec63 commit a459700

File tree

70 files changed

+1576
-413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1576
-413
lines changed

Readme.md

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,8 @@ $ make -j
3333
## Sample Code
3434
This snippet shows the basic usage of our library.
3535
```cpp
36-
// Start preview
37-
PreviewRender image_clbk;
38-
Preview preview;
39-
bool success = preview.StartPreview(image_clbk);
40-
41-
// Create device controller instance and connect to the device on COM9 which is of type USB
42-
RealSenseID::DeviceController deviceController;
43-
auto connect_status = deviceController.Connect({RealSenseID::SerialType::USB, "COM9"});
44-
45-
// Pair with host
46-
auto pair_status = deviceController.Pair(host_pubkey, host_pubkey_signature, device_pubkey);
47-
48-
// Disconnect from the device
49-
deviceController.Disconnect();
50-
51-
// Create face authenticator instance and connect to the device on COM9 which is of type USB
52-
MySigClbk sig_clbk;
53-
RealSenseID::FaceAuthenticator authenticator {&sig_clbk};
36+
// Create face authenticator and connect it to the device on port COM9
37+
RealSenseID::FaceAuthenticator authenticator;
5438
connect_status = authenticator.Connect({RealSenseID::SerialType::USB, "COM9"});
5539

5640
// Enroll a user
@@ -65,19 +49,16 @@ status = authenticator.Authenticate(auth_clbk);
6549
// Remove the user from device
6650
success = authenticator.RemoveUser(user_id);
6751

68-
// Disconnect from the device
69-
authenticator.Disconnect();
70-
71-
// Stop preview
72-
success = preview.StopPreview();
7352
```
7453
7554
For additional languages, build instruction and detailed code please see our [examples](./examples).
7655
7756
## Secure Communication
78-
The communication with the device is encrypted using the Elliptic-curve Diffie–Hellman key exchange (ECDH).
57+
The library can be compiled in secure mode.
58+
Once secure communication is enabled, the communication with the device is encrypted using the Elliptic-curve Diffie–Hellman key exchange (ECDH).
7959
80-
To enable secure communication, the host should perform the following steps:
60+
To enable secure mode, the host should perform the following steps:
61+
* Compile the library with `RSID_SECURE` defined. e.g. ```cmake -DRSID_SECURE=ON ..```
8162
* Generate a set of ECDSA public and private keys. The host is responsible for keeping his private key safe.
8263
* Pair with the device to enable secure communication. Pairing is performed once using the FaceAuthenticator API.
8364
* Implement a [SignatureCallback](./include/RealSenseID/SignatureCallback.h). Signing and verifying is done with the ECDSA keys.

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ For Example:
176176
3. In Android Studio, File->Open: \<RealSenseID repository\>/examples/android_example
177177
4. "Sync project" and then "Make project".
178178

179-
Note: Application and "RealSenseIDSwigClient" module have two flavors. "Secured" and "Unsecured" to choose between the two supported modes. If when trying to switch between them, you suffer compilation issues, you might need to clear files generated by SWIG in previous build (.i files as well as generated cpp_gen folder and api folder containing .java files). One way to do it is with "git clean -dfix".
179+
Note: Application and "RealSenseIDSwigClient" module have two flavors. "Secured" and "Unsecured" to choose between the two supported modes. If when trying to switch between them, you suffer compilation issues, try Android Studio's "Refresh Linked C++ Projects" option. Another thing that might work is to remove all auto generated files (try "git clean -dfix" can help).
180180

181181
**Done!**
182182
## **How to run example application**

examples/android_example/app/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android {
1313
applicationId "com.intel.realsenseid.f450androidexample"
1414
minSdkVersion 23
1515
targetSdkVersion 27
16-
versionName "0_12_1"
16+
versionName "0_13_0"
1717

1818
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1919

@@ -54,7 +54,10 @@ dependencies {
5454
implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
5555
implementation 'com.google.android.material:material:1.2.1'
5656
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
57+
implementation 'androidx.recyclerview:recyclerview:1.1.0'
5758
implementation project(path: ':RealSenseIDSwigClient')
59+
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
60+
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
5861
testImplementation 'junit:junit:4.13.1'
5962
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
6063
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

examples/android_example/app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.intel.realsenseid.f450androidexample">
44

5+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
6+
57
<application
68
android:allowBackup="true"
79
android:icon="@mipmap/ic_launcher"
810
android:label="@string/app_name"
911
android:roundIcon="@mipmap/ic_launcher_round"
1012
android:theme="@style/Theme.MyApplication">
11-
13+
<activity android:name=".FilesListActivity"></activity>
1214
<activity
1315
android:name=".MainActivity"
1416
android:configChanges="orientation"
@@ -22,7 +24,10 @@
2224
<intent-filter>
2325
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
2426
</intent-filter>
25-
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/device_filter" />
27+
28+
<meta-data
29+
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
30+
android:resource="@xml/device_filter" />
2631
</activity>
2732
</application>
2833

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.intel.realsenseid.f450androidexample;
2+
3+
import com.intel.realsenseid.api.FacePose;
4+
5+
import java.util.LinkedList;
6+
import java.util.List;
7+
8+
public class EnrollmentPoseTracker {
9+
private List<TrackedPose> m_trackedPoses;
10+
11+
private class TrackedPose {
12+
13+
private final FacePose m_pose;
14+
private boolean m_check;
15+
16+
public TrackedPose(FacePose p) {
17+
m_pose = p;
18+
m_check = false;
19+
}
20+
21+
22+
public FacePose getPose() {
23+
return m_pose;
24+
}
25+
26+
public boolean isCheck() {
27+
return m_check;
28+
}
29+
30+
public void setCheck() {
31+
this.m_check = true;
32+
}
33+
}
34+
35+
public EnrollmentPoseTracker(FacePose[] facePoses) {
36+
m_trackedPoses = new LinkedList<>();
37+
for (FacePose p : facePoses) {
38+
m_trackedPoses.add(new TrackedPose(p));
39+
}
40+
}
41+
42+
public void markPoseCheck(FacePose pose) {
43+
for (TrackedPose tp: m_trackedPoses) {
44+
if ((tp.getPose() == pose) && !tp.isCheck()) {
45+
tp.setCheck();
46+
return;
47+
}
48+
}
49+
}
50+
51+
public FacePose getNext() {
52+
for (TrackedPose tp: m_trackedPoses) {
53+
if (!tp.isCheck()) {
54+
return tp.getPose();
55+
}
56+
}
57+
return null;
58+
}
59+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.intel.realsenseid.f450androidexample;
2+
3+
4+
public class FileModel {
5+
public String getPath() {
6+
return path;
7+
}
8+
9+
public void setPath(String path) {
10+
this.path = path;
11+
}
12+
13+
public FileType getFileType() {
14+
return fileType;
15+
}
16+
17+
public void setFileType(FileType fileType) {
18+
this.fileType = fileType;
19+
}
20+
21+
public String getName() {
22+
return name;
23+
}
24+
25+
public void setName(String name) {
26+
this.name = name;
27+
}
28+
29+
public Double getSizeInMB() {
30+
return sizeInMB;
31+
}
32+
33+
public void setSizeInMB(Double sizeInMB) {
34+
this.sizeInMB = sizeInMB;
35+
}
36+
37+
public String getExtension() {
38+
return extension;
39+
}
40+
41+
public void setExtension(String extension) {
42+
this.extension = extension;
43+
}
44+
45+
public int getSubFiles() {
46+
return subFiles;
47+
}
48+
49+
public void setSubFiles(int subFiles) {
50+
this.subFiles = subFiles;
51+
}
52+
53+
private String path;
54+
private FileType fileType;
55+
private String name;
56+
private Double sizeInMB;
57+
private String extension;
58+
private int subFiles;
59+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.intel.realsenseid.f450androidexample;
2+
3+
import java.io.File;
4+
5+
public enum FileType {
6+
FILE,
7+
FOLDER;
8+
9+
public static FileType getType(File file) {
10+
if (file.isDirectory())
11+
return FOLDER;
12+
return FILE;
13+
}
14+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.intel.realsenseid.f450androidexample;
2+
3+
import java.io.File;
4+
import java.util.ArrayList;
5+
import java.util.Arrays;
6+
import java.util.List;
7+
8+
public class FileUtils {
9+
10+
public static List<File> getFilesFromPath(String path) {
11+
File file = new File(path);
12+
return Arrays.asList(file.listFiles());
13+
}
14+
15+
public static List<FileModel> getFileModelsFromFiles(List<File> files) {
16+
List<FileModel> outList = new ArrayList<>();
17+
for (File it : files) {
18+
FileModel fm = new FileModel(); // TODO: create builder for FileModel and use it instead
19+
fm.setPath(it.getPath());
20+
fm.setFileType(FileType.getType(it));
21+
fm.setName(it.getName());
22+
fm.setSizeInMB(convertFileSizeToMB(it.length()));
23+
fm.setExtension(getExtension(it));
24+
fm.setSubFiles(getNumberOfSubFiles(it));
25+
outList.add(fm);
26+
}
27+
return outList;
28+
}
29+
30+
private static int getNumberOfSubFiles(File f) {
31+
if (!f.isDirectory())
32+
return 0;
33+
return f.listFiles().length;
34+
}
35+
36+
private static String getExtension(File f) {
37+
String filename = f.getName();
38+
int lastDotIndex = filename.lastIndexOf(".");
39+
if (lastDotIndex < 0)
40+
return "";
41+
return filename.substring(lastDotIndex);
42+
}
43+
44+
private static Double convertFileSizeToMB(Long sizeInBytes) {
45+
return (sizeInBytes.doubleValue()) / (1024 * 1024);
46+
}
47+
}

0 commit comments

Comments
 (0)