public void onPreviewFrame(byte[] data, int rotation, int width, int height) { int[] argb = argbPool.acquire(width, height); if (argb == null || argb.Length != width * height) { argb = new int[width * height]; } rotation = rotation < 0 ? 360 + rotation : rotation; long starttime = DateTime.Now.Millisecond; FaceDetector.yuvToARGB(data, width, height, argb, rotation, 0); // 旋转了90或270度。高宽需要替换 if (rotation % 180 == 90) { int temp = width; width = height; height = temp; } ImageFrame frame = new ImageFrame(); frame.setArgb(argb); frame.setWidth(width); frame.setHeight(height); frame.setPool(argbPool); List <OnFrameAvailableListener> listeners = getListeners(); foreach (OnFrameAvailableListener listener in listeners) { listener.onFrameAvailable(frame); } argbPool.release(argb); }
private FaceSDKManager() { faceDetector = new FaceDetector(); faceFeature = new FaceFeature(); }