├── LICENSE.md
├── Prj-Android
├── Prj-Android.iml
├── app
│ ├── app.iml
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── assets
│ │ └── ZeuseesFaceTracking
│ │ │ └── models
│ │ │ ├── det1.bin
│ │ │ ├── det1.param
│ │ │ ├── det2.bin
│ │ │ ├── det2.param
│ │ │ ├── det3.bin
│ │ │ ├── det3.param
│ │ │ ├── tracking.bin
│ │ │ └── tracking.proto.bin
│ │ ├── java
│ │ └── com
│ │ │ └── zeusee
│ │ │ └── main
│ │ │ └── hyperlandmark
│ │ │ ├── CameraOverlap.java
│ │ │ ├── EGLUtils.java
│ │ │ ├── FileUtil.java
│ │ │ ├── FixedAspectRatioRelativeLayout.java
│ │ │ ├── GLBitmap.java
│ │ │ ├── GLFrame.java
│ │ │ ├── GLFramebuffer.java
│ │ │ ├── GLPoints.java
│ │ │ ├── MainActivity.java
│ │ │ ├── ShaderUtils.java
│ │ │ └── jni
│ │ │ ├── Face.java
│ │ │ └── FaceTracking.java
│ │ ├── jniLibs
│ │ ├── arm64-v8a
│ │ │ └── libzeuseesTracking-lib.so
│ │ └── armeabi-v7a
│ │ │ └── libzeuseesTracking-lib.so
│ │ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_background.xml
│ │ └── ic_logo.png
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── activity_multitracker.xml
│ │ └── fragment_camera_overlap.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── local.properties
└── settings.gradle
├── Prj-Win
├── model
│ ├── haar_facedetection.xml
│ └── landmark-model.bin
├── sdm
│ ├── sdm.sln
│ ├── sdm.v12.suo
│ ├── sdm.vcxproj
│ └── sdm.vcxproj.filters
└── src
│ ├── feature_descriptor.cpp
│ ├── helper.cpp
│ ├── hog.c
│ ├── include
│ ├── cereal
│ │ ├── access.hpp
│ │ ├── archives
│ │ │ ├── adapters.hpp
│ │ │ ├── binary.hpp
│ │ │ ├── json.hpp
│ │ │ ├── portable_binary.hpp
│ │ │ └── xml.hpp
│ │ ├── cereal.hpp
│ │ ├── details
│ │ │ ├── helpers.hpp
│ │ │ ├── polymorphic_impl.hpp
│ │ │ ├── static_object.hpp
│ │ │ ├── traits.hpp
│ │ │ └── util.hpp
│ │ ├── external
│ │ │ ├── base64.hpp
│ │ │ ├── rapidjson
│ │ │ │ ├── document.h
│ │ │ │ ├── filestream.h
│ │ │ │ ├── genericstream.h
│ │ │ │ ├── internal
│ │ │ │ │ ├── pow10.h
│ │ │ │ │ ├── stack.h
│ │ │ │ │ └── strfunc.h
│ │ │ │ ├── license.txt
│ │ │ │ ├── prettywriter.h
│ │ │ │ ├── rapidjson.h
│ │ │ │ ├── reader.h
│ │ │ │ ├── stringbuffer.h
│ │ │ │ └── writer.h
│ │ │ └── rapidxml
│ │ │ │ ├── license.txt
│ │ │ │ ├── manual.html
│ │ │ │ ├── rapidxml.hpp
│ │ │ │ ├── rapidxml_iterators.hpp
│ │ │ │ ├── rapidxml_print.hpp
│ │ │ │ └── rapidxml_utils.hpp
│ │ ├── macros.hpp
│ │ └── types
│ │ │ ├── array.hpp
│ │ │ ├── base_class.hpp
│ │ │ ├── bitset.hpp
│ │ │ ├── boost_variant.hpp
│ │ │ ├── chrono.hpp
│ │ │ ├── common.hpp
│ │ │ ├── complex.hpp
│ │ │ ├── deque.hpp
│ │ │ ├── forward_list.hpp
│ │ │ ├── list.hpp
│ │ │ ├── map.hpp
│ │ │ ├── memory.hpp
│ │ │ ├── polymorphic.hpp
│ │ │ ├── queue.hpp
│ │ │ ├── set.hpp
│ │ │ ├── stack.hpp
│ │ │ ├── string.hpp
│ │ │ ├── tuple.hpp
│ │ │ ├── unordered_map.hpp
│ │ │ ├── unordered_set.hpp
│ │ │ ├── utility.hpp
│ │ │ └── vector.hpp
│ ├── cereal_extension
│ │ ├── ThreadPool.h
│ │ ├── mat_cerealisation.hpp
│ │ └── mat_serialization.hpp
│ ├── feature_descriptor.h
│ ├── helper.h
│ ├── hog.h
│ └── ldmarkmodel.h
│ ├── ldmarkmodel.cpp
│ └── main.cpp
├── README.md
├── images
├── landmark_order.png
└── res1.png
└── resource
├── demo.gif
├── demo.mp4
└── demo2.gif
/Prj-Android/Prj-Android.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Prj-Android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "com.zeusee.main.hyperlandmark"
7 | minSdkVersion 19
8 | targetSdkVersion 28
9 | versionCode 2
10 | versionName "2.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 |
13 | externalNativeBuild {
14 | cmake {
15 | cmake {
16 | cppFlags "-std=c++11 -frtti -fexceptions"
17 | abiFilters 'armeabi-v7a', 'arm64-v8a'
18 | version "3.10.2"
19 | }
20 | }
21 | }
22 | }
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 |
30 | // externalNativeBuild {
31 | // cmake {
32 | // path "CMakeLists.txt"
33 | // version "3.10.2" // The key line
34 | // }
35 | // }
36 |
37 | sourceSets {
38 | main {
39 | jniLibs.srcDirs = ['src/main/jniLibs']
40 | }
41 | }
42 | }
43 | dependencies {
44 | implementation fileTree(dir: 'libs', include: ['*.jar'])
45 | implementation 'com.android.support:appcompat-v7:28.0.0'
46 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
47 | testImplementation 'junit:junit:4.12'
48 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
49 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
50 | }
51 |
--------------------------------------------------------------------------------
/Prj-Android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
16 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/assets/ZeuseesFaceTracking/models/det1.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/assets/ZeuseesFaceTracking/models/det1.bin
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/assets/ZeuseesFaceTracking/models/det1.param:
--------------------------------------------------------------------------------
1 | 7767517
2 | 12 13
3 | Input data 0 1 data 0=3 1=12 2=12
4 | Convolution conv1 1 1 data conv1 0=10 1=3 2=1 3=1 4=0 5=1 6=270
5 | PReLU PReLU1 1 1 conv1 conv1_PReLU1 0=10
6 | Pooling pool1 1 1 conv1_PReLU1 pool1 0=0 1=2 2=2 3=0 4=0
7 | Convolution conv2 1 1 pool1 conv2 0=16 1=3 2=1 3=1 4=0 5=1 6=1440
8 | PReLU PReLU2 1 1 conv2 conv2_PReLU2 0=16
9 | Convolution conv3 1 1 conv2_PReLU2 conv3 0=32 1=3 2=1 3=1 4=0 5=1 6=4608
10 | PReLU PReLU3 1 1 conv3 conv3_PReLU3 0=32
11 | Split splitncnn_0 1 2 conv3_PReLU3 conv3_PReLU3_splitncnn_0 conv3_PReLU3_splitncnn_1
12 | Convolution conv4-1 1 1 conv3_PReLU3_splitncnn_1 conv4-1 0=2 1=1 2=1 3=1 4=0 5=1 6=64
13 | Convolution conv4-2 1 1 conv3_PReLU3_splitncnn_0 conv4-2 0=4 1=1 2=1 3=1 4=0 5=1 6=128
14 | Softmax prob1 1 1 conv4-1 prob1 0=0
15 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/assets/ZeuseesFaceTracking/models/det2.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/assets/ZeuseesFaceTracking/models/det2.bin
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/assets/ZeuseesFaceTracking/models/det2.param:
--------------------------------------------------------------------------------
1 | 7767517
2 | 15 16
3 | Input data 0 1 data 0=3 1=24 2=24
4 | Convolution conv1 1 1 data conv1 0=28 1=3 2=1 3=1 4=0 5=1 6=756
5 | PReLU prelu1 1 1 conv1 conv1_prelu1 0=28
6 | Pooling pool1 1 1 conv1_prelu1 pool1 0=0 1=3 2=2 3=0 4=0
7 | Convolution conv2 1 1 pool1 conv2 0=48 1=3 2=1 3=1 4=0 5=1 6=12096
8 | PReLU prelu2 1 1 conv2 conv2_prelu2 0=48
9 | Pooling pool2 1 1 conv2_prelu2 pool2 0=0 1=3 2=2 3=0 4=0
10 | Convolution conv3 1 1 pool2 conv3 0=64 1=2 2=1 3=1 4=0 5=1 6=12288
11 | PReLU prelu3 1 1 conv3 conv3_prelu3 0=64
12 | InnerProduct conv4 1 1 conv3_prelu3 conv4 0=128 1=1 2=73728
13 | PReLU prelu4 1 1 conv4 conv4_prelu4 0=128
14 | Split splitncnn_0 1 2 conv4_prelu4 conv4_prelu4_splitncnn_0 conv4_prelu4_splitncnn_1
15 | InnerProduct conv5-1 1 1 conv4_prelu4_splitncnn_1 conv5-1 0=2 1=1 2=256
16 | InnerProduct conv5-2 1 1 conv4_prelu4_splitncnn_0 conv5-2 0=4 1=1 2=512
17 | Softmax prob1 1 1 conv5-1 prob1 0=0
18 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/assets/ZeuseesFaceTracking/models/det3.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/assets/ZeuseesFaceTracking/models/det3.bin
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/assets/ZeuseesFaceTracking/models/det3.param:
--------------------------------------------------------------------------------
1 | 7767517
2 | 20 22
3 | Input data 0 1 data 0=3 1=48 2=48
4 | Convolution conv1 1 1 data conv1 0=32 1=3 2=1 3=1 4=0 5=1 6=864
5 | PReLU prelu1 1 1 conv1 conv1_prelu1 0=32
6 | Pooling pool1 1 1 conv1_prelu1 pool1 0=0 1=3 2=2 3=0 4=0
7 | Convolution conv2 1 1 pool1 conv2 0=64 1=3 2=1 3=1 4=0 5=1 6=18432
8 | PReLU prelu2 1 1 conv2 conv2_prelu2 0=64
9 | Pooling pool2 1 1 conv2_prelu2 pool2 0=0 1=3 2=2 3=0 4=0
10 | Convolution conv3 1 1 pool2 conv3 0=64 1=3 2=1 3=1 4=0 5=1 6=36864
11 | PReLU prelu3 1 1 conv3 conv3_prelu3 0=64
12 | Pooling pool3 1 1 conv3_prelu3 pool3 0=0 1=2 2=2 3=0 4=0
13 | Convolution conv4 1 1 pool3 conv4 0=128 1=2 2=1 3=1 4=0 5=1 6=32768
14 | PReLU prelu4 1 1 conv4 conv4_prelu4 0=128
15 | InnerProduct conv5 1 1 conv4_prelu4 conv5 0=256 1=1 2=294912
16 | Dropout drop5 1 1 conv5 conv5_drop5
17 | PReLU prelu5 1 1 conv5_drop5 conv5_prelu5 0=256
18 | Split splitncnn_0 1 3 conv5_prelu5 conv5_prelu5_splitncnn_0 conv5_prelu5_splitncnn_1 conv5_prelu5_splitncnn_2
19 | InnerProduct conv6-1 1 1 conv5_prelu5_splitncnn_2 conv6-1 0=2 1=1 2=512
20 | InnerProduct conv6-2 1 1 conv5_prelu5_splitncnn_1 conv6-2 0=4 1=1 2=1024
21 | InnerProduct conv6-3 1 1 conv5_prelu5_splitncnn_0 conv6-3 0=10 1=1 2=2560
22 | Softmax prob1 1 1 conv6-1 prob1 0=0
23 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/assets/ZeuseesFaceTracking/models/tracking.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/assets/ZeuseesFaceTracking/models/tracking.bin
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/java/com/zeusee/main/hyperlandmark/CameraOverlap.java:
--------------------------------------------------------------------------------
1 | package com.zeusee.main.hyperlandmark;
2 |
3 | import android.content.Context;
4 | import android.content.res.Configuration;
5 | import android.graphics.SurfaceTexture;
6 | import android.hardware.Camera;
7 |
8 | import java.util.List;
9 |
10 | public class CameraOverlap {
11 |
12 | protected Camera mCamera = null;
13 | protected Camera.CameraInfo mCameraInfo = null;
14 | public static final int PREVIEW_WIDTH = 640;
15 | public static final int PREVIEW_HEIGHT = 480;
16 | public static final int SCALLE_FACTOR = 2;
17 |
18 | private int CameraFacing = Camera.CameraInfo.CAMERA_FACING_FRONT;
19 | private Camera.PreviewCallback mPreviewCallback;
20 |
21 | private Context context;
22 |
23 | public CameraOverlap(Context context) {
24 | this.context = context;
25 | }
26 |
27 |
28 | public void openCamera(SurfaceTexture surfaceTexture) {
29 | if (null != mCamera) {
30 | mCamera.setPreviewCallback(null);
31 | mCamera.stopPreview();
32 | mCamera.release();
33 | mCamera = null;
34 | }
35 | Camera.CameraInfo info = new Camera.CameraInfo();
36 | for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
37 | Camera.getCameraInfo(i, info);
38 | if (info.facing == CameraFacing) {
39 | try {
40 | mCamera = Camera.open(i);
41 | mCameraInfo = info;
42 | } catch (RuntimeException e) {
43 | e.printStackTrace();
44 | mCamera = null;
45 | continue;
46 | }
47 | break;
48 | }
49 | }
50 | try {
51 | mCamera.setPreviewTexture(surfaceTexture);
52 | initCamera();
53 | } catch (Exception ex) {
54 | if (null != mCamera) {
55 | mCamera.release();
56 | mCamera = null;
57 | }
58 | }
59 | }
60 |
61 |
62 | private void initCamera() {
63 | if (null != mCamera) {
64 | try {
65 | Camera.Parameters parameters = mCamera.getParameters();
66 | List flashModes = parameters.getSupportedFlashModes();
67 | if (flashModes != null && flashModes.contains(Camera.Parameters.FLASH_MODE_OFF)) {
68 | parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
69 | }
70 |
71 |
72 | List pictureSizes = mCamera.getParameters()
73 | .getSupportedPictureSizes();
74 |
75 | parameters.setPreviewSize(PREVIEW_WIDTH, PREVIEW_HEIGHT);
76 |
77 | Camera.Size fs = null;
78 | for (int i = 0; i < pictureSizes.size(); i++) {
79 | Camera.Size psize = pictureSizes.get(i);
80 | if (fs == null && psize.width >= 1280)
81 | fs = psize;
82 |
83 | }
84 | parameters.setPictureSize(fs.width, fs.height);
85 |
86 | if (context.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {
87 | parameters.set("orientation", "portrait");
88 | parameters.set("rotation", 90);
89 |
90 | int orientation = CameraFacing == Camera.CameraInfo.CAMERA_FACING_FRONT ? 360 - mCameraInfo.orientation : mCameraInfo.orientation;
91 | mCamera.setDisplayOrientation(orientation);
92 |
93 | } else {
94 | parameters.set("orientation", "landscape");
95 | mCamera.setDisplayOrientation(0);
96 |
97 | }
98 |
99 | if (CameraFacing == Camera.CameraInfo.CAMERA_FACING_BACK) {
100 | if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
101 | parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
102 | } else {
103 | parameters.setFocusMode(parameters.FOCUS_MODE_AUTO);
104 | }
105 | }
106 |
107 | mCamera.setParameters(parameters);
108 | mCamera.setPreviewCallback(this.mPreviewCallback);
109 | mCamera.startPreview();
110 | } catch (Exception e) {
111 | e.printStackTrace();
112 | }
113 | }
114 | }
115 |
116 | public void setPreviewCallback(Camera.PreviewCallback previewCallback) {
117 | this.mPreviewCallback = previewCallback;
118 | if (mCamera != null) {
119 | mCamera.setPreviewCallback(previewCallback);
120 | }
121 | }
122 |
123 | public int getOrientation() {
124 | if (mCameraInfo != null) {
125 | return mCameraInfo.orientation;
126 | }
127 | return 0;
128 | }
129 |
130 | public void release() {
131 | if (null != mCamera) {
132 | mCamera.setPreviewCallback(null);
133 | mCamera.stopPreview();
134 | mCamera.release();
135 | mCamera = null;
136 | }
137 | }
138 |
139 | }
140 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/java/com/zeusee/main/hyperlandmark/EGLUtils.java:
--------------------------------------------------------------------------------
1 | package com.zeusee.main.hyperlandmark;
2 |
3 | import android.opengl.EGL14;
4 | import android.opengl.EGLConfig;
5 | import android.opengl.EGLContext;
6 | import android.opengl.EGLDisplay;
7 | import android.opengl.EGLSurface;
8 | import android.view.Surface;
9 |
10 | public class EGLUtils {
11 |
12 | private static final int EGL_RECORDABLE_ANDROID = 0x3142;
13 |
14 | private EGLSurface eglSurface = EGL14.EGL_NO_SURFACE;
15 | private EGLContext eglCtx = EGL14.EGL_NO_CONTEXT;
16 | private EGLDisplay eglDis = EGL14.EGL_NO_DISPLAY;
17 |
18 |
19 | public void initEGL(Surface surface) {
20 | eglDis = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
21 | int[] version = new int[2];
22 | EGL14.eglInitialize(eglDis, version, 0, version, 1);
23 | int confAttr[] = {
24 | EGL14.EGL_SURFACE_TYPE,EGL14.EGL_WINDOW_BIT,
25 | EGL14.EGL_RED_SIZE, 8,
26 | EGL14.EGL_GREEN_SIZE, 8,
27 | EGL14.EGL_BLUE_SIZE, 8,
28 | EGL14.EGL_ALPHA_SIZE, 8,
29 | EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
30 | EGL_RECORDABLE_ANDROID, 1,
31 | EGL14.EGL_SAMPLE_BUFFERS, 1,
32 | EGL14.EGL_SAMPLES, 4,
33 | EGL14.EGL_NONE
34 | };
35 |
36 |
37 |
38 | EGLConfig[] configs = new EGLConfig[1];
39 | int[] numConfigs = new int[1];
40 | EGL14.eglChooseConfig(eglDis, confAttr, 0, configs, 0, 1, numConfigs, 0);
41 | int ctxAttr[] = {
42 | EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,// 0x3098
43 | EGL14.EGL_NONE
44 | };
45 | eglCtx = EGL14.eglCreateContext(eglDis, configs[0], EGL14.EGL_NO_CONTEXT, ctxAttr, 0);
46 | int[] surfaceAttr = {
47 | EGL14.EGL_NONE
48 | };
49 | eglSurface = EGL14.eglCreateWindowSurface(eglDis, configs[0], surface, surfaceAttr, 0);
50 |
51 | EGL14.eglMakeCurrent(eglDis, eglSurface, eglSurface, eglCtx);
52 |
53 | }
54 |
55 | public EGLContext getContext() {
56 | return eglCtx;
57 | }
58 |
59 | public void swap() {
60 | EGL14.eglSwapBuffers(eglDis, eglSurface);
61 | }
62 |
63 | public void release() {
64 | if (eglSurface != EGL14.EGL_NO_SURFACE) {
65 | EGL14.eglMakeCurrent(eglDis, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
66 | EGL14.eglDestroySurface(eglDis, eglSurface);
67 | eglSurface = EGL14.EGL_NO_SURFACE;
68 | }
69 | if (eglCtx != EGL14.EGL_NO_CONTEXT) {
70 | EGL14.eglDestroyContext(eglDis, eglCtx);
71 | eglCtx = EGL14.EGL_NO_CONTEXT;
72 | }
73 | if (eglDis != EGL14.EGL_NO_DISPLAY) {
74 | EGL14.eglTerminate(eglDis);
75 | eglDis = EGL14.EGL_NO_DISPLAY;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/java/com/zeusee/main/hyperlandmark/FileUtil.java:
--------------------------------------------------------------------------------
1 | package com.zeusee.main.hyperlandmark;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.os.Environment;
6 |
7 | import java.io.File;
8 | import java.io.FileOutputStream;
9 | import java.io.InputStream;
10 |
11 | public class FileUtil {
12 |
13 | public static String modelPath = Environment.getExternalStorageDirectory()
14 | + File.separator + "ZeuseesFaceTracking";
15 |
16 | public static String copyFilesFromAssets(Context context, String oldPath, String newPath) {
17 | try {
18 | String[] fileNames = context.getAssets().list(oldPath);
19 | if (fileNames.length > 0) {
20 | // directory
21 | File file = new File(newPath);
22 | if (!file.exists()) {
23 | file.mkdirs();
24 | }
25 |
26 | for (String fileName : fileNames) {
27 | copyFilesFromAssets(context, oldPath + "/" + fileName,
28 | newPath + "/" + fileName);
29 | }
30 | } else {
31 | // file
32 | InputStream is = context.getAssets().open(oldPath);
33 | FileOutputStream fos = new FileOutputStream(new File(newPath));
34 | byte[] buffer = new byte[1024];
35 | int byteCount;
36 | while ((byteCount = is.read(buffer)) != -1) {
37 | fos.write(buffer, 0, byteCount);
38 | }
39 | fos.flush();
40 | is.close();
41 | fos.close();
42 | }
43 |
44 | return newPath;
45 | } catch (Exception e) {
46 | // TODO Auto-generated catch block
47 | e.printStackTrace();
48 | }
49 |
50 | return null;
51 | }
52 |
53 | public static boolean saveBitmap(Bitmap bitmap, String targetFilePath) {
54 | File file = new File(targetFilePath);
55 | try {
56 | file.createNewFile();
57 | FileOutputStream fos = new FileOutputStream(file);
58 | bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fos);
59 | fos.flush();
60 | fos.close();
61 | return true;
62 | } catch (Exception e) {
63 | // Log.d(TAG, "" + e.getMessage());
64 | e.printStackTrace();
65 | return false;
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/java/com/zeusee/main/hyperlandmark/FixedAspectRatioRelativeLayout.java:
--------------------------------------------------------------------------------
1 | package com.zeusee.main.hyperlandmark;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.RelativeLayout;
6 |
7 |
8 | public class FixedAspectRatioRelativeLayout extends RelativeLayout {
9 | private int mAspectRatioWidth = 480;
10 | private int mAspectRatioHeight = 640;
11 |
12 | public FixedAspectRatioRelativeLayout(Context context) {
13 | super(context);
14 | }
15 |
16 | public FixedAspectRatioRelativeLayout(Context context, AttributeSet attrs) {
17 | super(context, attrs);
18 | }
19 |
20 | public FixedAspectRatioRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
21 | super(context, attrs, defStyle);
22 | }
23 |
24 | @Override
25 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
26 | int originalWidth = MeasureSpec.getSize(widthMeasureSpec);
27 | int originalHeight = MeasureSpec.getSize(heightMeasureSpec);
28 |
29 | int calculatedHeight = originalWidth * mAspectRatioHeight / mAspectRatioWidth;
30 | int finalWidth, finalHeight;
31 |
32 | if (calculatedHeight > originalHeight) {
33 | finalWidth = originalHeight * mAspectRatioWidth / mAspectRatioHeight;
34 | finalHeight = originalHeight;
35 | } else {
36 | finalWidth = originalWidth;
37 | finalHeight = calculatedHeight;
38 | }
39 |
40 | super.onMeasure(
41 | MeasureSpec.makeMeasureSpec(finalWidth, MeasureSpec.EXACTLY),
42 | MeasureSpec.makeMeasureSpec(finalHeight, MeasureSpec.EXACTLY));
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/java/com/zeusee/main/hyperlandmark/GLBitmap.java:
--------------------------------------------------------------------------------
1 | package com.zeusee.main.hyperlandmark;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.opengl.GLES20;
7 | import android.opengl.GLUtils;
8 |
9 | import java.nio.ByteBuffer;
10 | import java.nio.ByteOrder;
11 | import java.nio.FloatBuffer;
12 |
13 | public class GLBitmap {
14 |
15 | private int aPositionHandle;
16 | private int uTextureSamplerHandle;
17 | private int aTextureCoordHandle;
18 | private int programId;
19 | private int[] textures;
20 | private int[] frameBuffers;
21 | private FloatBuffer vertexBuffer;
22 | private final float[] vertexData = {
23 | 1f, -1f,
24 | -1f, -1f,
25 | 1f, 1f,
26 | -1f, 1f
27 | };
28 | private FloatBuffer textureVertexBuffer;
29 | private final float[] textureVertexData = {
30 | 1f, 0f,//右下
31 | 0f, 0f,//左下
32 | 1f, 1f,//右上
33 | 0f, 1f//左上
34 | };
35 | private Bitmap bitmap;
36 | public GLBitmap(Context context, int id){
37 | vertexBuffer = ByteBuffer.allocateDirect(vertexData.length * 4)
38 | .order(ByteOrder.nativeOrder())
39 | .asFloatBuffer()
40 | .put(vertexData);
41 | vertexBuffer.position(0);
42 |
43 | textureVertexBuffer = ByteBuffer.allocateDirect(textureVertexData.length * 4)
44 | .order(ByteOrder.nativeOrder())
45 | .asFloatBuffer()
46 | .put(textureVertexData);
47 | textureVertexBuffer.position(0);
48 | bitmap = BitmapFactory.decodeResource(context.getResources(),id);
49 |
50 | }
51 | private String vertexShader = "attribute vec4 aPosition;\n" +
52 | "attribute vec2 aTexCoord;\n" +
53 | "varying vec2 vTexCoord;\n" +
54 | "void main() {\n" +
55 | " vTexCoord=aTexCoord;\n" +
56 | " gl_Position = aPosition;\n" +
57 | "}";
58 | private String fragmentShader = "varying highp vec2 vTexCoord;\n" +
59 | "uniform highp sampler2D sTexture;\n"+
60 | "void main() {\n" +
61 | " gl_FragColor = texture2D(sTexture,vec2(vTexCoord.x,1.0 - vTexCoord.y));\n" +
62 | "}";
63 | public void initFrame(int width,int height){
64 | this.width = width;
65 | this.height = height;
66 | programId = ShaderUtils.createProgram(vertexShader, fragmentShader);
67 | aPositionHandle = GLES20.glGetAttribLocation(programId, "aPosition");
68 | uTextureSamplerHandle=GLES20.glGetUniformLocation(programId,"sTexture");
69 | aTextureCoordHandle=GLES20.glGetAttribLocation(programId,"aTexCoord");
70 | textures = new int[2];
71 | GLES20.glGenTextures(2,textures,0);
72 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,textures[0]);
73 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MIN_FILTER,GLES20.GL_LINEAR);
74 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
75 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
76 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
77 | GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,0,GLES20.GL_RGBA,bitmap,0);
78 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,textures[1]);
79 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MIN_FILTER,GLES20.GL_LINEAR);
80 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
81 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
82 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
83 | GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D,0,GLES20.GL_RGBA,width,height,0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
84 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,0);
85 | frameBuffers = new int[1];
86 | GLES20.glGenFramebuffers(1,frameBuffers,0);
87 | GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,frameBuffers[0]);
88 | GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, textures[1], 0);
89 | GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,0);
90 | }
91 | public void setPoints(float[] points){
92 | vertexBuffer.rewind();
93 | vertexBuffer.put(points);
94 | vertexBuffer.position(0);
95 | }
96 | private int width,height;
97 | public int drawFrame(){
98 | GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,frameBuffers[0]);
99 | GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
100 | GLES20.glViewport(0, 0, width, height);
101 | GLES20.glUseProgram(programId);
102 | GLES20.glEnableVertexAttribArray(aPositionHandle);
103 | GLES20.glVertexAttribPointer(aPositionHandle, 2, GLES20.GL_FLOAT, false,
104 | 8, vertexBuffer);
105 |
106 | GLES20.glEnableVertexAttribArray(aTextureCoordHandle);
107 | GLES20.glVertexAttribPointer(aTextureCoordHandle,2,GLES20.GL_FLOAT,false,8,textureVertexBuffer);
108 |
109 | GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
110 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,textures[0]);
111 | GLES20.glUniform1i(uTextureSamplerHandle,0);
112 | GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
113 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,0);
114 | GLES20.glUseProgram(0);
115 | GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,0);
116 | return textures[1];
117 | }
118 | public void release(){
119 | GLES20.glDeleteTextures(2,textures,0);
120 | GLES20.glDeleteFramebuffers(1,frameBuffers,0);
121 | GLES20.glDeleteProgram(programId);
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/java/com/zeusee/main/hyperlandmark/GLFramebuffer.java:
--------------------------------------------------------------------------------
1 | package com.zeusee.main.hyperlandmark;
2 |
3 | import android.graphics.SurfaceTexture;
4 | import android.opengl.GLES11Ext;
5 | import android.opengl.GLES20;
6 |
7 |
8 | public class GLFramebuffer {
9 |
10 | private float[] mSTMatrix = new float[16];
11 |
12 | private int[] textures;
13 |
14 | private SurfaceTexture surfaceTexture;
15 | public void initFramebuffer(){
16 |
17 | textures = new int[1];
18 | GLES20.glGenTextures(1, textures, 0);
19 | GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textures[0]);
20 | GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER,
21 | GLES20.GL_NEAREST);
22 | GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER,
23 | GLES20.GL_LINEAR);
24 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
25 | }
26 |
27 | public SurfaceTexture getSurfaceTexture(){
28 | surfaceTexture = new SurfaceTexture(textures[0]);
29 | return surfaceTexture;
30 | }
31 |
32 | public void release(){
33 | GLES20.glDeleteTextures(1,textures,0);
34 | if(surfaceTexture != null ){
35 | surfaceTexture.release();
36 | surfaceTexture = null;
37 | }
38 | }
39 |
40 | public int drawFrameBuffer(){
41 | if(surfaceTexture != null){
42 | surfaceTexture.updateTexImage();
43 | surfaceTexture.getTransformMatrix(mSTMatrix);
44 | }
45 | return textures[0];
46 | }
47 |
48 | public float[] getMatrix() {
49 | return mSTMatrix;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/java/com/zeusee/main/hyperlandmark/GLPoints.java:
--------------------------------------------------------------------------------
1 | package com.zeusee.main.hyperlandmark;
2 |
3 | import android.opengl.GLES20;
4 |
5 | import java.nio.ByteBuffer;
6 | import java.nio.ByteOrder;
7 | import java.nio.FloatBuffer;
8 |
9 | public class GLPoints {
10 | private FloatBuffer vertexBuffer;
11 | private int bufferLength = 106*2*4;
12 | private int programId = -1;
13 | private int aPositionHandle;
14 |
15 | private int[] vertexBuffers;
16 |
17 |
18 | private String fragmentShader =
19 | "void main() {\n" +
20 | " gl_FragColor = vec4(1.0,0.0,0.0,1.0);\n" +
21 | "}";
22 | private String vertexShader = "attribute vec2 aPosition;\n" +
23 | "void main() {\n" +
24 | " gl_Position = vec4(aPosition,0.0,1.0);\n" +
25 | " gl_PointSize = 10.0;\n"+
26 | "}";
27 | public GLPoints(){
28 | vertexBuffer = ByteBuffer.allocateDirect(bufferLength)
29 | .order(ByteOrder.nativeOrder())
30 | .asFloatBuffer();
31 | vertexBuffer.position(0);
32 | }
33 | public void initPoints(){
34 | programId = ShaderUtils.createProgram(vertexShader, fragmentShader);
35 | aPositionHandle = GLES20.glGetAttribLocation(programId, "aPosition");
36 |
37 | vertexBuffers = new int[1];
38 | GLES20.glGenBuffers(1,vertexBuffers,0);
39 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vertexBuffers[0]);
40 | GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, bufferLength, vertexBuffer,GLES20.GL_STATIC_DRAW);
41 |
42 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
43 | }
44 | public void setPoints(float[] points){
45 | vertexBuffer.rewind();
46 | vertexBuffer.put(points);
47 | vertexBuffer.position(0);
48 | }
49 |
50 |
51 | public void drawPoints(){
52 | GLES20.glUseProgram(programId);
53 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vertexBuffers[0]);
54 | GLES20.glBufferSubData(GLES20.GL_ARRAY_BUFFER,0,bufferLength,vertexBuffer);
55 | GLES20.glEnableVertexAttribArray(aPositionHandle);
56 | GLES20.glVertexAttribPointer(aPositionHandle, 2, GLES20.GL_FLOAT, false,
57 | 0, 0);
58 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
59 | GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 106);
60 | }
61 |
62 | public void release(){
63 | GLES20.glDeleteProgram(programId);
64 | GLES20.glDeleteBuffers(1,vertexBuffers,0);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/java/com/zeusee/main/hyperlandmark/ShaderUtils.java:
--------------------------------------------------------------------------------
1 | package com.zeusee.main.hyperlandmark;
2 |
3 | import android.content.Context;
4 | import android.opengl.GLES20;
5 | import android.util.Log;
6 |
7 | import java.io.BufferedReader;
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 | import java.io.InputStreamReader;
11 |
12 | public class ShaderUtils {
13 | private static final String TAG = "ShaderUtils";
14 |
15 | public static void checkGlError(String label) {
16 | int error;
17 | while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) {
18 | Log.e(TAG, label + ": glError " + error);
19 | throw new RuntimeException(label + ": glError " + error);
20 | }
21 | }
22 |
23 | public static int createProgram(String vertexSource, String fragmentSource) {
24 | int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource);
25 | if (vertexShader == 0) {
26 | return 0;
27 | }
28 | int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource);
29 | if (pixelShader == 0) {
30 | return 0;
31 | }
32 | int program = GLES20.glCreateProgram();
33 | if (program != 0) {
34 | GLES20.glAttachShader(program, vertexShader);
35 | checkGlError("glAttachShader");
36 | GLES20.glAttachShader(program, pixelShader);
37 | checkGlError("glAttachShader");
38 | GLES20.glLinkProgram(program);
39 | int[] linkStatus = new int[1];
40 | GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0);
41 | if (linkStatus[0] != GLES20.GL_TRUE) {
42 | Log.e(TAG, "Could not link program: ");
43 | Log.e(TAG, GLES20.glGetProgramInfoLog(program));
44 | GLES20.glDeleteProgram(program);
45 | program = 0;
46 | }
47 | }
48 | return program;
49 | }
50 |
51 |
52 | public static int loadShader(int shaderType, String source) {
53 | int shader = GLES20.glCreateShader(shaderType);
54 | if (shader != 0) {
55 | GLES20.glShaderSource(shader, source);
56 | GLES20.glCompileShader(shader);
57 | int[] compiled = new int[1];
58 | GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0);
59 | if (compiled[0] == 0) {
60 | Log.e(TAG, "Could not compile shader " + shaderType + ":");
61 | Log.e(TAG, GLES20.glGetShaderInfoLog(shader));
62 | GLES20.glDeleteShader(shader);
63 | shader = 0;
64 | }
65 | }
66 | return shader;
67 | }
68 |
69 | public static String readRawTextFile(Context context, int resId) {
70 | InputStream inputStream = context.getResources().openRawResource(resId);
71 | try {
72 | BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
73 | StringBuilder sb = new StringBuilder();
74 | String line;
75 | while ((line = reader.readLine()) != null) {
76 | sb.append(line).append("\n");
77 | }
78 | reader.close();
79 | return sb.toString();
80 | } catch (IOException e) {
81 | e.printStackTrace();
82 | }
83 | return null;
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/java/com/zeusee/main/hyperlandmark/jni/Face.java:
--------------------------------------------------------------------------------
1 | package com.zeusee.main.hyperlandmark.jni;
2 |
3 | public class Face {
4 |
5 |
6 | public int ID;
7 | public int left;
8 | public int top;
9 | public int right;
10 | public int bottom;
11 | public int height;
12 | public int width;
13 | public int[] landmarks;
14 | public int monthState;
15 | public int eyeState;
16 | public int shakeState;
17 | public int riseState;
18 | public float pitch;
19 | public float yaw;
20 | public float roll;
21 | public boolean isStable;
22 |
23 |
24 | Face(int x1, int y1, int x2, int y2) {
25 | left = x1;
26 | top = y1;
27 | right = x2;
28 | bottom = y2;
29 | height = y2 - y1;
30 | width = x2 - x1;
31 | landmarks = new int[106 * 2];
32 | monthState = 0;
33 | eyeState = 0;
34 | }
35 |
36 |
37 | Face(int x1, int y1, int _width, int _height, int[] landmark, int id) {
38 | left = x1;
39 | top = y1;
40 | right = x1 + _width;
41 | bottom = y1 + _height;
42 | width = _width;
43 | height = _height;
44 | landmarks = landmark;
45 | ID = id;
46 | monthState = 0;
47 | eyeState = 0;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/java/com/zeusee/main/hyperlandmark/jni/FaceTracking.java:
--------------------------------------------------------------------------------
1 | package com.zeusee.main.hyperlandmark.jni;
2 |
3 | import com.zeusee.main.hyperlandmark.CameraOverlap;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | import static java.lang.Math.abs;
9 |
10 |
11 | public class FaceTracking {
12 |
13 | static {
14 | System.loadLibrary("zeuseesTracking-lib");
15 | }
16 |
17 | private static class FaceTrackingHolder {
18 | private static final FaceTracking instance = new FaceTracking();
19 | }
20 |
21 |
22 | public static FaceTracking getInstance() {
23 | return FaceTrackingHolder.instance;
24 | }
25 |
26 |
27 | public native static void update(byte[] data, int height, int width, int angle, boolean mirror, long session);
28 |
29 | //scale 跟踪时缩小,对速度有要求可以考虑,1 为 原图, 2 为 缩小一般,以此类推
30 | public native static void initTracker(int height, int width, int scale, long session);
31 |
32 | public native static long createSession(String modelPath);
33 |
34 | public native static void releaseSession(long session);
35 |
36 | public native static int getTrackingNum(long session);
37 |
38 | public native static int[] getTrackingLandmarkByIndex(int index, long session);
39 |
40 | public native static int[] getTrackingLocationByIndex(int index, long session);
41 |
42 | public native static int[] getAttributeByIndex(int index, long session);
43 |
44 | public native static float[] getEulerAngleByIndex(int index, long session);
45 |
46 | public native static int getTrackingIDByIndex(int index, long session);
47 |
48 | private long session;
49 | private List faces;
50 | private int tracking_seq = 0;
51 |
52 | public FaceTracking() {
53 | }
54 |
55 |
56 | // public FaceTracking(String pathModel) {
57 | // session = createSession(pathModel);
58 | // faces = new ArrayList();
59 | // }
60 |
61 | public void release() {
62 | releaseSession(session);
63 | }
64 |
65 |
66 | public void FaceTrackingInit(String pathModel, int height, int width) {
67 | session = createSession(pathModel);
68 | faces = new ArrayList();
69 | initTracker(height, width, CameraOverlap.SCALLE_FACTOR, session);
70 | }
71 |
72 | public boolean postProcess(int[] landmark_prev, int[] landmark_curr) {
73 | int diff = 0;
74 |
75 | for (int i = 0; i < 106 * 2; i++) {
76 | diff += abs(landmark_curr[i] - landmark_prev[i]);
77 |
78 | }
79 |
80 | if (diff < 1.0 * 106 * 2) {
81 | for (int j = 0; j < 106 * 2; j++) {
82 | landmark_curr[j] = (landmark_curr[j] + landmark_prev[j]) / 2;
83 | }
84 | return true;
85 | } else if (diff < 2 * 106 * 2) {
86 | for (int j = 0; j < 106 * 2; j++) {
87 | landmark_curr[j] = (landmark_curr[j] + landmark_prev[j]) / 2;
88 | }
89 | return true;
90 | }
91 | return false;
92 | }
93 |
94 | public int find_id_face(List faces, int targetID) {
95 | for (int i = 0; i < faces.size(); i++) {
96 | if (faces.get(i).ID == targetID)
97 | return i;
98 | }
99 | return -1;
100 | }
101 |
102 | public void postProcess_aux(int[] landmark_prev, int[] landmark_curr) {
103 |
104 | for (int i = 0; i < 106 * 2; i++) {
105 | landmark_curr[i] = (landmark_curr[i]);
106 |
107 | }
108 | }
109 |
110 |
111 | public void Update(byte[] data, int height, int width) {
112 | update(data, height, width, 270, true, session);
113 | int numsFace = getTrackingNum(session);
114 | List _faces = new ArrayList();
115 | for (int i = 0; i < numsFace; i++) {
116 | int ID_GET = -1;
117 | int flag = -1;
118 |
119 | int[] faceRect = getTrackingLocationByIndex(i, session);
120 | int id = getTrackingIDByIndex(i, session);
121 | // Log.e("TAG","====id====="+id);
122 | int[] landmarks = getTrackingLandmarkByIndex(i, session);
123 | float[] attitudes = getEulerAngleByIndex(i, session);
124 | if (tracking_seq > 0) {
125 | ID_GET = find_id_face(faces, id);
126 | if (ID_GET != -1) {
127 | boolean res = postProcess(faces.get(ID_GET).landmarks, landmarks);
128 | if (res)
129 | flag = -2;
130 | }
131 | if (ID_GET != -1) {
132 | if (faces.get(ID_GET).isStable) {
133 | postProcess_aux(faces.get(ID_GET).landmarks, landmarks);
134 | }
135 | }
136 | }
137 | Face face = new Face(faceRect[0], faceRect[1], faceRect[2], faceRect[3], landmarks, id);
138 | face.pitch = attitudes[0];
139 | face.yaw = attitudes[1];
140 | face.roll = attitudes[2];
141 | if (flag == -2)
142 | face.isStable = true;
143 | else
144 | face.isStable = false;
145 | _faces.add(face);
146 | // faces.(i,face);
147 | }
148 | faces.clear();
149 | faces = _faces;
150 | tracking_seq += 1;
151 |
152 | }
153 |
154 |
155 | public List getTrackingInfo() {
156 | return faces;
157 |
158 | }
159 | }
160 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/jniLibs/arm64-v8a/libzeuseesTracking-lib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/jniLibs/arm64-v8a/libzeuseesTracking-lib.so
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/jniLibs/armeabi-v7a/libzeuseesTracking-lib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/jniLibs/armeabi-v7a/libzeuseesTracking-lib.so
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/drawable/ic_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/res/drawable/ic_logo.png
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
5 |
8 |
12 |
13 |
20 |
26 |
33 |
34 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/layout/activity_multitracker.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
17 |
18 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/layout/fragment_camera_overlap.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
11 |
12 |
16 |
17 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | HyperTrack
5 | Settings
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Prj-Android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
18 |
26 |
27 |
--------------------------------------------------------------------------------
/Prj-Android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.4.1'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/Prj-Android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/Prj-Android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Prj-Android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Nov 28 16:03:36 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/Prj-Android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/Prj-Android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/Prj-Android/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | #Thu Jun 18 21:20:57 CST 2020
8 | #Wed Mar 25 23:49:17 CST 2020
9 | sdk.dir=/Users/yang/Library/Android/sdk
10 |
--------------------------------------------------------------------------------
/Prj-Android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/Prj-Win/model/landmark-model.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Win/model/landmark-model.bin
--------------------------------------------------------------------------------
/Prj-Win/sdm/sdm.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.21005.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdm", "sdm.vcxproj", "{8D4BE3A2-ACC4-4ACB-A116-1089B7907AA0}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Win32 = Debug|Win32
11 | Release|Win32 = Release|Win32
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {8D4BE3A2-ACC4-4ACB-A116-1089B7907AA0}.Debug|Win32.ActiveCfg = Debug|Win32
15 | {8D4BE3A2-ACC4-4ACB-A116-1089B7907AA0}.Debug|Win32.Build.0 = Debug|Win32
16 | {8D4BE3A2-ACC4-4ACB-A116-1089B7907AA0}.Release|Win32.ActiveCfg = Release|Win32
17 | {8D4BE3A2-ACC4-4ACB-A116-1089B7907AA0}.Release|Win32.Build.0 = Release|Win32
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/Prj-Win/sdm/sdm.v12.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/szad670401/HyperLandmark/412ac3461a5dc63c45a62991f6247024509f2766/Prj-Win/sdm/sdm.v12.suo
--------------------------------------------------------------------------------
/Prj-Win/src/feature_descriptor.cpp:
--------------------------------------------------------------------------------
1 | #include "feature_descriptor.h"
2 |
3 |
4 | cv::Mat CalculateHogDescriptor(cv::Mat &src, cv::Mat shape, std::vector LandmarkIndexs, std::vector eyes_index, HoGParam mHoGParam){
5 | assert(shape.rows == 1 && eyes_index.size() == 4);
6 |
7 | cv::Mat grayImage;
8 | if (src.channels() == 1){
9 | grayImage = src;
10 | }
11 | else if (src.channels() == 3){
12 | cv::cvtColor(src, grayImage, CV_BGR2GRAY);
13 | }
14 | else if (src.channels() == 4){
15 | cv::cvtColor(src, grayImage, CV_RGBA2GRAY);
16 | }
17 | else{
18 | return cv::Mat();
19 | }
20 |
21 | // This is in pixels in the original image:
22 | int numLandmarks = shape.cols / 2;
23 | float lx = (shape.at(eyes_index.at(0)) + shape.at(eyes_index.at(1)))*0.5;
24 | float ly = (shape.at(eyes_index.at(0) + numLandmarks) + shape.at(eyes_index.at(1) + numLandmarks))*0.5;
25 | float rx = (shape.at(eyes_index.at(2)) + shape.at(eyes_index.at(3)))*0.5;
26 | float ry = (shape.at(eyes_index.at(2) + numLandmarks) + shape.at(eyes_index.at(3) + numLandmarks))*0.5;
27 | float distance = sqrt((rx - lx)*(rx - lx) + (ry - ly)*(ry - ly));
28 | int patch_width_half = std::round(mHoGParam.relative_patch_size * distance);
29 |
30 | cv::Mat hogDescriptors; // We'll get the dimensions later from vl_hog_get_*
31 | for (int i = 0; i < LandmarkIndexs.size(); i++) {
32 | int x = cvRound(shape.at(LandmarkIndexs.at(i)));
33 | int y = cvRound(shape.at(LandmarkIndexs.at(i) + numLandmarks));
34 |
35 | cv::Mat roiImg;
36 | if (x - patch_width_half < 0 || y - patch_width_half < 0 || x + patch_width_half >= grayImage.cols || y + patch_width_half >= grayImage.rows) {
37 | // The feature extraction location is too far near a border. We extend the
38 | // image (add a black canvas) and then extract from this larger image.
39 | int borderLeft = (x - patch_width_half) < 0 ? std::abs(x - patch_width_half) : 0; // x and y are patch-centers
40 | int borderTop = (y - patch_width_half) < 0 ? std::abs(y - patch_width_half) : 0;
41 | int borderRight = (x + patch_width_half) >= grayImage.cols ? std::abs(grayImage.cols - (x + patch_width_half)) : 0;
42 | int borderBottom = (y + patch_width_half) >= grayImage.rows ? std::abs(grayImage.rows - (y + patch_width_half)) : 0;
43 | cv::Mat extendedImage = grayImage.clone();
44 | cv::copyMakeBorder(extendedImage, extendedImage, borderTop, borderBottom, borderLeft, borderRight, cv::BORDER_CONSTANT, cv::Scalar(0));
45 | cv::Rect roi((x - patch_width_half) + borderLeft, (y - patch_width_half) + borderTop, patch_width_half * 2, patch_width_half * 2); // Rect: x y w h. x and y are top-left corner.
46 | roiImg = extendedImage(roi).clone(); // clone because we need a continuous memory block
47 | }
48 | else {
49 | cv::Rect roi(x - patch_width_half, y - patch_width_half, patch_width_half * 2, patch_width_half * 2); // x y w h. Rect: x and y are top-left corner. Our x and y are center. Convert.
50 | roiImg = grayImage(roi).clone(); // clone because we need a continuous memory block
51 | }
52 | // This has to be the same for each image, so each image's HOG descriptor will have the same dimensions, independent of the image's resolution
53 | int fixed_roi_size = mHoGParam.num_cells * mHoGParam.cell_size;
54 | cv::resize(roiImg, roiImg, cv::Size(fixed_roi_size, fixed_roi_size));
55 |
56 | roiImg.convertTo(roiImg, CV_32FC1); // vl_hog_put_image expects a float* (values 0.0f-255.0f)
57 | VlHog* hog = vl_hog_new(VlHogVariant::VlHogVariantUoctti, mHoGParam.num_bins, false); // transposed (=col-major) = false
58 | vl_hog_put_image(hog, (float*)roiImg.data, roiImg.cols, roiImg.rows, 1, mHoGParam.cell_size); // (the '1' is numChannels)
59 | int ww = static_cast(vl_hog_get_width(hog)); // assert ww == hh == numCells
60 | int hh = static_cast(vl_hog_get_height(hog));
61 | int dd = static_cast(vl_hog_get_dimension(hog)); // assert ww=hogDim1, hh=hogDim2, dd=hogDim3
62 | cv::Mat hogArray(1, ww*hh*dd, CV_32FC1); // safer & same result. Don't use C-style memory management.
63 | vl_hog_extract(hog, hogArray.ptr(0));
64 | vl_hog_delete(hog);
65 | cv::Mat hogDescriptor(hh*ww*dd, 1, CV_32FC1);
66 | // Stack the third dimensions of the HOG descriptor of this patch one after each other in a column-vector:
67 | for (int j = 0; j < dd; ++j) {
68 | cv::Mat hogFeatures(hh, ww, CV_32FC1, hogArray.ptr(0) + j*ww*hh); // Creates the same array as in Matlab. I might have to check this again if hh!=ww (non-square)
69 | hogFeatures = hogFeatures.t(); // necessary because the Matlab reshape() takes column-wise from the matrix while the OpenCV reshape() takes row-wise.
70 | hogFeatures = hogFeatures.reshape(0, hh*ww); // make it to a column-vector
71 | cv::Mat currentDimSubMat = hogDescriptor.rowRange(j*ww*hh, j*ww*hh + ww*hh);
72 | hogFeatures.copyTo(currentDimSubMat);
73 | }
74 | hogDescriptor = hogDescriptor.t(); // now a row-vector
75 | hogDescriptors.push_back(hogDescriptor);
76 | }
77 | // concatenate all the descriptors for this sample vertically (into a row-vector):
78 | hogDescriptors = hogDescriptors.reshape(0, hogDescriptors.cols * hogDescriptors.rows).t();
79 |
80 | // add a bias row (affine part)
81 | cv::Mat bias = cv::Mat::ones(1, 1, CV_32FC1);
82 | cv::hconcat(hogDescriptors, bias, hogDescriptors);
83 | return hogDescriptors;
84 | }
--------------------------------------------------------------------------------
/Prj-Win/src/helper.cpp:
--------------------------------------------------------------------------------
1 | #include "helper.h"
2 |
3 |
4 | cv::Mat align_mean(cv::Mat mean, cv::Rect facebox, float scaling_x, float scaling_y, float translation_x, float translation_y)
5 | {
6 | using cv::Mat;
7 | // Initial estimate x_0: Center the mean face at the [-0.5, 0.5] x [-0.5, 0.5] square (assuming the face-box is that square)
8 | // More precise: Take the mean as it is (assume it is in a space [-0.5, 0.5] x [-0.5, 0.5]), and just place it in the face-box as
9 | // if the box is [-0.5, 0.5] x [-0.5, 0.5]. (i.e. the mean coordinates get upscaled)
10 | Mat aligned_mean = mean.clone();
11 | Mat aligned_mean_x = aligned_mean.colRange(0, aligned_mean.cols / 2);
12 | Mat aligned_mean_y = aligned_mean.colRange(aligned_mean.cols / 2, aligned_mean.cols);
13 | aligned_mean_x = (aligned_mean_x*scaling_x + 0.5f + translation_x) * facebox.width + facebox.x;
14 | aligned_mean_y = (aligned_mean_y*scaling_y + 0.3f + translation_y) * facebox.height + facebox.y;
15 | return aligned_mean;
16 | }
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/details/static_object.hpp:
--------------------------------------------------------------------------------
1 | /*! \file static_object.hpp
2 | \brief Internal polymorphism static object support
3 | \ingroup Internal */
4 | /*
5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant
6 | All rights reserved.
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are met:
9 | * Redistributions of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 | * Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 | * Neither the name of cereal nor the
15 | names of its contributors may be used to endorse or promote products
16 | derived from this software without specific prior written permission.
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 | #ifndef CEREAL_DETAILS_STATIC_OBJECT_HPP_
29 | #define CEREAL_DETAILS_STATIC_OBJECT_HPP_
30 |
31 | //! Prevent link optimization from removing non-referenced static objects
32 | /*! Especially for polymorphic support, we create static objects which
33 | may not ever be explicitly referenced. Most linkers will detect this
34 | and remove the code causing various unpleasant runtime errors. These
35 | macros, adopted from Boost (see force_include.hpp) prevent this
36 | (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
37 | Use, modification and distribution is subject to the Boost Software
38 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
39 | http://www.boost.org/LICENSE_1_0.txt) */
40 |
41 | #ifdef _MSC_VER
42 | # define CEREAL_DLL_EXPORT __declspec(dllexport)
43 | # define CEREAL_USED
44 | #else // clang or gcc
45 | # define CEREAL_DLL_EXPORT
46 | # define CEREAL_USED __attribute__ ((__used__))
47 | #endif
48 |
49 | namespace cereal
50 | {
51 | namespace detail
52 | {
53 | //! A static, pre-execution object
54 | /*! This class will create a single copy (singleton) of some
55 | type and ensures that merely referencing this type will
56 | cause it to be instantiated and initialized pre-execution.
57 | For example, this is used heavily in the polymorphic pointer
58 | serialization mechanisms to bind various archive types with
59 | different polymorphic classes */
60 | template
61 | class CEREAL_DLL_EXPORT StaticObject
62 | {
63 | private:
64 | //! Forces instantiation at pre-execution time
65 | static void instantiate( T const & ) {}
66 |
67 | static T & create()
68 | {
69 | static T t;
70 | instantiate(instance);
71 | return t;
72 | }
73 |
74 | StaticObject( StaticObject const & /*other*/ ) {}
75 |
76 | public:
77 | static T & getInstance()
78 | {
79 | return create();
80 | }
81 |
82 | private:
83 | static T & instance;
84 | };
85 |
86 | template T & StaticObject::instance = StaticObject::create();
87 | } // namespace detail
88 | } // namespace cereal
89 |
90 | #endif // CEREAL_DETAILS_STATIC_OBJECT_HPP_
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/details/util.hpp:
--------------------------------------------------------------------------------
1 | /*! \file util.hpp
2 | \brief Internal misc utilities
3 | \ingroup Internal */
4 | /*
5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of cereal nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | */
30 | #ifndef CEREAL_DETAILS_UTIL_HPP_
31 | #define CEREAL_DETAILS_UTIL_HPP_
32 |
33 | #include
34 | #include
35 |
36 | #ifdef _MSC_VER
37 | namespace cereal
38 | {
39 | namespace util
40 | {
41 | //! Demangles the type encoded in a string
42 | /*! @internal */
43 | inline std::string demangle( std::string const & name )
44 | { return name; }
45 |
46 | //! Gets the demangled name of a type
47 | /*! @internal */
48 | template inline
49 | std::string demangledName()
50 | { return typeid( T ).name(); }
51 | } // namespace util
52 | } // namespace cereal
53 | #else // clang or gcc
54 | #include
55 | #include
56 | namespace cereal
57 | {
58 | namespace util
59 | {
60 | //! Demangles the type encoded in a string
61 | /*! @internal */
62 | inline std::string demangle(std::string mangledName)
63 | {
64 | int status = 0;
65 | char *demangledName = nullptr;
66 | std::size_t len;
67 |
68 | demangledName = abi::__cxa_demangle(mangledName.c_str(), 0, &len, &status);
69 |
70 | std::string retName(demangledName);
71 | free(demangledName);
72 |
73 | return retName;
74 | }
75 |
76 | //! Gets the demangled name of a type
77 | /*! @internal */
78 | template inline
79 | std::string demangledName()
80 | { return demangle(typeid(T).name()); }
81 | }
82 | } // namespace cereal
83 | #endif // clang or gcc branch of _MSC_VER
84 | #endif // CEREAL_DETAILS_UTIL_HPP_
85 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/external/base64.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2004-2008 René Nyffenegger
3 |
4 | This source code is provided 'as-is', without any express or implied
5 | warranty. In no event will the author be held liable for any damages
6 | arising from the use of this software.
7 |
8 | Permission is granted to anyone to use this software for any purpose,
9 | including commercial applications, and to alter it and redistribute it
10 | freely, subject to the following restrictions:
11 |
12 | 1. The origin of this source code must not be misrepresented; you must not
13 | claim that you wrote the original source code. If you use this source code
14 | in a product, an acknowledgment in the product documentation would be
15 | appreciated but is not required.
16 |
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original source code.
19 |
20 | 3. This notice may not be removed or altered from any source distribution.
21 |
22 | René Nyffenegger rene.nyffenegger@adp-gmbh.ch
23 | */
24 |
25 | #ifndef CEREAL_EXTERNAL_BASE64_HPP_
26 | #define CEREAL_EXTERNAL_BASE64_HPP_
27 |
28 | #include
29 |
30 | namespace base64
31 | {
32 | static const std::string chars =
33 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34 | "abcdefghijklmnopqrstuvwxyz"
35 | "0123456789+/";
36 |
37 | static inline bool is_base64(unsigned char c) {
38 | return (isalnum(c) || (c == '+') || (c == '/'));
39 | }
40 |
41 | inline std::string encode(unsigned char const* bytes_to_encode, size_t in_len) {
42 | std::string ret;
43 | int i = 0;
44 | int j = 0;
45 | unsigned char char_array_3[3];
46 | unsigned char char_array_4[4];
47 |
48 | while (in_len--) {
49 | char_array_3[i++] = *(bytes_to_encode++);
50 | if (i == 3) {
51 | char_array_4[0] = (unsigned char) ((char_array_3[0] & 0xfc) >> 2);
52 | char_array_4[1] = (unsigned char) ( ( ( char_array_3[0] & 0x03 ) << 4 ) + ( ( char_array_3[1] & 0xf0 ) >> 4 ) );
53 | char_array_4[2] = (unsigned char) ( ( ( char_array_3[1] & 0x0f ) << 2 ) + ( ( char_array_3[2] & 0xc0 ) >> 6 ) );
54 | char_array_4[3] = (unsigned char) ( char_array_3[2] & 0x3f );
55 |
56 | for(i = 0; (i <4) ; i++)
57 | ret += chars[char_array_4[i]];
58 | i = 0;
59 | }
60 | }
61 |
62 | if (i)
63 | {
64 | for(j = i; j < 3; j++)
65 | char_array_3[j] = '\0';
66 |
67 | char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
68 | char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
69 | char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
70 | char_array_4[3] = char_array_3[2] & 0x3f;
71 |
72 | for (j = 0; (j < i + 1); j++)
73 | ret += chars[char_array_4[j]];
74 |
75 | while((i++ < 3))
76 | ret += '=';
77 |
78 | }
79 |
80 | return ret;
81 |
82 | }
83 |
84 | inline std::string decode(std::string const& encoded_string) {
85 | size_t in_len = encoded_string.size();
86 | size_t i = 0;
87 | size_t j = 0;
88 | int in_ = 0;
89 | unsigned char char_array_4[4], char_array_3[3];
90 | std::string ret;
91 |
92 | while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
93 | char_array_4[i++] = encoded_string[in_]; in_++;
94 | if (i ==4) {
95 | for (i = 0; i <4; i++)
96 | char_array_4[i] = (unsigned char) chars.find( char_array_4[i] );
97 |
98 | char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
99 | char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
100 | char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
101 |
102 | for (i = 0; (i < 3); i++)
103 | ret += char_array_3[i];
104 | i = 0;
105 | }
106 | }
107 |
108 | if (i) {
109 | for (j = i; j <4; j++)
110 | char_array_4[j] = 0;
111 |
112 | for (j = 0; j <4; j++)
113 | char_array_4[j] = (unsigned char) chars.find( char_array_4[j] );
114 |
115 | char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
116 | char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
117 | char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
118 |
119 | for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
120 | }
121 |
122 | return ret;
123 | }
124 | } // base64
125 | #endif // CEREAL_EXTERNAL_BASE64_HPP_
126 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/external/rapidjson/filestream.h:
--------------------------------------------------------------------------------
1 | #ifndef RAPIDJSON_FILESTREAM_H_
2 | #define RAPIDJSON_FILESTREAM_H_
3 |
4 | #include
5 |
6 | namespace rapidjson {
7 |
8 | //! Wrapper of C file stream for input or output.
9 | /*!
10 | This simple wrapper does not check the validity of the stream.
11 | \implements Stream
12 | */
13 | class FileStream {
14 | public:
15 | typedef char Ch; //!< Character type. Only support char.
16 |
17 | FileStream(FILE* fp) : fp_(fp), count_(0) { Read(); }
18 |
19 | char Peek() const { return current_; }
20 | char Take() { char c = current_; Read(); return c; }
21 | size_t Tell() const { return count_; }
22 | void Put(char c) { fputc(c, fp_); }
23 |
24 | // Not implemented
25 | char* PutBegin() { return 0; }
26 | size_t PutEnd(char*) { return 0; }
27 |
28 | private:
29 | void Read() {
30 | RAPIDJSON_ASSERT(fp_ != 0);
31 | int c = fgetc(fp_);
32 | if (c != EOF) {
33 | current_ = (char)c;
34 | count_++;
35 | }
36 | else
37 | current_ = '\0';
38 | }
39 |
40 | FILE* fp_;
41 | char current_;
42 | size_t count_;
43 | };
44 |
45 | } // namespace rapidjson
46 |
47 | #endif // RAPIDJSON_FILESTREAM_H_
48 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/external/rapidjson/genericstream.h:
--------------------------------------------------------------------------------
1 | // Generic*Stream code from https://code.google.com/p/rapidjson/issues/detail?id=20
2 | #ifndef RAPIDJSON_GENERICSTREAM_H_
3 | #define RAPIDJSON_GENERICSTREAM_H_
4 |
5 | #include "rapidjson.h"
6 | #include
7 |
8 | #ifdef _MSC_VER
9 | #pragma warning(push)
10 | #pragma warning(disable: 4127) // conditional expression is constant
11 | #pragma warning(disable: 4512) // assignment operator could not be generated
12 | #pragma warning(disable: 4100) // unreferenced formal parameter
13 | #endif
14 |
15 | namespace rapidjson {
16 |
17 | //! Wrapper of std::istream for input.
18 | class GenericReadStream {
19 | public:
20 | typedef char Ch; //!< Character type (byte).
21 |
22 | //! Constructor.
23 | /*!
24 | \param is Input stream.
25 | */
26 | GenericReadStream(std::istream & is) : is_(&is) {
27 | }
28 |
29 |
30 | Ch Peek() const {
31 | if(is_->eof()) return '\0';
32 | return static_cast(is_->peek());
33 | }
34 |
35 | Ch Take() {
36 | if(is_->eof()) return '\0';
37 | return static_cast(is_->get());
38 | }
39 |
40 | size_t Tell() const {
41 | return (int)is_->tellg();
42 | }
43 |
44 | // Not implemented
45 | void Put(Ch) { RAPIDJSON_ASSERT(false); }
46 | void Flush() { RAPIDJSON_ASSERT(false); }
47 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
48 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
49 |
50 | std::istream * is_;
51 | };
52 |
53 |
54 | //! Wrapper of std::ostream for output.
55 | class GenericWriteStream {
56 | public:
57 | typedef char Ch; //!< Character type. Only support char.
58 |
59 | //! Constructor
60 | /*!
61 | \param os Output stream.
62 | */
63 | GenericWriteStream(std::ostream& os) : os_(os) {
64 | }
65 |
66 | void Put(char c) {
67 | os_.put(c);
68 | }
69 |
70 | void PutN(char c, size_t n) {
71 | for (size_t i = 0; i < n; ++i) {
72 | Put(c);
73 | }
74 | }
75 |
76 | void Flush() {
77 | os_.flush();
78 | }
79 |
80 | size_t Tell() const {
81 | return (int)os_.tellp();
82 | }
83 |
84 | // Not implemented
85 | char Peek() const { RAPIDJSON_ASSERT(false); }
86 | char Take() { RAPIDJSON_ASSERT(false); }
87 | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
88 | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; }
89 |
90 | private:
91 | std::ostream& os_;
92 | };
93 |
94 | template<>
95 | inline void PutN(GenericWriteStream& stream, char c, size_t n) {
96 | stream.PutN(c, n);
97 | }
98 |
99 | } // namespace rapidjson
100 |
101 | // On MSVC, restore warnings state
102 | #ifdef _MSC_VER
103 | #pragma warning(pop)
104 | #endif
105 | #endif // RAPIDJSON_GENERICSTREAM_H_
106 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/external/rapidjson/internal/pow10.h:
--------------------------------------------------------------------------------
1 | #ifndef RAPIDJSON_POW10_
2 | #define RAPIDJSON_POW10_
3 |
4 | namespace rapidjson {
5 | namespace internal {
6 |
7 | //! Computes integer powers of 10 in double (10.0^n).
8 | /*! This function uses lookup table for fast and accurate results.
9 | \param n positive/negative exponent. Must <= 308.
10 | \return 10.0^n
11 | */
12 | inline double Pow10(int n) {
13 | static const double e[] = { // 1e-308...1e308: 617 * 8 bytes = 4936 bytes
14 | 1e-308,1e-307,1e-306,1e-305,1e-304,1e-303,1e-302,1e-301,1e-300,
15 | 1e-299,1e-298,1e-297,1e-296,1e-295,1e-294,1e-293,1e-292,1e-291,1e-290,1e-289,1e-288,1e-287,1e-286,1e-285,1e-284,1e-283,1e-282,1e-281,1e-280,
16 | 1e-279,1e-278,1e-277,1e-276,1e-275,1e-274,1e-273,1e-272,1e-271,1e-270,1e-269,1e-268,1e-267,1e-266,1e-265,1e-264,1e-263,1e-262,1e-261,1e-260,
17 | 1e-259,1e-258,1e-257,1e-256,1e-255,1e-254,1e-253,1e-252,1e-251,1e-250,1e-249,1e-248,1e-247,1e-246,1e-245,1e-244,1e-243,1e-242,1e-241,1e-240,
18 | 1e-239,1e-238,1e-237,1e-236,1e-235,1e-234,1e-233,1e-232,1e-231,1e-230,1e-229,1e-228,1e-227,1e-226,1e-225,1e-224,1e-223,1e-222,1e-221,1e-220,
19 | 1e-219,1e-218,1e-217,1e-216,1e-215,1e-214,1e-213,1e-212,1e-211,1e-210,1e-209,1e-208,1e-207,1e-206,1e-205,1e-204,1e-203,1e-202,1e-201,1e-200,
20 | 1e-199,1e-198,1e-197,1e-196,1e-195,1e-194,1e-193,1e-192,1e-191,1e-190,1e-189,1e-188,1e-187,1e-186,1e-185,1e-184,1e-183,1e-182,1e-181,1e-180,
21 | 1e-179,1e-178,1e-177,1e-176,1e-175,1e-174,1e-173,1e-172,1e-171,1e-170,1e-169,1e-168,1e-167,1e-166,1e-165,1e-164,1e-163,1e-162,1e-161,1e-160,
22 | 1e-159,1e-158,1e-157,1e-156,1e-155,1e-154,1e-153,1e-152,1e-151,1e-150,1e-149,1e-148,1e-147,1e-146,1e-145,1e-144,1e-143,1e-142,1e-141,1e-140,
23 | 1e-139,1e-138,1e-137,1e-136,1e-135,1e-134,1e-133,1e-132,1e-131,1e-130,1e-129,1e-128,1e-127,1e-126,1e-125,1e-124,1e-123,1e-122,1e-121,1e-120,
24 | 1e-119,1e-118,1e-117,1e-116,1e-115,1e-114,1e-113,1e-112,1e-111,1e-110,1e-109,1e-108,1e-107,1e-106,1e-105,1e-104,1e-103,1e-102,1e-101,1e-100,
25 | 1e-99, 1e-98, 1e-97, 1e-96, 1e-95, 1e-94, 1e-93, 1e-92, 1e-91, 1e-90, 1e-89, 1e-88, 1e-87, 1e-86, 1e-85, 1e-84, 1e-83, 1e-82, 1e-81, 1e-80,
26 | 1e-79, 1e-78, 1e-77, 1e-76, 1e-75, 1e-74, 1e-73, 1e-72, 1e-71, 1e-70, 1e-69, 1e-68, 1e-67, 1e-66, 1e-65, 1e-64, 1e-63, 1e-62, 1e-61, 1e-60,
27 | 1e-59, 1e-58, 1e-57, 1e-56, 1e-55, 1e-54, 1e-53, 1e-52, 1e-51, 1e-50, 1e-49, 1e-48, 1e-47, 1e-46, 1e-45, 1e-44, 1e-43, 1e-42, 1e-41, 1e-40,
28 | 1e-39, 1e-38, 1e-37, 1e-36, 1e-35, 1e-34, 1e-33, 1e-32, 1e-31, 1e-30, 1e-29, 1e-28, 1e-27, 1e-26, 1e-25, 1e-24, 1e-23, 1e-22, 1e-21, 1e-20,
29 | 1e-19, 1e-18, 1e-17, 1e-16, 1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e+0,
30 | 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20,
31 | 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40,
32 | 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60,
33 | 1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80,
34 | 1e+81, 1e+82, 1e+83, 1e+84, 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100,
35 | 1e+101,1e+102,1e+103,1e+104,1e+105,1e+106,1e+107,1e+108,1e+109,1e+110,1e+111,1e+112,1e+113,1e+114,1e+115,1e+116,1e+117,1e+118,1e+119,1e+120,
36 | 1e+121,1e+122,1e+123,1e+124,1e+125,1e+126,1e+127,1e+128,1e+129,1e+130,1e+131,1e+132,1e+133,1e+134,1e+135,1e+136,1e+137,1e+138,1e+139,1e+140,
37 | 1e+141,1e+142,1e+143,1e+144,1e+145,1e+146,1e+147,1e+148,1e+149,1e+150,1e+151,1e+152,1e+153,1e+154,1e+155,1e+156,1e+157,1e+158,1e+159,1e+160,
38 | 1e+161,1e+162,1e+163,1e+164,1e+165,1e+166,1e+167,1e+168,1e+169,1e+170,1e+171,1e+172,1e+173,1e+174,1e+175,1e+176,1e+177,1e+178,1e+179,1e+180,
39 | 1e+181,1e+182,1e+183,1e+184,1e+185,1e+186,1e+187,1e+188,1e+189,1e+190,1e+191,1e+192,1e+193,1e+194,1e+195,1e+196,1e+197,1e+198,1e+199,1e+200,
40 | 1e+201,1e+202,1e+203,1e+204,1e+205,1e+206,1e+207,1e+208,1e+209,1e+210,1e+211,1e+212,1e+213,1e+214,1e+215,1e+216,1e+217,1e+218,1e+219,1e+220,
41 | 1e+221,1e+222,1e+223,1e+224,1e+225,1e+226,1e+227,1e+228,1e+229,1e+230,1e+231,1e+232,1e+233,1e+234,1e+235,1e+236,1e+237,1e+238,1e+239,1e+240,
42 | 1e+241,1e+242,1e+243,1e+244,1e+245,1e+246,1e+247,1e+248,1e+249,1e+250,1e+251,1e+252,1e+253,1e+254,1e+255,1e+256,1e+257,1e+258,1e+259,1e+260,
43 | 1e+261,1e+262,1e+263,1e+264,1e+265,1e+266,1e+267,1e+268,1e+269,1e+270,1e+271,1e+272,1e+273,1e+274,1e+275,1e+276,1e+277,1e+278,1e+279,1e+280,
44 | 1e+281,1e+282,1e+283,1e+284,1e+285,1e+286,1e+287,1e+288,1e+289,1e+290,1e+291,1e+292,1e+293,1e+294,1e+295,1e+296,1e+297,1e+298,1e+299,1e+300,
45 | 1e+301,1e+302,1e+303,1e+304,1e+305,1e+306,1e+307,1e+308
46 | };
47 | RAPIDJSON_ASSERT(n <= 308);
48 | return n < -308 ? 0.0 : e[n + 308];
49 | }
50 |
51 | } // namespace internal
52 | } // namespace rapidjson
53 |
54 | #endif // RAPIDJSON_POW10_
55 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/external/rapidjson/internal/stack.h:
--------------------------------------------------------------------------------
1 | #ifndef RAPIDJSON_INTERNAL_STACK_H_
2 | #define RAPIDJSON_INTERNAL_STACK_H_
3 |
4 | namespace rapidjson {
5 | namespace internal {
6 |
7 | ///////////////////////////////////////////////////////////////////////////////
8 | // Stack
9 |
10 | //! A type-unsafe stack for storing different types of data.
11 | /*! \tparam Allocator Allocator for allocating stack memory.
12 | */
13 | template
14 | class Stack {
15 | public:
16 | Stack(Allocator* allocator, size_t stack_capacity) : allocator_(allocator), own_allocator_(0), stack_(0), stack_top_(0), stack_end_(0), stack_capacity_(stack_capacity) {
17 | RAPIDJSON_ASSERT(stack_capacity_ > 0);
18 | if (!allocator_)
19 | own_allocator_ = allocator_ = new Allocator();
20 | stack_top_ = stack_ = (char*)allocator_->Malloc(stack_capacity_);
21 | stack_end_ = stack_ + stack_capacity_;
22 | }
23 |
24 | ~Stack() {
25 | Allocator::Free(stack_);
26 | delete own_allocator_; // Only delete if it is owned by the stack
27 | }
28 |
29 | void Clear() { /*stack_top_ = 0;*/ stack_top_ = stack_; }
30 |
31 | template
32 | T* Push(size_t count = 1) {
33 | // Expand the stack if needed
34 | if (stack_top_ + sizeof(T) * count >= stack_end_) {
35 | size_t new_capacity = stack_capacity_ * 2;
36 | size_t size = GetSize();
37 | size_t new_size = GetSize() + sizeof(T) * count;
38 | if (new_capacity < new_size)
39 | new_capacity = new_size;
40 | stack_ = (char*)allocator_->Realloc(stack_, stack_capacity_, new_capacity);
41 | stack_capacity_ = new_capacity;
42 | stack_top_ = stack_ + size;
43 | stack_end_ = stack_ + stack_capacity_;
44 | }
45 | T* ret = (T*)stack_top_;
46 | stack_top_ += sizeof(T) * count;
47 | return ret;
48 | }
49 |
50 | template
51 | T* Pop(size_t count) {
52 | RAPIDJSON_ASSERT(GetSize() >= count * sizeof(T));
53 | stack_top_ -= count * sizeof(T);
54 | return (T*)stack_top_;
55 | }
56 |
57 | template
58 | T* Top() {
59 | RAPIDJSON_ASSERT(GetSize() >= sizeof(T));
60 | return (T*)(stack_top_ - sizeof(T));
61 | }
62 |
63 | template
64 | T* Bottom() { return (T*)stack_; }
65 |
66 | Allocator& GetAllocator() { return *allocator_; }
67 | size_t GetSize() const { return stack_top_ - stack_; }
68 | size_t GetCapacity() const { return stack_capacity_; }
69 |
70 | private:
71 | Allocator* allocator_;
72 | Allocator* own_allocator_;
73 | char *stack_;
74 | char *stack_top_;
75 | char *stack_end_;
76 | size_t stack_capacity_;
77 | };
78 |
79 | } // namespace internal
80 | } // namespace rapidjson
81 |
82 | #endif // RAPIDJSON_STACK_H_
83 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/external/rapidjson/internal/strfunc.h:
--------------------------------------------------------------------------------
1 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_
2 | #define RAPIDJSON_INTERNAL_STRFUNC_H_
3 |
4 | namespace rapidjson {
5 | namespace internal {
6 |
7 | //! Custom strlen() which works on different character types.
8 | /*! \tparam Ch Character type (e.g. char, wchar_t, short)
9 | \param s Null-terminated input string.
10 | \return Number of characters in the string.
11 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints.
12 | */
13 | template
14 | inline SizeType StrLen(const Ch* s) {
15 | const Ch* p = s;
16 | while (*p != '\0')
17 | ++p;
18 | return SizeType(p - s);
19 | }
20 |
21 | } // namespace internal
22 | } // namespace rapidjson
23 |
24 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_
25 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/external/rapidjson/license.txt:
--------------------------------------------------------------------------------
1 | Copyright (C) 2011 Milo Yip
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/external/rapidjson/prettywriter.h:
--------------------------------------------------------------------------------
1 | #ifndef RAPIDJSON_PRETTYWRITER_H_
2 | #define RAPIDJSON_PRETTYWRITER_H_
3 |
4 | #include "writer.h"
5 |
6 | namespace rapidjson {
7 |
8 | //! Writer with indentation and spacing.
9 | /*!
10 | \tparam Stream Type of ouptut stream.
11 | \tparam Encoding Encoding of both source strings and output.
12 | \tparam Allocator Type of allocator for allocating memory of stack.
13 | */
14 | template, typename Allocator = MemoryPoolAllocator<> >
15 | class PrettyWriter : public Writer {
16 | public:
17 | typedef Writer Base;
18 | typedef typename Base::Ch Ch;
19 |
20 | //! Constructor
21 | /*! \param stream Output stream.
22 | \param allocator User supplied allocator. If it is null, it will create a private one.
23 | \param levelDepth Initial capacity of
24 | */
25 | PrettyWriter(Stream& stream, int precision = 20, Allocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) :
26 | Base(stream, precision, allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {}
27 |
28 | //! Set custom indentation.
29 | /*! \param indentChar Character for indentation. Must be whitespace character (' ', '\t', '\n', '\r').
30 | \param indentCharCount Number of indent characters for each indentation level.
31 | \note The default indentation is 4 spaces.
32 | */
33 | PrettyWriter& SetIndent(Ch indentChar, unsigned indentCharCount) {
34 | RAPIDJSON_ASSERT(indentChar == ' ' || indentChar == '\t' || indentChar == '\n' || indentChar == '\r');
35 | indentChar_ = indentChar;
36 | indentCharCount_ = indentCharCount;
37 | return *this;
38 | }
39 |
40 | //@name Implementation of Handler.
41 | //@{
42 |
43 | PrettyWriter& Null_() { PrettyPrefix(kNull_Type); Base::WriteNull_(); return *this; }
44 | PrettyWriter& Bool_(bool b) { PrettyPrefix(b ? kTrueType : kFalseType); Base::WriteBool_(b); return *this; }
45 | PrettyWriter& Int(int i) { PrettyPrefix(kNumberType); Base::WriteInt(i); return *this; }
46 | PrettyWriter& Uint(unsigned u) { PrettyPrefix(kNumberType); Base::WriteUint(u); return *this; }
47 | PrettyWriter& Int64(int64_t i64) { PrettyPrefix(kNumberType); Base::WriteInt64(i64); return *this; }
48 | PrettyWriter& Uint64(uint64_t u64) { PrettyPrefix(kNumberType); Base::WriteUint64(u64); return *this; }
49 | PrettyWriter& Double(double d) { PrettyPrefix(kNumberType); Base::WriteDouble(d); return *this; }
50 |
51 | PrettyWriter& String(const Ch* str, SizeType length, bool copy = false) {
52 | (void)copy;
53 | PrettyPrefix(kStringType);
54 | Base::WriteString(str, length);
55 | return *this;
56 | }
57 |
58 | PrettyWriter& StartObject() {
59 | PrettyPrefix(kObjectType);
60 | new (Base::level_stack_.template Push()) typename Base::Level(false);
61 | Base::WriteStartObject();
62 | return *this;
63 | }
64 |
65 | PrettyWriter& EndObject(SizeType memberCount = 0) {
66 | (void)memberCount;
67 | RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level));
68 | RAPIDJSON_ASSERT(!Base::level_stack_.template Top()->inArray);
69 | bool empty = Base::level_stack_.template Pop(1)->valueCount == 0;
70 |
71 | if (!empty) {
72 | Base::stream_.Put('\n');
73 | WriteIndent();
74 | }
75 | Base::WriteEndObject();
76 | return *this;
77 | }
78 |
79 | PrettyWriter& StartArray() {
80 | PrettyPrefix(kArrayType);
81 | new (Base::level_stack_.template Push()) typename Base::Level(true);
82 | Base::WriteStartArray();
83 | return *this;
84 | }
85 |
86 | PrettyWriter& EndArray(SizeType memberCount = 0) {
87 | (void)memberCount;
88 | RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level));
89 | RAPIDJSON_ASSERT(Base::level_stack_.template Top()->inArray);
90 | bool empty = Base::level_stack_.template Pop(1)->valueCount == 0;
91 |
92 | if (!empty) {
93 | Base::stream_.Put('\n');
94 | WriteIndent();
95 | }
96 | Base::WriteEndArray();
97 | return *this;
98 | }
99 |
100 | //@}
101 |
102 | //! Simpler but slower overload.
103 | PrettyWriter& String(const Ch* str) { return String(str, internal::StrLen(str)); }
104 |
105 | protected:
106 | void PrettyPrefix(Type type) {
107 | (void)type;
108 | if (Base::level_stack_.GetSize() != 0) { // this value is not at root
109 | typename Base::Level* level = Base::level_stack_.template Top();
110 |
111 | if (level->inArray) {
112 | if (level->valueCount > 0) {
113 | Base::stream_.Put(','); // add comma if it is not the first element in array
114 | Base::stream_.Put('\n');
115 | }
116 | else
117 | Base::stream_.Put('\n');
118 | WriteIndent();
119 | }
120 | else { // in object
121 | if (level->valueCount > 0) {
122 | if (level->valueCount % 2 == 0) {
123 | Base::stream_.Put(',');
124 | Base::stream_.Put('\n');
125 | }
126 | else {
127 | Base::stream_.Put(':');
128 | Base::stream_.Put(' ');
129 | }
130 | }
131 | else
132 | Base::stream_.Put('\n');
133 |
134 | if (level->valueCount % 2 == 0)
135 | WriteIndent();
136 | }
137 | if (!level->inArray && level->valueCount % 2 == 0)
138 | RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name
139 | level->valueCount++;
140 | }
141 | else
142 | RAPIDJSON_ASSERT(type == kObjectType || type == kArrayType);
143 | }
144 |
145 | void WriteIndent() {
146 | size_t count = (Base::level_stack_.GetSize() / sizeof(typename Base::Level)) * indentCharCount_;
147 | PutN(Base::stream_, indentChar_, count);
148 | }
149 |
150 | Ch indentChar_;
151 | unsigned indentCharCount_;
152 | };
153 |
154 | } // namespace rapidjson
155 |
156 | #endif // RAPIDJSON_RAPIDJSON_H_
157 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/external/rapidjson/stringbuffer.h:
--------------------------------------------------------------------------------
1 | #ifndef RAPIDJSON_STRINGBUFFER_H_
2 | #define RAPIDJSON_STRINGBUFFER_H_
3 |
4 | #include "rapidjson.h"
5 | #include "internal/stack.h"
6 |
7 | namespace rapidjson {
8 |
9 | //! Represents an in-memory output stream.
10 | /*!
11 | \tparam Encoding Encoding of the stream.
12 | \tparam Allocator type for allocating memory buffer.
13 | \implements Stream
14 | */
15 | template
16 | struct GenericStringBuffer {
17 | typedef typename Encoding::Ch Ch;
18 |
19 | GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {}
20 |
21 | void Put(Ch c) { *stack_.template Push() = c; }
22 |
23 | void Clear() { stack_.Clear(); }
24 |
25 | const char* GetString() const {
26 | // Push and pop a null terminator. This is safe.
27 | *stack_.template Push() = '\0';
28 | stack_.template Pop(1);
29 |
30 | return stack_.template Bottom();
31 | }
32 |
33 | size_t Size() const { return stack_.GetSize(); }
34 |
35 | static const size_t kDefaultCapacity = 256;
36 | mutable internal::Stack stack_;
37 | };
38 |
39 | typedef GenericStringBuffer > StringBuffer;
40 |
41 | //! Implement specialized version of PutN() with memset() for better performance.
42 | template<>
43 | inline void PutN(GenericStringBuffer >& stream, char c, size_t n) {
44 | memset(stream.stack_.Push(n), c, n * sizeof(c));
45 | }
46 |
47 | } // namespace rapidjson
48 |
49 | #endif // RAPIDJSON_STRINGBUFFER_H_
50 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/external/rapidxml/license.txt:
--------------------------------------------------------------------------------
1 | Use of this software is granted under one of the following two licenses,
2 | to be chosen freely by the user.
3 |
4 | 1. Boost Software License - Version 1.0 - August 17th, 2003
5 | ===============================================================================
6 |
7 | Copyright (c) 2006, 2007 Marcin Kalicinski
8 |
9 | Permission is hereby granted, free of charge, to any person or organization
10 | obtaining a copy of the software and accompanying documentation covered by
11 | this license (the "Software") to use, reproduce, display, distribute,
12 | execute, and transmit the Software, and to prepare derivative works of the
13 | Software, and to permit third-parties to whom the Software is furnished to
14 | do so, all subject to the following:
15 |
16 | The copyright notices in the Software and this entire statement, including
17 | the above license grant, this restriction and the following disclaimer,
18 | must be included in all copies of the Software, in whole or in part, and
19 | all derivative works of the Software, unless such copies or derivative
20 | works are solely in the form of machine-executable object code generated by
21 | a source language processor.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
26 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
27 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
28 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 | DEALINGS IN THE SOFTWARE.
30 |
31 | 2. The MIT License
32 | ===============================================================================
33 |
34 | Copyright (c) 2006, 2007 Marcin Kalicinski
35 |
36 | Permission is hereby granted, free of charge, to any person obtaining a copy
37 | of this software and associated documentation files (the "Software"), to deal
38 | in the Software without restriction, including without limitation the rights
39 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
40 | of the Software, and to permit persons to whom the Software is furnished to do so,
41 | subject to the following conditions:
42 |
43 | The above copyright notice and this permission notice shall be included in all
44 | copies or substantial portions of the Software.
45 |
46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
49 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
52 | IN THE SOFTWARE.
53 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/external/rapidxml/rapidxml_iterators.hpp:
--------------------------------------------------------------------------------
1 | #ifndef RAPIDXML_ITERATORS_HPP_INCLUDED
2 | #define RAPIDXML_ITERATORS_HPP_INCLUDED
3 |
4 | // Copyright (C) 2006, 2009 Marcin Kalicinski
5 | // Version 1.13
6 | // Revision $DateTime: 2009/05/13 01:46:17 $
7 |
8 | #include "rapidxml.hpp"
9 |
10 | namespace rapidxml
11 | {
12 |
13 | //! Iterator of child nodes of xml_node
14 | template
15 | class node_iterator
16 | {
17 |
18 | public:
19 |
20 | typedef typename xml_node value_type;
21 | typedef typename xml_node &reference;
22 | typedef typename xml_node *pointer;
23 | typedef std::ptrdiff_t difference_type;
24 | typedef std::bidirectional_iterator_tag iterator_category;
25 |
26 | node_iterator()
27 | : m_node(0)
28 | {
29 | }
30 |
31 | node_iterator(xml_node *node)
32 | : m_node(node->first_node())
33 | {
34 | }
35 |
36 | reference operator *() const
37 | {
38 | assert(m_node);
39 | return *m_node;
40 | }
41 |
42 | pointer operator->() const
43 | {
44 | assert(m_node);
45 | return m_node;
46 | }
47 |
48 | node_iterator& operator++()
49 | {
50 | assert(m_node);
51 | m_node = m_node->next_sibling();
52 | return *this;
53 | }
54 |
55 | node_iterator operator++(int)
56 | {
57 | node_iterator tmp = *this;
58 | ++this;
59 | return tmp;
60 | }
61 |
62 | node_iterator& operator--()
63 | {
64 | assert(m_node && m_node->previous_sibling());
65 | m_node = m_node->previous_sibling();
66 | return *this;
67 | }
68 |
69 | node_iterator operator--(int)
70 | {
71 | node_iterator tmp = *this;
72 | ++this;
73 | return tmp;
74 | }
75 |
76 | bool operator ==(const node_iterator &rhs)
77 | {
78 | return m_node == rhs.m_node;
79 | }
80 |
81 | bool operator !=(const node_iterator &rhs)
82 | {
83 | return m_node != rhs.m_node;
84 | }
85 |
86 | private:
87 |
88 | xml_node *m_node;
89 |
90 | };
91 |
92 | //! Iterator of child attributes of xml_node
93 | template
94 | class attribute_iterator
95 | {
96 |
97 | public:
98 |
99 | typedef typename xml_attribute value_type;
100 | typedef typename xml_attribute &reference;
101 | typedef typename xml_attribute *pointer;
102 | typedef std::ptrdiff_t difference_type;
103 | typedef std::bidirectional_iterator_tag iterator_category;
104 |
105 | attribute_iterator()
106 | : m_attribute(0)
107 | {
108 | }
109 |
110 | attribute_iterator(xml_node *node)
111 | : m_attribute(node->first_attribute())
112 | {
113 | }
114 |
115 | reference operator *() const
116 | {
117 | assert(m_attribute);
118 | return *m_attribute;
119 | }
120 |
121 | pointer operator->() const
122 | {
123 | assert(m_attribute);
124 | return m_attribute;
125 | }
126 |
127 | attribute_iterator& operator++()
128 | {
129 | assert(m_attribute);
130 | m_attribute = m_attribute->next_attribute();
131 | return *this;
132 | }
133 |
134 | attribute_iterator operator++(int)
135 | {
136 | attribute_iterator tmp = *this;
137 | ++this;
138 | return tmp;
139 | }
140 |
141 | attribute_iterator& operator--()
142 | {
143 | assert(m_attribute && m_attribute->previous_attribute());
144 | m_attribute = m_attribute->previous_attribute();
145 | return *this;
146 | }
147 |
148 | attribute_iterator operator--(int)
149 | {
150 | attribute_iterator tmp = *this;
151 | ++this;
152 | return tmp;
153 | }
154 |
155 | bool operator ==(const attribute_iterator &rhs)
156 | {
157 | return m_attribute == rhs.m_attribute;
158 | }
159 |
160 | bool operator !=(const attribute_iterator &rhs)
161 | {
162 | return m_attribute != rhs.m_attribute;
163 | }
164 |
165 | private:
166 |
167 | xml_attribute *m_attribute;
168 |
169 | };
170 |
171 | }
172 |
173 | #endif
174 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/external/rapidxml/rapidxml_utils.hpp:
--------------------------------------------------------------------------------
1 | #ifndef RAPIDXML_UTILS_HPP_INCLUDED
2 | #define RAPIDXML_UTILS_HPP_INCLUDED
3 |
4 | // Copyright (C) 2006, 2009 Marcin Kalicinski
5 | // Version 1.13
6 | // Revision $DateTime: 2009/05/13 01:46:17 $
7 | //! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective.
8 |
9 | #include "rapidxml.hpp"
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | namespace rapidxml
16 | {
17 |
18 | //! Represents data loaded from a file
19 | template
20 | class file
21 | {
22 |
23 | public:
24 |
25 | //! Loads file into the memory. Data will be automatically destroyed by the destructor.
26 | //! \param filename Filename to load.
27 | file(const char *filename)
28 | {
29 | using namespace std;
30 |
31 | // Open stream
32 | basic_ifstream stream(filename, ios::binary);
33 | if (!stream)
34 | throw runtime_error(string("cannot open file ") + filename);
35 | stream.unsetf(ios::skipws);
36 |
37 | // Determine stream size
38 | stream.seekg(0, ios::end);
39 | size_t size = stream.tellg();
40 | stream.seekg(0);
41 |
42 | // Load data and add terminating 0
43 | m_data.resize(size + 1);
44 | stream.read(&m_data.front(), static_cast(size));
45 | m_data[size] = 0;
46 | }
47 |
48 | //! Loads file into the memory. Data will be automatically destroyed by the destructor
49 | //! \param stream Stream to load from
50 | file(std::basic_istream &stream)
51 | {
52 | using namespace std;
53 |
54 | // Load data and add terminating 0
55 | stream.unsetf(ios::skipws);
56 | m_data.assign(istreambuf_iterator(stream), istreambuf_iterator());
57 | if (stream.fail() || stream.bad())
58 | throw runtime_error("error reading stream");
59 | m_data.push_back(0);
60 | }
61 |
62 | //! Gets file data.
63 | //! \return Pointer to data of file.
64 | Ch *data()
65 | {
66 | return &m_data.front();
67 | }
68 |
69 | //! Gets file data.
70 | //! \return Pointer to data of file.
71 | const Ch *data() const
72 | {
73 | return &m_data.front();
74 | }
75 |
76 | //! Gets file data size.
77 | //! \return Size of file data, in characters.
78 | std::size_t size() const
79 | {
80 | return m_data.size();
81 | }
82 |
83 | private:
84 |
85 | std::vector m_data; // File data
86 |
87 | };
88 |
89 | //! Counts children of node. Time complexity is O(n).
90 | //! \return Number of children of node
91 | template
92 | inline std::size_t count_children(xml_node *node)
93 | {
94 | xml_node *child = node->first_node();
95 | std::size_t count = 0;
96 | while (child)
97 | {
98 | ++count;
99 | child = child->next_sibling();
100 | }
101 | return count;
102 | }
103 |
104 | //! Counts attributes of node. Time complexity is O(n).
105 | //! \return Number of attributes of node
106 | template
107 | inline std::size_t count_attributes(xml_node *node)
108 | {
109 | xml_attribute *attr = node->first_attribute();
110 | std::size_t count = 0;
111 | while (attr)
112 | {
113 | ++count;
114 | attr = attr->next_attribute();
115 | }
116 | return count;
117 | }
118 |
119 | }
120 |
121 | #endif
122 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/macros.hpp:
--------------------------------------------------------------------------------
1 | /*! \file macros.hpp
2 | \brief Preprocessor macros that can customise the cereal library
3 |
4 | By default, cereal looks for serialization functions with very
5 | specific names, that is: serialize, load, save, load_minimal,
6 | or save_minimal.
7 |
8 | This file allows an advanced user to change these names to conform
9 | to some other style or preference. This is implemented using
10 | preprocessor macros.
11 |
12 | As a result of this, in internal cereal code you will see macros
13 | used for these function names. In user code, you should name
14 | the functions like you normally would and not use the macros
15 | to improve readability.
16 | \ingroup utility */
17 | /*
18 | Copyright (c) 2014, Randolph Voorhies, Shane Grant
19 | All rights reserved.
20 |
21 | Redistribution and use in source and binary forms, with or without
22 | modification, are permitted provided that the following conditions are met:
23 | * Redistributions of source code must retain the above copyright
24 | notice, this list of conditions and the following disclaimer.
25 | * Redistributions in binary form must reproduce the above copyright
26 | notice, this list of conditions and the following disclaimer in the
27 | documentation and/or other materials provided with the distribution.
28 | * Neither the name of cereal nor the
29 | names of its contributors may be used to endorse or promote products
30 | derived from this software without specific prior written permission.
31 |
32 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
36 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 | */
43 |
44 | #ifndef CEREAL_MACROS_HPP_
45 | #define CEREAL_MACROS_HPP_
46 |
47 | #ifndef CEREAL_SERIALIZE_FUNCTION_NAME
48 | //! The serialization/deserialization function name to search for.
49 | /*! You can define @c CEREAL_SERIALIZE_FUNCTION_NAME to be different assuming
50 | you do so before this file is included. */
51 | #define CEREAL_SERIALIZE_FUNCTION_NAME serialize
52 | #endif // CEREAL_SERIALIZE_FUNCTION_NAME
53 |
54 | #ifndef CEREAL_LOAD_FUNCTION_NAME
55 | //! The deserialization (load) function name to search for.
56 | /*! You can define @c CEREAL_LOAD_FUNCTION_NAME to be different assuming you do so
57 | before this file is included. */
58 | #define CEREAL_LOAD_FUNCTION_NAME load
59 | #endif // CEREAL_LOAD_FUNCTION_NAME
60 |
61 | #ifndef CEREAL_SAVE_FUNCTION_NAME
62 | //! The serialization (save) function name to search for.
63 | /*! You can define @c CEREAL_SAVE_FUNCTION_NAME to be different assuming you do so
64 | before this file is included. */
65 | #define CEREAL_SAVE_FUNCTION_NAME save
66 | #endif // CEREAL_SAVE_FUNCTION_NAME
67 |
68 | #ifndef CEREAL_LOAD_MINIMAL_FUNCTION_NAME
69 | //! The deserialization (load_minimal) function name to search for.
70 | /*! You can define @c CEREAL_LOAD_MINIMAL_FUNCTION_NAME to be different assuming you do so
71 | before this file is included. */
72 | #define CEREAL_LOAD_MINIMAL_FUNCTION_NAME load_minimal
73 | #endif // CEREAL_LOAD_MINIMAL_FUNCTION_NAME
74 |
75 | #ifndef CEREAL_SAVE_MINIMAL_FUNCTION_NAME
76 | //! The serialization (save_minimal) function name to search for.
77 | /*! You can define @c CEREAL_SAVE_MINIMAL_FUNCTION_NAME to be different assuming you do so
78 | before this file is included. */
79 | #define CEREAL_SAVE_MINIMAL_FUNCTION_NAME save_minimal
80 | #endif // CEREAL_SAVE_MINIMAL_FUNCTION_NAME
81 |
82 | #endif // CEREAL_MACROS_HPP_
83 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/types/array.hpp:
--------------------------------------------------------------------------------
1 | /*! \file array.hpp
2 | \brief Support for types found in \
3 | \ingroup STLSupport */
4 | /*
5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of cereal nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | */
30 | #ifndef CEREAL_TYPES_ARRAY_HPP_
31 | #define CEREAL_TYPES_ARRAY_HPP_
32 |
33 | #include
34 | #include
35 |
36 | namespace cereal
37 | {
38 | //! Saving for std::array primitive types
39 | //! using binary serialization, if supported
40 | template inline
41 | typename std::enable_if, Archive>::value
42 | && std::is_arithmetic::value, void>::type
43 | CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::array const & array )
44 | {
45 | ar( binary_data( array.data(), sizeof(array) ) );
46 | }
47 |
48 | //! Loading for std::array primitive types
49 | //! using binary serialization, if supported
50 | template inline
51 | typename std::enable_if, Archive>::value
52 | && std::is_arithmetic::value, void>::type
53 | CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::array & array )
54 | {
55 | ar( binary_data( array.data(), sizeof(array) ) );
56 | }
57 |
58 | //! Saving for std::array all other types
59 | template inline
60 | typename std::enable_if, Archive>::value
61 | || !std::is_arithmetic::value, void>::type
62 | CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::array const & array )
63 | {
64 | for( auto const & i : array )
65 | ar( i );
66 | }
67 |
68 | //! Loading for std::array all other types
69 | template inline
70 | typename std::enable_if, Archive>::value
71 | || !std::is_arithmetic::value, void>::type
72 | CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::array & array )
73 | {
74 | for( auto & i : array )
75 | ar( i );
76 | }
77 | } // namespace cereal
78 |
79 | #endif // CEREAL_TYPES_ARRAY_HPP_
80 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/types/bitset.hpp:
--------------------------------------------------------------------------------
1 | /*! \file bitset.hpp
2 | \brief Support for types found in \
3 | \ingroup STLSupport */
4 | /*
5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of cereal nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | */
30 | #ifndef CEREAL_TYPES_BITSET_HPP_
31 | #define CEREAL_TYPES_BITSET_HPP_
32 |
33 | #include
34 | #include
35 |
36 | namespace cereal
37 | {
38 | namespace bitset_detail
39 | {
40 | //! The type the bitset is encoded with
41 | /*! @internal */
42 | enum class type : uint8_t
43 | {
44 | ulong,
45 | ullong,
46 | string
47 | };
48 | }
49 |
50 | //! Serializing (save) for std::bitset
51 | template inline
52 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::bitset const & bits )
53 | {
54 | try
55 | {
56 | auto const b = bits.to_ulong();
57 | ar( CEREAL_NVP_("type", bitset_detail::type::ulong) );
58 | ar( CEREAL_NVP_("data", b) );
59 | }
60 | catch( std::overflow_error const & )
61 | {
62 | try
63 | {
64 | auto const b = bits.to_ullong();
65 | ar( CEREAL_NVP_("type", bitset_detail::type::ullong) );
66 | ar( CEREAL_NVP_("data", b) );
67 | }
68 | catch( std::overflow_error const & )
69 | {
70 | ar( CEREAL_NVP_("type", bitset_detail::type::string) );
71 | ar( CEREAL_NVP_("data", bits.to_string()) );
72 | }
73 | }
74 | }
75 |
76 | //! Serializing (load) for std::bitset
77 | template inline
78 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::bitset & bits )
79 | {
80 | bitset_detail::type t;
81 | ar( CEREAL_NVP_("type", t) );
82 |
83 | switch( t )
84 | {
85 | case bitset_detail::type::ulong:
86 | {
87 | unsigned long b;
88 | ar( CEREAL_NVP_("data", b) );
89 | bits = std::bitset( b );
90 | break;
91 | }
92 | case bitset_detail::type::ullong:
93 | {
94 | unsigned long long b;
95 | ar( CEREAL_NVP_("data", b) );
96 | bits = std::bitset( b );
97 | break;
98 | }
99 | case bitset_detail::type::string:
100 | {
101 | std::string b;
102 | ar( CEREAL_NVP_("data", b) );
103 | bits = std::bitset( b );
104 | break;
105 | }
106 | default:
107 | throw Exception("Invalid bitset data representation");
108 | }
109 | }
110 | } // namespace cereal
111 |
112 | #endif // CEREAL_TYPES_BITSET_HPP_
113 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/types/boost_variant.hpp:
--------------------------------------------------------------------------------
1 | /*! \file boost_variant.hpp
2 | \brief Support for boost::variant
3 | \ingroup OtherTypes */
4 | /*
5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of cereal nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | */
30 | #ifndef CEREAL_TYPES_BOOST_VARIANT_HPP_
31 | #define CEREAL_TYPES_BOOST_VARIANT_HPP_
32 |
33 | #include
34 | #include
35 | #include
36 |
37 | namespace cereal
38 | {
39 | namespace variant_detail
40 | {
41 | //! @internal
42 | template
43 | struct variant_save_visitor : boost::static_visitor<>
44 | {
45 | variant_save_visitor(Archive & ar_) : ar(ar_) {}
46 |
47 | template
48 | void operator()(T const & value) const
49 | {
50 | ar( CEREAL_NVP_("data", value) );
51 | }
52 |
53 | Archive & ar;
54 | };
55 |
56 | //! @internal
57 | template
58 | typename std::enable_if::value, void>::type
59 | load_variant(Archive & /*ar*/, int /*target*/, Variant & /*variant*/)
60 | {
61 | throw ::cereal::Exception("Error traversing variant during load");
62 | }
63 |
64 | //! @internal
65 | template
66 | typename std::enable_if::value, void>::type
67 | load_variant(Archive & ar, int target, Variant & variant)
68 | {
69 | if(N == target)
70 | {
71 | H value;
72 | ar( CEREAL_NVP_("data", value) );
73 | variant = value;
74 | }
75 | else
76 | load_variant(ar, target, variant);
77 | }
78 |
79 | } // namespace variant_detail
80 |
81 | //! Saving for boost::variant
82 | template inline
83 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, boost::variant const & variant )
84 | {
85 | int32_t which = variant.which();
86 | ar( CEREAL_NVP_("which", which) );
87 | variant_detail::variant_save_visitor visitor(ar);
88 | variant.apply_visitor(visitor);
89 | }
90 |
91 | //! Loading for boost::variant
92 | template inline
93 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, boost::variant & variant )
94 | {
95 | typedef typename boost::variant::types types;
96 |
97 | int32_t which;
98 | ar( CEREAL_NVP_("which", which) );
99 | if(which >= boost::mpl::size::value)
100 | throw Exception("Invalid 'which' selector when deserializing boost::variant");
101 |
102 | variant_detail::load_variant<0, boost::variant, VariantTypes...>(ar, which, variant);
103 | }
104 | } // namespace cereal
105 |
106 | #endif // CEREAL_TYPES_BOOST_VARIANT_HPP_
107 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/types/chrono.hpp:
--------------------------------------------------------------------------------
1 | /*! \file chrono.hpp
2 | \brief Support for types found in \
3 | \ingroup STLSupport */
4 | /*
5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of cereal nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | */
30 | #ifndef CEREAL_TYPES_CHRONO_HPP_
31 | #define CEREAL_TYPES_CHRONO_HPP_
32 |
33 | #include
34 |
35 | namespace cereal
36 | {
37 | //! Saving std::chrono::duration
38 | template inline
39 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::chrono::duration const & dur )
40 | {
41 | ar( CEREAL_NVP_("count", dur.count()) );
42 | }
43 |
44 | //! Loading std::chrono::duration
45 | template inline
46 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::chrono::duration & dur )
47 | {
48 | R count;
49 | ar( CEREAL_NVP_("count", count) );
50 |
51 | dur = std::chrono::duration{count};
52 | }
53 |
54 | //! Saving std::chrono::time_point
55 | template inline
56 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::chrono::time_point const & dur )
57 | {
58 | ar( CEREAL_NVP_("time_since_epoch", dur.time_since_epoch()) );
59 | }
60 |
61 | //! Loading std::chrono::time_point
62 | template inline
63 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::chrono::time_point & dur )
64 | {
65 | D elapsed;
66 | ar( CEREAL_NVP_("time_since_epoch", elapsed) );
67 |
68 | dur = std::chrono::time_point{elapsed};
69 | }
70 | } // namespace cereal
71 |
72 | #endif // CEREAL_TYPES_CHRONO_HPP_
73 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/types/common.hpp:
--------------------------------------------------------------------------------
1 | /*! \file common.hpp
2 | \brief Support common types - always included automatically
3 | \ingroup OtherTypes */
4 | /*
5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of cereal nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | */
30 | #ifndef CEREAL_TYPES_COMMON_HPP_
31 | #define CEREAL_TYPES_COMMON_HPP_
32 |
33 | #include
34 |
35 | namespace cereal
36 | {
37 | namespace common_detail
38 | {
39 | //! Serialization for arrays if BinaryData is supported and we are arithmetic
40 | /*! @internal */
41 | template inline
42 | void serializeArray( Archive & ar, T & array, std::true_type /* binary_supported */ )
43 | {
44 | ar( binary_data( array, sizeof(array) ) );
45 | }
46 |
47 | //! Serialization for arrays if BinaryData is not supported or we are not arithmetic
48 | /*! @internal */
49 | template inline
50 | void serializeArray( Archive & ar, T & array, std::false_type /* binary_supported */ )
51 | {
52 | for( auto & i : array )
53 | ar( i );
54 | }
55 |
56 | namespace
57 | {
58 | //! Gets the underlying type of an enum
59 | /*! @internal */
60 | template
61 | struct enum_underlying_type : std::false_type {};
62 |
63 | //! Gets the underlying type of an enum
64 | /*! Specialization for when we actually have an enum
65 | @internal */
66 | template
67 | struct enum_underlying_type { using type = typename std::underlying_type::type; };
68 | } // anon namespace
69 |
70 | //! Checks if a type is an enum
71 | /*! This is needed over simply calling std::is_enum because the type
72 | traits checking at compile time will attempt to call something like
73 | load_minimal with a special NoConvertRef struct that wraps up the true type.
74 |
75 | This will strip away any of that and also expose the true underlying type.
76 | @internal */
77 | template
78 | class is_enum
79 | {
80 | private:
81 | using DecayedT = typename std::decay::type;
82 | using StrippedT = typename ::cereal::traits::strip_minimal::type;
83 |
84 | public:
85 | static const bool value = std::is_enum::value;
86 | using type = StrippedT;
87 | using base_type = typename enum_underlying_type::type;
88 | };
89 | }
90 |
91 | //! Saving for enum types
92 | template inline
93 | typename std::enable_if::value,
94 | typename common_detail::is_enum::base_type>::type
95 | CEREAL_SAVE_MINIMAL_FUNCTION_NAME( Archive const &, T const & t )
96 | {
97 | return static_cast::base_type>(t);
98 | }
99 |
100 | //! Loading for enum types
101 | template inline
102 | typename std::enable_if::value, void>::type
103 | CEREAL_LOAD_MINIMAL_FUNCTION_NAME( Archive const &, T && t,
104 | typename common_detail::is_enum::base_type const & value )
105 | {
106 | t = reinterpret_cast::type const &>( value );
107 | }
108 |
109 | //! Serialization for raw pointers
110 | /*! This exists only to throw a static_assert to let users know we don't support raw pointers. */
111 | template inline
112 | void CEREAL_SERIALIZE_FUNCTION_NAME( Archive &, T * & )
113 | {
114 | static_assert(cereal::traits::detail::delay_static_assert::value,
115 | "Cereal does not support serializing raw pointers - please use a smart pointer");
116 | }
117 |
118 | //! Serialization for C style arrays
119 | template inline
120 | typename std::enable_if::value, void>::type
121 | CEREAL_SERIALIZE_FUNCTION_NAME(Archive & ar, T & array)
122 | {
123 | common_detail::serializeArray( ar, array,
124 | std::integral_constant, Archive>::value &&
125 | std::is_arithmetic::type>::value>() );
126 | }
127 | } // namespace cereal
128 |
129 | #endif // CEREAL_TYPES_COMMON_HPP_
130 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/types/complex.hpp:
--------------------------------------------------------------------------------
1 | /*! \file complex.hpp
2 | \brief Support for types found in \
3 | \ingroup STLSupport */
4 | /*
5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of cereal nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | */
30 | #ifndef CEREAL_TYPES_COMPLEX_HPP_
31 | #define CEREAL_TYPES_COMPLEX_HPP_
32 |
33 | #include
34 |
35 | namespace cereal
36 | {
37 | //! Serializing (save) for std::complex
38 | template inline
39 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::complex const & comp )
40 | {
41 | ar( CEREAL_NVP_("real", comp.real()),
42 | CEREAL_NVP_("imag", comp.imag()) );
43 | }
44 |
45 | //! Serializing (load) for std::complex
46 | template inline
47 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::complex & bits )
48 | {
49 | T real, imag;
50 | ar( CEREAL_NVP_("real", real),
51 | CEREAL_NVP_("imag", imag) );
52 | bits = {real, imag};
53 | }
54 | } // namespace cereal
55 |
56 | #endif // CEREAL_TYPES_COMPLEX_HPP_
57 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/types/deque.hpp:
--------------------------------------------------------------------------------
1 | /*! \file deque.hpp
2 | \brief Support for types found in \
3 | \ingroup STLSupport */
4 | /*
5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of cereal nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | */
30 | #ifndef CEREAL_TYPES_DEQUE_HPP_
31 | #define CEREAL_TYPES_DEQUE_HPP_
32 |
33 | #include
34 | #include
35 |
36 | namespace cereal
37 | {
38 | //! Saving for std::deque
39 | template inline
40 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::deque const & deque )
41 | {
42 | ar( make_size_tag( static_cast(deque.size()) ) );
43 |
44 | for( auto const & i : deque )
45 | ar( i );
46 | }
47 |
48 | //! Loading for std::deque
49 | template inline
50 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::deque & deque )
51 | {
52 | size_type size;
53 | ar( make_size_tag( size ) );
54 |
55 | deque.resize( static_cast( size ) );
56 |
57 | for( auto & i : deque )
58 | ar( i );
59 | }
60 | } // namespace cereal
61 |
62 | #endif // CEREAL_TYPES_DEQUE_HPP_
63 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/types/forward_list.hpp:
--------------------------------------------------------------------------------
1 | /*! \file forward_list.hpp
2 | \brief Support for types found in \
3 | \ingroup STLSupport */
4 | /*
5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of cereal nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | */
30 | #ifndef CEREAL_TYPES_FORWARD_LIST_HPP_
31 | #define CEREAL_TYPES_FORWARD_LIST_HPP_
32 |
33 | #include
34 | #include
35 |
36 | namespace cereal
37 | {
38 | //! Saving for std::forward_list all other types
39 | template inline
40 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::forward_list const & forward_list )
41 | {
42 | // write the size - note that this is slow because we need to traverse
43 | // the entire list. there are ways we could avoid this but this was chosen
44 | // since it works in the most general fashion with any archive type
45 | size_type const size = std::distance( forward_list.begin(), forward_list.end() );
46 |
47 | ar( make_size_tag( size ) );
48 |
49 | // write the list
50 | for( const auto & i : forward_list )
51 | ar( i );
52 | }
53 |
54 | //! Loading for std::forward_list all other types from
55 | template
56 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::forward_list & forward_list )
57 | {
58 | size_type size;
59 | ar( make_size_tag( size ) );
60 |
61 | forward_list.resize( static_cast( size ) );
62 |
63 | for( auto & i : forward_list )
64 | ar( i );
65 | }
66 | } // namespace cereal
67 |
68 | #endif // CEREAL_TYPES_FORWARD_LIST_HPP_
69 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/types/list.hpp:
--------------------------------------------------------------------------------
1 | /*! \file list.hpp
2 | \brief Support for types found in \
3 | \ingroup STLSupport */
4 | /*
5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of cereal nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | */
30 | #ifndef CEREAL_TYPES_LIST_HPP_
31 | #define CEREAL_TYPES_LIST_HPP_
32 |
33 | #include
34 | #include
35 |
36 | namespace cereal
37 | {
38 | //! Saving for std::list
39 | template inline
40 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::list const & list )
41 | {
42 | ar( make_size_tag( static_cast(list.size()) ) );
43 |
44 | for( auto const & i : list )
45 | ar( i );
46 | }
47 |
48 | //! Loading for std::list
49 | template inline
50 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::list & list )
51 | {
52 | size_type size;
53 | ar( make_size_tag( size ) );
54 |
55 | list.resize( static_cast( size ) );
56 |
57 | for( auto & i : list )
58 | ar( i );
59 | }
60 | } // namespace cereal
61 |
62 | #endif // CEREAL_TYPES_LIST_HPP_
63 |
--------------------------------------------------------------------------------
/Prj-Win/src/include/cereal/types/map.hpp:
--------------------------------------------------------------------------------
1 | /*! \file map.hpp
2 | \brief Support for types found in \