關于百度新版活體離線檢測SDK無法橫屏檢測
FaceDetectActivity 中onPreviewFrame(byte[] data, Camera camera)

獲得視頻幀數(shù)據(jù),mPreviewDegree為當前的橫豎屏角度
```
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
if (mIsCompletion) {
return;
? ? }
//saveImageBitmap(BitmapUtils.getYUVBitmap(data,camera));
? ? Log.i(TAG,"data22222 = "+data+"----data.lenght="+data.length);
? ? if (mIDetectStrategy ==null &&mFaceDetectRoundView !=null &&mFaceDetectRoundView.getRound() >0) {
mIDetectStrategy = FaceSDKManager.getInstance().getDetectStrategyModule();
? ? ? ? //設置預覽圖片的旋轉角度
? ? ? ? mIDetectStrategy.setPreviewDegree(360-mPreviewDegree);
? ? ? ? mIDetectStrategy.setDetectStrategySoundEnable(mIsEnableSound);
? ? ? ? Rect detectRect = FaceDetectRoundView.getPreviewDetectRect(mDisplayWidth,mPreviewWidth , mPreviewHight);
? ? ? ? mIDetectStrategy.setDetectStrategyConfig(mPreviewRect, detectRect, this);
? ? }
if (mIDetectStrategy !=null) {
mIDetectStrategy.detectStrategy(data);
? ? }
}
```
為了解決橫屏無法檢測問題,增加以下核心代碼
在FaceModule.java ?的faceTrackerDecode方法
,增加以下代碼,橫屏狀態(tài)下,調換寬高

// 旋轉了0度000000000000000000。高寬需要替換,橫屏狀態(tài)調換寬高
```
if (mDegree %180 ==0) {
int temp = imageWidth;
? ? imageWidth = imageHeight;
? ? imageHeight = temp;
}
==================================================
int argb = FaceSDK.getARGBFromYUVimg(imageData, mArgbData,
? ? ? ? imageWidth, imageHeight,
? ? ? ? mDegree, 0);
Log.i(TAG,"argb="+argb);
// 旋轉了0度000000000000000000。高寬需要替換,橫屏狀態(tài)調換寬高
if (mDegree %180 ==0) {
int temp = imageWidth;
? ? imageWidth = imageHeight;
? ? imageHeight = temp;
}
// rows=768-cols=432
FaceTracker.ErrCode errorCode =mFaceTracker.faceVerification(
mArgbData,
imageWidth, imageHeight,
FaceSDK.ImgType.ARGB,
FaceTracker.ActionType.RECOGNIZE);
```
橫屏檢測ok,謝謝
覺得有用的話,就請小菜喝杯奶茶吧