1
z8018
2025-06-06 7876ac5d67b12e206a68db17c4034df52fa2f060
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
//using System;
//using System.IO;
//using System.Threading;
//using System.Collections;
//using System.Runtime.InteropServices;
//using System.Collections.Generic;
//using OpenCvSharp;
 
//namespace FaceAI
//{
//    [StructLayout(LayoutKind.Sequential, Pack = 1)]
//    // 活体分值
//    struct BDLivenessScore
//    {
//        public float score; //分值
//    };
//    // 活体检测
//    class FaceLiveness
//    {
//        // 单目RGB静默活体检测
//        [DllImport("BaiduFaceApi.dll", EntryPoint = "rgb_liveness", CharSet = CharSet.Ansi
//           , CallingConvention = CallingConvention.Cdecl)]
//        public static extern int rgb_liveness(IntPtr ptr_boxinfo, IntPtr ptr_score, IntPtr mat);
 
//        // 单目近红外静默活体检测
//        [DllImport("BaiduFaceApi.dll", EntryPoint = "nir_liveness", CharSet = CharSet.Ansi
//           , CallingConvention = CallingConvention.Cdecl)]
//        public static extern int nir_liveness(IntPtr ptr_boxinfo, IntPtr ptr_score, IntPtr mat);
 
//        // 双目深度静默活体检测
//        [DllImport("BaiduFaceApi.dll", EntryPoint = "rgb_depth_liveness", CharSet = CharSet.Ansi
//           , CallingConvention = CallingConvention.Cdecl)]
//        public static extern int rgb_depth_liveness(IntPtr ptr_boxinfo, IntPtr ptr_rgbscore, IntPtr ptr_depthcore, IntPtr rgb_mat, IntPtr depth_mat);
              
 
//        public void test_liveness_by_image()
//        {
//            // rgb 活体检测
//            string img_rgb = "../images/rgb.png";
//            liveness_check(img_rgb, 0);
//            // nir 活体检测
//            string img_nir = "../images/nir.png";
//           // liveness_check(img_nir, 1);
           
//        }
 
//        // 测试单目RGB静默活体检测(传入图片文件路径,活体类型)
//        public void liveness_check(string img_path, int live_type)
//        {
//            Mat mat = Cv2.ImRead(img_path);
//            int max_face_num = 1; // 活体仅返回一个人脸,多人取最大人脸
 
//            BDFaceBBox[] box_info = new BDFaceBBox[max_face_num];
            
//            int sizeBox = Marshal.SizeOf(typeof(BDFaceBBox));
//            IntPtr ptT = Marshal.AllocHGlobal(sizeBox * max_face_num);
           
 
//            BDLivenessScore[] score_info = new BDLivenessScore[max_face_num];
//            int sizeScore = Marshal.SizeOf(typeof(BDLivenessScore));
//            IntPtr ptS = Marshal.AllocHGlobal(sizeScore * max_face_num);
//            // faceNum为返回的检测到的人脸个数
//            int faceNum = 0;
//            if (live_type == 0)
//            {
//                faceNum = rgb_liveness(ptT, ptS, mat.CvPtr);
//            }
//            else if (live_type == 1)
//            {
//                faceNum = nir_liveness(ptT, ptS, mat.CvPtr);
//            }
//            mat.Release();
 
 
//            Console.WriteLine("faceSize is:" + faceNum);
//            for (int index = 0; index < faceNum; index++)
//            {
 
//                IntPtr ptr = new IntPtr();
//                IntPtr ptrScore = new IntPtr();
//                if (8 == IntPtr.Size)
//                {
//                    ptr = (IntPtr)(ptT.ToInt64() + sizeBox * index);
//                    ptrScore = (IntPtr)(ptS.ToInt64() + sizeScore * index);
//                }
//                else if (4 == IntPtr.Size)
//                {
//                    ptr = (IntPtr)(ptT.ToInt32() + sizeBox * index);
//                    ptrScore = (IntPtr)(ptS.ToInt32() + sizeScore * index);
//                }
 
//                box_info[index] = (BDFaceBBox)Marshal.PtrToStructure(ptr, typeof(BDFaceBBox));
 
//                score_info[index] = (BDLivenessScore)Marshal.PtrToStructure(ptrScore, typeof(BDLivenessScore));
              
