我正在尝试使用Google Play服务(Vision)中的新功能将QR码扫描添加到我的应用程序中.但当我运行我的应用程序时,我得到了这个:
I/Vision? Supported ABIS: [armeabi-v7a, armeabi]
D/Vision? Library not found: /data/data/com.google.android.gms/files/com.google.android.gms.vision/barcode/libs/armeabi-v7a/libbarhopper.so
I/Vision? Requesting barcode detector download.
Run Code Online (Sandbox Code Playgroud)
我按照教程声明了条形码依赖:
<meta-data
android:name="com.google.android.gms.vision.DEPENDENCIES"
android:value="barcode" />
Run Code Online (Sandbox Code Playgroud)
我尝试重新安装应用程序并重新启动手机,没有任何帮助.
使用Google Play Services 7.8,设备上安装的版本为7.8.11.
compile 'com.google.android.gms:play-services-vision:7.8.0'
Run Code Online (Sandbox Code Playgroud)
用于创建条形码检测器的代码:
boolean initBarcodeDetector() {
final BarcodeTrackerFactory barcodeTrackerFactory = new BarcodeTrackerFactory(this);
final MultiProcessor<Barcode> multiProcessor = new MultiProcessor.Builder<>(barcodeTrackerFactory)
.build();
barcodeDetector = new BarcodeDetector.Builder(this)
.build();
barcodeDetector.setProcessor(multiProcessor);
if (barcodeDetector.isOperational() == false) {
Toast.makeText(this, R.string.barcode_not_operational, Toast.LENGTH_LONG).show();
finish();
return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
上面的close返回false并barcodeDetector.isOperational()
返回活动,因为返回false
.
android barcode google-play-services google-vision android-vision
我正在阅读有关vision API请求架构的文档.在图像源中,我只看到使用GCS图像路径的URL的选项.是否可以使用http://example.com/images/image01.jpg等外部图片网址?
我对Python比较陌生,而且我坚持一些可能相对容易解决的问题.
我安装了以下软件包:
pip install --upgrade google-api-python-client
pip install --upgrade google-cloud
pip install --upgrade google-cloud-vision
Run Code Online (Sandbox Code Playgroud)
在我的Python文件中,我有:
import cv2
import io
import os
# Imports the Google Cloud client library
from google.cloud import vision
...etc...
Run Code Online (Sandbox Code Playgroud)
这给了我错误:
Traceback (most recent call last):
File "test.py", line 6, in <module>
from google.cloud import vision
ImportError: No module named 'google.cloud'
Run Code Online (Sandbox Code Playgroud)
我错过了什么,我应该在哪里(日志?)找到答案.
PS:
Pip安装google-cloud
并google-cloud-vision
输出:
Cannot remove entries from nonexistent file /Users/foobar/anaconda/lib/python3.5/site-packages/easy-install.pth
Run Code Online (Sandbox Code Playgroud)
更新:
运行pip freeze
不显示要安装的包...
我正在使用新的Google Play服务视觉库编写应用程序以检测条形码.
在我测试过的大多数设备上一切正常,但是一个特定设备拒绝安装本机库(在此评论中提到)
// Note: The first time that an app using the barcode or face API is installed on a
// device, GMS will download a native libraries to the device in order to do detection.
// Usually this completes before the app is run for the first time. But if that
// download has not yet completed, then the above call will not detect any barcodes
// and/or faces.
//
// isOperational() can be used to check if …
Run Code Online (Sandbox Code Playgroud) 我对此感到非常愚蠢,但我已经下载了Android Mobile Vision API的示例代码:https://github.com/googlesamples/android-vision.
我正在尝试将此代码导入Android Studio,以便我能够运行示例应用程序,但无论我如何导入(导入现有Android Studio项目,导入非Android Studio项目,打开项目),我不是能够以我可以编译和点击播放来运行应用程序的方式导入它.
由于这是Android的官方示例代码,我相信它不应该是这么复杂.我错过了什么?
我试图了解GoogleVision API Java库.
我创建了一个服务帐户,下载了json并设置了这个环境变量.
GOOGLE_APPLICATION_CREDENTIALS=C:\GoogleAPI\keys\translate-41428d4d1ec6.json
Run Code Online (Sandbox Code Playgroud)
我使用以下方法设置了应用程序默认凭据:
gcloud beta auth application-default login
Run Code Online (Sandbox Code Playgroud)
我在这里关注这个例子:https: //cloud.google.com/vision/docs/reference/libraries
我现在假设所有调用都将使用服务帐户,就像魔术一样,因为我没有在代码中进行任何身份验证(根据示例).
但是,我无法看到我授权服务帐户使用Google Vision API的位置,我认为我必须这样做.所以,我可能根本就不能使用服务帐户......
当我进入IAM并尝试为服务帐户分配"角色"时,与视觉API没有任何关系?有角色,如
文档中的示例显示了如何
任何帮助赞赏.
此外,我感兴趣的是如何调整示例以不使用Application Default Credentials,但实际上创建了一个特定的Credential实例并使用它来调用Google Vision,因为这一点并不清楚.示例给出的是调用GoogleStorage,但我无法将其转换为Google Vision.
public class StorageFactory {
private static Storage instance = null;
public static synchronized Storage getService() throws IOException, GeneralSecurityException {
if (instance == null) {
instance = buildService();
}
return instance;
}
private static Storage buildService() throws IOException, GeneralSecurityException {
HttpTransport transport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = new JacksonFactory();
GoogleCredential credential …
Run Code Online (Sandbox Code Playgroud) 由于谷歌视觉对输入图像大小有一些限制,我想首先调整输入图像的大小,然后使用该detect_labels()
功能。
这是他们的示例代码
def detect_labels(path):
"""Detects labels in the file."""
vision_client = vision.Client()
with io.open(path, 'rb') as image_file:
content = image_file.read()
image = vision_client.image(content=content)
labels = image.detect_labels()
print('Labels:')
for label in labels:
print(label.description)
Run Code Online (Sandbox Code Playgroud)
他们用来io
打开图像文件。我想知道这样,如何调整内存中图像的大小然后调用detect_labels()
?