Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php android中的Google vision API食品标签检测_Php_Android_Google Play Services_Google Cloud Vision - Fatal编程技术网

Php android中的Google vision API食品标签检测

Php android中的Google vision API食品标签检测,php,android,google-play-services,google-cloud-vision,Php,Android,Google Play Services,Google Cloud Vision,我正在为android mobile制作一个深入的食品记录应用程序,我想使用google vision API添加一些基本的图像识别 我一直在尝试API和使用PHP,但没有成功。 我一直在看所有的教程,总是在某些问题上卡住 这是我到目前为止在php方面最接近的一次 <?php # Includes the autoloader for libraries installed with composer require __DIR__ . '/vendor/autoload.php'; #

我正在为android mobile制作一个深入的食品记录应用程序,我想使用google vision API添加一些基本的图像识别

我一直在尝试API和使用PHP,但没有成功。 我一直在看所有的教程,总是在某些问题上卡住

这是我到目前为止在php方面最接近的一次

<?php
# Includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';

# Imports the Google Cloud client library
use Google\Cloud\Vision\VisionClient;

# Your Google Cloud Platform project ID
$projectId = 'foodlogging-160914';

putenv('GOOGLE_APPLICATION_CREDENTIALS=./FoodLogging-ae7e284eb66e.json');

# Instantiates a client
$vision = new VisionClient([
    'projectId' => $projectId
]);

# The name of the image file to annotate
$fileName = __DIR__ . '/hamburger.jpg';

# Prepare the image to be annotated
$image = $vision->image(fopen($fileName, 'r'), [
    'LABEL_DETECTION'
]);

# Performs label detection on the image file
$labels = $vision->annotate($image)->labels();

echo "Labels:\n";
foreach ($labels as $label) {
    echo $label->description() . "\n";
}
?>
我已经看完了整个文档,但我不知道它为什么会在日期时间方面出现问题,因为我甚至从未使用过它

有没有人有谷歌视觉API的经验可以帮助我?最好是android部分,帮我上路还是帮我开始


谢谢。在php.ini中设置时区

➜  ~ cat/etc/php.ini | grep时区
; 定义日期函数使用的默认时区
; http://php.net/date.timezone
date.timezone=美国/圣保罗

在php.ini中设置时区

➜  ~ cat/etc/php.ini | grep时区
; 定义日期函数使用的默认时区
; http://php.net/date.timezone
date.timezone=美国/圣保罗

我刚刚在脚本的顶部添加了“日期默认时区设置('UTC')”,这也起到了作用!谢谢我刚刚在我的脚本顶部添加了“日期\默认值\时区\设置('UTC');”,这也起到了作用!谢谢
Fatal error: Uncaught exception 'Google\Cloud\Exception\ServiceException' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.' in /Library/WebServer/Documents/foodLogging/vendor/google/cloud/src/RequestWrapper.php:223 Stack trace: #0 /Library/WebServer/Documents/foodLogging/vendor/google/cloud/src/RequestWrapper.php(136): Google\Cloud\RequestWrapper->convertToGoogleException(Object(Google\Cloud\Exception\ServiceException)) #1 /Library/WebServer/Documents/foodLogging/vendor/google/cloud/src/RestTrait.php(83): Google\Cloud\RequestWrapper->send(Object(GuzzleHttp\Psr7\Request), Array) #2 /Library/WebServer/Documents/foodLogging/vendor/google/cloud/src/Vision/Connecti in /Library/WebServer/Documents/foodLogging/vendor/google/cloud/src/RequestWrapper.php on line 223