//                // 索引值
//                Console.WriteLine("track index is:{0}", box_info[index].index);
//                // 置信度
//                Console.WriteLine("track score is:{0}", box_info[index].score);              
//                // 人脸宽度
//                Console.WriteLine("track mWidth is:{0}", box_info[index].width);
//                // 中心点X,Y坐标
//                Console.WriteLine("track mCenter_x is:{0}", box_info[index].center_x);
//                Console.WriteLine("track mCenter_y is:{0}", box_info[index].center_y);
//                // rgb 活体分值
//                Console.WriteLine("liveness score is:{0}", score_info[index].score);
 
//            }
//            Marshal.FreeHGlobal(ptT);
//        }
 
//        // 选择usb视频摄像头id,方法里面有获取连接的摄像头列表,包括id,名称和路径等
//        public int select_usb_device_id()
//        {
//            ArrayList capDevs = new ArrayList();
//            int device_id = 0;
//            try
//            {
//                if (!File.Exists(Path.Combine(Environment.SystemDirectory, @"dpnhpast.dll")))
//                {
//                    Console.WriteLine("DirectX NOT installed!");
//                    return - 1;
//                }
//                if (!DevEnum.GetDevicesOfCat(FilterCategory.VideoInputDevice, out capDevs))
//                {
//                    Console.WriteLine("No video capture devices found!");
//                    return -1;
//                }
//                if (capDevs.Count < 2)
//                {
//                    Console.WriteLine("ir and rgb camera devices needed");
//                    return -1;
//                }
//                foreach (DsDevice d in capDevs) {
//                    Console.WriteLine("== VIDEO DEVICE (id:{0}) ==", d.id);
//                    Console.WriteLine("Name: {0}", d.Name);
//                    Console.WriteLine("Path: {0}", d.Path);
//                }
 
//                if (capDevs.Count > 0)
//                {
//                    device_id = ((DsDevice)capDevs[0]).id;
//                    Console.WriteLine("select device id is:{0}", device_id);
//                }
//            }
//            catch(Exception)
//            {
//                if (capDevs != null)
//                {
//                    foreach (DsDevice d in capDevs)
//                        d.Dispose();
//                    capDevs = null;
//                }
//                return -1;
//            }
//            return device_id;
//        }
 
//        // 双目RGB和IR静默活体检测(可使用迪威泰或视派尔等rgb+nir双目摄像头),rgb和nir的分值都通过如0.8才算活体通过
//        public bool rgb_ir_liveness_check_mat()
//        {
//            int max_face_num = 1;//取最大人脸的活体
//            BDLivenessScore[] rgb_score_info = new BDLivenessScore[max_face_num];
//            BDLivenessScore[] nir_score_info = new BDLivenessScore[max_face_num];
//            int sizeScore = Marshal.SizeOf(typeof(BDLivenessScore));
//            IntPtr ptSRGB = Marshal.AllocHGlobal(sizeScore * max_face_num);
//            IntPtr ptSNIR = Marshal.AllocHGlobal(sizeScore * max_face_num);
 
//            // 初始化rgb 返回的人脸数据
//            BDFaceBBox[] rgb_box_info = new BDFaceBBox[max_face_num];
            
//            int sizeBox = Marshal.SizeOf(typeof(BDFaceBBox));
//            IntPtr ptTRGB = Marshal.AllocHGlobal(sizeBox * max_face_num);
 
//            // 初始化nir 返回的人脸数据
//            BDFaceBBox[] nir_box_info = new BDFaceBBox[max_face_num];
            
//            sizeBox = Marshal.SizeOf(typeof(BDFaceBBox));
//            IntPtr ptTNIR = Marshal.AllocHGlobal(sizeBox * max_face_num);
 
//            // 序号0为电脑识别的usb摄像头编号,本demo中0为ir红外摄像头
//            // 不同摄像头和电脑识别可能有区别
//            // 编号一般从0-10   */            
//            int device = select_usb_device_id();
//            VideoCapture camera1 = VideoCapture.FromCamera(device);
//            if(!camera1.IsOpened())
//            {
//                Console.WriteLine("camera1 open error");
//                return false;
//            }
 
