Skip to content
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

TEXT_DETECTION, DOCUMENT_TEXT_DETECTION display error #38

Open
ifwelove opened this issue Dec 11, 2019 · 3 comments
Open

TEXT_DETECTION, DOCUMENT_TEXT_DETECTION display error #38

ifwelove opened this issue Dec 11, 2019 · 3 comments

Comments

@ifwelove
Copy link

Symfony\Component\Debug\Exception\FatalThrowableError
Argument 1 passed to Vision\Annotation\Word::__construct() must be an instance of Vision\Annotation\TextProperty, null given, called in /project/vendor/jordikroon/google-vision/src/Hydrator/Strategy/WordsStrategy.php on line 82

$apiKey = 'test';
$vision = new \Vision\Vision(
           $apiKey,
            [
                new \Vision\Feature(\Vision\Feature::TEXT_DETECTION, 100)
            ]
);
$imagePath = 'https://img.ali-img.net/img.alicdn.com/imgextra/i1/2243067373/O1CN01eE61ag24KskpsXLPX_!!2243067373.jpg_v_600.jpg';
$response = $vision->request(
            new \Vision\Request\Image\RemoteImage($imagePath)
);
dd($response);

public function hydrate($value)
    {
        $wordEntities = [];

        foreach ($value as $wordEntityInfo) {
            $textProperty = isset($wordEntityInfo['property'])
                ? $this->textPropertyStrategy->hydrate($wordEntityInfo['property'])
                : null;

            $boundingBox = isset($wordEntityInfo['boundingBox'])
                 ? $this->boundingPolyStrategy->hydrate($wordEntityInfo['boundingBox'])
                 : null;

            $symbols = isset($wordEntityInfo['symbols'])
                 ? $this->symbolsStrategy->hydrate($wordEntityInfo['symbols'])
                 : null;
            // $textProperty is null, Cause an error
            $wordEntities[] = new Word(
                $textProperty,
                $boundingBox,
                $symbols
            );
        }

        return $wordEntities;
    }
@natelloyd
Copy link

Also experiencing this on 1.8.0 and after upgrading to 1.8.2. Unfortunately not time to debug it much right now.

@stephanrossi
Copy link

There is a way to get it back to work again ?

@jericosdelacruz
Copy link

In the Word Class Constructor, do this:

public function __construct(TextProperty $property = null, BoundingPoly $boundingBox, array $symbols)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants