android 调用相机ar,在Android上录制并播放AR会话
通过Recording&Playback API,您可以在给定的环境中记录一次视频和AR数据,并使用该内容替换实时摄像头会话。
先决条件
在继续之前,请确保您了解基本的AR概念以及如何配置ARCore会话。
与其他ARCore API的兼容性
由于会话数据的处理方式,ARCore API可能在回放过程中产生与记录过程中所观察到的结果不同的结果。在随后的播放会话中,它们也可能产生不同的结果。例如,在回放过程中,检测到的可跟踪对象的数量,检测到的精确定时以及它们随时间的姿势可能会有所不同。
与共享相机的兼容性
可以记录使用共享摄像机的会话。但是,当前无法使用“共享照相机”模式播放这些会话。
与云锚的兼容性
您可以在录制或回放会话时托管和解析Cloud Anchors 。
记录
开始,停止并检查ARCore会话记录的状态。
记录ARCore会话
爪哇// Configure the ARCore session.
Session session = new Session(context);
String destination = new File(context.getFilesDir(), "recording.mp4").getAbsolutePath();
RecordingConfig recordingConfig =
new RecordingConfig(session)
.setMp4DatasetFilePath(destination)
.setAutoStopOnPause(true);
try {
// Prepare the session for recording, but do not start recording yet.
session.startRecording(recordingConfig);
} catch (RecordingFailedException e) {
Log.e(TAG, "Failed to start recording", e);
}
// Resume the ARCore session to start recording.
session.resume();科特林// Configure the ARCore session.
val session = Session(context)
val destination = File(context.getFilesDir(), "recording.mp4").getAbsolutePath()
val recordingConfig = RecordingConfig(session)
.setMp4DatasetFilePath(destination)
.setAutoStopOnPause(true)
session.startRecording(recordingConfig)
// Resume the ARCore session to start recording.
session.resume()
停止会话记录
要在不暂停当前运行的AR会话的情况下停止记录,请调用session.stopRecording() 。
爪哇try {
session.stopRecording(); // Stop recording.
} catch (RecordingFailedException e) {
Log.e(TAG, "Failed to stop recording", e);
}科特林session.stopRecording()
检查录音状态
爪哇// Use any time to determine current RecordingStatus.
if (session.getRecordingStatus() == RecordingStatus.OK) {
// Update the UI to show that the session is currently being recorded.
}科特林// Use any time to determine current RecordingStatus.
if (session.recordingStatus == RecordingStatus.OK) {
// Update the UI to show that the session is currently being recorded.
}
回放
播放以前录制的AR会话。会话会实时播放,并且无法调整会话播放或速度。
播放以前录制的会话
一旦由于第一次调用session.resume()而开始播放,通过调用session.pause()暂停会话将暂停对数据集中所有相机图像帧和任何其他记录的传感器数据的处理。通过调用session.resume()再次恢复会话时,不会重新处理以这种方式丢弃的相机图像帧和传感器帧数据。由于处理数据的差异,会话的AR跟踪通常会受到影响。
爪哇// Configure the ARCore session.
Session session = new Session(context);
// Specify the previously recorded MP4 file.
String recordingPath = new File(context.getFilesDir(), "recording.mp4").getAbsolutePath();
session.setPlaybackDataset(recordingPath);
…
// Start playback from the beginning of the dataset.
session.resume();
…
// Pause the AR session, but silently continue MP4 playback. Camera frames
// and other recorded sensor data is discarded while the session is paused.
session.pause();
…
// Resume the AR session. Camera frames and other sensor data from the MP4
// that was silently played back while the session was paused is not
// processed by ARCore.
session.resume();科特林// Configure the ARCore session.
val session = Session(context)
// Specify the previously recorded MP4 file.
val recordingPath = File(context.filesDir, "recording.mp4").absolutePath
session.playbackDataset = recordingPath
…
// Start playback from the beginning of the dataset.
session.resume()
…
// Pause the AR session, but silently continue MP4 playback. Camera frames
// and other recorded sensor data is discarded while the session is paused.
session.pause()
…
// Resume the AR session. Camera frames and other sensor data from the MP4
// that was silently played back while the session was paused is not
// processed by ARCore.
session.resume()
从头开始重新播放
要从数据集的开头重新开始播放,请暂停会话并调用session.setPlaybackDataset() ,然后在恢复会话之前指定相同的MP4录音。
爪哇session.pause();
// Pause and specify the SAME dataset:
session.setPlaybackDataset(previousRecordingPath);
session.resume(); // Playback starts from the BEGINNING of the dataset.科特林session.pause()
// Pause and specify the SAME dataset:
session.playbackDataset = previousRecordingPath
session.resume() // Playback starts from the BEGINNING of the dataset.
播放不同的会话
要播放其他数据集,请在恢复会话之前暂停会话并指定新的数据集。
爪哇第0342章科特林// Switch to a different dataset.
session.pause() // Pause the playback of the first dataset.
// Specify a different dataset to use.
session.playbackDataset = newRecordingPath
session.resume() // Start playback from the beginning of the new dataset.
检查播放状态
爪哇// Use any time to determine current PlaybackStatus.
if (session.getPlaybackStatus() != PlaybackStatus.OK) {
// Update the UI to show that the session playback has finished.
}科特林// Use any time to determine current PlaybackStatus.
if (session.playbackStatus != PlaybackStatus.OK) {
// Update the UI to show that the session playback has finished.
}
下一步是什么了解如何将自定义数据添加到录制的会话中。
android 调用相机ar,在Android上录制并播放AR会话相关推荐
- android调用相机返回大图,Android调用相机拍照返回原图
在开始之前,先说下正常调用相机的状况: 正常调用相机,在 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActiv ...
- Android调用相机与相册的方法
Android调用相机与相册的方法 操作流程 点击拍摄 效果图 点击相册选择 效果图 拒绝权限的情况 效果图 功能实现 项目配置 1.先在项目根目录的build.gradle的repositories ...
- android 调用相机并获取图片地址,Android 7.0使用FileProvider获取相机拍照的图片路径...
这里主要是基于Android 7.0,Nougat 实现一个获取相机拍照的图片后,使用FileProvider把图片转换为实际的路径. 首先需要在AndroidManifest.xml声明调用相机的权 ...
- android 调用相机拍照。适配到 Android 10
Photograph 项目地址:donkingliang/Photograph 简介: android 调用相机拍照.适配到 Android 10 更多:作者 提 Bug 标签: android ...
- Android调用相机,录像,相册
Android调用相机,录像,相册 调用相机 录像的调用 相册 我们在安卓开发过程中,可能会遇到需要用到照片的情况,今天就说一下如何使用相机,相册这些系统软件的调用方法 调用相机 首先我们将权限添加 ...
- iOS学习:调用相机,选择图片上传,带预览功能
iOS学习:调用相机,选择图片上传,带预览功能 发表于2年前(2013-05-30 21:38) 阅读( 18194) | 评论( 16) 27人收藏此文章,我要收藏 赞3 8月22日珠海 OSC ...
- Android实现调用相机拍摄图片并post上传
如果你只是在找retrofit怎么使用formdata格式上传图片,请直接看最后一个函数和retrofit代码,有什么不懂直接留言交流吧!!我也是小白 在android中调用相机拍摄图片,并通过pos ...
- android 调用相机ar,AR相机使用方法_AR相机_AR相机安卓版_易玩网
网提供AR相机app,AR相机是一款AR软件,这款软件通过AR技术,实现虚拟现实增强功能,让用户观看栩栩如生的3D动画,感受AR世界带来的奇妙体验,感兴趣的朋友快来吧! 软件简介 拍我所想,见你未见, ...
- android 相机和相册,[转载][转载] android调用相机和相册
很多同学在做客户端的时候,都需要做上传图片,那么上传图片如何上传呢?自己写一个SurfaceView做为展示区,然后用camera类来实现?太out了!直接调用相机拍照获取或者调用相册来取照片才是王道 ...
最新文章
- 电子科技大学通信原理视频教程 瓦特芯收藏
- 7-4 最短工期 (25 分)
- 【报告分享】2022跨境电商行业趋势报告.pdf(附下载链接)
- matlab中怎么画五维图,使用MatLab绘制散点图的方法
- 查找命令find和其他常用查找命令
- python将txt读入矩阵_python读入txt数据,并转成矩阵
- TableViewCell的折展(Masonry)
- 芝麻信用倒逼银行改革,纷纷模仿支付宝推出借呗!
- 第三方对接秀米图文编辑器遇到的坑
- 使用SCCM管理Office ProPlus(二)--升级最到最新更新
- mysql异常-SQLSTATE[HY000]: General error: 1436 Thread stack overrun
- 《SLA by Short brain》—学好英语口语的终极法宝!
- DBA备录_ORA-24247_网络访问被访问控制列表 (ACL) 拒绝
- 手机上的android版本下载视频播放器,ZZPlayer手机版下载
- 一个简单的购物类网站
- 音频压缩的方法有哪些?三个方法介绍给你
- 华为路由器负载均衡_华为路由器双出口负载均衡+备份(示例代码)
- 计算机检测报告素材,笔记本检测报告模板.doc
- iOS-NSUserDefaults详解
- 涂鸦win7电脑主题