HarmonyOS 拍完照获取设备方向,非屏幕方向

用于对图片数据进行处理,有什么接口

HarmonyOS
2024-12-25 17:49:27
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zxjiu

建议用sensor:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-sensor-V5#orientation9

import { sensor } from '@kit.SensorServiceKit';
import { BusinessError } from '@kit.BasicServicesKit';

try {
  sensor.on(sensor.SensorId.ORIENTATION, (data: sensor.OrientationResponse) => {
    console.info('Succeeded in the device rotating at an angle around the Z axis: ' + data.alpha);
    console.info('Succeeded in the device rotating at an angle around the X axis: ' + data.beta);
    console.info('Succeeded in the device rotating at an angle around the Y axis: ' + data.gamma);
  }, { interval: 100000000 });
  setTimeout(() => {
    sensor.off(sensor.SensorId.ORIENTATION);
  }, 500);
} catch (error) {
  let e: BusinessError = error as BusinessError;
  console.error(`Failed to invoke on. Code: ${e.code}, message: ${e.message}`);
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
分享
微博
QQ
微信
回复
2024-12-25 19:29:53
相关问题
获取当前设备屏幕方向
1045浏览 • 1回复 待解决
window获取屏幕方向配置
1395浏览 • 1回复 待解决
HarmonyOS 旋转设备获取设备方向问题
853浏览 • 1回复 待解决
HarmonyOS 如何通过传感器获取设备方向
1016浏览 • 1回复 待解决
HarmonyOS 传感器判断屏幕方向
810浏览 • 1回复 待解决
HarmonyOS 代码中如何设置屏幕旋转方向
1360浏览 • 1回复 待解决
如何设置屏幕方向为横屏
2479浏览 • 1回复 待解决
如何获取当前window的窗口方向
1098浏览 • 1回复 待解决
HarmonyOS 如何判断滑动的方向
597浏览 • 1回复 待解决
HarmonyOS web组件滚动方向判断
557浏览 • 1回复 待解决
HarmonyOS 组件旋转后,平移方向出错
589浏览 • 1回复 待解决
HarmonyOS 关于Abiliaty显示方向的问题
556浏览 • 1回复 待解决
HarmonyOS Text组件如何设置文字方向
660浏览 • 1回复 待解决