//            VideoCapture camera2 = VideoCapture.FromCamera(device+1);
//            if (!camera2.IsOpened())
//            {
//                Console.WriteLine("camera2 open error");
//                return false;
//            }
 
//            Mat frame1 = new Mat();
//            Mat frame2 = new Mat();
//            Mat rgb_mat = new Mat();
//            Mat ir_mat = new Mat();
//            var window_ir = new Window("ir_face");
//            var window_rgb = new Window("rgb_face");
//            while (true)
//            {               
//                camera1.Read(frame1);
//                camera2.Read(frame2);
//                if(!frame1.Empty() && !frame2.Empty())
//                {                   
//                    if (frame1.Channels() == 3)
//                    {
//                        rgb_mat = frame1;
//                        ir_mat = frame2;
//                    }
//                    else
//                    {
//                        rgb_mat = frame2;
//                        ir_mat = frame1;
//                    }
//                    float rgb_score = 0;
//                    float ir_score = 0;
 
//                    int face_size = 0;
//                    int nir_size = nir_liveness(ptTNIR, ptSNIR, ir_mat.CvPtr);
//                    int rgb_size = rgb_liveness(ptTRGB, ptSRGB, rgb_mat.CvPtr);
                    
//                    face_size = nir_size <= rgb_size?nir_size:rgb_size;                
//                    // 获取的人脸数
//                    Console.WriteLine("faceNum is:{0}", face_size);
//                    for (int index = 0; index < face_size; index++)
//                    {
                        
//                        IntPtr ptrBox = new IntPtr();
//                        IntPtr ptrRGBScore = new IntPtr();
//                        IntPtr ptrNIRScore = new IntPtr();
//                        if (8 == IntPtr.Size)
//                        {
//                            ptrBox = (IntPtr)(ptTRGB.ToInt64() + sizeBox * index);
//                            ptrRGBScore = (IntPtr)(ptSRGB.ToInt64() + sizeScore * index);
//                            ptrNIRScore = (IntPtr)(ptSNIR.ToInt64() + sizeScore * index);
//                        }
//                        else if (4 == IntPtr.Size)
//                        {
//                            ptrBox = (IntPtr)(ptTRGB.ToInt32() + sizeBox * index);
//                            ptrRGBScore = (IntPtr)(ptSRGB.ToInt32() + sizeScore * index);
//                            ptrNIRScore = (IntPtr)(ptSNIR.ToInt32() + sizeScore * index);
//                        }
                        
//                        rgb_box_info[index] = (BDFaceBBox)Marshal.PtrToStructure(ptrBox, typeof(BDFaceBBox));
                        
//                        rgb_score_info[index] = (BDLivenessScore)Marshal.PtrToStructure(ptrRGBScore, typeof(BDLivenessScore));
//                        nir_score_info[index] = (BDLivenessScore)Marshal.PtrToStructure(ptrNIRScore, typeof(BDLivenessScore));
//                        rgb_score = rgb_score_info[index].score;
//                        ir_score = nir_score_info[index].score;
//                        if (rgb_score <= 0.1f)
//                        {
//                            rgb_score = 0;
//                        }
//                        if (ir_score <= 0.1f)
//                        {
//                            ir_score = 0;
//                        }
//                        Console.WriteLine("demo ccccc");                     
//                        // 人脸宽度
//                        Console.WriteLine("mWidth is:{0:f}", rgb_box_info[index].width);
//                        // 中心点X,Y坐标
//                        Console.WriteLine("mCenter_x is:{0:f}", rgb_box_info[index].center_x);
//                        Console.WriteLine("mCenter_y is:{0:f}", rgb_box_info[index].center_y);
                                          
//                    }
                    
//                    string msg_depth = "ir score is:" + ir_score.ToString();
                   
//                    Cv2.PutText(ir_mat, msg_depth, new Point(20, 50), HersheyFonts.HersheyComplex, 1, new Scalar(255, 100, 0));
                   
