Microsoft Computer Vision手写API未发送“内容位置”标头

时间:2018-06-25 15:35:30

标签: php azure computer-vision ocr httpresponse

我正在尝试使用Microsoft Computer Vision对图像进行手写分析,但是没有收到202响应,并且我无法在我的响应者上找到“ Content-Location”标头使用Microsoft示例在PHP,Javascript,Python和Curl上进行尝试,但在任何测试中都找不到标题。

require_once 'HTTP/Request2.php';

$request = new Http_Request2('https://brazilsouth.api.cognitive.microsoft.com/vision/v1.0/analyze?recognizeText');
$url = $request->getUrl();

$subscriptionKey = <>;

$headers = array(
    'Content-Type' => 'application/json',
    'Ocp-Apim-Subscription-Key' => $subscriptionKey,
);

$request->setHeader($headers);

$parameters = array(
    'handwriting' => 'true',
);

$url->setQueryVariables($parameters);

$request->setMethod(HTTP_Request2::METHOD_POST);

$body = array('url' => 'http://www.fki.inf.unibe.ch/databases/iam-on-line-handwriting-database/images/processed-strokes.png');

$request->setBody(json_encode($body));

$func = function($value) {
    return $value;
};

try{
    $response = $request->send();

    echo json_encode(json_decode($response->getBody()), JSON_PRETTY_PRINT);

}
catch (HttpException $ex){
    echo $ex;
}

这是我的答复:

    {
    "categories": [
        {
            "name": "others_",
            "score": 0.00390625
        },
        {
            "name": "text_",
            "score": 0.5625
        },
        {
            "name": "text_sign",
            "score": 0.16796875
        }
    ],
    "requestId": "eaa0613b-f14d-4889-9488-487afabbab17",
    "metadata": {
        "height": 205,
        "width": 543,
        "format": "Png"
    }
}

我也尝试转储响应,但是我也找不到标题。

0 个答案:

没有答案