File tree Expand file tree Collapse file tree 1 file changed +27
-23
lines changed
util/src/main/java/cn/readsense/module/camera1 Expand file tree Collapse file tree 1 file changed +27
-23
lines changed Original file line number Diff line number Diff line change @@ -139,30 +139,34 @@ public void releaseCamera() {
139
139
140
140
141
141
private int getCameraDisplayOrientation (Context context , int cameraId ) {
142
- Camera .CameraInfo info = new Camera .CameraInfo ();
143
- Camera .getCameraInfo (cameraId , info );
144
- int rotation = ((Activity ) context ).getWindowManager ().getDefaultDisplay ().getRotation ();
145
- short degrees = 0 ;
146
- switch (rotation ) {
147
- case 0 :
148
- degrees = 0 ;
149
- break ;
150
- case 1 :
151
- degrees = 90 ;
152
- break ;
153
- case 2 :
154
- degrees = 180 ;
155
- break ;
156
- case 3 :
157
- degrees = 270 ;
158
- }
142
+ int result = 0 ;
143
+ try {
144
+ Camera .CameraInfo info = new Camera .CameraInfo ();
145
+ Camera .getCameraInfo (cameraId , info );
146
+ int rotation = ((Activity ) context ).getWindowManager ().getDefaultDisplay ().getRotation ();
147
+ short degrees = 0 ;
148
+ switch (rotation ) {
149
+ case 0 :
150
+ degrees = 0 ;
151
+ break ;
152
+ case 1 :
153
+ degrees = 90 ;
154
+ break ;
155
+ case 2 :
156
+ degrees = 180 ;
157
+ break ;
158
+ case 3 :
159
+ degrees = 270 ;
160
+ }
159
161
160
- int result ;
161
- if (info .facing == 1 ) {
162
- result = (info .orientation + degrees ) % 360 ;
163
- result = (360 - result ) % 360 ;
164
- } else {
165
- result = (info .orientation - degrees + 360 ) % 360 ;
162
+ if (info .facing == 1 ) {
163
+ result = (info .orientation + degrees ) % 360 ;
164
+ result = (360 - result ) % 360 ;
165
+ } else {
166
+ result = (info .orientation - degrees + 360 ) % 360 ;
167
+ }
168
+ } catch (Exception e ) {
169
+ e .printStackTrace ();
166
170
}
167
171
168
172
return result ;
You can’t perform that action at this time.
0 commit comments