Loading app/src/main/java/net/sourceforge/opencamera/Preview/Preview.java +11 −10 Original line number Diff line number Diff line Loading @@ -1905,7 +1905,16 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu return; } // don't assign to faces_detected yet, as that has to be done on the UI thread // convert rects to preview screen space // We don't synchronize on faces_detected, as the array may be passed to other // classes via getFacesDetected(). Although that function could copy instead, // that would mean an allocation in every frame in DrawPreview. // Easier to just do the assignment on the UI thread. Activity activity = (Activity)Preview.this.getContext(); activity.runOnUiThread(new Runnable() { public void run() { // convert rects to preview screen space - also needs to be done on UI thread // (otherwise can have crashes if camera_controller becomes null in the meantime) final Matrix matrix = getCameraToPreviewMatrix(); for(CameraController.Face face : faces) { face_rect.set(face.rect); Loading @@ -1915,13 +1924,6 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu reportFaces(faces); // We don't synchronize on faces_detected, as the array may be passed to other // classes via getFacesDetected(). Although that function could copy instead, // that would mean an allocation in every frame in DrawPreview. // Easier to just do the assignment on the UI thread. Activity activity = (Activity)Preview.this.getContext(); activity.runOnUiThread(new Runnable() { public void run() { if( faces_detected == null || faces_detected.length != faces.length ) { // avoid unnecessary reallocations if( MyDebug.LOG ) Loading @@ -1934,7 +1936,6 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu } /** Accessibility: report number of faces for talkback etc. * Note, at least for Camera2 API, reportFaces() isn't called on UI thread. */ private void reportFaces(CameraController.Face[] local_faces) { if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && accessibility_manager.isEnabled() && accessibility_manager.isTouchExplorationEnabled() ) { Loading Loading
app/src/main/java/net/sourceforge/opencamera/Preview/Preview.java +11 −10 Original line number Diff line number Diff line Loading @@ -1905,7 +1905,16 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu return; } // don't assign to faces_detected yet, as that has to be done on the UI thread // convert rects to preview screen space // We don't synchronize on faces_detected, as the array may be passed to other // classes via getFacesDetected(). Although that function could copy instead, // that would mean an allocation in every frame in DrawPreview. // Easier to just do the assignment on the UI thread. Activity activity = (Activity)Preview.this.getContext(); activity.runOnUiThread(new Runnable() { public void run() { // convert rects to preview screen space - also needs to be done on UI thread // (otherwise can have crashes if camera_controller becomes null in the meantime) final Matrix matrix = getCameraToPreviewMatrix(); for(CameraController.Face face : faces) { face_rect.set(face.rect); Loading @@ -1915,13 +1924,6 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu reportFaces(faces); // We don't synchronize on faces_detected, as the array may be passed to other // classes via getFacesDetected(). Although that function could copy instead, // that would mean an allocation in every frame in DrawPreview. // Easier to just do the assignment on the UI thread. Activity activity = (Activity)Preview.this.getContext(); activity.runOnUiThread(new Runnable() { public void run() { if( faces_detected == null || faces_detected.length != faces.length ) { // avoid unnecessary reallocations if( MyDebug.LOG ) Loading @@ -1934,7 +1936,6 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu } /** Accessibility: report number of faces for talkback etc. * Note, at least for Camera2 API, reportFaces() isn't called on UI thread. */ private void reportFaces(CameraController.Face[] local_faces) { if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && accessibility_manager.isEnabled() && accessibility_manager.isTouchExplorationEnabled() ) { Loading