-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Google Video Intelligence: Class 'Google\Cloud\Videointelligence\V1\Feature' not found #950
Comments
Thanks for the report @hypercms. In your vendor directory do you have google/proto-client? It should contain the necessary dependencies, such as the Feature class. The package is required by the Video Intelligence package, so it should be pulled into your project automatically for you when running Have you tried deleting your vendor directory, removing your composer.lock file (if one exists), and attempting a fresh install? |
Thanks for the quick reply. I checked that already and google/proto-client has been included by composer. The class file Feature.php is present and the class looks fine too. So I was suprised it didn't find the class. I manually copied the class to my test PHP file to avoid the error, but that caused another error and I gave up digging deeper. |
I doubt an older version of composer would be causing the issue. It could be the casing of the import, could you try |
Thank you, I really didn't see that. I used a small "i". Of course that won't work on Linux. The class Feature can be found but unfortunately there is a TypeError: PHP Fatal error: Uncaught TypeError: Argument 1 passed to Google\ApiCore\Middleware\RetryMiddleware::Google\ApiCore\Middleware{closure}() must be an instance of Exception, instance of Error given, called in /library/google-cloud-api/guzzlehttp/promises/src/Promise.php on line 203 and defined in /library/google-cloud-api/google/gax/src/ApiCore/Middleware/RetryMiddleware.php:90 |
Could you please share the full snippet which is triggering the error? While on PHP7 I don't get the same issue while running the snippet provided in the original comment. |
The error is triggered by $operation->pollUntilComplete(); in the following function: use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
use Google\Cloud\VideoIntelligence\V1\Feature;
function GCanalyzevideo ($path)
{
global $mgmt_config;
if (!empty ($mgmt_config['gs_access_json']))
{
// authenticate
putenv ("GOOGLE_APPLICATION_CREDENTIALS=".$mgmt_config['gs_access_json']);
try
{
// Instantiate a client
$video = new VideoIntelligenceServiceClient();
// Read the local video file
$inputContent = file_get_contents ($path);
// Execute a request
$options = ['inputContent'=>$inputContent, 'features'=>[Feature::LABEL_DETECTION]];
$operation = $video->annotateVideo($options);
// Wait for the request to complete
$operation->pollUntilComplete();
// Results
if ($operation->operationSucceeded())
{
$results = $operation->getResult()->getAnnotationResults()[0];
// Process video/segment level label annotations
foreach ($results->getSegmentLabelAnnotations() as $label)
{
$description = $label->getEntity()->getDescription();
$keywords = array();
foreach ($label->getCategoryEntities() as $categoryEntity)
{
$keywords[] = $categoryEntity->getDescription();
}
$i = 0;
$result = array();
foreach ($label->getSegments() as $segment)
{
$startTimeOffset = $segment->getSegment()->getStartTimeOffset();
$startSeconds = $startTimeOffset->getSeconds();
$startNanoseconds = floatval($startTimeOffset->getNanos())/1000000000.00;
$startTime = $startSeconds + $startNanoseconds;
$endTimeOffset = $segment->getSegment()->getEndTimeOffset();
$endSeconds = $endTimeOffset->getSeconds();
$endNanoseconds = floatval($endTimeOffset->getNanos())/1000000000.00;
$endTime = $endSeconds + $endNanoseconds;
$result[$i]['starttime'] = $startTime;
$result[$i]['endtime'] = $endTime;
$result[$i]['description'] = $description;
$result[$i]['keywords'] = implode (",", $keywords);
$result[$i]['confidence'] = $segment->getConfidence();
$i++;
}
}
return $result;
}
else return false;
}
catch (Exception $e)
{
return false;
}
}
else return false;
} |
Thanks @hypercms, I will look into this more. |
@hypercms, I ran the provided script on PHP 7.0 and was able to get back results:
A few questions to help us get to the bottom of this :)
|
I am using PHP Version 7.0.27-0+deb9u1 (cli) (built: Jan 5 2018 13:51:52). |
Uninstalled all Google Cloud API packages and uninstalled composer as well. Reinstalled everything, so I am using Google Video Intelligence Version 0.10.0. But there is still the same issue. |
We have a gRPC package for PHP which is used to facilitate the gRPC C extension. The PHP package comes for free, but the C extension requires a bit of extra set up. For some more details on gRPC, take a look here to see if it is worthwhile for your use case.
It looks like you're already using it, actually. After a little more research I believe I found the root of the issue here. When installing a fresh copy of PHP on a Compute Engine instance I started to get the same error you have mentioned. This is due to the fact one of our dependencies requires the bcmath extension which does not come with the default PHP 7 install. I have reported this issue on the relevant repository. While we work on getting this resolved, you have got a few options:
Hope this helps, and thanks again for the report :) |
I installed bcmath, restarted Apache and it worked :) |
Awesome! I'm going to keep this issue open just until we hear back from the protobuf team as to how they would like to handle the situation. |
Just had the same problem with the not-found Feature class. In the documentation (https://cloud.google.com/video-intelligence/docs/analyze-labels) it is written |
Good eye @florianbrinkmann! It looks like the source has been corrected to use the right import, and it may just be a matter of getting those changes propagated out to the documentation site. I'll poke around a bit and see what we can do to get that taken care of :). |
Great, thanks @dwsupplee! :) |
I'm going to close this out now. Please see the issue on the protobuf repository to follow up on #950 (comment). |
Running Apache 2.4, PHP7 on Debian 9, Google Video Intelligence API has been installed with composer.
After declaring the features [Feature::LABEL_DETECTION] for the request an error is reported that the class Feature is missing.
Code:
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
use Google\Cloud\Videointelligence\V1\Feature;
....
$video = new VideoIntelligenceServiceClient();
$options = ['inputContent'=>$inputContent, 'features'=>[Feature::LABEL_DETECTION]];
$operation = $video->annotateVideo($options);
Error:
PHP Fatal error: Uncaught Error: Class 'Google\Cloud\Videointelligence\V1\Feature' not found
The text was updated successfully, but these errors were encountered: