r - R中自动一张一张选择图像文件的功能
问题描述
我有一个包含 100 多张图片的文件夹。我想在 R 中对它们中的每一个运行谷歌视觉分析。我不想一次对一张图像运行分析,而是想创建一个函数来逐个访问每个图像并运行分析。
使用以下代码:
getGooglevisionResponse(file.choose(),feature = 'text_detection')
我file.choose()
习惯一次选择一个文件,但我想创建一个循环,该循环将动态选择每个图像并对其运行分析.. 使用list.files()
但低于错误
the following condition has length >1 and only the first element will be used
找到了一篇文章,但那是在 python 中无法在 R 中复制它
解决方案
在没有看到更多代码的情况下,您只需要使用lapply
and list.files
。
fil <- list.files("<myImgDir>", full.names = T)
out <- lapply(fil, getGoogleVisionResponse, feature = 'text_detection'))
推荐阅读
- .net - 使用supervisord在后台运行时如何将Ctrl-C发送到dotMemory命令行CLI?
- android - Macbook M1 - 安装未成功完成。有关详细信息,请参阅 IDE 日志 - Android Studio
- python - 使用 ffmpeg 从 python openCV 流式传输图像
- python - 使用假期库 -python 检查是否是基于日期的假期
- python - 在 Keras 中连接参差不齐的输入
- json - 赛普拉斯不在日历上选择日期
- c++ - 为什么继承在方法内部不起作用?
- javascript - 如何在数据表中使用国际字符进行排序
- android - 如何找到我的 React Native 应用程序中使用的所有权限?
- android - 我想为电话号码使用服务