C#下調試百度人臉離線SDK問題集

1、sdk_init 問題

in main
auth result is -1

運行控制檯就停在  auth result is -1  

解決辦法:

使用release 運行而不是使用debug

2、項目路徑問題

因爲我的項目放在了一個帶有中文的路徑下,在使用人臉註冊的時候,出現了問題。

一直報錯   Can't open database: unable to open database file

上網查,關於百度SDK問題,無果,

查關於C# sqllite的問題,無果,

有答案的分2種:

1、權限問題 

運行 calcs  加文件路徑 + 權限 ,嘗試後未解決

2、文件句柄問題

項目多次運行出現了未釋放句柄(因爲是百度底層實現的sql操作,應該不會出現這樣弱智的錯誤)嘗試後無果。

 

最後只能猜是文件路徑問題,轉移文件到根目錄,運行,ok。

3、C#如何實現form窗體預覽 

控件:

using AForge;
using AForge.Controls;
using AForge.Video;
using AForge.Video.DirectShow;
using Size = System.Drawing.Size;

頁面上添加:videoSourcePlayer1

代碼:

videoDevices = new FilterInfoCollection(AForge.Video.DirectShow.FilterCategory.VideoInputDevice);
            index_usb = 1;
                         videoSource = new VideoCaptureDevice(videoDevices[index_usb].MonikerString);//連接攝像頭。
                        videoSource.VideoResolution = videoSource.VideoCapabilities[index_usb];
                         videoSourcePlayer1.VideoSource = videoSource;
                         // set NewFrame event handler
              videoSourcePlayer1.Start();
            timer1.Enabled = true;
            Face.test_face_setting();//人臉識別設置
            Face.test_face_manager();//照片庫管理

         FaceCompare.load_db_face();//將照片庫加載到內存

定時器:

//定時獲取照片 通過照片和加載到內存的照片庫進行比對

 private void timer1_Tick_1(object sender, EventArgs e)
        {
            RotatedRect box;
            Bitmap bitmap = videoSourcePlayer1.GetCurrentVideoFrame();
            string fileName = i+".jpg";
            i++;
            string filePase = @"D:\file\" + fileName;
            bitmap.Save(filePase, ImageFormat.Jpeg);
            FaceCompare  comp = new FaceCompare();
            comp.test_identify_with_all(filePase); //比對照片

            bitmap.Dispose();
           
        }

4、獲取照片分辨率問題

_cameraDevice.VideoResolution = _cameraDevice.VideoCapabilities[15];//分辨率,每個攝像頭獲取到的分辨率數組不同,這裏按需要選擇分辨率。

加上這個,否則照片分辨率太低,也是無法進行讀取特徵值的。會導致識別失敗

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章