yedincisenol/video-intelligence

Laravel wrapper for GCloud Video Intelligence PHP client

0.1.1 2018-08-09 22:30 UTC

This package is auto-updated.

Last update: 2024-11-19 06:43:40 UTC


README

Travis Packagist Packagist Packagist

Laravel Install

  • Add composer
composer require "yedincisenol/video-intelligence"
  • Add service provider (For Laravel 5.6 before) config/app.php
'providers' => [
    ...
    yedincisenol\VideoIntelligence\LaravelServiceProvider::class
],
  • Add Facede

config/app.php

'aliases' => [
        ...
        'VideoIntelligence'    =>  \yedincisenol\VideoIntelligence\LaravelFacede::class
],
  • Fill Environments

copy theese parameters to your project .env and fill

VIDEO_INTELLIGENCE_CREDENTIALS_PATH=

How to get credentials file? Visit here

  • Laravel Usage
use VideoIntelligence;

VideoIntelligence::annotateVideo(['inputUri' => 'gs://pandora-test/video-1.mp4', 'features' => [1]]);
$operationResponse = VideoIntelligence::annotateVideo(['inputUri' => 'gs://pandora-test/video-1.mp4', 'features' => [1]]);

$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
    $results = $operationResponse->getResult();
    foreach ($results->getAnnotationResults() as $result) {
        echo 'Segment labels' . PHP_EOL;
        foreach ($result->getSegmentLabelAnnotations() as $labelAnnotation) {
            echo "Label: " . $labelAnnotation->getEntity()->getDescription()
                . PHP_EOL;
        }
        echo 'Shot labels' . PHP_EOL;
        foreach ($result->getShotLabelAnnotations() as $labelAnnotation) {
            echo "Label: " . $labelAnnotation->getEntity()->getDescription()
                . PHP_EOL;
        }
        echo 'Frame labels' . PHP_EOL;
        foreach ($result->getFrameLabelAnnotations() as $labelAnnotation) {
            echo "Label: " . $labelAnnotation->getEntity()->getDescription()
                . PHP_EOL;
        }
    }
} else {
    $error = $operationResponse->getError();
    echo "error: " . $error->getMessage() . PHP_EOL;
}

For more detail visit here

Label Codes: here

  • Publish Config file (Optional)
php artisan vendor:publish --tag=videointelligence