//                    string msg_rgb = "rgb score is:" + rgb_score.ToString();
//                    Cv2.PutText(rgb_mat, msg_rgb, new Point(20, 50), HersheyFonts.HersheyComplex, 1, new Scalar(255, 100, 0));
//                    if (face_size > 0)
//                    {
//                        // 画人脸框
//                        FaceDraw.draw_rects(ref rgb_mat, face_size, rgb_box_info);
//                        // 画关键点
//                        // FaceDraw.draw_shape(ref rgb_mat, face_size, rgb_track_info);
//                    }                   
//                    window_rgb.ShowImage(rgb_mat);
//                    window_ir.ShowImage(ir_mat);
//                    Cv2.WaitKey(1);                   
//                }
//            }
//            Marshal.FreeHGlobal(ptTRGB);
//            Marshal.FreeHGlobal(ptTNIR);
//            rgb_mat.Release();
//            ir_mat.Release();
//            frame1.Release();
//            frame2.Release();
//            Cv2.DestroyWindow("ir_face");
//            Cv2.DestroyWindow("rgb_face");
//            return true;
//        }
//        // 双目摄像头进行rgb,depth活体检测(此处适配了华杰艾米的双目摄像头)rgb和depth的分值都通过如0.8才算活体通过
//        public bool rgb_depth_liveness_check_hjimi()
//        {
//            int max_face_num = 1;//取最大人脸的活体
          
//            BDLivenessScore[] rgb_score_info = new BDLivenessScore[max_face_num];
//            BDLivenessScore[] depth_score_info = new BDLivenessScore[max_face_num];
//            int sizeScore = Marshal.SizeOf(typeof(BDLivenessScore));
//            IntPtr ptRGBS = Marshal.AllocHGlobal(sizeScore * max_face_num);
//            IntPtr ptDepthS = Marshal.AllocHGlobal(sizeScore * max_face_num);
 
//            BDFaceBBox[] box_info = new BDFaceBBox[max_face_num];
           
//            int sizeBox = Marshal.SizeOf(typeof(BDFaceBBox));
//            IntPtr ptT = Marshal.AllocHGlobal(sizeBox * max_face_num);
//            IntPtr phjimi = HjimiCamera.new_hjimi();
//            var rgb_win = new Window("rgb", WindowMode.AutoSize);
//            var depth_win = new Window("depth", WindowMode.Normal);
//            float rgb_score = 0;
//            float depth_score = 0;
//            Mat cv_depth = new Mat();
//            Mat cv_rgb = new Mat();
//            while (true)
//            {
//                bool ok = HjimiCamera.open_hjimimat(phjimi, cv_rgb.CvPtr, cv_depth.CvPtr);
//                if (!ok)
//                {
//                    depth_score = 0;
//                    rgb_score = depth_score; 
//                    Console.WriteLine("open camera faile");
//                    continue;
//                }
//                if(cv_rgb.Empty())
//                {
//                    continue;
//                }
//                if (cv_depth.Empty())
//                {
//                    continue;
//                }
//                // 返回人脸个数
//                int face_size = rgb_depth_liveness(ptT, ptRGBS, ptDepthS, cv_rgb.CvPtr, cv_depth.CvPtr);
                
//                Console.WriteLine("res is:{0}", face_size);                             
//                depth_score = 0;
//                rgb_score = depth_score;                           
//                for (int index = 0; index < face_size; index++)
//                {
//                    IntPtr ptrBox = new IntPtr();
//                    IntPtr ptrRGBScore = new IntPtr();
//                    IntPtr ptrDepthScore = new IntPtr();
//                    if (8 == IntPtr.Size)
//                    {
//                        ptrBox = (IntPtr)(ptT.ToInt64() + sizeBox * index);
//                        ptrRGBScore = (IntPtr)(ptRGBS.ToInt64() + sizeScore * index);
//                        ptrDepthScore = (IntPtr)(ptDepthS.ToInt64() + sizeScore * index);
//                    }
//                    else if (4 == IntPtr.Size)
//                    {
//                        ptrBox = (IntPtr)(ptT.ToInt32() + sizeBox * index);
//                        ptrRGBScore = (IntPtr)(ptRGBS.ToInt32() + sizeScore * index);
//                        ptrDepthScore = (IntPtr)(ptDepthS.ToInt32() + sizeScore * index);
//                    }
                    
//                    box_info[index] = (BDFaceBBox)Marshal.PtrToStructure(ptrBox, typeof(BDFaceBBox));
                    
