├── .gitattributes ├── .gitignore ├── AssemblyCopyright.cs ├── Data └── CustomTime.cs ├── FaceFeatureClient.csproj ├── FaceFeatureClient.sln ├── FaceTextOrganizer.cs ├── FaceTracking.cs ├── FacialExpression.cs ├── File ├── ConfigReader.cs ├── StateTable.cs └── UploadFile.cs ├── HttpServer ├── BaseHeader.cs ├── ConsoleLogger.cs ├── ExampleServer.cs ├── HeadersHelper.cs ├── HttpRequest.cs ├── HttpResponse.cs ├── HttpServer.cs ├── ILogger.cs ├── IServer.cs ├── Protocols.cs ├── RequestHeaders.cs └── ResponseHeaders.cs ├── LICENSE ├── MainForm.Designer.cs ├── MainForm.cs ├── MainForm.resx ├── ModuleSettings.cs ├── Program.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── README.md ├── RealSenseclient └── RealSenseclient.vdproj ├── WriteLog.cs ├── app.config ├── intel.ico ├── libpxcclr.cs.dll ├── libpxccpp2c.dll ├── packages.config └── timer.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /AssemblyCopyright.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | #if RELEASE_VERSIONING 5 | [assembly: AssemblyCopyright("Copyright(C) 2012-2015, Intel Corporation. All Rights Reserved.")] 6 | #endif -------------------------------------------------------------------------------- /Data/CustomTime.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DF_FaceTracking.cs.Data 7 | { 8 | public class CustomTime 9 | { 10 | // 世界时刻(时间戳) 11 | public long absTS { set; get; } 12 | // 视频时刻 (单位是s) 13 | public int videoTS { set; get; } 14 | 15 | private static DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0, 0)); 16 | 17 | public static long ConvertDateTimeToTimeStamp(DateTime time) 18 | { 19 | long t = (time.Ticks - startTime.Ticks) / 10000000; //精确到秒 20 | return t; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /FaceFeatureClient.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {DED2187A-52A5-466E-8B3D-BFF013770412} 9 | WinExe 10 | Properties 11 | DF_FaceTracking.cs 12 | DF_FaceTracking.cs 13 | v4.5 14 | 15 | 16 | 512 17 | false 18 | publish\ 19 | true 20 | Disk 21 | false 22 | Foreground 23 | 7 24 | Days 25 | false 26 | false 27 | true 28 | 0 29 | 1.0.0.%2a 30 | false 31 | true 32 | 33 | 34 | x86 35 | true 36 | full 37 | false 38 | bin\win32\Debug\ 39 | DEBUG;TRACE 40 | prompt 41 | 4 42 | Auto 43 | $(RSSDK_DIR)\bin\win32\libpxcclr.cs.dll 44 | false 45 | 46 | 47 | x86 48 | pdbonly 49 | true 50 | bin\win32\Release\ 51 | TRACE 52 | prompt 53 | 4 54 | $(RSSDK_DIR)\bin\win32\libpxcclr.cs.dll 55 | false 56 | 57 | 58 | true 59 | bin\x64\Debug\ 60 | DEBUG;TRACE 61 | full 62 | x64 63 | prompt 64 | $(RSSDK_DIR)\bin\x64\libpxcclr.cs.dll 65 | false 66 | 67 | 68 | bin\x64\Release\ 69 | TRACE 70 | true 71 | pdbonly 72 | x64 73 | prompt 74 | $(RSSDK_DIR)\bin\x64\libpxcclr.cs.dll 75 | false 76 | 77 | 78 | 79 | 80 | 81 | intel.ico 82 | 83 | 84 | 85 | False 86 | bin\x64\Debug\libpxcclr.cs.dll 87 | 88 | 89 | packages\MaterialSkin.0.2.1\lib\MaterialSkin.dll 90 | 91 | 92 | False 93 | ..\..\Newtonsoft.Json.dll 94 | 95 | 96 | 97 | 98 | 99 | C:\Users\hao_chen\Desktop\新建文件夹\System.Data.SQLite.dll 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | Form 142 | 143 | 144 | MainForm.cs 145 | 146 | 147 | 148 | 149 | 150 | True 151 | True 152 | Resources.resx 153 | 154 | 155 | True 156 | True 157 | Settings.settings 158 | 159 | 160 | 161 | 162 | 163 | Designer 164 | 165 | 166 | 167 | SettingsSingleFileGenerator 168 | Settings.Designer.cs 169 | 170 | 171 | 172 | 173 | False 174 | Microsoft .NET Framework 4 Client Profile %28x86 and x64%29 175 | true 176 | 177 | 178 | False 179 | .NET Framework 3.5 SP1 Client Profile 180 | false 181 | 182 | 183 | False 184 | .NET Framework 3.5 SP1 185 | false 186 | 187 | 188 | False 189 | Windows Installer 3.1 190 | true 191 | 192 | 193 | 194 | 195 | MainForm.cs 196 | Designer 197 | 198 | 199 | ResXFileCodeGenerator 200 | Resources.Designer.cs 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | if "$(Platform)" == "x86" ( copy /y "$(RSSDK_DIR)\bin\win32\libpxccpp2c.dll" "$(TargetDir)" ) else ( copy /y "$(RSSDK_DIR)\bin\$(Platform)\libpxccpp2c.dll" "$(TargetDir)" ) 216 | 217 | 218 | 225 | -------------------------------------------------------------------------------- /FaceFeatureClient.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27703.2042 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FaceFeatureClient", "FaceFeatureClient.csproj", "{DED2187A-52A5-466E-8B3D-BFF013770412}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|Any CPU = Release|Any CPU 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {DED2187A-52A5-466E-8B3D-BFF013770412}.Debug|Any CPU.ActiveCfg = Debug|x86 19 | {DED2187A-52A5-466E-8B3D-BFF013770412}.Debug|x64.ActiveCfg = Debug|x64 20 | {DED2187A-52A5-466E-8B3D-BFF013770412}.Debug|x64.Build.0 = Debug|x64 21 | {DED2187A-52A5-466E-8B3D-BFF013770412}.Debug|x86.ActiveCfg = Debug|x86 22 | {DED2187A-52A5-466E-8B3D-BFF013770412}.Debug|x86.Build.0 = Debug|x86 23 | {DED2187A-52A5-466E-8B3D-BFF013770412}.Release|Any CPU.ActiveCfg = Release|x86 24 | {DED2187A-52A5-466E-8B3D-BFF013770412}.Release|x64.ActiveCfg = Release|x64 25 | {DED2187A-52A5-466E-8B3D-BFF013770412}.Release|x64.Build.0 = Release|x64 26 | {DED2187A-52A5-466E-8B3D-BFF013770412}.Release|x86.ActiveCfg = Release|x86 27 | {DED2187A-52A5-466E-8B3D-BFF013770412}.Release|x86.Build.0 = Release|x86 28 | EndGlobalSection 29 | GlobalSection(SolutionProperties) = preSolution 30 | HideSolutionNode = FALSE 31 | EndGlobalSection 32 | GlobalSection(ExtensibilityGlobals) = postSolution 33 | SolutionGuid = {0580008F-A1EE-408F-BF31-F2490DA2B2ED} 34 | EndGlobalSection 35 | EndGlobal 36 | -------------------------------------------------------------------------------- /FaceTextOrganizer.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace DF_FaceTracking.cs 4 | { 5 | public class FaceTextOrganizer 6 | { 7 | private readonly Color[] m_colorList = 8 | { 9 | Color.Yellow, Color.Orange, Color.Lime, Color.Magenta, Color.Brown, 10 | Color.Turquoise, Color.DeepSkyBlue 11 | }; 12 | 13 | private Color m_color; 14 | private Point m_expression; 15 | private Point m_faceId; 16 | private int m_imageWidth; 17 | private Point m_pose; 18 | private Point m_recognitionId; 19 | private Point m_pulse; 20 | private PXCMRectI32 m_rectangle; 21 | 22 | public PointF RecognitionLocation 23 | { 24 | get { return m_recognitionId; } 25 | } 26 | 27 | public PointF FaceIdLocation 28 | { 29 | get { return m_faceId; } 30 | } 31 | 32 | public PointF PoseLocation 33 | { 34 | get { return m_pose; } 35 | } 36 | 37 | public PointF PulseLocation 38 | { 39 | get { return m_pulse; } 40 | } 41 | 42 | public Point ExpressionsLocation 43 | { 44 | get { return m_expression; } 45 | } 46 | 47 | public Rectangle RectangleLocation 48 | { 49 | get { return new Rectangle(m_rectangle.x, m_rectangle.y, m_rectangle.w, m_rectangle.h); } 50 | } 51 | 52 | public Color Colour 53 | { 54 | get { return m_color; } 55 | } 56 | 57 | public int FontSize 58 | { 59 | get { return CalculateDefiniteFontSize(); } 60 | } 61 | 62 | private int CalculateDefiniteFontSize() 63 | { 64 | switch (m_imageWidth) 65 | { 66 | case 640: 67 | case 848: 68 | case 960: 69 | return 6; 70 | case 1280: 71 | return 8; 72 | case 1920: 73 | return 12; 74 | default: 75 | return 12; 76 | } 77 | } 78 | 79 | public void ChangeFace(int faceIndex, PXCMFaceData.Face face, int imageHeight, int imageWidth) 80 | { 81 | const int threshold = 5; 82 | const int expressionThreshold = 55; 83 | const int faceTextWidth = 100; 84 | const int textHeightThreshold = 30; 85 | 86 | m_imageWidth = imageWidth; 87 | 88 | PXCMFaceData.DetectionData fdetectionData = face.QueryDetection(); 89 | m_color = m_colorList[faceIndex % m_colorList.Length]; 90 | 91 | if (fdetectionData == null) 92 | { 93 | int currentWidth = faceIndex * faceTextWidth; 94 | 95 | m_recognitionId.X = threshold + currentWidth; 96 | m_recognitionId.Y = threshold; 97 | 98 | m_pose.X = threshold + currentWidth; 99 | m_pose.Y = m_recognitionId.Y + 3 * threshold; 100 | 101 | m_pulse.X = threshold + currentWidth; 102 | m_pulse.Y = m_pose.Y + 6 * threshold; 103 | 104 | m_expression.X = threshold + currentWidth; 105 | m_expression.Y = m_pulse.Y + threshold + textHeightThreshold; 106 | } 107 | else 108 | { 109 | fdetectionData.QueryBoundingRect(out m_rectangle); 110 | 111 | m_recognitionId.X = m_rectangle.x + threshold; 112 | m_recognitionId.Y = m_rectangle.y + CalculateDefiniteFontSize() + threshold; 113 | 114 | m_faceId.X = m_rectangle.x + threshold; 115 | m_faceId.Y = m_rectangle.y + threshold; 116 | 117 | m_pose.X = m_rectangle.x + threshold; 118 | m_pose.Y = m_rectangle.y + m_rectangle.h - 3 * CalculateDefiniteFontSize() - 2 * threshold; 119 | 120 | m_pulse.X = m_rectangle.x + m_rectangle.w - 10 * CalculateDefiniteFontSize(); 121 | m_pulse.Y = m_faceId.Y; 122 | 123 | m_expression.X = (m_rectangle.x + m_rectangle.w + expressionThreshold >= m_imageWidth) 124 | ? (m_rectangle.x - expressionThreshold) 125 | : (m_rectangle.x + m_rectangle.w + threshold); 126 | m_expression.Y = m_rectangle.y + threshold; 127 | } 128 | } 129 | } 130 | } -------------------------------------------------------------------------------- /FaceTracking.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Linq; 4 | using System.Runtime.Remoting.Channels; 5 | using System.Windows.Forms; 6 | using System.Data; 7 | using System.Data.SqlClient; 8 | using System.Data.OleDb; 9 | using System.Reflection; 10 | 11 | namespace DF_FaceTracking.cs 12 | { 13 | internal class FaceTracking 14 | { 15 | private readonly MainForm m_form; 16 | private FPSTimer m_timer; 17 | private bool m_wasConnected; 18 | public static int m_frame = 0; 19 | 20 | 21 | 22 | public FaceTracking(MainForm form) 23 | { 24 | m_form = form; 25 | //zz 26 | //Savedata(); 27 | } 28 | 29 | private void DisplayDeviceConnection(bool isConnected) 30 | { 31 | if (isConnected && !m_wasConnected) m_form.UpdateStatus("Device Reconnected", MainForm.Label.StatusLabel); 32 | else if (!isConnected && m_wasConnected) 33 | m_form.UpdateStatus("Device Disconnected", MainForm.Label.StatusLabel); 34 | m_wasConnected = isConnected; 35 | } 36 | 37 | private void DisplayPicture(PXCMImage image) 38 | { 39 | PXCMImage.ImageData data; 40 | 41 | if (image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB32, out data) < 42 | pxcmStatus.PXCM_STATUS_NO_ERROR) return; 43 | m_form.DrawBitmap(data.ToBitmap(0, image.info.width, image.info.height)); 44 | 45 | m_timer.Tick(""); 46 | image.ReleaseAccess(data); 47 | } 48 | 49 | private void CheckForDepthStream(PXCMCapture.Device.StreamProfileSet profiles, PXCMFaceModule faceModule) 50 | { 51 | PXCMFaceConfiguration faceConfiguration = faceModule.CreateActiveConfiguration(); 52 | if (faceConfiguration == null) 53 | { 54 | Debug.Assert(faceConfiguration != null); 55 | return; 56 | } 57 | 58 | PXCMFaceConfiguration.TrackingModeType trackingMode = faceConfiguration.GetTrackingMode(); 59 | faceConfiguration.Dispose(); 60 | 61 | if (trackingMode != PXCMFaceConfiguration.TrackingModeType.FACE_MODE_COLOR_PLUS_DEPTH 62 | || trackingMode != PXCMFaceConfiguration.TrackingModeType.FACE_MODE_IR) 63 | return; 64 | if (profiles.depth.imageInfo.format == PXCMImage.PixelFormat.PIXEL_FORMAT_DEPTH) return; 65 | PXCMCapture.DeviceInfo dinfo; 66 | m_form.Devices.TryGetValue(m_form.GetCheckedDevice(), out dinfo); 67 | 68 | if (dinfo != null) 69 | MessageBox.Show( 70 | String.Format("Depth stream is not supported for device: {0}. \nUsing 2D tracking", dinfo.name), 71 | @"Face Tracking", 72 | MessageBoxButtons.OK, MessageBoxIcon.Information); 73 | } 74 | 75 | private void FaceAlertHandler(PXCMFaceData.AlertData alert) 76 | { 77 | m_form.UpdateStatus(alert.label.ToString(), MainForm.Label.StatusLabel); 78 | } 79 | 80 | public void SimplePipeline() 81 | { 82 | PXCMSenseManager pp = m_form.Session.CreateSenseManager(); 83 | 84 | if (pp == null) 85 | { 86 | throw new Exception("PXCMSenseManager null"); 87 | } 88 | 89 | PXCMCaptureManager captureMgr = pp.captureManager; 90 | if (captureMgr == null) 91 | { 92 | throw new Exception("PXCMCaptureManager null"); 93 | } 94 | 95 | var selectedRes = m_form.GetCheckedColorResolution(); 96 | if (selectedRes != null ) 97 | { 98 | // Set active camera 99 | PXCMCapture.DeviceInfo deviceInfo; 100 | m_form.Devices.TryGetValue(m_form.GetCheckedDevice(), out deviceInfo); 101 | captureMgr.FilterByDeviceInfo(m_form.GetCheckedDeviceInfo()); 102 | 103 | // activate filter only live/record mode , no need in playback mode 104 | var set = new PXCMCapture.Device.StreamProfileSet 105 | { 106 | color = 107 | { 108 | frameRate = selectedRes.Item2, 109 | imageInfo = 110 | { 111 | format = selectedRes.Item1.format, 112 | height = selectedRes.Item1.height, 113 | width = selectedRes.Item1.width 114 | } 115 | } 116 | }; 117 | 118 | if (m_form.IsPulseEnabled() && (set.color.imageInfo.width < 1280 || set.color.imageInfo.height < 720)) 119 | { 120 | captureMgr.FilterByStreamProfiles(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 1280, 720, 0); 121 | } 122 | else 123 | { 124 | captureMgr.FilterByStreamProfiles(set); 125 | } 126 | } 127 | // Set Source & Landmark Profile Index 128 | if (m_form.GetRecordState()) 129 | { 130 | captureMgr.SetFileName(m_form.GetFileName(), true); 131 | } 132 | // Set Module 133 | pp.EnableFace(); 134 | PXCMFaceModule faceModule = pp.QueryFace(); 135 | if (faceModule == null) 136 | { 137 | Debug.Assert(faceModule != null); 138 | return; 139 | } 140 | 141 | PXCMFaceConfiguration moduleConfiguration = faceModule.CreateActiveConfiguration(); 142 | 143 | if (moduleConfiguration == null) 144 | { 145 | Debug.Assert(moduleConfiguration != null); 146 | return; 147 | } 148 | 149 | var checkedProfile = m_form.GetCheckedProfile(); 150 | var mode = m_form.FaceModesMap.First(x => x.Value == checkedProfile).Key; 151 | 152 | moduleConfiguration.SetTrackingMode(mode); 153 | 154 | moduleConfiguration.strategy = PXCMFaceConfiguration.TrackingStrategyType.STRATEGY_RIGHT_TO_LEFT; 155 | 156 | moduleConfiguration.detection.maxTrackedFaces = 2; 157 | moduleConfiguration.landmarks.maxTrackedFaces = 2; 158 | moduleConfiguration.pose.maxTrackedFaces = 2; 159 | 160 | PXCMFaceConfiguration.ExpressionsConfiguration econfiguration = moduleConfiguration.QueryExpressions(); 161 | if (econfiguration == null) 162 | { 163 | throw new Exception("ExpressionsConfiguration null"); 164 | } 165 | econfiguration.properties.maxTrackedFaces =2; 166 | 167 | econfiguration.EnableAllExpressions(); 168 | moduleConfiguration.detection.isEnabled = true; 169 | moduleConfiguration.landmarks.isEnabled = true; 170 | moduleConfiguration.pose.isEnabled = true; 171 | 172 | econfiguration.Enable(); 173 | 174 | 175 | PXCMFaceConfiguration.PulseConfiguration pulseConfiguration = moduleConfiguration.QueryPulse(); 176 | if (pulseConfiguration == null) 177 | { 178 | throw new Exception("pulseConfiguration null"); 179 | } 180 | 181 | pulseConfiguration.properties.maxTrackedFaces =2; 182 | if (m_form.IsPulseEnabled()) 183 | { 184 | pulseConfiguration.Enable(); 185 | } 186 | 187 | PXCMFaceConfiguration.RecognitionConfiguration qrecognition = moduleConfiguration.QueryRecognition(); 188 | if (qrecognition == null) 189 | { 190 | throw new Exception("PXCMFaceConfiguration.RecognitionConfiguration null"); 191 | } 192 | if (m_form.IsRecognitionChecked()) 193 | { 194 | qrecognition.Enable(); 195 | } 196 | 197 | moduleConfiguration.EnableAllAlerts(); 198 | moduleConfiguration.SubscribeAlert(FaceAlertHandler); 199 | 200 | pxcmStatus applyChangesStatus = moduleConfiguration.ApplyChanges(); 201 | 202 | m_form.UpdateStatus("Init Started", MainForm.Label.StatusLabel); 203 | 204 | if (applyChangesStatus < pxcmStatus.PXCM_STATUS_NO_ERROR || pp.Init() < pxcmStatus.PXCM_STATUS_NO_ERROR) 205 | { 206 | m_form.UpdateStatus("Init Failed", MainForm.Label.StatusLabel); 207 | } 208 | else 209 | { 210 | using (PXCMFaceData moduleOutput = faceModule.CreateOutput()) 211 | { 212 | PXCMFaceData lastmoduleOutput = moduleOutput; ; 213 | Debug.Assert(moduleOutput != null); 214 | PXCMCapture.Device.StreamProfileSet profiles; 215 | PXCMCapture.Device device = captureMgr.QueryDevice(); 216 | 217 | if (device == null) 218 | { 219 | throw new Exception("device null"); 220 | } 221 | 222 | device.QueryStreamProfileSet(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 0, out profiles); 223 | CheckForDepthStream(profiles, faceModule); 224 | 225 | m_form.UpdateStatus("Streaming", MainForm.Label.StatusLabel); 226 | m_timer = new FPSTimer(m_form); 227 | 228 | while (!m_form.Stopped) 229 | { 230 | m_frame++; 231 | 232 | if (pp.AcquireFrame(true) < pxcmStatus.PXCM_STATUS_NO_ERROR) break; 233 | var isConnected = pp.IsConnected(); 234 | DisplayDeviceConnection(isConnected); 235 | if (isConnected) 236 | { 237 | var sample = pp.QueryFaceSample(); 238 | if (sample == null) 239 | { 240 | pp.ReleaseFrame(); 241 | continue; 242 | } 243 | switch (mode) 244 | { 245 | case PXCMFaceConfiguration.TrackingModeType.FACE_MODE_IR: 246 | if (sample.ir != null) 247 | DisplayPicture(sample.ir); 248 | break; 249 | default: 250 | DisplayPicture(sample.color); 251 | break; 252 | } 253 | 254 | moduleOutput.Update(); 255 | PXCMFaceConfiguration.RecognitionConfiguration recognition = moduleConfiguration.QueryRecognition(); 256 | if (recognition == null) 257 | { 258 | pp.ReleaseFrame(); 259 | continue; 260 | } 261 | m_form.DrawGraphics(moduleOutput,lastmoduleOutput); 262 | lastmoduleOutput = moduleOutput; 263 | m_form.UpdatePanel(); 264 | } 265 | pp.ReleaseFrame(); 266 | } 267 | 268 | } 269 | m_form.UpdateStatus("Stopped", MainForm.Label.StatusLabel); 270 | } 271 | moduleConfiguration.Dispose(); 272 | pp.Close(); 273 | pp.Dispose(); 274 | } 275 | 276 | private string MarkPointName(int index) 277 | { 278 | string PName = null; 279 | switch (index) 280 | { 281 | case 70: 282 | PName = "EYEBROW_RIGHT_CENTER";break; 283 | case 0: 284 | PName= "EYEBROW_RIGHT_RIGHT"; break; 285 | case 4: 286 | PName = "EYEBROW_RIGHT_LEFT";break; 287 | case 5: 288 | PName = "EYEBROW_LEFT_RIGHT";break; 289 | case 7: 290 | PName = "EYEBROW_LEFT_CENTER";break; 291 | case 9: 292 | PName = "EYEBROW_LEFT_LEFT";break; 293 | 294 | case 76: 295 | PName = "EYE_RIGHT_CENTER";break; 296 | case 77: 297 | PName = "EYE_LEFT_CENTER";break; 298 | 299 | case 12: 300 | PName = "EYELID_RIGHT_TOP";break; 301 | case 16: 302 | PName = "EYELID_RIGHT_BOTTOM";break; 303 | case 14: 304 | PName = "EYELID_RIGHT_RIGHT";break; 305 | case 10: 306 | PName = "EYELID_RIGHT_LEFT";break; 307 | 308 | case 20: 309 | PName = "EYELID_LEFT_TOP";break; 310 | case 24: 311 | PName = "EYELID_LEFT_BOTTOM";break; 312 | case 18: 313 | PName = "EYELID_LEFT_RIGHT";break; 314 | case 22: 315 | PName = "EYELID_LEFT_LEFT";break; 316 | 317 | case 29: 318 | PName = "NOSE_TIP";break; 319 | case 26: 320 | PName = "NOSE_TOP";break; 321 | case 31: 322 | PName = "NOSE_BOTTOM";break; 323 | case 30: 324 | PName = "NOSE_RIGHT";break; 325 | case 32: 326 | PName = "NOSE_LEFT";break; 327 | 328 | case 39: 329 | PName = "LIP_RIGHT";break; 330 | case 33: 331 | PName = "LIP_LEFT";break; 332 | 333 | case 47: 334 | PName = "UPPER_LIP_CENTER";break; 335 | case 46: 336 | PName = "UPPER_LIP_RIGHT";break; 337 | case 48: 338 | PName = "UPPER_LIP_LEFT";break; 339 | 340 | case 51: 341 | PName = "LOWER_LIP_CENTER";break; 342 | case 52: 343 | PName = "LOWER_LIP_RIGHT";break; 344 | case 50: 345 | PName = "LOWER_LIP_LEFT";break; 346 | 347 | case 56: 348 | PName = "FACE_BORDER_TOP_RIGHT";break; 349 | case 65: 350 | PName = "FACE_BORDER_TOP_LEFT";break; 351 | case 61: 352 | PName = "CHIN";break; 353 | 354 | default: 355 | PName = "NOT_USE"; 356 | break; 357 | } 358 | 359 | return PName; 360 | } 361 | } 362 | } -------------------------------------------------------------------------------- /FacialExpression.cs: -------------------------------------------------------------------------------- 1 | using DF_FaceTracking.cs.Data; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace DF_FaceTracking.cs 8 | { 9 | public class FacialExpression 10 | { 11 | //{ 12 | // EXPRESSION_BROW_RAISER_LEFT = 0, 13 | // EXPRESSION_BROW_RAISER_RIGHT = 1, 14 | // EXPRESSION_BROW_LOWERER_LEFT = 2, 15 | // EXPRESSION_BROW_LOWERER_RIGHT = 3, 16 | // EXPRESSION_SMILE = 4, 17 | // EXPRESSION_KISS = 5, 18 | // EXPRESSION_MOUTH_OPEN = 6, 19 | // EXPRESSION_EYES_CLOSED_LEFT = 7, 20 | // EXPRESSION_EYES_CLOSED_RIGHT = 8, 21 | // EXPRESSION_HEAD_TURN_LEFT = 9, 22 | // EXPRESSION_HEAD_TURN_RIGHT = 10, 23 | // EXPRESSION_HEAD_UP = 11, 24 | // EXPRESSION_HEAD_DOWN = 12, 25 | // EXPRESSION_HEAD_TILT_LEFT = 13, 26 | // EXPRESSION_HEAD_TILT_RIGHT = 14, 27 | // EXPRESSION_EYES_TURN_LEFT = 15, 28 | // EXPRESSION_EYES_TURN_RIGHT = 16, 29 | // EXPRESSION_EYES_UP = 17, 30 | // EXPRESSION_EYES_DOWN = 18, 31 | // EXPRESSION_TONGUE_OUT = 19, 32 | // EXPRESSION_PUFF_RIGHT = 20, 33 | // EXPRESSION_PUFF_LEFT = 21 34 | //} 35 | 36 | // RealSense提供,包含表情及程度 37 | public int[] facialExpressionIndensity { set; get; } 38 | // 表情发生时间 39 | public CustomTime happenTS { set; get; } 40 | 41 | public FacialExpression() 42 | { 43 | this.facialExpressionIndensity = new int[22]; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /File/ConfigReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Configuration; 5 | 6 | namespace DF_FaceTracking.cs.File 7 | { 8 | class ConfigReader 9 | { 10 | private static Configuration config = null; 11 | public static String GetConfigValue(String key) 12 | { 13 | if(config == null) 14 | { 15 | string file = System.Windows.Forms.Application.ExecutablePath; 16 | config = ConfigurationManager.OpenExeConfiguration(file); 17 | } 18 | return config.AppSettings.Settings[key].Value.ToString(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /File/StateTable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Data.SQLite; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace DF_FaceTracking.cs.File 10 | { 11 | 12 | class StateTable 13 | { 14 | //SQLite3表内容:id(char),state(int), createtime(datetime), updatetime(datetime), token(varchar); 15 | 16 | private static SQLiteConnection sqlc = null; 17 | private static String dbName = ConfigReader.GetConfigValue("dbName"); 18 | private static String dbPath= ConfigReader.GetConfigValue("dbPath"); 19 | 20 | //表名称 21 | public static readonly String TABLE_VIDEO = "videorecord"; 22 | public static readonly String TABLE_PICTURE = "picturerecord"; 23 | 24 | //状态表 25 | public static readonly int STATE_CREATE = 0; 26 | public static readonly int STATE_TRANSCODE = 1; 27 | public static readonly int STATE_UPLOAD = 2; 28 | public static readonly int STATE_COMPLETE = 3; 29 | 30 | public struct RecordInfo 31 | { 32 | public String ID; 33 | public String token; 34 | } 35 | 36 | public static void createState(String tableName, String ID, String token) 37 | { 38 | checkConnection(); 39 | String time = DateTime.Now.ToLocalTime().ToString(); 40 | String sql = "insert into " + tableName + " values ('" + ID + "'," + STATE_CREATE + ",'" + time + "','" + time + "','" + token + "')"; 41 | SQLiteCommand cmd = new SQLiteCommand(sql, sqlc); 42 | cmd.ExecuteNonQuery(); 43 | } 44 | 45 | public static void updateState(String tableName, String ID, int state) 46 | { 47 | checkConnection(); 48 | String time = DateTime.Now.ToLocalTime().ToString(); 49 | String sql = "update "+ tableName + " set state=" + state + ", updatetime='" + time + "' where id='" + ID + "'"; 50 | SQLiteCommand cmd = new SQLiteCommand(sql, sqlc); 51 | cmd.ExecuteNonQuery(); 52 | } 53 | 54 | public static ArrayList getStateLists(String tableName, int state) 55 | { 56 | checkConnection(); 57 | ArrayList al = new ArrayList(); 58 | String sql = "select id, token from " + tableName+ " where state=" + state; 59 | SQLiteCommand command = new SQLiteCommand(sql, sqlc); 60 | SQLiteDataReader reader = command.ExecuteReader(); 61 | while (reader.Read()) 62 | { 63 | RecordInfo iteminfo; 64 | iteminfo.ID = reader["id"].ToString(); 65 | iteminfo.token = reader["token"].ToString(); 66 | al.Add(iteminfo); 67 | } 68 | return al; 69 | } 70 | private static void checkConnection() 71 | { 72 | if (sqlc == null) 73 | sqlc = new SQLiteConnection("Data Source=" + dbPath + dbName); 74 | sqlc.Open(); 75 | 76 | } 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /File/UploadFile.cs: -------------------------------------------------------------------------------- 1 | using DF_FaceTracking.cs; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Net; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace DF_FaceTracking.cs.File 10 | { 11 | class UploadFile 12 | { 13 | 14 | private static String uploadUrl = ConfigReader.GetConfigValue("upload_Url"); 15 | 16 | //这两个目前不用 17 | private static String username = ConfigReader.GetConfigValue("upload_username"); 18 | private static String password = ConfigReader.GetConfigValue("upload_password"); 19 | 20 | //private static String testToken = "1d44662ee7e0452a9d594841799d00ac"; 21 | public static bool Upload(String filename, String filepath, String token) 22 | { 23 | String newUrl = uploadUrl + "?filename=" + filename + "&token=" + token; 24 | using (WebClient client = new WebClient()) 25 | { 26 | try 27 | { 28 | String response = Encoding.Default.GetString(client.UploadFile(newUrl, filepath)); 29 | if (response.Contains("success"))//上传成功 30 | return true; 31 | else//上传重名文件 32 | return false; 33 | } 34 | catch(Exception e) 35 | { 36 | WriteLog.WriteError(e.ToString()); 37 | return false; 38 | } 39 | } 40 | } 41 | 42 | 43 | //这个方法目前也不用 44 | //UploadFile.upload(@"http://192.168.0.153:8080/file/upload", @"C:\Users\73582\Desktop\Demo\PreviewDemo\video\T12.mp4","T15.mp4"); 45 | public static bool upload(string address, string fileNamePath, string saveName) 46 | { 47 | string param = "filename=" + saveName + "&file="; 48 | byte[] paramArray = System.Text.Encoding.Default.GetBytes(param); 49 | 50 | FileStream fs = new FileStream(fileNamePath, FileMode.Open, FileAccess.Read); 51 | BinaryReader r = new BinaryReader(fs); 52 | byte[] fileArray = r.ReadBytes((int)fs.Length); 53 | 54 | List byteSource = new List(); 55 | byteSource.AddRange(paramArray); 56 | byteSource.AddRange(fileArray); 57 | byte[] postArray = byteSource.ToArray(); 58 | 59 | // 根据uri创建HttpWebRequest对象 60 | HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(new Uri(address)); 61 | httpReq.Method = "POST"; 62 | //httpReq.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", username, password)))); 63 | httpReq.Credentials = CredentialCache.DefaultCredentials; 64 | httpReq.ContentType = "multipart/form-data"; 65 | httpReq.AllowWriteStreamBuffering = false; 66 | httpReq.Timeout = 300000; 67 | httpReq.ContentLength = postArray.Length; 68 | 69 | Stream postStream = httpReq.GetRequestStream(); 70 | try 71 | { 72 | 73 | postStream.Write(postArray, 0, postArray.Length); 74 | //postStream.Flush(); 75 | postStream.Close(); 76 | HttpWebResponse webRespon = (HttpWebResponse)httpReq.GetResponse(); 77 | 78 | if (webRespon.StatusCode == HttpStatusCode.Created || webRespon.StatusCode == HttpStatusCode.NoContent) 79 | { 80 | return true; 81 | } 82 | else 83 | { 84 | return false; 85 | } 86 | } 87 | catch (Exception e2) 88 | 89 | { 90 | Console.Write(e2); 91 | return false; 92 | } 93 | finally 94 | { 95 | fs.Close(); 96 | r.Close(); 97 | } 98 | } 99 | /* 100 | public static async Task Upload(string url, string filepath, string filename) 101 | { 102 | // Convert each of the three inputs into HttpContent objects 103 | FileStream fileStream = new FileStream(filepath, FileMode.Open, FileAccess.Read); 104 | HttpContent stringContent = new StringContent(filename); 105 | // examples of converting both Stream and byte [] to HttpContent objects 106 | // representing input type file 107 | HttpContent fileStreamContent = new StreamContent(fileStream); 108 | //HttpContent bytesContent = new ByteArrayContent(fileBytes); 109 | 110 | // Submit the form using HttpClient and 111 | // create form data as Multipart (enctype="multipart/form-data") 112 | 113 | using (var client = new HttpClient()) 114 | 115 | using (var formData = new MultipartFormDataContent()) 116 | { 117 | // Add the HttpContent objects to the form data 118 | 119 | // 120 | formData.Add(stringContent, "filename"); 121 | // 122 | formData.Add(fileStreamContent, "file"); 123 | // 124 | //formData.Add(bytesContent, "file2", "file2"); 125 | 126 | // Invoke the request to the server 127 | 128 | // equivalent to pressing the submit button on 129 | // a form with attributes (action="{url}" method="post") 130 | var response = await client.PostAsync(url, formData); 131 | if (!response.IsSuccessStatusCode) 132 | { 133 | return null; 134 | } 135 | return await response.Content.ReadAsStreamAsync(); 136 | } 137 | } 138 | */ 139 | } 140 | 141 | 142 | 143 | //带进度条 144 | /* 145 | private int Upload_Request(string address, string fileNamePath, string saveName, ProgressBar progressBar) 146 | { 147 | int returnValue = 0; 148 | 149 | // 要上传的文件 150 | FileStream fs = new FileStream(fileNamePath, FileMode.Open, FileAccess.Read); 151 | BinaryReader r = new BinaryReader(fs); 152 | 153 | //时间戳 154 | string strBoundary = "----------" + DateTime.Now.Ticks.ToString("x"); 155 | byte[] boundaryBytes = Encoding.ASCII.GetBytes("/r/n--" + strBoundary + "/r/n"); 156 | 157 | //请求头部信息 158 | StringBuilder sb = new StringBuilder(); 159 | sb.Append("--"); 160 | sb.Append(strBoundary); 161 | sb.Append("/r/n"); 162 | sb.Append("Content-Disposition: form-data; name=/""); 163 | sb.Append("file"); 164 | sb.Append("/"; filename=/""); 165 | sb.Append(saveName); 166 | sb.Append("/""); 167 | sb.Append("/r/n"); 168 | sb.Append("Content-Type: "); 169 | sb.Append("application/octet-stream"); 170 | sb.Append("/r/n"); 171 | sb.Append("/r/n"); 172 | string strPostHeader = sb.ToString(); 173 | byte[] postHeaderBytes = Encoding.UTF8.GetBytes(strPostHeader); 174 | 175 | // 根据uri创建HttpWebRequest对象 176 | HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(new Uri(address)); 177 | httpReq.Method = "POST"; 178 | 179 | //对发送的数据不使用缓存 180 | httpReq.AllowWriteStreamBuffering = false; 181 | 182 | //设置获得响应的超时时间(300秒) 183 | httpReq.Timeout = 300000; 184 | httpReq.ContentType = "multipart/form-data; boundary=" + strBoundary; 185 | long length = fs.Length + postHeaderBytes.Length + boundaryBytes.Length; 186 | long fileLength = fs.Length; 187 | httpReq.ContentLength = length; 188 | try 189 | { 190 | progressBar.Maximum = int.MaxValue; 191 | progressBar.Minimum = 0; 192 | progressBar.Value = 0; 193 | 194 | //每次上传4k 195 | int bufferLength = 4096; 196 | byte[] buffer = new byte[bufferLength]; 197 | 198 | //已上传的字节数 199 | long offset = 0; 200 | 201 | //开始上传时间 202 | DateTime startTime = DateTime.Now; 203 | int size = r.Read(buffer, 0, bufferLength); 204 | Stream postStream = httpReq.GetRequestStream(); 205 | 206 | //发送请求头部消息 207 | postStream.Write(postHeaderBytes, 0, postHeaderBytes.Length); 208 | while (size > 0) 209 | { 210 | postStream.Write(buffer, 0, size); 211 | offset += size; 212 | progressBar.Value = (int)(offset * (int.MaxValue / length)); 213 | TimeSpan span = DateTime.Now - startTime; 214 | double second = span.TotalSeconds; 215 | lblTime.Text = "已用时:" + second.ToString("F2") + "秒"; 216 | if (second > 0.001) 217 | { 218 | lblSpeed.Text = " 平均速度:" + (offset / 1024 / second).ToString("0.00") + "KB/秒"; 219 | } 220 | else 221 | { 222 | lblSpeed.Text = " 正在连接…"; 223 | } 224 | lblState.Text = "已上传:" + (offset * 100.0 / length).ToString("F2") + "%"; 225 | lblSize.Text = (offset / 1048576.0).ToString("F2") + "M/" + (fileLength / 1048576.0).ToString("F2") + "M"; 226 | Application.DoEvents(); 227 | size = r.Read(buffer, 0, bufferLength); 228 | } 229 | //添加尾部的时间戳 230 | postStream.Write(boundaryBytes, 0, boundaryBytes.Length); 231 | postStream.Close(); 232 | 233 | //获取服务器端的响应 234 | WebResponse webRespon = httpReq.GetResponse(); 235 | Stream s = webRespon.GetResponseStream(); 236 | StreamReader sr = new StreamReader(s); 237 | 238 | //读取服务器端返回的消息 239 | String sReturnString = sr.ReadLine(); 240 | s.Close(); 241 | sr.Close(); 242 | if (sReturnString == "Success") 243 | { 244 | returnValue = 1; 245 | } 246 | else if (sReturnString == "Error") 247 | { 248 | returnValue = 0; 249 | } 250 | 251 | } 252 | catch 253 | { 254 | returnValue = 0; 255 | } 256 | finally 257 | { 258 | fs.Close(); 259 | r.Close(); 260 | } 261 | 262 | return returnValue; 263 | } 264 | */ 265 | } 266 | -------------------------------------------------------------------------------- /HttpServer/BaseHeader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DF_FaceTracking.cs.HttpServer 8 | { 9 | public class BaseHeader 10 | { 11 | public string Body { get; set; } 12 | 13 | public Encoding Encoding { get; set; } 14 | 15 | public string Content_Type { get; set; } 16 | 17 | public string Content_Length { get; set; } 18 | 19 | public string Content_Encoding { get; set; } 20 | 21 | public string ContentLanguage { get; set; } 22 | 23 | public Dictionary Headers { get; set; } 24 | 25 | /// 26 | /// 不支持枚举类型约束,所以采取下列方案:) 27 | /// 28 | protected string GetHeaderByKey(Enum header) 29 | { 30 | var fieldName = header.GetDescription(); 31 | if (fieldName == null) return null; 32 | var hasKey = Headers.ContainsKey(fieldName); 33 | if (!hasKey) return null; 34 | return Headers[fieldName]; 35 | } 36 | 37 | protected string GetHeaderByKey(string fieldName) 38 | { 39 | if (string.IsNullOrEmpty(fieldName)) return null; 40 | var hasKey = Headers.ContainsKey(fieldName); 41 | if (!hasKey) return null; 42 | return Headers[fieldName]; 43 | } 44 | 45 | /// 46 | /// 不支持枚举类型约束,所以采取下列方案:) 47 | /// 48 | protected void SetHeaderByKey(Enum header, string value) 49 | { 50 | var fieldName = header.GetDescription(); 51 | if (fieldName == null) return; 52 | var hasKey = Headers.ContainsKey(fieldName); 53 | if (!hasKey) Headers.Add(fieldName, value); 54 | Headers[fieldName] = value; 55 | } 56 | 57 | protected void SetHeaderByKey(string fieldName, string value) 58 | { 59 | if (string.IsNullOrEmpty(fieldName)) return; 60 | var hasKey = Headers.ContainsKey(fieldName); 61 | if (!hasKey) Headers.Add(fieldName, value); 62 | Headers[fieldName] = value; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /HttpServer/ConsoleLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DF_FaceTracking.cs.HttpServer 8 | { 9 | class ConsoleLogger : ILogger 10 | { 11 | public void Log(object message) 12 | { 13 | Console.WriteLine(message); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /HttpServer/ExampleServer.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Windows.Forms; 7 | using DF_FaceTracking.cs.File; 8 | using System.IO; 9 | using System.Reflection; 10 | 11 | namespace DF_FaceTracking.cs.HttpServer 12 | { 13 | class ExampleServer : HttpServer 14 | {/// 15 | /// 构造函数 16 | /// 17 | /// IP地址 18 | /// 端口号 19 | public ExampleServer(string ipAddress, int port) 20 | : base(ipAddress, port) 21 | { 22 | 23 | } 24 | private PXCMSession session; 25 | private MainForm mainForm; 26 | //用于判断get请求的次数,状态0代表未发送get请求,1表示发送了一次get请求,2表示启动了客户端,3表示启动了客户端并且关闭了摄像头 27 | int state = 0; 28 | string CurState = ""; 29 | StreamWriter sw_interaction; 30 | Stream interactionFeature; 31 | //文件名 32 | private string realName; 33 | public override void OnPost(HttpRequest request, HttpResponse response) 34 | { 35 | //获取客户端传递的参数 36 | string data = request.Params["type"]; 37 | //构造响应报文 38 | response.Content_Encoding = "utf-8"; 39 | response.StatusCode = "200"; 40 | response.Headers = new Dictionary(); 41 | response.SetHeader(ResponseHeaders.Allow, "*"); 42 | response.Headers.Add("Access-Control-Allow-Origin", "*"); 43 | response.Headers.Add("Access-Control-Allow-Credentials", "true"); 44 | response.Headers.Add("Access-Control-Allow-Methods", "*"); 45 | response.Headers.Add("Access-Control-Allow-Headers", "*"); 46 | response.Headers.Add("Access-Control-Expose-Headers", "*"); 47 | response.Content_Type = "application/json"; 48 | byte[] buffer = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { success = "true", msg = "提交成功" })); 49 | if (data.Equals("start") && mainForm != null) 50 | { 51 | realName = request.Params["fileName"]; 52 | mainForm.StartClick(realName); 53 | CurState = "Start"; 54 | //发送响应 55 | buffer = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { success = "true", msg = "摄像头启动成功" })); 56 | response.SetContent(buffer); 57 | response.Send(); 58 | } 59 | else if (data.Equals("stop") && mainForm != null && CurState.Equals("Start")) 60 | { 61 | state = 3; 62 | CurState = "Stop"; 63 | mainForm.StopClick(); 64 | //发送响应 65 | string fileContent = request.Params["fileContent"]; 66 | string token = request.Params["token"]; 67 | this.Log(string.Format("fileContent {0} token {1}", fileContent, token)); 68 | if (fileContent.Equals("undefined") && token.Equals("undefined")) 69 | { 70 | buffer = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { success = "true", msg = "摄像头关闭成功", flag = "false" })); 71 | response.SetContent(buffer); 72 | response.Send(); 73 | } 74 | else { 75 | if (realName != null && fileContent != null) 76 | { 77 | string FileNameSuffix = "study_" + realName; 78 | string interactionSuffix = "interaction_" + realName; 79 | interactionFeature = new FileStream(string.Format("{0}{1}", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "\\" + interactionSuffix + ".txt"), FileMode.Append); 80 | sw_interaction = new StreamWriter(interactionFeature); 81 | sw_interaction.BaseStream.Seek(0, SeekOrigin.End); 82 | try 83 | { 84 | sw_interaction.Write(fileContent); 85 | } 86 | catch (Exception e) 87 | { 88 | WriteLog.WriteError(e.ToString()); 89 | throw; 90 | } 91 | finally 92 | { 93 | sw_interaction.Close(); 94 | interactionFeature.Close(); 95 | } 96 | if (UploadFile.Upload(FileNameSuffix, Environment.CurrentDirectory + "\\" + FileNameSuffix + ".txt", token) == true) 97 | { 98 | WriteLog.WriteError(FileNameSuffix + "上传成功"); 99 | } 100 | else 101 | { 102 | WriteLog.WriteError(FileNameSuffix + "上传失败"); 103 | } 104 | if (UploadFile.Upload(interactionSuffix, Environment.CurrentDirectory + "\\" + interactionSuffix + ".txt", token) == true) 105 | { 106 | WriteLog.WriteError(interactionSuffix + "上传成功"); 107 | } 108 | else 109 | { 110 | WriteLog.WriteError(interactionSuffix + "上传失败"); 111 | } 112 | buffer = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { success = "true", msg = "摄像头关闭成功", flag = "true" })); 113 | response.SetContent(buffer); 114 | response.Send(); 115 | } 116 | } 117 | 118 | } 119 | else { 120 | buffer = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { success = "false", msg = "提交失败" })); 121 | response.SetContent(buffer); 122 | response.Send(); 123 | } 124 | } 125 | //系统一定要先执行get请求 126 | public override void OnGet(HttpRequest request, HttpResponse response) 127 | { 128 | response.StatusCode = "200"; 129 | response.Headers = new Dictionary(); 130 | response.SetHeader(ResponseHeaders.Allow, "*"); 131 | response.Headers.Add("Access-Control-Allow-Origin", "*"); 132 | response.Headers.Add("Access-Control-Allow-Credentials","true"); 133 | response.Headers.Add("Access-Control-Allow-Methods", "*"); 134 | response.Headers.Add("Access-Control-Allow-Headers", "*"); 135 | response.Headers.Add("Access-Control-Expose-Headers", "*"); 136 | response.Content_Type = "application/json"; 137 | response.Encoding = Encoding.UTF8; 138 | byte[] buffer = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { success = "true", msg = "打开成功" })); 139 | response.SetContent(buffer); 140 | response.Body = JsonConvert.SerializeObject(new { success = "true", msg = "打开成功" }); 141 | response.Headers.Add("Content-Length",""+buffer.Length); 142 | //文件名由前端传进来,默认文件名合法 143 | Application.EnableVisualStyles(); 144 | Application.SetCompatibleTextRenderingDefault(false); 145 | session = PXCMSession.CreateInstance(); 146 | //if (session!=null&&mainForm == null) { 147 | // mainForm = new MainForm(session); 148 | // state = 1; 149 | // mainForm.response = response; 150 | //} 151 | //if (session != null&&(state!=2&&state!=3)) 152 | //{ 153 | // state = 2; 154 | // // Application.Run(mainForm); 155 | // mainForm.Invoke(new Action(() => mainForm.Show())); 156 | // session.Dispose(); 157 | //} 158 | if (mainForm != null) { 159 | if(mainForm.IsHandleCreated){ 160 | mainForm.Invoke(new Action(() => { 161 | mainForm.Visible = false; 162 | } )); 163 | } 164 | } 165 | mainForm = new MainForm(session); 166 | mainForm.response = response; 167 | if (session != null) { 168 | mainForm.StartPosition = FormStartPosition.CenterScreen; 169 | Application.Run(mainForm); 170 | session.Dispose(); 171 | } 172 | } 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /HttpServer/HeadersHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace DF_FaceTracking.cs.HttpServer 8 | { 9 | static class HeadersHelper 10 | { 11 | public static string GetDescription(this Enum value) 12 | { 13 | var valueType = value.GetType(); 14 | var memberName = Enum.GetName(valueType, value); 15 | if (memberName == null) return null; 16 | var fieldInfo = valueType.GetField(memberName); 17 | var attribute = Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute)); 18 | if (attribute == null) return null; 19 | return (attribute as DescriptionAttribute).Description; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /HttpServer/HttpRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Text.RegularExpressions; 9 | 10 | namespace DF_FaceTracking.cs.HttpServer 11 | { 12 | public class HttpRequest : BaseHeader 13 | { 14 | /// 15 | /// URL参数 16 | /// 17 | public Dictionary Params { get; private set; } 18 | 19 | /// 20 | /// HTTP请求方式 21 | /// 22 | public string Method { get; private set; } 23 | 24 | /// 25 | /// HTTP(S)地址 26 | /// 27 | public string URL { get; set; } 28 | 29 | /// 30 | /// HTTP协议版本 31 | /// 32 | public string ProtocolVersion { get; set; } 33 | 34 | /// 35 | /// 定义缓冲区 36 | /// 37 | private const int MAX_SIZE = 1024 * 1024 * 2; 38 | private byte[] bytes = new byte[MAX_SIZE]; 39 | 40 | public ILogger Logger { get; set; } 41 | 42 | private Stream handler; 43 | 44 | public HttpRequest(Stream stream) 45 | { 46 | this.handler = stream; 47 | var data = GetRequestData(handler); 48 | var rows = Regex.Split(data, Environment.NewLine); 49 | 50 | //Request URL & Method & Version 51 | var first = Regex.Split(rows[0], @"(\s+)") 52 | .Where(e => e.Trim() != string.Empty) 53 | .ToArray(); 54 | if (first.Length > 0) this.Method = first[0]; 55 | if (first.Length > 1) this.URL = Uri.UnescapeDataString(first[1]).Split('?')[0]; 56 | if (first.Length > 2) this.ProtocolVersion = first[2]; 57 | 58 | //Request Headers 59 | this.Headers = GetRequestHeaders(rows); 60 | 61 | //Request "GET" 62 | if (this.Method == "GET") 63 | { 64 | this.Body = GetRequestBody(rows); 65 | var isUrlencoded = Uri.UnescapeDataString(first[1]).Contains('?'); 66 | if (isUrlencoded) this.Params = GetRequestParameters(Uri.UnescapeDataString(first[1]).Split('?')[1]); 67 | } 68 | 69 | //Request "POST" 70 | if (this.Method == "POST") 71 | { 72 | //post请求的参数取自body 73 | this.Body = GetRequestBody(rows); 74 | Console.WriteLine(string.Format("body {0}",this.Body)); 75 | var contentType = GetHeader(RequestHeaders.ContentType); 76 | var isUrlencoded = contentType == @"application/x-www-form-urlencoded"; 77 | if (isUrlencoded) 78 | { 79 | if (!this.Body.Equals("")) 80 | { 81 | string bodyContent = this.Body; 82 | string fileContent = ""; 83 | string token = ""; 84 | //确保Json字符串完整,如果不完整,那么就舍弃该次 85 | if (bodyContent.Contains("}")) 86 | { 87 | try 88 | { 89 | JObject jo = (JObject)JsonConvert.DeserializeObject(bodyContent); 90 | fileContent = jo["fileContent"].ToString(); 91 | token = jo["token"].ToString(); 92 | first[1] += ("&fileContent=" + fileContent); 93 | first[1] += ("&token=" + token); 94 | } 95 | catch (Exception e) 96 | { 97 | WriteLog.WriteError(e.ToString()); 98 | throw; 99 | } 100 | } 101 | else { 102 | first[1] += ("&fileContent=" + "undefined"); 103 | first[1] += ("&token=" + "undefined"); 104 | } 105 | 106 | } 107 | this.Params = GetRequestParameters(Uri.UnescapeDataString(first[1]).Split('?')[1]); 108 | } 109 | } 110 | } 111 | 112 | public Stream GetRequestStream() 113 | { 114 | return this.handler; 115 | } 116 | 117 | public string GetHeader(RequestHeaders header) 118 | { 119 | return GetHeaderByKey(header); 120 | } 121 | 122 | public string GetHeader(string fieldName) 123 | { 124 | return GetHeaderByKey(fieldName); 125 | } 126 | 127 | public void SetHeader(RequestHeaders header, string value) 128 | { 129 | SetHeaderByKey(header, value); 130 | } 131 | 132 | public void SetHeader(string fieldName, string value) 133 | { 134 | SetHeaderByKey(fieldName, value); 135 | } 136 | 137 | private string GetRequestData(Stream stream) 138 | { 139 | var length = 0; 140 | var data = string.Empty; 141 | //read heahers 142 | do 143 | { 144 | data += (char)stream.ReadByte(); 145 | } while (!data.EndsWith("\r\n\r\n")); 146 | //read body 147 | string contentLenHeader = "Content-Length: "; 148 | if(!data.Contains(contentLenHeader)) 149 | { 150 | return data; 151 | } 152 | int startIndex = data.IndexOf(contentLenHeader)+contentLenHeader.Length; 153 | int endIndex = data.IndexOf('\r',startIndex); 154 | int contentLen = int.Parse( data.Substring(startIndex, endIndex-startIndex)); 155 | if (contentLen == 0) return data; 156 | byte[] buffer = new byte[contentLen]; 157 | int currentIndex = 0; 158 | do 159 | { 160 | currentIndex += stream.Read(buffer, currentIndex, contentLen - currentIndex); 161 | } while (currentIndex < contentLen); 162 | data+= Encoding.UTF8.GetString(buffer, 0, contentLen); 163 | return data; 164 | } 165 | 166 | private string GetRequestBody(IEnumerable rows) 167 | { 168 | var target = rows.Select((v, i) => new { Value = v, Index = i }).FirstOrDefault(e => e.Value.Trim() == string.Empty); 169 | if (target == null) return null; 170 | var range = Enumerable.Range(target.Index + 1, rows.Count() - target.Index - 1); 171 | return string.Join(Environment.NewLine, range.Select(e => rows.ElementAt(e)).ToArray()); 172 | } 173 | 174 | private Dictionary GetRequestHeaders(IEnumerable rows) 175 | { 176 | if (rows == null || rows.Count() <= 0) return null; 177 | var target = rows.Select((v, i) => new { Value = v, Index = i }).FirstOrDefault(e => e.Value.Trim() == string.Empty); 178 | var length = target == null ? rows.Count() - 1 : target.Index; 179 | if (length <= 1) return null; 180 | var range = Enumerable.Range(1, length - 1); 181 | return range.Select(e => rows.ElementAt(e)).ToDictionary(e => e.Split(':')[0], e => e.Split(':')[1].Trim()); 182 | } 183 | 184 | private Dictionary GetRequestParameters(string row) 185 | { 186 | if (string.IsNullOrEmpty(row)) return null; 187 | var kvs = Regex.Split(row, "&"); 188 | if (kvs == null || kvs.Count() <= 0) return null; 189 | 190 | return kvs.ToDictionary(e => Regex.Split(e, "=")[0], e => Regex.Split(e, "=")[1]); 191 | } 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /HttpServer/HttpResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace DF_FaceTracking.cs.HttpServer 8 | { 9 | public class HttpResponse : BaseHeader 10 | { 11 | public string StatusCode { get; set; } 12 | 13 | public string Protocols { get; set; } 14 | 15 | public string ProtocolsVersion { get; set; } 16 | 17 | public byte[] Content { get; private set; } 18 | 19 | private Stream handler; 20 | 21 | public ILogger Logger { get; set; } 22 | 23 | public HttpResponse(Stream stream) 24 | { 25 | this.handler = stream; 26 | } 27 | 28 | public HttpResponse SetContent(byte[] content, Encoding encoding = null) 29 | { 30 | this.Content = content; 31 | this.Encoding = encoding != null ? encoding : Encoding.UTF8; 32 | this.Content_Length = content.Length.ToString(); 33 | return this; 34 | } 35 | 36 | public HttpResponse SetContent(string content, Encoding encoding = null) 37 | { 38 | //初始化内容 39 | encoding = encoding != null ? encoding : Encoding.UTF8; 40 | return SetContent(encoding.GetBytes(content), encoding); 41 | } 42 | 43 | public Stream GetResponseStream() 44 | { 45 | return this.handler; 46 | } 47 | 48 | public string GetHeader(ResponseHeaders header) 49 | { 50 | return GetHeaderByKey(header); 51 | } 52 | 53 | public string GetHeader(string fieldName) 54 | { 55 | return GetHeaderByKey(fieldName); 56 | } 57 | 58 | public void SetHeader(ResponseHeaders header, string value) 59 | { 60 | SetHeaderByKey(header, value); 61 | } 62 | 63 | public void SetHeader(string fieldName, string value) 64 | { 65 | SetHeaderByKey(fieldName, value); 66 | } 67 | 68 | /// 69 | /// 构建响应头部 70 | /// 71 | /// 72 | protected string BuildHeader() 73 | { 74 | StringBuilder builder = new StringBuilder(); 75 | 76 | if (!string.IsNullOrEmpty(StatusCode)) 77 | builder.Append("HTTP/1.1 " + StatusCode + "\r\n"); 78 | 79 | if (!string.IsNullOrEmpty(this.Content_Type)) 80 | builder.AppendLine("Content-Type:" + this.Content_Type); 81 | 82 | foreach (var head in this.Headers.Keys) 83 | { 84 | builder.AppendLine(head+":"+this.Headers[head]); 85 | } 86 | return builder.ToString(); 87 | } 88 | 89 | /// 90 | /// 发送数据 91 | /// 92 | public void Send() 93 | { 94 | if (!handler.CanWrite) return; 95 | 96 | try 97 | { 98 | //发送响应头 99 | var header = BuildHeader(); 100 | byte[] headerBytes = this.Encoding.GetBytes(header); 101 | handler.Write(headerBytes, 0, headerBytes.Length); 102 | 103 | //发送空行 104 | byte[] lineBytes = this.Encoding.GetBytes(System.Environment.NewLine); 105 | handler.Write(lineBytes, 0, lineBytes.Length); 106 | 107 | //发送内容 108 | handler.Write(Content, 0, Content.Length); 109 | } 110 | catch (Exception e) 111 | { 112 | Log(e.Message); 113 | } 114 | finally 115 | { 116 | handler.Close(); 117 | } 118 | } 119 | 120 | /// 121 | /// 记录日志 122 | /// 123 | /// 日志消息 124 | private void Log(object message) 125 | { 126 | if (Logger != null) 127 | Logger.Log(message); 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /HttpServer/HttpServer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Net.Security; 7 | using System.Net.Sockets; 8 | using System.Security.Authentication; 9 | using System.Security.Cryptography.X509Certificates; 10 | using System.Text; 11 | using System.Threading; 12 | using System.Web; 13 | 14 | namespace DF_FaceTracking.cs.HttpServer 15 | { 16 | public class HttpServer : IServer 17 | { 18 | /// 19 | /// 服务器IP 20 | /// 21 | public string ServerIP { get; private set; } 22 | 23 | /// 24 | /// 服务器端口 25 | /// 26 | public int ServerPort { get; private set; } 27 | 28 | /// 29 | /// 服务器目录 30 | /// 31 | public string ServerRoot { get; private set; } 32 | 33 | /// 34 | /// 是否运行 35 | /// 36 | public bool IsRunning { get; private set; } 37 | 38 | /// 39 | /// 服务器协议 40 | /// 41 | public Protocols Protocol { get; private set; } 42 | 43 | /// 44 | /// 服务端Socet 45 | /// 46 | private TcpListener serverListener; 47 | 48 | /// 49 | /// 日志接口 50 | /// 51 | public ILogger Logger { get; set; } 52 | 53 | /// 54 | /// SSL证书 55 | /// 56 | private X509Certificate serverCertificate = null; 57 | 58 | /// 59 | /// 构造函数 60 | /// 61 | /// IP地址 62 | /// 端口号 63 | /// 根目录 64 | private HttpServer(IPAddress ipAddress, int port, string root) 65 | { 66 | this.ServerIP = ipAddress.ToString(); 67 | this.ServerPort = port; 68 | 69 | //如果指定目录不存在则采用默认目录 70 | if (!Directory.Exists(root)) 71 | this.ServerRoot = AppDomain.CurrentDomain.BaseDirectory; 72 | 73 | this.ServerRoot = root; 74 | } 75 | 76 | /// 77 | /// 构造函数 78 | /// 79 | /// IP地址 80 | /// 端口号 81 | /// 根目录 82 | public HttpServer(string ipAddress, int port, string root) : 83 | this(IPAddress.Parse(ipAddress), port, root) 84 | { } 85 | 86 | /// 87 | /// 构造函数 88 | /// 89 | /// IP地址 90 | /// 端口号 91 | public HttpServer(string ipAddress, int port) : 92 | this(IPAddress.Parse(ipAddress), port, AppDomain.CurrentDomain.BaseDirectory) 93 | { } 94 | 95 | 96 | /// 97 | /// 构造函数 98 | /// 99 | /// 端口号 100 | /// 根目录 101 | public HttpServer(int port, string root) : 102 | this(IPAddress.Loopback, port, root) 103 | { } 104 | 105 | /// 106 | /// 构造函数 107 | /// 108 | /// 端口号 109 | public HttpServer(int port) : 110 | this(IPAddress.Loopback, port, AppDomain.CurrentDomain.BaseDirectory) 111 | { } 112 | 113 | 114 | /// 115 | /// 构造函数 116 | /// 117 | /// 118 | public HttpServer(string ip) : 119 | this(IPAddress.Parse(ip), 80, AppDomain.CurrentDomain.BaseDirectory) 120 | { } 121 | 122 | #region 公开方法 123 | 124 | /// 125 | /// 开启服务器 126 | /// 127 | public void Start() 128 | { 129 | if (IsRunning) return; 130 | 131 | //创建服务端Socket 132 | this.serverListener = new TcpListener(IPAddress.Parse(ServerIP), ServerPort); 133 | this.Protocol = serverCertificate == null ? Protocols.Http : Protocols.Https; 134 | this.IsRunning = true; 135 | this.serverListener.Start(); 136 | this.Log(string.Format("Sever is running at {0}://{1}:{2}", Protocol.ToString().ToLower(), ServerIP, ServerPort)); 137 | try 138 | { 139 | while (IsRunning) 140 | { 141 | TcpClient client = serverListener.AcceptTcpClient(); 142 | Thread requestThread = new Thread(() => { ProcessRequest(client); });// 143 | requestThread.Start(); 144 | } 145 | } 146 | catch (Exception e) 147 | { 148 | Log(e.Message); 149 | } 150 | } 151 | 152 | 153 | public HttpServer SetSSL(string certificate) 154 | { 155 | return SetSSL(X509Certificate.CreateFromCertFile(certificate)); 156 | } 157 | 158 | 159 | public HttpServer SetSSL(X509Certificate certifiate) 160 | { 161 | this.serverCertificate = certifiate; 162 | return this; 163 | } 164 | 165 | public void Stop() 166 | { 167 | if (!IsRunning) return; 168 | 169 | IsRunning = false; 170 | serverListener.Stop(); 171 | } 172 | 173 | /// 174 | /// 设置服务器目录 175 | /// 176 | /// 177 | public HttpServer SetRoot(string root) 178 | { 179 | if (!Directory.Exists(root)) 180 | this.ServerRoot = AppDomain.CurrentDomain.BaseDirectory; 181 | 182 | this.ServerRoot = root; 183 | return this; 184 | } 185 | /// 186 | /// 获取服务器目录 187 | /// 188 | public string GetRoot() 189 | { 190 | return this.ServerRoot; 191 | } 192 | 193 | /// 194 | /// 设置端口 195 | /// 196 | /// 端口号 197 | /// 198 | public HttpServer SetPort(int port) 199 | { 200 | this.ServerPort = port; 201 | return this; 202 | } 203 | 204 | 205 | #endregion 206 | 207 | #region 内部方法 208 | 209 | /// 210 | /// 处理客户端请求 211 | /// 212 | /// 客户端Socket 213 | private void ProcessRequest(TcpClient handler) 214 | { 215 | //处理请求 216 | Stream clientStream = handler.GetStream(); 217 | 218 | //处理SSL 219 | if (serverCertificate != null) clientStream = ProcessSSL(clientStream); 220 | if (clientStream == null) return; 221 | 222 | //构造HTTP请求 223 | HttpRequest request = new HttpRequest(clientStream); 224 | request.Logger = Logger; 225 | 226 | //构造HTTP响应 227 | HttpResponse response = new HttpResponse(clientStream); 228 | response.Logger = Logger; 229 | 230 | //处理请求类型 231 | switch (request.Method) 232 | { 233 | case "GET": 234 | OnGet(request, response); 235 | break; 236 | case "POST": 237 | OnPost(request, response); 238 | break; 239 | default: 240 | OnDefault(request, response); 241 | break; 242 | } 243 | } 244 | /// 245 | /// 处理ssl加密请求 246 | /// 247 | /// 248 | /// 249 | private Stream ProcessSSL(Stream clientStream) 250 | { 251 | try 252 | { 253 | SslStream sslStream = new SslStream(clientStream); 254 | sslStream.AuthenticateAsServer(serverCertificate, false, SslProtocols.Tls, true); 255 | sslStream.ReadTimeout = 10000; 256 | sslStream.WriteTimeout = 10000; 257 | return sslStream; 258 | } 259 | catch (Exception e) 260 | { 261 | Log(e.Message); 262 | clientStream.Close(); 263 | } 264 | 265 | return null; 266 | } 267 | 268 | /// 269 | /// 记录日志 270 | /// 271 | /// 日志消息 272 | protected void Log(object message) 273 | { 274 | if (Logger != null) Logger.Log(message); 275 | } 276 | 277 | #endregion 278 | 279 | #region 虚方法 280 | 281 | /// 282 | /// 响应Get请求 283 | /// 284 | /// 请求报文 285 | public virtual void OnGet(HttpRequest request, HttpResponse response) 286 | { 287 | 288 | } 289 | 290 | /// 291 | /// 响应Post请求 292 | /// 293 | /// 294 | public virtual void OnPost(HttpRequest request, HttpResponse response) 295 | { 296 | 297 | } 298 | 299 | /// 300 | /// 响应默认请求 301 | /// 302 | 303 | public virtual void OnDefault(HttpRequest request, HttpResponse response) 304 | { 305 | 306 | } 307 | 308 | #endregion 309 | } 310 | } 311 | -------------------------------------------------------------------------------- /HttpServer/ILogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DF_FaceTracking.cs.HttpServer 8 | { 9 | public interface ILogger 10 | { 11 | void Log(object message); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /HttpServer/IServer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Web; 6 | 7 | namespace DF_FaceTracking.cs.HttpServer 8 | { 9 | public interface IServer 10 | { 11 | /// 12 | /// 响应GET方法 13 | /// 14 | /// Http请求 15 | void OnGet(HttpRequest request, HttpResponse response); 16 | 17 | 18 | /// 19 | /// 响应Post方法 20 | /// 21 | /// Http请求 22 | void OnPost(HttpRequest request, HttpResponse response); 23 | 24 | 25 | /// 26 | /// 响应默认请求 27 | /// 28 | /// Http请求 29 | void OnDefault(HttpRequest request, HttpResponse response); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /HttpServer/Protocols.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DF_FaceTracking.cs.HttpServer 7 | { 8 | public enum Protocols 9 | { 10 | Http = 0, 11 | 12 | Https = 1 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /HttpServer/RequestHeaders.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace DF_FaceTracking.cs.HttpServer 8 | { 9 | public enum RequestHeaders 10 | { 11 | /// 12 | /// Cache-Control 标头,指定请求/响应链上所有缓存控制机制必须服从的指令。 13 | /// 14 | [Description("Cache-Control")] 15 | CacheControl = 0, 16 | 17 | /// 18 | /// Connection 标头,指定特定连接需要的选项。 19 | /// 20 | [Description("Connection")] 21 | Connection = 1, 22 | 23 | /// 24 | /// Date 标头,指定开始创建请求的日期和时间。 25 | /// 26 | [Description("Date")] 27 | Date = 2, 28 | 29 | /// 30 | /// Keep-Alive 标头,指定用以维护持久性连接的参数。 31 | /// 32 | [Description("Keep-Alive")] 33 | KeepAlive = 3, 34 | 35 | /// 36 | /// Pragma 标头,指定可应用于请求/响应链上的任何代理的特定于实现的指令。 37 | /// 38 | [Description("Pragma")] 39 | Pragma = 4, 40 | 41 | /// 42 | /// Trailer 标头,指定标头字段显示在以 chunked 传输编码方式编码的消息的尾部。 43 | /// 44 | [Description("Trailer")] 45 | Trailer = 5, 46 | 47 | /// 48 | /// Transfer-Encoding 标头,指定对消息正文应用的转换的类型(如果有)。 49 | /// 50 | [Description("Transfer-Encoding")] 51 | TransferEncoding = 6, 52 | 53 | /// 54 | /// Upgrade 标头,指定客户端支持的附加通信协议。 55 | /// 56 | [Description("Upgrade")] 57 | Upgrade = 7, 58 | 59 | /// 60 | /// Via 标头,指定网关和代理程序要使用的中间协议。 61 | /// 62 | [Description("Via")] 63 | Via = 8, 64 | 65 | /// 66 | /// Warning 标头,指定关于可能未在消息中反映的消息的状态或转换的附加信息。 67 | /// 68 | [Description("Warning")] 69 | Warning = 9, 70 | 71 | /// 72 | /// Allow 标头,指定支持的 HTTP 方法集。 73 | /// 74 | [Description("Allow")] 75 | Allow = 10, 76 | 77 | /// 78 | /// Content-Length 标头,指定伴随正文数据的长度(以字节为单位)。 79 | /// 80 | [Description("Content-Length")] 81 | ContentLength = 11, 82 | 83 | /// 84 | /// Content-Type 标头,指定伴随正文数据的 MIME 类型。 85 | /// 86 | [Description("Content-Type")] 87 | ContentType = 12, 88 | 89 | /// 90 | /// Content-Encoding 标头,指定已应用于伴随正文数据的编码。 91 | /// 92 | [Description("Content-Encoding")] 93 | ContentEncoding = 13, 94 | 95 | /// 96 | /// Content-Langauge 标头,指定伴随正文数据的自然语言。 97 | /// 98 | [Description("Content-Langauge")] 99 | ContentLanguage = 14, 100 | 101 | /// 102 | /// Content-Location 标头,指定可从其中获得伴随正文的 URI。 103 | /// 104 | [Description("Content-Location")] 105 | ContentLocation = 15, 106 | 107 | /// 108 | /// Content-MD5 标头,指定伴随正文数据的 MD5 摘要,用于提供端到端消息完整性检查。 109 | /// 110 | [Description("Content-MD5")] 111 | ContentMd5 = 16, 112 | 113 | /// 114 | /// Content-Range 标头,指定在完整正文中应用伴随部分正文数据的位置。 115 | /// 116 | [Description("Content-Range")] 117 | ContentRange = 17, 118 | 119 | /// 120 | /// Expires 标头,指定日期和时间,在此之后伴随的正文数据应视为陈旧的。 121 | /// 122 | [Description("Expires")] 123 | Expires = 18, 124 | 125 | /// 126 | /// Last-Modified 标头,指定上次修改伴随的正文数据的日期和时间。 127 | /// 128 | [Description("Last-Modified")] 129 | LastModified = 19, 130 | 131 | /// 132 | /// Accept 标头,指定响应可接受的 MIME 类型。 133 | /// 134 | [Description("Accept")] 135 | Accept = 20, 136 | 137 | /// 138 | /// Accept-Charset 标头,指定响应可接受的字符集。 139 | /// 140 | [Description("Accept-Charset")] 141 | AcceptCharset = 21, 142 | 143 | /// 144 | /// Accept-Encoding 标头,指定响应可接受的内容编码。 145 | /// 146 | [Description("Accept-Encoding")] 147 | AcceptEncoding = 22, 148 | 149 | /// 150 | /// Accept-Langauge 标头,指定响应首选的自然语言。 151 | /// 152 | [Description("Accept-Langauge")] 153 | AcceptLanguage = 23, 154 | 155 | /// 156 | /// Authorization 标头,指定客户端为向服务器验证自身身份而出示的凭据。 157 | /// 158 | [Description("Authorization")] 159 | Authorization = 24, 160 | 161 | /// 162 | /// Cookie 标头,指定向服务器提供的 Cookie 数据。 163 | /// 164 | [Description("Cookie")] 165 | Cookie = 25, 166 | 167 | /// 168 | /// Expect 标头,指定客户端要求的特定服务器行为。 169 | /// 170 | [Description("Expect")] 171 | Expect = 26, 172 | 173 | /// 174 | /// From 标头,指定控制请求用户代理的用户的 Internet 电子邮件地址。 175 | /// 176 | [Description("From")] 177 | From = 27, 178 | 179 | /// 180 | /// Host 标头,指定所请求资源的主机名和端口号。 181 | /// 182 | [Description("Host")] 183 | Host = 28, 184 | 185 | /// 186 | /// If-Match 标头,指定仅当客户端的指示资源的缓存副本是最新的时,才执行请求的操作。 187 | /// 188 | [Description("If-Match")] 189 | IfMatch = 29, 190 | 191 | /// 192 | /// If-Modified-Since 标头,指定仅当自指示的数据和时间之后修改了请求的资源时,才执行请求的操作。 193 | /// 194 | [Description("If-Modified-Since")] 195 | IfModifiedSince = 30, 196 | 197 | /// 198 | /// If-None-Match 标头,指定仅当客户端的指示资源的缓存副本都不是最新的时,才执行请求的操作。 199 | /// 200 | [Description("If-None-Match")] 201 | IfNoneMatch = 31, 202 | 203 | /// 204 | /// If-Range 标头,指定如果客户端的缓存副本是最新的,仅发送指定范围的请求资源。 205 | /// 206 | [Description("If-Range")] 207 | IfRange = 32, 208 | 209 | /// 210 | /// If-Unmodified-Since 标头,指定仅当自指示的日期和时间之后修改了请求的资源时,才执行请求的操作。 211 | /// 212 | [Description("If-Unmodified-Since")] 213 | IfUnmodifiedSince = 33, 214 | 215 | /// 216 | /// Max-Forwards 标头,指定一个整数,表示此请求还可转发的次数。 217 | /// 218 | [Description("Max-Forwards")] 219 | MaxForwards = 34, 220 | 221 | /// 222 | /// Proxy-Authorization 标头,指定客户端为向代理验证自身身份而出示的凭据。 223 | /// 224 | [Description("Proxy-Authorization")] 225 | ProxyAuthorization = 35, 226 | 227 | /// 228 | /// Referer 标头,指定从中获得请求 URI 的资源的 URI。 229 | /// 230 | [Description("Referer")] 231 | Referer = 36, 232 | 233 | /// 234 | /// Range 标头,指定代替整个响应返回的客户端请求的响应的子范围。 235 | /// 236 | [Description("Range")] 237 | Range = 37, 238 | 239 | /// 240 | /// TE 标头,指定响应可接受的传输编码方式。 241 | /// 242 | [Description("TE")] 243 | Te = 38, 244 | 245 | /// 246 | /// Translate 标头,与 WebDAV 功能一起使用的 HTTP 规范的 Microsoft 扩展。 247 | /// 248 | [Description("Translate")] 249 | Translate = 39, 250 | 251 | /// 252 | /// User-Agent 标头,指定有关客户端代理的信息。 253 | /// 254 | [Description("User-Agent")] 255 | UserAgent = 40, 256 | 257 | 258 | } 259 | } 260 | -------------------------------------------------------------------------------- /HttpServer/ResponseHeaders.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace DF_FaceTracking.cs.HttpServer 8 | { 9 | public enum ResponseHeaders 10 | { 11 | /// 12 | /// Cache-Control 标头,指定请求/响应链上所有缓存机制必须服从的缓存指令。 13 | /// 14 | [Description("Cache-Control")] 15 | CacheControl = 0, 16 | 17 | /// 18 | /// Connection 标头,指定特定连接需要的选项。 19 | /// 20 | [Description("Connection")] 21 | Connection = 1, 22 | 23 | /// 24 | /// Date 标头,指定响应产生的日期和时间。 25 | /// 26 | [Description("Date")] 27 | Date = 2, 28 | 29 | /// 30 | /// Keep-Alive 标头,指定用于维护持久连接的参数。 31 | /// 32 | [Description("Keep-Alive")] 33 | KeepAlive = 3, 34 | 35 | /// 36 | /// Pragma 标头,指定可应用于请求/响应链上的任何代理的特定于实现的指令。 37 | /// 38 | [Description("Pragma")] 39 | Pragma = 4, 40 | 41 | /// 42 | /// Trailer 标头,指定指示的标头字段在消息(使用分块传输编码方法进行编码)的尾部显示。 43 | /// 44 | [Description("Trailer")] 45 | Trailer = 5, 46 | 47 | /// 48 | /// Transfer-Encoding 标头,指定对消息正文应用哪种类型的转换(如果有)。 49 | /// 50 | [Description("Transfer-Encoding")] 51 | TransferEncoding = 6, 52 | 53 | /// 54 | /// Upgrade 标头,指定客户端支持的附加通信协议。 55 | /// 56 | [Description("Upgrade")] 57 | Upgrade = 7, 58 | 59 | /// 60 | /// Via 标头,指定网关和代理程序要使用的中间协议。 61 | /// 62 | [Description("Via")] 63 | Via = 8, 64 | 65 | /// 66 | /// Warning 标头,指定关于可能未在消息中反映的消息的状态或转换的附加信息。 67 | /// 68 | [Description("Warning")] 69 | Warning = 9, 70 | 71 | /// 72 | /// Allow 标头,指定支持的 HTTP 方法集。 73 | /// 74 | [Description("Allow")] 75 | Allow = 10, 76 | 77 | /// 78 | /// Content-Length 标头,指定伴随正文数据的长度(以字节为单位)。 79 | /// 80 | [Description("Content-Length")] 81 | ContentLength = 11, 82 | 83 | /// 84 | /// Content-Type 标头,指定伴随正文数据的 MIME 类型。 85 | /// 86 | [Description("Content-Type")] 87 | ContentType = 12, 88 | 89 | /// 90 | /// Content-Encoding 标头,指定已应用于伴随正文数据的编码。 91 | /// 92 | [Description("Content-Encoding")] 93 | ContentEncoding = 13, 94 | 95 | /// 96 | /// Content-Langauge 标头,指定自然语言或伴随正文数据的语言。 97 | /// 98 | [Description("Content-Langauge")] 99 | ContentLanguage = 14, 100 | 101 | /// 102 | /// Content-Location 标头,指定可以从中获取伴随正文的 URI。 103 | /// 104 | [Description("Content-Location")] 105 | ContentLocation = 15, 106 | 107 | /// 108 | /// Content-MD5 标头,指定伴随正文数据的 MD5 摘要,用于提供端到端消息完整性检查。 109 | /// 110 | [Description("Content-MD5")] 111 | ContentMd5 = 16, 112 | 113 | /// 114 | /// Range 标头,指定客户端请求返回的响应的单个或多个子范围来代替整个响应。 115 | /// 116 | [Description("Range")] 117 | ContentRange = 17, 118 | 119 | /// 120 | /// Expires 标头,指定日期和时间,在此之后伴随的正文数据应视为陈旧的。 121 | /// 122 | [Description("Expires")] 123 | Expires = 18, 124 | 125 | /// 126 | /// Last-Modified 标头,指定上次修改伴随的正文数据的日期和时间。 127 | /// 128 | [Description("Last-Modified")] 129 | LastModified = 19, 130 | 131 | /// 132 | /// Accept-Ranges 标头,指定服务器接受的范围。 133 | /// 134 | [Description("Accept-Ranges")] 135 | AcceptRanges = 20, 136 | 137 | /// 138 | /// Age 标头,指定自起始服务器生成响应以来的时间长度(以秒为单位)。 139 | /// 140 | [Description("Age")] 141 | Age = 21, 142 | 143 | /// 144 | /// Etag 标头,指定请求的变量的当前值。 145 | /// 146 | [Description("Etag")] 147 | ETag = 22, 148 | 149 | /// 150 | /// Location 标头,指定为获取请求的资源而将客户端重定向到的 URI。 151 | /// 152 | [Description("Location")] 153 | Location = 23, 154 | 155 | /// 156 | /// Proxy-Authenticate 标头,指定客户端必须对代理验证其自身。 157 | /// 158 | [Description("Proxy-Authenticate")] 159 | ProxyAuthenticate = 24, 160 | 161 | /// 162 | /// Retry-After 标头,指定某个时间(以秒为单位)或日期和时间,在此时间之后客户端可以重试其请求。 163 | /// 164 | [Description("Retry-After")] 165 | RetryAfter = 25, 166 | 167 | /// 168 | /// Server 标头,指定关于起始服务器代理的信息。 169 | /// 170 | [Description("Server")] 171 | Server = 26, 172 | 173 | /// 174 | /// Set-Cookie 标头,指定提供给客户端的 Cookie 数据。 175 | /// 176 | [Description("Set-Cookie")] 177 | SetCookie = 27, 178 | 179 | /// 180 | /// Vary 标头,指定用于确定缓存的响应是否为新响应的请求标头。 181 | /// 182 | [Description("Vary")] 183 | Vary = 28, 184 | 185 | /// 186 | /// WWW-Authenticate 标头,指定客户端必须对服务器验证其自身。 187 | /// 188 | [Description("WWW-Authenticate")] 189 | WwwAuthenticate = 29, 190 | 191 | 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /MainForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DF_FaceTracking.cs 2 | { 3 | partial class MainForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.Start = new MaterialSkin.Controls.MaterialRaisedButton(); 32 | this.Stop = new MaterialSkin.Controls.MaterialRaisedButton(); 33 | this.sourceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 34 | this.moduleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 35 | this.MainMenu = new System.Windows.Forms.MenuStrip(); 36 | this.colorResolutionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 37 | this.ProfileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 38 | this.modeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 39 | this.Live = new System.Windows.Forms.ToolStripMenuItem(); 40 | this.Record = new System.Windows.Forms.ToolStripMenuItem(); 41 | this.Status2 = new System.Windows.Forms.StatusStrip(); 42 | this.StatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); 43 | this.AlertsLabel = new System.Windows.Forms.ToolStripStatusLabel(); 44 | this.Panel2 = new System.Windows.Forms.PictureBox(); 45 | this.MainMenu.SuspendLayout(); 46 | this.Status2.SuspendLayout(); 47 | ((System.ComponentModel.ISupportInitialize)(this.Panel2)).BeginInit(); 48 | this.SuspendLayout(); 49 | // 50 | // Start 51 | // 52 | this.Start.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 53 | this.Start.Depth = 0; 54 | this.Start.Enabled = false; 55 | this.Start.Location = new System.Drawing.Point(843, 159); 56 | this.Start.MouseState = MaterialSkin.MouseState.HOVER; 57 | this.Start.Name = "Start"; 58 | this.Start.Primary = true; 59 | this.Start.Size = new System.Drawing.Size(80, 21); 60 | this.Start.TabIndex = 2; 61 | this.Start.Text = "Start"; 62 | this.Start.UseVisualStyleBackColor = true; 63 | this.Start.Click += new System.EventHandler(this.Start_Click); 64 | // 65 | // Stop 66 | // 67 | this.Stop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 68 | this.Stop.Depth = 0; 69 | this.Stop.Enabled = false; 70 | this.Stop.Location = new System.Drawing.Point(843, 224); 71 | this.Stop.MouseState = MaterialSkin.MouseState.HOVER; 72 | this.Stop.Name = "Stop"; 73 | this.Stop.Primary = true; 74 | this.Stop.Size = new System.Drawing.Size(80, 21); 75 | this.Stop.TabIndex = 3; 76 | this.Stop.Text = "Stop"; 77 | this.Stop.UseVisualStyleBackColor = true; 78 | this.Stop.Click += new System.EventHandler(this.Stop_Click); 79 | // 80 | // sourceToolStripMenuItem 81 | // 82 | this.sourceToolStripMenuItem.Name = "sourceToolStripMenuItem"; 83 | this.sourceToolStripMenuItem.Size = new System.Drawing.Size(58, 21); 84 | this.sourceToolStripMenuItem.Text = "Device"; 85 | // 86 | // moduleToolStripMenuItem 87 | // 88 | this.moduleToolStripMenuItem.Name = "moduleToolStripMenuItem"; 89 | this.moduleToolStripMenuItem.Size = new System.Drawing.Size(65, 21); 90 | this.moduleToolStripMenuItem.Text = "Module"; 91 | // 92 | // MainMenu 93 | // 94 | this.MainMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 95 | this.sourceToolStripMenuItem, 96 | this.colorResolutionToolStripMenuItem, 97 | this.moduleToolStripMenuItem, 98 | this.ProfileToolStripMenuItem, 99 | this.modeToolStripMenuItem}); 100 | this.MainMenu.Location = new System.Drawing.Point(0, 0); 101 | this.MainMenu.Name = "MainMenu"; 102 | this.MainMenu.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; 103 | this.MainMenu.Size = new System.Drawing.Size(941, 25); 104 | this.MainMenu.TabIndex = 0; 105 | this.MainMenu.Text = "MainMenu"; 106 | this.MainMenu.Visible = false; 107 | // 108 | // colorResolutionToolStripMenuItem 109 | // 110 | this.colorResolutionToolStripMenuItem.Name = "colorResolutionToolStripMenuItem"; 111 | this.colorResolutionToolStripMenuItem.Size = new System.Drawing.Size(52, 21); 112 | this.colorResolutionToolStripMenuItem.Text = "Color"; 113 | // 114 | // ProfileToolStripMenuItem 115 | // 116 | this.ProfileToolStripMenuItem.Name = "ProfileToolStripMenuItem"; 117 | this.ProfileToolStripMenuItem.Size = new System.Drawing.Size(57, 21); 118 | this.ProfileToolStripMenuItem.Text = "Profile"; 119 | // 120 | // modeToolStripMenuItem 121 | // 122 | this.modeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 123 | this.Live, 124 | this.Record}); 125 | this.modeToolStripMenuItem.Name = "modeToolStripMenuItem"; 126 | this.modeToolStripMenuItem.Size = new System.Drawing.Size(55, 21); 127 | this.modeToolStripMenuItem.Text = "Mode"; 128 | // 129 | // Live 130 | // 131 | this.Live.Checked = true; 132 | this.Live.CheckState = System.Windows.Forms.CheckState.Checked; 133 | this.Live.Name = "Live"; 134 | this.Live.Size = new System.Drawing.Size(118, 22); 135 | this.Live.Text = "Live"; 136 | this.Live.Click += new System.EventHandler(this.Live_Click); 137 | // 138 | // Record 139 | // 140 | this.Record.Name = "Record"; 141 | this.Record.Size = new System.Drawing.Size(118, 22); 142 | this.Record.Text = "Record"; 143 | this.Record.Click += new System.EventHandler(this.Record_Click); 144 | // 145 | // Status2 146 | // 147 | this.Status2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 148 | this.StatusLabel, 149 | this.AlertsLabel}); 150 | this.Status2.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow; 151 | this.Status2.Location = new System.Drawing.Point(0, 440); 152 | this.Status2.Name = "Status2"; 153 | this.Status2.Size = new System.Drawing.Size(941, 22); 154 | this.Status2.TabIndex = 25; 155 | this.Status2.Text = "Status2"; 156 | // 157 | // StatusLabel 158 | // 159 | this.StatusLabel.Name = "StatusLabel"; 160 | this.StatusLabel.Padding = new System.Windows.Forms.Padding(0, 0, 50, 0); 161 | this.StatusLabel.Size = new System.Drawing.Size(76, 17); 162 | this.StatusLabel.Text = "OK"; 163 | this.StatusLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 164 | // 165 | // AlertsLabel 166 | // 167 | this.AlertsLabel.AutoSize = false; 168 | this.AlertsLabel.Name = "AlertsLabel"; 169 | this.AlertsLabel.Size = new System.Drawing.Size(200, 15); 170 | this.AlertsLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 171 | // 172 | // Panel2 173 | // 174 | this.Panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 175 | | System.Windows.Forms.AnchorStyles.Left) 176 | | System.Windows.Forms.AnchorStyles.Right))); 177 | this.Panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 178 | this.Panel2.ErrorImage = null; 179 | this.Panel2.InitialImage = null; 180 | this.Panel2.Location = new System.Drawing.Point(12, 25); 181 | this.Panel2.Name = "Panel2"; 182 | this.Panel2.Size = new System.Drawing.Size(802, 410); 183 | this.Panel2.TabIndex = 27; 184 | this.Panel2.TabStop = false; 185 | // 186 | // MainForm 187 | // 188 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 189 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 190 | this.AutoSize = true; 191 | this.ClientSize = new System.Drawing.Size(941, 462); 192 | this.Controls.Add(this.Panel2); 193 | this.Controls.Add(this.Status2); 194 | this.Controls.Add(this.Stop); 195 | this.Controls.Add(this.Start); 196 | this.Controls.Add(this.MainMenu); 197 | this.Name = "MainForm"; 198 | this.Text = "Intel RealSense 视频图像采集"; 199 | this.MainMenu.ResumeLayout(false); 200 | this.MainMenu.PerformLayout(); 201 | this.Status2.ResumeLayout(false); 202 | this.Status2.PerformLayout(); 203 | ((System.ComponentModel.ISupportInitialize)(this.Panel2)).EndInit(); 204 | this.ResumeLayout(false); 205 | this.PerformLayout(); 206 | 207 | } 208 | 209 | #endregion 210 | 211 | private MaterialSkin.Controls.MaterialRaisedButton Start; 212 | private MaterialSkin.Controls.MaterialRaisedButton Stop; 213 | private System.Windows.Forms.ToolStripMenuItem sourceToolStripMenuItem; 214 | private System.Windows.Forms.ToolStripMenuItem moduleToolStripMenuItem; 215 | private System.Windows.Forms.MenuStrip MainMenu; 216 | private System.Windows.Forms.StatusStrip Status2; 217 | private System.Windows.Forms.ToolStripStatusLabel StatusLabel; 218 | private System.Windows.Forms.PictureBox Panel2; 219 | private System.Windows.Forms.ToolStripMenuItem modeToolStripMenuItem; 220 | private System.Windows.Forms.ToolStripMenuItem Live; 221 | private System.Windows.Forms.ToolStripMenuItem Record; 222 | private System.Windows.Forms.ToolStripStatusLabel AlertsLabel; 223 | private System.Windows.Forms.ToolStripMenuItem colorResolutionToolStripMenuItem; 224 | private System.Windows.Forms.ToolStripMenuItem ProfileToolStripMenuItem; 225 | } 226 | } -------------------------------------------------------------------------------- /MainForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | True 125 | 126 | 127 | 127, 17 128 | 129 | 130 | True 131 | 132 | 133 | True 134 | 135 | 136 | True 137 | 138 | 139 | 61 140 | 141 | -------------------------------------------------------------------------------- /ModuleSettings.cs: -------------------------------------------------------------------------------- 1 | namespace DF_FaceTracking.cs 2 | { 3 | public class ModuleSettings 4 | { 5 | public bool IsEnabled { get; set; } 6 | public int NumberOfFaces { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | INTEL CORPORATION PROPRIETARY INFORMATION 4 | This software is supplied under the terms of a license agreement or nondisclosure 5 | agreement with Intel Corporation and may not be copied or disclosed except in 6 | accordance with the terms of that agreement 7 | Copyright(c) 2013 Intel Corporation. All Rights Reserved. 8 | 9 | *******************************************************************************/ 10 | 11 | using DF_FaceTracking.cs.HttpServer; 12 | using System; 13 | using System.Windows.Forms; 14 | using DF_FaceTracking.cs.File; 15 | 16 | namespace DF_FaceTracking.cs 17 | { 18 | static class Program 19 | { 20 | private static String ipAddress = ConfigReader.GetConfigValue("IP"); 21 | private static int portAddress = Int32.Parse(ConfigReader.GetConfigValue("port")); 22 | /// 23 | /// The main entry point for the application. 24 | /// 25 | [STAThread] 26 | static void Main() 27 | { 28 | //Application.EnableVisualStyles(); 29 | //Application.SetCompatibleTextRenderingDefault(false); 30 | 31 | //PXCMSession session = PXCMSession.CreateInstance(); 32 | //if (session != null) 33 | //{ 34 | // Application.Run(new MainForm(session,"feature")); 35 | // session.Dispose(); 36 | //} 37 | ExampleServer server = new ExampleServer(ipAddress, portAddress); 38 | server.Logger = new ConsoleLogger(); 39 | try 40 | { 41 | server.Start(); 42 | } 43 | catch (Exception e) 44 | { 45 | WriteLog.WriteError(e.ToString()); 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | #if RELEASE_VERSIONING 9 | [assembly: AssemblyTitle("DF_FaceTracking.cs")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyProduct("Intel(R) RealSense(TM) SDK")] 13 | #endif 14 | 15 | // Setting ComVisible to false makes the types in this assembly not visible 16 | // to COM components. If you need to access a type in this assembly from 17 | // COM, set the ComVisible attribute to true on that type. 18 | [assembly: ComVisible(false)] 19 | 20 | // The following GUID is for the ID of the typelib if this project is exposed to COM 21 | [assembly: Guid("b51e736a-bcfc-4d3d-b2a6-9abc50c783c4")] 22 | 23 | // Version information for an assembly consists of the following four values: 24 | // 25 | // Major Version 26 | // Minor Version 27 | // Build Number 28 | // Revision 29 | // 30 | // You can specify all the values or you can default the Build and Revision Numbers 31 | // by using the '*' as shown below: 32 | // [assembly: AssemblyVersion("1.0.*")] 33 | -------------------------------------------------------------------------------- /Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DF_FaceTracking.cs.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DF_FaceTracking.cs.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 65 | /// 66 | internal static System.Drawing.Bitmap Brow_Lowerer_Left { 67 | get { 68 | object obj = ResourceManager.GetObject("Brow_Lowerer_Left", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 75 | /// 76 | internal static System.Drawing.Bitmap Brow_Lowerer_Right { 77 | get { 78 | object obj = ResourceManager.GetObject("Brow_Lowerer_Right", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 85 | /// 86 | internal static System.Drawing.Bitmap Brow_Raiser_Left { 87 | get { 88 | object obj = ResourceManager.GetObject("Brow_Raiser_Left", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | 93 | /// 94 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 95 | /// 96 | internal static System.Drawing.Bitmap Brow_Raiser_Right { 97 | get { 98 | object obj = ResourceManager.GetObject("Brow_Raiser_Right", resourceCulture); 99 | return ((System.Drawing.Bitmap)(obj)); 100 | } 101 | } 102 | 103 | /// 104 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 105 | /// 106 | internal static System.Drawing.Bitmap Eyes_Closed_Left { 107 | get { 108 | object obj = ResourceManager.GetObject("Eyes_Closed_Left", resourceCulture); 109 | return ((System.Drawing.Bitmap)(obj)); 110 | } 111 | } 112 | 113 | /// 114 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 115 | /// 116 | internal static System.Drawing.Bitmap Eyes_Closed_Right { 117 | get { 118 | object obj = ResourceManager.GetObject("Eyes_Closed_Right", resourceCulture); 119 | return ((System.Drawing.Bitmap)(obj)); 120 | } 121 | } 122 | 123 | /// 124 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 125 | /// 126 | internal static System.Drawing.Bitmap Eyes_Turn_Down { 127 | get { 128 | object obj = ResourceManager.GetObject("Eyes_Turn_Down", resourceCulture); 129 | return ((System.Drawing.Bitmap)(obj)); 130 | } 131 | } 132 | 133 | /// 134 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 135 | /// 136 | internal static System.Drawing.Bitmap Eyes_Turn_Left { 137 | get { 138 | object obj = ResourceManager.GetObject("Eyes_Turn_Left", resourceCulture); 139 | return ((System.Drawing.Bitmap)(obj)); 140 | } 141 | } 142 | 143 | /// 144 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 145 | /// 146 | internal static System.Drawing.Bitmap Eyes_Turn_Right { 147 | get { 148 | object obj = ResourceManager.GetObject("Eyes_Turn_Right", resourceCulture); 149 | return ((System.Drawing.Bitmap)(obj)); 150 | } 151 | } 152 | 153 | /// 154 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 155 | /// 156 | internal static System.Drawing.Bitmap Eyes_Turn_Up { 157 | get { 158 | object obj = ResourceManager.GetObject("Eyes_Turn_Up", resourceCulture); 159 | return ((System.Drawing.Bitmap)(obj)); 160 | } 161 | } 162 | 163 | /// 164 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 165 | /// 166 | internal static System.Drawing.Bitmap Kiss { 167 | get { 168 | object obj = ResourceManager.GetObject("Kiss", resourceCulture); 169 | return ((System.Drawing.Bitmap)(obj)); 170 | } 171 | } 172 | 173 | /// 174 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 175 | /// 176 | internal static System.Drawing.Bitmap MouthOpen { 177 | get { 178 | object obj = ResourceManager.GetObject("MouthOpen", resourceCulture); 179 | return ((System.Drawing.Bitmap)(obj)); 180 | } 181 | } 182 | 183 | /// 184 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 185 | /// 186 | internal static System.Drawing.Bitmap Smile { 187 | get { 188 | object obj = ResourceManager.GetObject("Smile", resourceCulture); 189 | return ((System.Drawing.Bitmap)(obj)); 190 | } 191 | } 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DF_FaceTracking.cs.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FaceFeatureClient 2 | C#客户端程序,用于启动RealSense摄像头、采集视频图像流、采集人脸特征点信息,并将该客户端发布为Http服务器,提供GET请求接口和Post请求接口,以供JS或者web调用 3 | -------------------------------------------------------------------------------- /RealSenseclient/RealSenseclient.vdproj: -------------------------------------------------------------------------------- 1 | "DeployProject" 2 | { 3 | "VSVersion" = "3:800" 4 | "ProjectType" = "8:{978C614F-708E-4E1A-B201-565925725DBA}" 5 | "IsWebType" = "8:FALSE" 6 | "ProjectName" = "8:RealSenseclient" 7 | "LanguageId" = "3:2052" 8 | "CodePage" = "3:936" 9 | "UILanguageId" = "3:2052" 10 | "SccProjectName" = "8:" 11 | "SccLocalPath" = "8:" 12 | "SccAuxPath" = "8:" 13 | "SccProvider" = "8:" 14 | "Hierarchy" 15 | { 16 | "Entry" 17 | { 18 | "MsmKey" = "8:_1582001AF0C0491EA2CC8EBF861F6C8D" 19 | "OwnerKey" = "8:_UNDEFINED" 20 | "MsmSig" = "8:_UNDEFINED" 21 | } 22 | "Entry" 23 | { 24 | "MsmKey" = "8:_B848847139192F2D43569162D879D359" 25 | "OwnerKey" = "8:_1582001AF0C0491EA2CC8EBF861F6C8D" 26 | "MsmSig" = "8:_UNDEFINED" 27 | } 28 | "Entry" 29 | { 30 | "MsmKey" = "8:_E6BD7B67B2E3F72CC2B60910497085F1" 31 | "OwnerKey" = "8:_1582001AF0C0491EA2CC8EBF861F6C8D" 32 | "MsmSig" = "8:_UNDEFINED" 33 | } 34 | "Entry" 35 | { 36 | "MsmKey" = "8:_F248803802B9D6E5C6DC20D0B16AEF47" 37 | "OwnerKey" = "8:_1582001AF0C0491EA2CC8EBF861F6C8D" 38 | "MsmSig" = "8:_UNDEFINED" 39 | } 40 | "Entry" 41 | { 42 | "MsmKey" = "8:_FA2A3712C28B79EF0140429C312CBE4F" 43 | "OwnerKey" = "8:_1582001AF0C0491EA2CC8EBF861F6C8D" 44 | "MsmSig" = "8:_UNDEFINED" 45 | } 46 | "Entry" 47 | { 48 | "MsmKey" = "8:_UNDEFINED" 49 | "OwnerKey" = "8:_E6BD7B67B2E3F72CC2B60910497085F1" 50 | "MsmSig" = "8:_UNDEFINED" 51 | } 52 | "Entry" 53 | { 54 | "MsmKey" = "8:_UNDEFINED" 55 | "OwnerKey" = "8:_1582001AF0C0491EA2CC8EBF861F6C8D" 56 | "MsmSig" = "8:_UNDEFINED" 57 | } 58 | "Entry" 59 | { 60 | "MsmKey" = "8:_UNDEFINED" 61 | "OwnerKey" = "8:_FA2A3712C28B79EF0140429C312CBE4F" 62 | "MsmSig" = "8:_UNDEFINED" 63 | } 64 | "Entry" 65 | { 66 | "MsmKey" = "8:_UNDEFINED" 67 | "OwnerKey" = "8:_F248803802B9D6E5C6DC20D0B16AEF47" 68 | "MsmSig" = "8:_UNDEFINED" 69 | } 70 | "Entry" 71 | { 72 | "MsmKey" = "8:_UNDEFINED" 73 | "OwnerKey" = "8:_B848847139192F2D43569162D879D359" 74 | "MsmSig" = "8:_UNDEFINED" 75 | } 76 | } 77 | "Configurations" 78 | { 79 | "Debug" 80 | { 81 | "DisplayName" = "8:Debug" 82 | "IsDebugOnly" = "11:TRUE" 83 | "IsReleaseOnly" = "11:FALSE" 84 | "OutputFilename" = "8:Debug\\RealSenseclient.msi" 85 | "PackageFilesAs" = "3:2" 86 | "PackageFileSize" = "3:-2147483648" 87 | "CabType" = "3:1" 88 | "Compression" = "3:2" 89 | "SignOutput" = "11:FALSE" 90 | "CertificateFile" = "8:" 91 | "PrivateKeyFile" = "8:" 92 | "TimeStampServer" = "8:" 93 | "InstallerBootstrapper" = "3:2" 94 | } 95 | "Release" 96 | { 97 | "DisplayName" = "8:Release" 98 | "IsDebugOnly" = "11:FALSE" 99 | "IsReleaseOnly" = "11:TRUE" 100 | "OutputFilename" = "8:Release\\RealSenseclient.msi" 101 | "PackageFilesAs" = "3:2" 102 | "PackageFileSize" = "3:-2147483648" 103 | "CabType" = "3:1" 104 | "Compression" = "3:2" 105 | "SignOutput" = "11:FALSE" 106 | "CertificateFile" = "8:" 107 | "PrivateKeyFile" = "8:" 108 | "TimeStampServer" = "8:" 109 | "InstallerBootstrapper" = "3:2" 110 | } 111 | } 112 | "Deployable" 113 | { 114 | "CustomAction" 115 | { 116 | } 117 | "DefaultFeature" 118 | { 119 | "Name" = "8:DefaultFeature" 120 | "Title" = "8:" 121 | "Description" = "8:" 122 | } 123 | "ExternalPersistence" 124 | { 125 | "LaunchCondition" 126 | { 127 | "{A06ECF26-33A3-4562-8140-9B0E340D4F24}:_D5658D58A8D7484D8497D2A6DEE3E78F" 128 | { 129 | "Name" = "8:.NET Framework" 130 | "Message" = "8:[VSDNETMSG]" 131 | "FrameworkVersion" = "8:.NETFramework,Version=v4.6.1" 132 | "AllowLaterVersions" = "11:FALSE" 133 | "InstallUrl" = "8:http://go.microsoft.com/fwlink/?LinkId=671728" 134 | } 135 | } 136 | } 137 | "File" 138 | { 139 | "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_B848847139192F2D43569162D879D359" 140 | { 141 | "AssemblyRegister" = "3:1" 142 | "AssemblyIsInGAC" = "11:FALSE" 143 | "AssemblyAsmDisplayName" = "8:libpxcclr.cs, Version=11.0.27.1384, Culture=neutral, PublicKeyToken=ca106b2214526f83, processorArchitecture=AMD64" 144 | "ScatterAssemblies" 145 | { 146 | "_B848847139192F2D43569162D879D359" 147 | { 148 | "Name" = "8:libpxcclr.cs.dll" 149 | "Attributes" = "3:512" 150 | } 151 | } 152 | "SourcePath" = "8:libpxcclr.cs.dll" 153 | "TargetName" = "8:" 154 | "Tag" = "8:" 155 | "Folder" = "8:_BD5D6BEB5C3845419F56E060D3146853" 156 | "Condition" = "8:" 157 | "Transitive" = "11:FALSE" 158 | "Vital" = "11:TRUE" 159 | "ReadOnly" = "11:FALSE" 160 | "Hidden" = "11:FALSE" 161 | "System" = "11:FALSE" 162 | "Permanent" = "11:FALSE" 163 | "SharedLegacy" = "11:FALSE" 164 | "PackageAs" = "3:1" 165 | "Register" = "3:1" 166 | "Exclude" = "11:FALSE" 167 | "IsDependency" = "11:TRUE" 168 | "IsolateTo" = "8:" 169 | } 170 | "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_E6BD7B67B2E3F72CC2B60910497085F1" 171 | { 172 | "AssemblyRegister" = "3:1" 173 | "AssemblyIsInGAC" = "11:FALSE" 174 | "AssemblyAsmDisplayName" = "8:System.Data.SQLite, Version=1.0.108.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=AMD64" 175 | "ScatterAssemblies" 176 | { 177 | "_E6BD7B67B2E3F72CC2B60910497085F1" 178 | { 179 | "Name" = "8:System.Data.SQLite.dll" 180 | "Attributes" = "3:512" 181 | } 182 | } 183 | "SourcePath" = "8:System.Data.SQLite.dll" 184 | "TargetName" = "8:" 185 | "Tag" = "8:" 186 | "Folder" = "8:_BD5D6BEB5C3845419F56E060D3146853" 187 | "Condition" = "8:" 188 | "Transitive" = "11:FALSE" 189 | "Vital" = "11:TRUE" 190 | "ReadOnly" = "11:FALSE" 191 | "Hidden" = "11:FALSE" 192 | "System" = "11:FALSE" 193 | "Permanent" = "11:FALSE" 194 | "SharedLegacy" = "11:FALSE" 195 | "PackageAs" = "3:1" 196 | "Register" = "3:1" 197 | "Exclude" = "11:FALSE" 198 | "IsDependency" = "11:TRUE" 199 | "IsolateTo" = "8:" 200 | } 201 | "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_F248803802B9D6E5C6DC20D0B16AEF47" 202 | { 203 | "AssemblyRegister" = "3:1" 204 | "AssemblyIsInGAC" = "11:FALSE" 205 | "AssemblyAsmDisplayName" = "8:MaterialSkin, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" 206 | "ScatterAssemblies" 207 | { 208 | "_F248803802B9D6E5C6DC20D0B16AEF47" 209 | { 210 | "Name" = "8:MaterialSkin.dll" 211 | "Attributes" = "3:512" 212 | } 213 | } 214 | "SourcePath" = "8:MaterialSkin.dll" 215 | "TargetName" = "8:" 216 | "Tag" = "8:" 217 | "Folder" = "8:_BD5D6BEB5C3845419F56E060D3146853" 218 | "Condition" = "8:" 219 | "Transitive" = "11:FALSE" 220 | "Vital" = "11:TRUE" 221 | "ReadOnly" = "11:FALSE" 222 | "Hidden" = "11:FALSE" 223 | "System" = "11:FALSE" 224 | "Permanent" = "11:FALSE" 225 | "SharedLegacy" = "11:FALSE" 226 | "PackageAs" = "3:1" 227 | "Register" = "3:1" 228 | "Exclude" = "11:FALSE" 229 | "IsDependency" = "11:TRUE" 230 | "IsolateTo" = "8:" 231 | } 232 | "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_FA2A3712C28B79EF0140429C312CBE4F" 233 | { 234 | "AssemblyRegister" = "3:1" 235 | "AssemblyIsInGAC" = "11:FALSE" 236 | "AssemblyAsmDisplayName" = "8:Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL" 237 | "ScatterAssemblies" 238 | { 239 | "_FA2A3712C28B79EF0140429C312CBE4F" 240 | { 241 | "Name" = "8:Newtonsoft.Json.dll" 242 | "Attributes" = "3:512" 243 | } 244 | } 245 | "SourcePath" = "8:Newtonsoft.Json.dll" 246 | "TargetName" = "8:" 247 | "Tag" = "8:" 248 | "Folder" = "8:_BD5D6BEB5C3845419F56E060D3146853" 249 | "Condition" = "8:" 250 | "Transitive" = "11:FALSE" 251 | "Vital" = "11:TRUE" 252 | "ReadOnly" = "11:FALSE" 253 | "Hidden" = "11:FALSE" 254 | "System" = "11:FALSE" 255 | "Permanent" = "11:FALSE" 256 | "SharedLegacy" = "11:FALSE" 257 | "PackageAs" = "3:1" 258 | "Register" = "3:1" 259 | "Exclude" = "11:FALSE" 260 | "IsDependency" = "11:TRUE" 261 | "IsolateTo" = "8:" 262 | } 263 | } 264 | "FileType" 265 | { 266 | } 267 | "Folder" 268 | { 269 | "{1525181F-901A-416C-8A58-119130FE478E}:_425F522DA8F1436C83244676BC70D4AA" 270 | { 271 | "Name" = "8:#1916" 272 | "AlwaysCreate" = "11:FALSE" 273 | "Condition" = "8:" 274 | "Transitive" = "11:FALSE" 275 | "Property" = "8:DesktopFolder" 276 | "Folders" 277 | { 278 | } 279 | } 280 | "{1525181F-901A-416C-8A58-119130FE478E}:_7F98B6471D524556AF77351E7DC40FCF" 281 | { 282 | "Name" = "8:#1919" 283 | "AlwaysCreate" = "11:FALSE" 284 | "Condition" = "8:" 285 | "Transitive" = "11:FALSE" 286 | "Property" = "8:ProgramMenuFolder" 287 | "Folders" 288 | { 289 | } 290 | } 291 | "{3C67513D-01DD-4637-8A68-80971EB9504F}:_BD5D6BEB5C3845419F56E060D3146853" 292 | { 293 | "DefaultLocation" = "8:[ProgramFilesFolder][Manufacturer]\\[ProductName]" 294 | "Name" = "8:#1925" 295 | "AlwaysCreate" = "11:FALSE" 296 | "Condition" = "8:" 297 | "Transitive" = "11:FALSE" 298 | "Property" = "8:TARGETDIR" 299 | "Folders" 300 | { 301 | } 302 | } 303 | } 304 | "LaunchCondition" 305 | { 306 | } 307 | "Locator" 308 | { 309 | } 310 | "MsiBootstrapper" 311 | { 312 | "LangId" = "3:2052" 313 | "RequiresElevation" = "11:FALSE" 314 | } 315 | "Product" 316 | { 317 | "Name" = "8:Microsoft Visual Studio" 318 | "ProductName" = "8:RealSenseclient" 319 | "ProductCode" = "8:{92F9A16D-2473-43B6-B9A4-D70762C1E416}" 320 | "PackageCode" = "8:{5BF3262C-2333-4832-8B10-16110C424D9A}" 321 | "UpgradeCode" = "8:{514567B4-9AE5-475B-A2EE-158D16192BB6}" 322 | "AspNetVersion" = "8:4.0.30319.0" 323 | "RestartWWWService" = "11:FALSE" 324 | "RemovePreviousVersions" = "11:FALSE" 325 | "DetectNewerInstalledVersion" = "11:TRUE" 326 | "InstallAllUsers" = "11:FALSE" 327 | "ProductVersion" = "8:1.0.0" 328 | "Manufacturer" = "8:HP Inc." 329 | "ARPHELPTELEPHONE" = "8:" 330 | "ARPHELPLINK" = "8:" 331 | "Title" = "8:RealSenseclient" 332 | "Subject" = "8:" 333 | "ARPCONTACT" = "8:HP Inc." 334 | "Keywords" = "8:" 335 | "ARPCOMMENTS" = "8:" 336 | "ARPURLINFOABOUT" = "8:" 337 | "ARPPRODUCTICON" = "8:" 338 | "ARPIconIndex" = "3:0" 339 | "SearchPath" = "8:" 340 | "UseSystemSearchPath" = "11:TRUE" 341 | "TargetPlatform" = "3:0" 342 | "PreBuildEvent" = "8:" 343 | "PostBuildEvent" = "8:" 344 | "RunPostBuildEvent" = "3:0" 345 | } 346 | "Registry" 347 | { 348 | "HKLM" 349 | { 350 | "Keys" 351 | { 352 | "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_F2877B3442164D1A9D6213108ACB4745" 353 | { 354 | "Name" = "8:Software" 355 | "Condition" = "8:" 356 | "AlwaysCreate" = "11:FALSE" 357 | "DeleteAtUninstall" = "11:FALSE" 358 | "Transitive" = "11:FALSE" 359 | "Keys" 360 | { 361 | "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_2DF73BA9978145F38236F990111D0555" 362 | { 363 | "Name" = "8:[Manufacturer]" 364 | "Condition" = "8:" 365 | "AlwaysCreate" = "11:FALSE" 366 | "DeleteAtUninstall" = "11:FALSE" 367 | "Transitive" = "11:FALSE" 368 | "Keys" 369 | { 370 | } 371 | "Values" 372 | { 373 | } 374 | } 375 | } 376 | "Values" 377 | { 378 | } 379 | } 380 | } 381 | } 382 | "HKCU" 383 | { 384 | "Keys" 385 | { 386 | "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_2184FA1B96F84BF2863F84458B72469F" 387 | { 388 | "Name" = "8:Software" 389 | "Condition" = "8:" 390 | "AlwaysCreate" = "11:FALSE" 391 | "DeleteAtUninstall" = "11:FALSE" 392 | "Transitive" = "11:FALSE" 393 | "Keys" 394 | { 395 | "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_40CEF16D39CC4CBBBCF6EEA253C557DA" 396 | { 397 | "Name" = "8:[Manufacturer]" 398 | "Condition" = "8:" 399 | "AlwaysCreate" = "11:FALSE" 400 | "DeleteAtUninstall" = "11:FALSE" 401 | "Transitive" = "11:FALSE" 402 | "Keys" 403 | { 404 | } 405 | "Values" 406 | { 407 | } 408 | } 409 | } 410 | "Values" 411 | { 412 | } 413 | } 414 | } 415 | } 416 | "HKCR" 417 | { 418 | "Keys" 419 | { 420 | } 421 | } 422 | "HKU" 423 | { 424 | "Keys" 425 | { 426 | } 427 | } 428 | "HKPU" 429 | { 430 | "Keys" 431 | { 432 | } 433 | } 434 | } 435 | "Sequences" 436 | { 437 | } 438 | "Shortcut" 439 | { 440 | "{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_5C2BCE3024C04F1790AEB31029A33FF6" 441 | { 442 | "Name" = "8:RealSenseClient" 443 | "Arguments" = "8:" 444 | "Description" = "8:" 445 | "ShowCmd" = "3:1" 446 | "IconIndex" = "3:0" 447 | "Transitive" = "11:FALSE" 448 | "Target" = "8:_1582001AF0C0491EA2CC8EBF861F6C8D" 449 | "Folder" = "8:_425F522DA8F1436C83244676BC70D4AA" 450 | "WorkingFolder" = "8:_BD5D6BEB5C3845419F56E060D3146853" 451 | "Icon" = "8:" 452 | "Feature" = "8:" 453 | } 454 | } 455 | "UserInterface" 456 | { 457 | "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_4378765134DE4230A9D6447A917239C1" 458 | { 459 | "Name" = "8:#1900" 460 | "Sequence" = "3:1" 461 | "Attributes" = "3:1" 462 | "Dialogs" 463 | { 464 | "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_3F0E073ADE6447459850ECA42AACD18D" 465 | { 466 | "Sequence" = "3:100" 467 | "DisplayName" = "8:欢迎使用" 468 | "UseDynamicProperties" = "11:TRUE" 469 | "IsDependency" = "11:FALSE" 470 | "SourcePath" = "8:\\VsdWelcomeDlg.wid" 471 | "Properties" 472 | { 473 | "BannerBitmap" 474 | { 475 | "Name" = "8:BannerBitmap" 476 | "DisplayName" = "8:#1001" 477 | "Description" = "8:#1101" 478 | "Type" = "3:8" 479 | "ContextData" = "8:Bitmap" 480 | "Attributes" = "3:4" 481 | "Setting" = "3:1" 482 | "UsePlugInResources" = "11:TRUE" 483 | } 484 | "CopyrightWarning" 485 | { 486 | "Name" = "8:CopyrightWarning" 487 | "DisplayName" = "8:#1002" 488 | "Description" = "8:#1102" 489 | "Type" = "3:3" 490 | "ContextData" = "8:" 491 | "Attributes" = "3:0" 492 | "Setting" = "3:1" 493 | "Value" = "8:#1202" 494 | "DefaultValue" = "8:#1202" 495 | "UsePlugInResources" = "11:TRUE" 496 | } 497 | "Welcome" 498 | { 499 | "Name" = "8:Welcome" 500 | "DisplayName" = "8:#1003" 501 | "Description" = "8:#1103" 502 | "Type" = "3:3" 503 | "ContextData" = "8:" 504 | "Attributes" = "3:0" 505 | "Setting" = "3:1" 506 | "Value" = "8:#1203" 507 | "DefaultValue" = "8:#1203" 508 | "UsePlugInResources" = "11:TRUE" 509 | } 510 | } 511 | } 512 | "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_B79F09CCA4AF49F38FF383E9989E3EC0" 513 | { 514 | "Sequence" = "3:300" 515 | "DisplayName" = "8:确认安装" 516 | "UseDynamicProperties" = "11:TRUE" 517 | "IsDependency" = "11:FALSE" 518 | "SourcePath" = "8:\\VsdConfirmDlg.wid" 519 | "Properties" 520 | { 521 | "BannerBitmap" 522 | { 523 | "Name" = "8:BannerBitmap" 524 | "DisplayName" = "8:#1001" 525 | "Description" = "8:#1101" 526 | "Type" = "3:8" 527 | "ContextData" = "8:Bitmap" 528 | "Attributes" = "3:4" 529 | "Setting" = "3:1" 530 | "UsePlugInResources" = "11:TRUE" 531 | } 532 | } 533 | } 534 | "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_D50F6F37C29A4613BB10007EE98B6484" 535 | { 536 | "Sequence" = "3:200" 537 | "DisplayName" = "8:安装文件夹" 538 | "UseDynamicProperties" = "11:TRUE" 539 | "IsDependency" = "11:FALSE" 540 | "SourcePath" = "8:\\VsdFolderDlg.wid" 541 | "Properties" 542 | { 543 | "BannerBitmap" 544 | { 545 | "Name" = "8:BannerBitmap" 546 | "DisplayName" = "8:#1001" 547 | "Description" = "8:#1101" 548 | "Type" = "3:8" 549 | "ContextData" = "8:Bitmap" 550 | "Attributes" = "3:4" 551 | "Setting" = "3:1" 552 | "UsePlugInResources" = "11:TRUE" 553 | } 554 | "InstallAllUsersVisible" 555 | { 556 | "Name" = "8:InstallAllUsersVisible" 557 | "DisplayName" = "8:#1059" 558 | "Description" = "8:#1159" 559 | "Type" = "3:5" 560 | "ContextData" = "8:1;True=1;False=0" 561 | "Attributes" = "3:0" 562 | "Setting" = "3:0" 563 | "Value" = "3:1" 564 | "DefaultValue" = "3:1" 565 | "UsePlugInResources" = "11:TRUE" 566 | } 567 | } 568 | } 569 | } 570 | } 571 | "{2479F3F5-0309-486D-8047-8187E2CE5BA0}:_594861B6D8B9416ABE5B0EC25C26BB5B" 572 | { 573 | "UseDynamicProperties" = "11:FALSE" 574 | "IsDependency" = "11:FALSE" 575 | "SourcePath" = "8:\\VsdUserInterface.wim" 576 | } 577 | "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_A1DA1831BC984315942CE977C70BFABE" 578 | { 579 | "Name" = "8:#1902" 580 | "Sequence" = "3:2" 581 | "Attributes" = "3:3" 582 | "Dialogs" 583 | { 584 | "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_EDB5839FE2BB4554A1CB1F6E6163FFCF" 585 | { 586 | "Sequence" = "3:100" 587 | "DisplayName" = "8:已完成" 588 | "UseDynamicProperties" = "11:TRUE" 589 | "IsDependency" = "11:FALSE" 590 | "SourcePath" = "8:\\VsdAdminFinishedDlg.wid" 591 | "Properties" 592 | { 593 | "BannerBitmap" 594 | { 595 | "Name" = "8:BannerBitmap" 596 | "DisplayName" = "8:#1001" 597 | "Description" = "8:#1101" 598 | "Type" = "3:8" 599 | "ContextData" = "8:Bitmap" 600 | "Attributes" = "3:4" 601 | "Setting" = "3:1" 602 | "UsePlugInResources" = "11:TRUE" 603 | } 604 | } 605 | } 606 | } 607 | } 608 | "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_BF7AE481C1214C4782CBF83EB064D9D1" 609 | { 610 | "Name" = "8:#1901" 611 | "Sequence" = "3:2" 612 | "Attributes" = "3:2" 613 | "Dialogs" 614 | { 615 | "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_63D12EB8FEA34AD189CC65325B604995" 616 | { 617 | "Sequence" = "3:100" 618 | "DisplayName" = "8:进度" 619 | "UseDynamicProperties" = "11:TRUE" 620 | "IsDependency" = "11:FALSE" 621 | "SourcePath" = "8:\\VsdAdminProgressDlg.wid" 622 | "Properties" 623 | { 624 | "BannerBitmap" 625 | { 626 | "Name" = "8:BannerBitmap" 627 | "DisplayName" = "8:#1001" 628 | "Description" = "8:#1101" 629 | "Type" = "3:8" 630 | "ContextData" = "8:Bitmap" 631 | "Attributes" = "3:4" 632 | "Setting" = "3:1" 633 | "UsePlugInResources" = "11:TRUE" 634 | } 635 | "ShowProgress" 636 | { 637 | "Name" = "8:ShowProgress" 638 | "DisplayName" = "8:#1009" 639 | "Description" = "8:#1109" 640 | "Type" = "3:5" 641 | "ContextData" = "8:1;True=1;False=0" 642 | "Attributes" = "3:0" 643 | "Setting" = "3:0" 644 | "Value" = "3:1" 645 | "DefaultValue" = "3:1" 646 | "UsePlugInResources" = "11:TRUE" 647 | } 648 | } 649 | } 650 | } 651 | } 652 | "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_DAB6D7C663E54CE89EFA1614D589C43D" 653 | { 654 | "Name" = "8:#1901" 655 | "Sequence" = "3:1" 656 | "Attributes" = "3:2" 657 | "Dialogs" 658 | { 659 | "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_3390D87392BA4FD5A094649DFE2B84BA" 660 | { 661 | "Sequence" = "3:100" 662 | "DisplayName" = "8:进度" 663 | "UseDynamicProperties" = "11:TRUE" 664 | "IsDependency" = "11:FALSE" 665 | "SourcePath" = "8:\\VsdProgressDlg.wid" 666 | "Properties" 667 | { 668 | "BannerBitmap" 669 | { 670 | "Name" = "8:BannerBitmap" 671 | "DisplayName" = "8:#1001" 672 | "Description" = "8:#1101" 673 | "Type" = "3:8" 674 | "ContextData" = "8:Bitmap" 675 | "Attributes" = "3:4" 676 | "Setting" = "3:1" 677 | "UsePlugInResources" = "11:TRUE" 678 | } 679 | "ShowProgress" 680 | { 681 | "Name" = "8:ShowProgress" 682 | "DisplayName" = "8:#1009" 683 | "Description" = "8:#1109" 684 | "Type" = "3:5" 685 | "ContextData" = "8:1;True=1;False=0" 686 | "Attributes" = "3:0" 687 | "Setting" = "3:0" 688 | "Value" = "3:1" 689 | "DefaultValue" = "3:1" 690 | "UsePlugInResources" = "11:TRUE" 691 | } 692 | } 693 | } 694 | } 695 | } 696 | "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_E26BE336D2FD4622AE7AC4265967280F" 697 | { 698 | "Name" = "8:#1902" 699 | "Sequence" = "3:1" 700 | "Attributes" = "3:3" 701 | "Dialogs" 702 | { 703 | "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_5770F6D59F1041298335EA3D24B0355D" 704 | { 705 | "Sequence" = "3:100" 706 | "DisplayName" = "8:已完成" 707 | "UseDynamicProperties" = "11:TRUE" 708 | "IsDependency" = "11:FALSE" 709 | "SourcePath" = "8:\\VsdFinishedDlg.wid" 710 | "Properties" 711 | { 712 | "BannerBitmap" 713 | { 714 | "Name" = "8:BannerBitmap" 715 | "DisplayName" = "8:#1001" 716 | "Description" = "8:#1101" 717 | "Type" = "3:8" 718 | "ContextData" = "8:Bitmap" 719 | "Attributes" = "3:4" 720 | "Setting" = "3:1" 721 | "UsePlugInResources" = "11:TRUE" 722 | } 723 | "UpdateText" 724 | { 725 | "Name" = "8:UpdateText" 726 | "DisplayName" = "8:#1058" 727 | "Description" = "8:#1158" 728 | "Type" = "3:15" 729 | "ContextData" = "8:" 730 | "Attributes" = "3:0" 731 | "Setting" = "3:1" 732 | "Value" = "8:#1258" 733 | "DefaultValue" = "8:#1258" 734 | "UsePlugInResources" = "11:TRUE" 735 | } 736 | } 737 | } 738 | } 739 | } 740 | "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_EFCB5865E9B14A239AF2BBE416634E21" 741 | { 742 | "Name" = "8:#1900" 743 | "Sequence" = "3:2" 744 | "Attributes" = "3:1" 745 | "Dialogs" 746 | { 747 | "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_70E15570568D4AACAAE6C3B8E86C4390" 748 | { 749 | "Sequence" = "3:100" 750 | "DisplayName" = "8:欢迎使用" 751 | "UseDynamicProperties" = "11:TRUE" 752 | "IsDependency" = "11:FALSE" 753 | "SourcePath" = "8:\\VsdAdminWelcomeDlg.wid" 754 | "Properties" 755 | { 756 | "BannerBitmap" 757 | { 758 | "Name" = "8:BannerBitmap" 759 | "DisplayName" = "8:#1001" 760 | "Description" = "8:#1101" 761 | "Type" = "3:8" 762 | "ContextData" = "8:Bitmap" 763 | "Attributes" = "3:4" 764 | "Setting" = "3:1" 765 | "UsePlugInResources" = "11:TRUE" 766 | } 767 | "CopyrightWarning" 768 | { 769 | "Name" = "8:CopyrightWarning" 770 | "DisplayName" = "8:#1002" 771 | "Description" = "8:#1102" 772 | "Type" = "3:3" 773 | "ContextData" = "8:" 774 | "Attributes" = "3:0" 775 | "Setting" = "3:1" 776 | "Value" = "8:#1202" 777 | "DefaultValue" = "8:#1202" 778 | "UsePlugInResources" = "11:TRUE" 779 | } 780 | "Welcome" 781 | { 782 | "Name" = "8:Welcome" 783 | "DisplayName" = "8:#1003" 784 | "Description" = "8:#1103" 785 | "Type" = "3:3" 786 | "ContextData" = "8:" 787 | "Attributes" = "3:0" 788 | "Setting" = "3:1" 789 | "Value" = "8:#1203" 790 | "DefaultValue" = "8:#1203" 791 | "UsePlugInResources" = "11:TRUE" 792 | } 793 | } 794 | } 795 | "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_856848DFD7464851BB801CD2F153D008" 796 | { 797 | "Sequence" = "3:300" 798 | "DisplayName" = "8:确认安装" 799 | "UseDynamicProperties" = "11:TRUE" 800 | "IsDependency" = "11:FALSE" 801 | "SourcePath" = "8:\\VsdAdminConfirmDlg.wid" 802 | "Properties" 803 | { 804 | "BannerBitmap" 805 | { 806 | "Name" = "8:BannerBitmap" 807 | "DisplayName" = "8:#1001" 808 | "Description" = "8:#1101" 809 | "Type" = "3:8" 810 | "ContextData" = "8:Bitmap" 811 | "Attributes" = "3:4" 812 | "Setting" = "3:1" 813 | "UsePlugInResources" = "11:TRUE" 814 | } 815 | } 816 | } 817 | "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_8D6214D80E094E878380737FF31C8A7B" 818 | { 819 | "Sequence" = "3:200" 820 | "DisplayName" = "8:安装文件夹" 821 | "UseDynamicProperties" = "11:TRUE" 822 | "IsDependency" = "11:FALSE" 823 | "SourcePath" = "8:\\VsdAdminFolderDlg.wid" 824 | "Properties" 825 | { 826 | "BannerBitmap" 827 | { 828 | "Name" = "8:BannerBitmap" 829 | "DisplayName" = "8:#1001" 830 | "Description" = "8:#1101" 831 | "Type" = "3:8" 832 | "ContextData" = "8:Bitmap" 833 | "Attributes" = "3:4" 834 | "Setting" = "3:1" 835 | "UsePlugInResources" = "11:TRUE" 836 | } 837 | } 838 | } 839 | } 840 | } 841 | "{2479F3F5-0309-486D-8047-8187E2CE5BA0}:_FB6A306C11CA4FB5843E20A0F94C3554" 842 | { 843 | "UseDynamicProperties" = "11:FALSE" 844 | "IsDependency" = "11:FALSE" 845 | "SourcePath" = "8:\\VsdBasicDialogs.wim" 846 | } 847 | } 848 | "MergeModule" 849 | { 850 | } 851 | "ProjectOutput" 852 | { 853 | "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_1582001AF0C0491EA2CC8EBF861F6C8D" 854 | { 855 | "SourcePath" = "8:..\\obj\\x64\\Debug\\DF_FaceTracking.cs.exe" 856 | "TargetName" = "8:" 857 | "Tag" = "8:" 858 | "Folder" = "8:_BD5D6BEB5C3845419F56E060D3146853" 859 | "Condition" = "8:" 860 | "Transitive" = "11:FALSE" 861 | "Vital" = "11:TRUE" 862 | "ReadOnly" = "11:FALSE" 863 | "Hidden" = "11:FALSE" 864 | "System" = "11:FALSE" 865 | "Permanent" = "11:FALSE" 866 | "SharedLegacy" = "11:FALSE" 867 | "PackageAs" = "3:1" 868 | "Register" = "3:1" 869 | "Exclude" = "11:FALSE" 870 | "IsDependency" = "11:FALSE" 871 | "IsolateTo" = "8:" 872 | "ProjectOutputGroupRegister" = "3:1" 873 | "OutputConfiguration" = "8:" 874 | "OutputGroupCanonicalName" = "8:Built" 875 | "OutputProjectGuid" = "8:{DED2187A-52A5-466E-8B3D-BFF013770412}" 876 | "ShowKeyOutput" = "11:TRUE" 877 | "ExcludeFilters" 878 | { 879 | } 880 | } 881 | } 882 | } 883 | } 884 | -------------------------------------------------------------------------------- /WriteLog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace DF_FaceTracking.cs 10 | { 11 | class WriteLog 12 | { 13 | private static StreamWriter streamWriter; //写文件 14 | 15 | 16 | public static void WriteError(string message) 17 | { 18 | try 19 | { 20 | //DateTime dt = new DateTime(); 21 | string directPath = ConfigurationManager.AppSettings["LogFilePath"].ToString().Trim(); //在获得文件夹路径 22 | if (!Directory.Exists(directPath)) //判断文件夹是否存在,如果不存在则创建 23 | { 24 | Directory.CreateDirectory(directPath); 25 | } 26 | directPath += string.Format(@"\{0}.log", DateTime.Now.ToString("yyyy-MM-dd")); 27 | if (streamWriter == null) 28 | { 29 | streamWriter = !System.IO.File.Exists(directPath) ? System.IO.File.CreateText(directPath) : System.IO.File.AppendText(directPath); //判断文件是否存在如果不存在则创建,如果存在则添加。 30 | } 31 | streamWriter.WriteLine("***********************************************************************"); 32 | streamWriter.WriteLine(DateTime.Now.ToString("HH:mm:ss")); 33 | streamWriter.WriteLine("输出信息:错误信息"); 34 | if (message != null) 35 | { 36 | streamWriter.WriteLine("异常信息:\r\n" + message); 37 | } 38 | } 39 | finally 40 | { 41 | if (streamWriter != null) 42 | { 43 | streamWriter.Flush(); 44 | streamWriter.Dispose(); 45 | streamWriter = null; 46 | } 47 | } 48 | } 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /intel.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmaxhao/FaceFeatureClient/d45758f7eec0f7d0c6d6c29c5683dd42bfd5f6ff/intel.ico -------------------------------------------------------------------------------- /libpxcclr.cs.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmaxhao/FaceFeatureClient/d45758f7eec0f7d0c6d6c29c5683dd42bfd5f6ff/libpxcclr.cs.dll -------------------------------------------------------------------------------- /libpxccpp2c.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmaxhao/FaceFeatureClient/d45758f7eec0f7d0c6d6c29c5683dd42bfd5f6ff/libpxccpp2c.dll -------------------------------------------------------------------------------- /packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /timer.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace DF_FaceTracking.cs 4 | { 5 | class FPSTimer 6 | { 7 | [DllImport("Kernel32.dll")] 8 | private static extern bool QueryPerformanceCounter(out long data); 9 | [DllImport("Kernel32.dll")] 10 | private static extern bool QueryPerformanceFrequency(out long data); 11 | 12 | private MainForm form; 13 | private long freq, last; 14 | private int fps; 15 | 16 | public FPSTimer(MainForm mf) 17 | { 18 | form = mf; 19 | QueryPerformanceFrequency(out freq); 20 | fps = 0; 21 | QueryPerformanceCounter(out last); 22 | } 23 | 24 | public void Tick(string text) 25 | { 26 | long now; 27 | QueryPerformanceCounter(out now); 28 | fps++; 29 | if (now - last > freq) // update every second 30 | { 31 | last = now; 32 | form.UpdateStatus(text+" FPS=" + fps, MainForm.Label.StatusLabel); 33 | fps = 0; 34 | } 35 | } 36 | } 37 | } 38 | --------------------------------------------------------------------------------