搜索分类、插件与代码仓

插件详情v0.0.2+7

ar_core

用于在应用程序中添加增强现实的 Flutter 插件 - 支持 iOS 和 Android 设备上的实时摄像头和物体放置

AndroidiOSWeb
近 30 天下载
6
喜欢数
30
Pub 分数
125

安装插件

flutter pub add ar_core

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

ar_core 是一个 Flutter 插件,可在 iOS 和 Android 移动应用中实现增强现实(AR)功能,支持实时摄像头访问和 3D 对象放置。它允许开发者通过简单的 API 将 AR 体验直接集成到其应用中。该插件利用每个平台的原生 AR 能力,并设计为在各种设备上无缝工作。虽然目前不支持 Web AR,但它为在 Flutter 应用中构建交互式 AR 功能提供了坚实的基础。

适合场景

  • 创建交互式产品预览
  • 开发AR游戏
  • 通过3D模型增强教育应用程序
  • 可视化建筑设计
  • 启用虚拟试穿

主要特点

  • 实时摄像头集成
  • AR空间中的3D对象放置
  • 跨平台支持(iOS 和 Android)
  • 简单的 Flutter API
  • 原生AR框架利用

适合对象

  • 移动AR应用开发者
  • 教育技术项目
  • 电子商务产品可视化
  • 寻求AR功能的游戏开发者
  • UX设计师探索沉浸式界面

使用建议

  • 无 Web 平台支持
  • 需要具备AR功能的设备
  • 可用文档有限
  • 依赖原生AR框架
  • 可能需要为复杂场景进行额外设置

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

ar_core Flutter Package for Augmented Reality

pub package

ar_core is an augmented reality mobile application kit for mobile devices that enables the creation of augmented reality applications.

Many thanks to Arslan Raza for the ar_core, he served as a great basis and starting point for this project.

Features

  • Display live camera preview in a widget.
  • Custom Camera, Place anywhere on the Screen.
  • Choose Asset, Network or 3d objects in png.
  • Drag, Resize, Rotate, Zoom in and out objects.
  • Add access to the image stream from Dart.

Getting Started

Installing

Add the Flutter package to your project by running:

flutter pub add ar_core

Or manually add this to your pubspec.yaml file (and run flutter pub get):

dependencies:
  ar_core: ^0.0.1
iOS

The camera plugin functionality works on iOS 10.0 or higher. If compiling for any version lower than 10.0, make sure to programmatically check the version of iOS running on the device before using any camera plugin features. The device_info_plus plugin, for example, can be used to check the iOS version.

Add two rows to the ios/Runner/Info.plist:

  • one with the key Privacy - Camera Usage Description and a usage description.
  • and one with the key Privacy - Microphone Usage Description and a usage description.

Or in text format add the key:

<key>NSCameraUsageDescription</key>
<string>Can I use the camera please?</string>
<key>NSMicrophoneUsageDescription</key>
<string>Can I use the mic please?</string>
Android

Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.

minSdkVersion 21

It's important to note that the MediaRecorder class is not working properly on emulators, as stated in the documentation: https://developer.android.com/reference/android/media/MediaRecorder. Specifically, when recording a video with sound enabled and trying to play it back, the duration won't be correct and you will only see the first frame.

Importing

Add this to your code:

import 'package:ar_core/ar_core.dart';
Usage or How to Use

Replace your Scaffold to Augmented(), and it will handle all your view. if you want to pass an image just pass an image as a constructor.

#Write this code in main


import 'package:camera/camera.dart';
import 'package:flutter/material.dart';

List<CameraDescription> cameras = [];
Future<void> main() async {
  try {
    WidgetsFlutterBinding.ensureInitialized();
    cameras = await availableCameras();
  } on CameraException catch (e) {
    print(e.description);
  }
  runApp(const MyApp());
}
Add main class
class AugmentedReality extends StatefulWidget {
  const AugmentedReality({Key? key}) : super(key: key);

  @override
  _AugmentedRealityState createState() => _AugmentedRealityState();
}

class _AugmentedRealityState extends State<AugmentedReality> {
  @override
  Widget build(BuildContext context) {
    return Augmented(
     /// Provide Network Image Link to add your object
    image: 'https://freepngimg.com/static/img/cat/hair.png'
    );
  }
}

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。