//                    rgb_score_info[index] = (BDLivenessScore)Marshal.PtrToStructure(ptrRGBScore, typeof(BDLivenessScore));
//                    rgb_score = rgb_score_info[index].score;
//                    depth_score_info[index] = (BDLivenessScore)Marshal.PtrToStructure(ptrDepthScore, typeof(BDLivenessScore));
//                    depth_score = depth_score_info[index].score;
//                    // 分值太低,会显示小数点太长,直接赋值0
//                    if (depth_score <= 0.1f)
//                    {
//                        depth_score = 0;
//                    }
//                    if (rgb_score <= 0.1f)
//                    {
//                        rgb_score = 0;
//                    }                   
//                    // 人脸宽度
//                    Console.WriteLine("mWidth is:{0:f}", box_info[index].width);
//                    // 中心点X,Y坐标
//                    Console.WriteLine("mCenter_x is:{0:f}", box_info[index].center_x);
//                    Console.WriteLine("mCenter_y is:{0:f}", box_info[index].center_y);
                   
//                } 
              
 
//                Mat depth_img = new Mat();
//                cv_depth.ConvertTo(depth_img, MatType.CV_8UC1, 255.0 / 4500);
//                string msg_depth = "depth score is:" + depth_score.ToString();
//                Cv2.PutText(depth_img, msg_depth, new Point(20, 50), HersheyFonts.HersheyComplex, 1, new Scalar(255, 100, 0));
 
//                string msg_rgb = "rgb score is:" + rgb_score.ToString();
//                Cv2.PutText(cv_rgb, msg_rgb, new Point(20, 50), HersheyFonts.HersheyComplex, 1, new Scalar(255, 100, 0));
//                if (face_size > 0)
//                {
//                    // 画人脸框
//                    FaceDraw.draw_rects(ref cv_rgb, face_size, box_info);
                    
//                }
                
//                rgb_win.ShowImage(cv_rgb);
//                depth_win.ShowImage(depth_img);
//                Cv2.WaitKey(1);
//                depth_img.Release();
//            }
//            Marshal.FreeHGlobal(ptT);
//            cv_rgb.Release();
//            cv_depth.Release();
//            Cv2.DestroyWindow("rgb");
//            Cv2.DestroyWindow("depth");
//            HjimiCamera.hjimi_release(phjimi);
//            return true;
//        }
//        //双目RGB和DEPTH静默活体检测(传入opencv视频帧)适配奥比中光海燕等双目摄像头
//        public bool rgb_depth_liveness_check_orbe()
//        {
//            int max_face_num = 1;//取最大人脸的活体
 
//            BDLivenessScore[] rgb_score_info = new BDLivenessScore[max_face_num];
//            BDLivenessScore[] depth_score_info = new BDLivenessScore[max_face_num];
//            int sizeScore = Marshal.SizeOf(typeof(BDLivenessScore));
//            IntPtr ptRGBS = Marshal.AllocHGlobal(sizeScore * max_face_num);
//            IntPtr ptDepthS = Marshal.AllocHGlobal(sizeScore * max_face_num);
 
//            BDFaceBBox[] box_info = new BDFaceBBox[max_face_num];
            
//            int sizeBox = Marshal.SizeOf(typeof(BDFaceTrackInfo));
//            IntPtr ptT = Marshal.AllocHGlobal(sizeBox * max_face_num);
 
//            IntPtr porbe = OrbeCamera.new_orbe();
//            var rgb_win = new Window("rgb", WindowMode.AutoSize);
//            var depth_win = new Window("depth", WindowMode.Normal);
//            float rgb_score = 0;
//            float depth_score = 0;
//            Mat cv_depth = new Mat();
//            Mat cv_rgb = new Mat();
//            while (true)
//            {
//                int res_ok = OrbeCamera.open_orbe(porbe, cv_rgb.CvPtr, cv_depth.CvPtr);
//                if (res_ok != 0)
//                {
//                    depth_score = 0;
//                    rgb_score = depth_score;
//                    Console.WriteLine("open camera faile");
//                    continue;
//                }
//                if (cv_rgb.Empty())
//                {
//                    continue;
//                }
//                if (cv_depth.Empty())
//                {
//                    continue;
//                }
//                // 返回人脸个数
//                int face_size = rgb_depth_liveness(ptT, ptRGBS, ptDepthS, cv_rgb.CvPtr, cv_depth.CvPtr);
 
