arcoreimg 工具
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
arcoreimg
是一个命令行工具,用于获取一组参考图片并生成图片数据库文件。此工具在 适用于 Android 的 ARCore SDK 中提供(请参阅 tools > arecoreimg),仅适用于 Android 和 Android NDK 开发者。
您还可以使用该工具检查参考图片的质量。
检查图片质量
好的参考图片在人眼中很难发现瑕疵。运行 arcoreimg eval-img
可为每张图片获取介于 0 到 100 之间的画质得分。
我们建议使用至少 75 分数的图片。
macOS
./arcoreimg eval-img --input_image_path=dog.jpg
Windows
arcoreimg.exe eval-img --input_image_path=dog.png
创建图片数据库文件
您可以在目录中或通过图片列表文件(首选)提供参考图片。请注意,仅支持 PNG 和 JPEG 图片,并且图片文件名仅支持 ASCII 字符。
基于图片目录创建图片数据库
使用 --input_images_directory
运行 arcoreimg build-db
,以指定包含图片的目录,如下所示:
macOS
./arcoreimg build-db --input_images_directory=/path/to/images \
--output_db_path=/path/to/myimages.imgdb
Windows
arcoreimg.exe build-db --input_images_directory=/path/to/images --output_db_path=/path/to/myimages.imgdb
系统会根据每个图片的路径为其分配默认名称。例如,dog.jpg
的名称为 /path/to/images/dog.jpg
。
此外,系统还会根据图片文件名的 ASCII 排序顺序,为每张图片分配一个基于 0
的整数索引。
系统会假定所有图片的实际宽度(以米为单位)均未知。
通过图片列表文件创建数据库(首选)
图片列表文件的格式如下所示:
mouse|path/to/mouse.png|0.1
little dog|/path/to/dog.jpg
每行包含名称、图片文件路径和图片的实际宽度(以米为单位)(可选)。
使用 --input_image_list_path
运行 arcoreimg build-db
以指定图片列表文件,如下所示:
macOS
./arcoreimg build-db --input_image_list_path=/path/to/image_list_file.txt \
--output_db_path=/path/to/myimages.imgdb
Windows
arcoreimg.exe build-db --input_image_list_path=/path/to/image_list_file.txt --output_db_path=/path/to/myimages.imgdb
系统会根据图片在图片列表文件中的位置,为每个图片分配一个名称和基于 0
的索引。
在运行时识别图片
使用 AugmentedImage.getIndex()
和 AugmentedImage.getName()
来识别检测到的图片。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003earcoreimg\u003c/code\u003e is a command-line tool used by Android and Android NDK developers to generate an image database file for AR experiences using a set of reference images.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can assess the quality of their reference images by running \u003ccode\u003earcoreimg eval-img\u003c/code\u003e, aiming for a quality score of 75 or higher.\u003c/p\u003e\n"],["\u003cp\u003eImage databases can be created from a directory of images, but using an image list file is preferred as it allows for specifying names and physical widths.\u003c/p\u003e\n"],["\u003cp\u003eWhen creating an image database, ensure image filenames contain only ASCII characters and are in PNG or JPEG format.\u003c/p\u003e\n"],["\u003cp\u003eUse \u003ccode\u003eAugmentedImage.getIndex()\u003c/code\u003e and \u003ccode\u003eAugmentedImage.getName()\u003c/code\u003e in your application code to identify detected images at runtime.\u003c/p\u003e\n"]]],["The `arcoreimg` tool, exclusive to Android and NDK developers, generates image databases from reference images. It evaluates image quality using `arcoreimg eval-img`, recommending scores above 75. `arcoreimg build-db` creates databases from image directories or, preferably, image list files. List files specify the name, path, and optional physical width of each image. The generated database assigns a name and index to each image, for which runtime image detection uses `AugmentedImage.getIndex()` and `AugmentedImage.getName()`.\n"],null,["# The arcoreimg tool\n\n`arcoreimg` is a command line tool that takes a set of reference images and generates\nan image database file. This tool is available in the\n[ARCore SDK for Android](https://github.com/google-ar/arcore-android-sdk/releases) (see **tools \\\u003e arecoreimg**),\nand is for only Android and Android NDK developers.\n\nThe tool also lets you check the quality of your reference images.\n\nCheck image quality\n-------------------\n\nA good reference image is hard to spot with the human eye. Run `arcoreimg eval-img` to get a quality score between **0** and **100** for each image.\n\nWe recommend using images with a score of **at least 75**. \n\n### macOS\n\n\u003cbr /\u003e\n\n```\n./arcoreimg eval-img --input_image_path=dog.jpg\n```\n\n### Windows\n\n\u003cbr /\u003e\n\n```\narcoreimg.exe eval-img --input_image_path=dog.png\n```\n\nCreate an image database file\n-----------------------------\n\nYou can supply reference images in a **directory** or via an **image list file** (preferred).\nNote that only PNG and JPEG images are supported, and only ASCII characters are\nsupported in image filenames.\n\n### Create image database from a directory of images\n\nRun `arcoreimg build-db` using `--input_images_directory` to specify a\ndirectory that contains your images as shown below: \n\n### macOS\n\n\u003cbr /\u003e\n\n```\n./arcoreimg build-db --input_images_directory=/path/to/images \\\n --output_db_path=/path/to/myimages.imgdb\n```\n\n### Windows\n\n\u003cbr /\u003e\n\n```\narcoreimg.exe build-db --input_images_directory=/path/to/images --output_db_path=/path/to/myimages.imgdb\n```\n\nEach image is assigned a default name based on its path. For example, `dog.jpg`\nis assigned `/path/to/images/dog.jpg` as its name.\n\nEach image is also assigned a `0`-based integer index, based on the ASCII sort\norder of the image filenames.\n\nAll images will be assumed to have an unknown physical width in meters.\n\n### Create a database from an image list file (Preferred)\n\nThe format of the image list file is shown below: \n\n```\nmouse|path/to/mouse.png|0.1\nlittle dog|/path/to/dog.jpg\n```\n\nEach line contains a **name** , the **image file path** , and the image's\n**physical width in meters** (optional).\n\nRun `arcoreimg build-db` using `--input_image_list_path` to specify an image\nlist file as shown below: \n\n### macOS\n\n\u003cbr /\u003e\n\n```\n./arcoreimg build-db --input_image_list_path=/path/to/image_list_file.txt \\\n --output_db_path=/path/to/myimages.imgdb\n```\n\n### Windows\n\n\u003cbr /\u003e\n\n```\narcoreimg.exe build-db --input_image_list_path=/path/to/image_list_file.txt --output_db_path=/path/to/myimages.imgdb\n```\n\nEach image is assigned a **name** and a `0`-based **index** based on its\nposition in the image list file.\n\n### Identifying images at runtime\n\nUse [`AugmentedImage.getIndex()`](/ar/reference/java/com/google/ar/core/AugmentedImage#getIndex())\nand [`AugmentedImage.getName()`](/ar/reference/java/com/google/ar/core/AugmentedImage#getName())\nto identify detected images."]]