//                Console.WriteLine("res is:{0}", face_size);
//                depth_score = 0;
//                rgb_score = depth_score;
//                for (int index = 0; index < face_size; index++)
//                {
//                    IntPtr ptrBox = new IntPtr();
//                    IntPtr ptrRGBScore = new IntPtr();
//                    IntPtr ptrDepthScore = new IntPtr();
//                    if (8 == IntPtr.Size)
//                    {
//                        ptrBox = (IntPtr)(ptT.ToInt64() + sizeBox * index);
//                        ptrRGBScore = (IntPtr)(ptRGBS.ToInt64() + sizeScore * index);
//                        ptrDepthScore = (IntPtr)(ptDepthS.ToInt64() + sizeScore * index);
//                    }
//                    else if (4 == IntPtr.Size)
//                    {
//                        ptrBox = (IntPtr)(ptT.ToInt32() + sizeBox * index);
//                        ptrRGBScore = (IntPtr)(ptRGBS.ToInt32() + sizeScore * index);
//                        ptrDepthScore = (IntPtr)(ptDepthS.ToInt32() + sizeScore * index);
//                    }
 
//                    box_info[index] = (BDFaceBBox)Marshal.PtrToStructure(ptrBox, typeof(BDFaceBBox));  
 
//                    rgb_score_info[index] = (BDLivenessScore)Marshal.PtrToStructure(ptrRGBScore, typeof(BDLivenessScore));
//                    rgb_score = rgb_score_info[index].score;
//                    depth_score_info[index] = (BDLivenessScore)Marshal.PtrToStructure(ptrDepthScore, typeof(BDLivenessScore));
//                    depth_score = depth_score_info[index].score;
//                    // 分值太低,会显示小数点太长,直接赋值0
//                    if (depth_score <= 0.1f)
//                    {
//                        depth_score = 0;
//                    }
//                    if (rgb_score <= 0.1f)
//                    {
//                        rgb_score = 0;
//                    }                    
//                    // 人脸宽度
//                    Console.WriteLine("mWidth is:{0:f}", box_info[index].width);
//                    // 中心点X,Y坐标
//                    Console.WriteLine("mCenter_x is:{0:f}", box_info[index].center_x);
//                    Console.WriteLine("mCenter_y is:{0:f}", box_info[index].center_y);
 
//                }
 
 
//                Mat depth_img = new Mat();
//                cv_depth.ConvertTo(depth_img, MatType.CV_8UC1, 255.0 / 4500);
//                string msg_depth = "depth score is:" + depth_score.ToString();
//                Cv2.PutText(depth_img, msg_depth, new Point(20, 50), HersheyFonts.HersheyComplex, 1, new Scalar(255, 100, 0));
 
//                string msg_rgb = "rgb score is:" + rgb_score.ToString();
//                Cv2.PutText(cv_rgb, msg_rgb, new Point(20, 50), HersheyFonts.HersheyComplex, 1, new Scalar(255, 100, 0));
//                if (face_size > 0)
//                {
//                    // 画人脸框
//                    FaceDraw.draw_rects(ref cv_rgb, face_size, box_info);
//                }
//                rgb_win.ShowImage(cv_rgb);
//                depth_win.ShowImage(depth_img);
//                Cv2.WaitKey(1);
//                depth_img.Release();
//            }
//            Marshal.FreeHGlobal(ptT);
//            cv_rgb.Release();
//            cv_depth.Release();
//            Cv2.DestroyWindow("rgb");
//            Cv2.DestroyWindow("depth");
//            OrbeCamera.orbe_release(porbe);
//            return true;
//        }
             
//        public void test_rgb_ir_liveness_check_by_opencv()
//        {
//            rgb_ir_liveness_check_mat();
//        }
 
//        // 双目RGB和DEPTH静默活体检测,适配奥比中光海燕等双目摄像头
//        public void test_rgb_depth_liveness_check_by_orbe()
//        {
//            rgb_depth_liveness_check_orbe();
//        }
      
//        // 双目摄像头进行rgb,depth活体检测(此处适配了华杰艾米的双目摄像头)
//        public void test_rgb_depth_liveness_check_by_hjimi()
//        {
//            rgb_depth_liveness_check_hjimi();
//        }
//    }
//}