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

migrate code from googleapis/python-vision #8512

Merged
merged 118 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
9f24bc2
chore: move samples from python-docs-sample (#45)
arithmetic1728 Sep 11, 2020
0f4f0e5
feat!: migrate to use microgen (#52)
arithmetic1728 Sep 29, 2020
89fcc35
chore(deps): update dependency google-cloud-vision to v2 (#55)
renovate-bot Oct 13, 2020
39bd282
chore(deps): update dependency pillow to v8 (#65)
renovate-bot Oct 14, 2020
f63f447
chore(deps): update dependency google-cloud-storage to v1.31.2 (#50)
renovate-bot Oct 16, 2020
d421c55
chore(deps): update dependency pillow to v8.0.1 (#71)
renovate-bot Oct 23, 2020
de5c807
chore(deps): update dependency google-cloud-storage to v1.32.0 (#69)
renovate-bot Oct 23, 2020
d28eb2a
chore(deps): update dependency google-cloud-storage to v1.33.0 (#75)
renovate-bot Nov 16, 2020
db13215
chore: fix flaky test by adding rerun (#77)
munkhuushmgl Dec 2, 2020
2c88f2e
chore(deps): update dependency google-cloud-storage to v1.35.0 (#80)
renovate-bot Dec 15, 2020
c12cfce
feat(v1): add text detection params; fix: remove client side recv lim…
yoshi-automation Dec 22, 2020
1d9a11c
chore(deps): update dependency pillow to v8.1.0 (#90)
renovate-bot Jan 13, 2021
07d8820
chore(deps): update dependency google-cloud-vision to v2.1.0 (#99)
renovate-bot Feb 2, 2021
e5b46b2
test: add 3.9 tests (#96)
yoshi-automation Feb 11, 2021
c971d6f
chore(deps): update dependency google-cloud-vision to v2.2.0 (#109)
renovate-bot Feb 12, 2021
f8f6a3e
chore(deps): update dependency google-cloud-storage to v1.36.0 (#101)
renovate-bot Feb 16, 2021
a68723e
chore(deps): update dependency google-cloud-storage to v1.36.1 (#113)
renovate-bot Feb 24, 2021
6a81ff4
chore(deps): update dependency pillow to v8.1.1 (#114)
renovate-bot Mar 2, 2021
0e852dd
chore(deps): update dependency pillow to v8.1.2 (#115)
renovate-bot Mar 6, 2021
96ac088
chore(deps): update dependency google-cloud-storage to v1.36.2 (#116)
renovate-bot Mar 11, 2021
6846b63
chore(deps): update dependency google-cloud-storage to v1.37.0 (#121)
renovate-bot Mar 26, 2021
d165917
chore(deps): update dependency google-cloud-vision to v2.3.0 (#124)
renovate-bot Apr 1, 2021
d90d307
chore(deps): update dependency pillow to v8.2.0 (#126)
renovate-bot Apr 2, 2021
982781c
chore(deps): update dependency google-cloud-vision to v2.3.1 (#135)
renovate-bot Apr 28, 2021
3fd9d8c
chore: migrate to owl bot (#143)
parthea May 12, 2021
af03940
chore(deps): update dependency pytest to v6.2.4 (#144)
renovate-bot May 14, 2021
fa2cfc3
chore(deps): update dependency google-cloud-storage to v1.38.0 (#127)
renovate-bot May 16, 2021
88c75e5
chore: new owl bot post processor docker image (#151)
gcf-owl-bot[bot] May 28, 2021
0a383c1
chore: increased timeout by 200s to reduce flakiness (#155)
parthea May 31, 2021
7aa5fd1
chore(deps): update dependency google-cloud-vision to v2.3.2 (#160)
renovate-bot Jun 18, 2021
4682994
chore(deps): update dependency google-cloud-storage to v1.39.0 (#167)
renovate-bot Jun 23, 2021
c429e10
chore(deps): update dependency pillow to v8.3.0 (#173)
renovate-bot Jul 1, 2021
8888096
chore(deps): update dependency google-cloud-storage to v1.40.0 (#172)
renovate-bot Jul 3, 2021
e59ac1e
chore(deps): update dependency pillow to v8.3.1 (#174)
renovate-bot Jul 7, 2021
13b4557
chore(deps): update dependency backoff to v1.11.0 (#177)
renovate-bot Jul 12, 2021
41630d3
chore(deps): update dependency backoff to v1.11.1 (#196)
renovate-bot Jul 16, 2021
271e382
chore(deps): update dependency google-cloud-storage to v1.41.0 (#195)
renovate-bot Jul 16, 2021
2913860
chore(deps): update dependency google-cloud-vision to v2.4.0 (#178)
renovate-bot Jul 16, 2021
024df7f
chore(deps): update dependency google-cloud-storage to v1.41.1 (#203)
renovate-bot Jul 21, 2021
d096a98
feat: add Samples section to CONTRIBUTING.rst (#201)
gcf-owl-bot[bot] Jul 22, 2021
a1a63a4
chore(deps): update dependency google-cloud-vision to v2.4.1 (#204)
renovate-bot Jul 22, 2021
4a9a7cf
chore(deps): update dependency google-cloud-vision to v2.4.2 (#211)
renovate-bot Jul 29, 2021
3024bb1
chore: fix INSTALL_LIBRARY_FROM_SOURCE in noxfile.py (#213)
gcf-owl-bot[bot] Aug 11, 2021
323627d
chore: drop mention of Python 2.7 from templates (#217)
gcf-owl-bot[bot] Aug 13, 2021
bea9b01
chore(deps): update dependency google-cloud-storage to v1.42.0 (#215)
renovate-bot Aug 13, 2021
9fcf2cd
chore(deps): update dependency pytest to v6.2.5 (#222)
renovate-bot Aug 31, 2021
724b600
build(deps): bump pillow in /samples/snippets/crop_hints (#228)
dependabot[bot] Sep 8, 2021
be0f5b6
chore(deps): update dependency google-cloud-storage to v1.42.1 (#229)
renovate-bot Sep 9, 2021
8785515
chore(deps): update dependency pillow to v8.3.2 (#230)
renovate-bot Sep 10, 2021
1d5e66c
chore(deps): update dependency google-cloud-storage to v1.42.2 (#232)
renovate-bot Sep 16, 2021
bd6c5f7
chore: blacken samples noxfile template (#231)
gcf-owl-bot[bot] Sep 17, 2021
01c5ea7
chore(deps): update dependency google-cloud-vision to v2.4.3 (#238)
renovate-bot Sep 27, 2021
268fb72
chore(deps): update dependency google-cloud-vision to v2.4.4 (#242)
renovate-bot Sep 30, 2021
e94c871
chore(deps): update dependency google-cloud-storage to v1.42.3 (#243)
renovate-bot Oct 1, 2021
789149c
chore: fail samples nox session if python version is missing (#241)
gcf-owl-bot[bot] Oct 4, 2021
427b5a2
chore(python): Add kokoro configs for python 3.10 samples testing (#250)
gcf-owl-bot[bot] Oct 8, 2021
56c6915
chore(deps): update dependency google-cloud-vision to v2.5.0 (#251)
renovate-bot Oct 12, 2021
54afb08
chore(deps): update dependency pillow to v8.4.0 (#255)
renovate-bot Oct 15, 2021
3966d8d
chore(deps): update dependency google-cloud-vision to v2.6.0 (#258)
renovate-bot Oct 25, 2021
c525a05
docs: update async_detect_document() sample (#260)
kweinmeister Oct 26, 2021
783834c
chore(deps): update dependency google-cloud-vision to v2.6.1 (#262)
renovate-bot Oct 26, 2021
b1a8284
chore(deps): update dependency google-cloud-vision to v2.6.2 (#265)
renovate-bot Nov 3, 2021
5475736
chore(deps): update dependency google-cloud-storage to v1.43.0 (#274)
renovate-bot Nov 18, 2021
dcc35c6
docs: Update doctext sample to include method signature (#275)
kweinmeister Nov 18, 2021
a14c009
docs: Add example of how to use max_results (#277)
andrewferlitsch Dec 10, 2021
eb5c8f9
chore: update python-docs-samples link to main branch (#278)
gcf-owl-bot[bot] Dec 12, 2021
2bb258f
chore(deps): update dependency google-cloud-vision to v2.6.3 (#281)
renovate-bot Dec 13, 2021
1af94f0
chore(samples): Add check for tests in directory (#288)
gcf-owl-bot[bot] Jan 11, 2022
87b8ae5
chore(deps): update all dependencies (#285)
renovate-bot Jan 14, 2022
1b23970
chore(deps): update dependency google-cloud-storage to v2 (#294)
renovate-bot Jan 16, 2022
1bf5707
chore(python): Noxfile recognizes that tests can live in a folder (#296)
gcf-owl-bot[bot] Jan 19, 2022
ef16b85
chore(deps): update dependency google-cloud-storage to v2.1.0 (#297)
renovate-bot Feb 26, 2022
af291d8
chore(deps): update all dependencies (#311)
renovate-bot Feb 28, 2022
cf8e5c5
chore(deps): update all dependencies (#313)
renovate-bot Mar 1, 2022
55a5098
chore: Adding support for pytest-xdist and pytest-parallel (#320)
gcf-owl-bot[bot] Mar 4, 2022
8c85e9d
chore(deps): update dependency google-cloud-vision to v2.7.1 (#323)
renovate-bot Mar 8, 2022
207e6e9
chore(deps): update dependency pytest to v7.1.0 (#325)
renovate-bot Mar 13, 2022
47620b0
chore(deps): update dependency google-cloud-storage to v2.2.0 (#326)
renovate-bot Mar 14, 2022
49e950b
chore(deps): update dependency google-cloud-storage to v2.2.1 (#327)
renovate-bot Mar 17, 2022
57f3425
chore(deps): update dependency pytest to v7.1.1 (#328)
renovate-bot Mar 19, 2022
53be1b0
chore(python): use black==22.3.0 (#333)
gcf-owl-bot[bot] Mar 29, 2022
f5fc180
chore(deps): update dependency google-cloud-vision to v2.7.2 (#332)
renovate-bot Mar 29, 2022
9901741
chore(deps): update dependency pillow to v9.1.0 (#338)
renovate-bot Apr 3, 2022
700c973
chore(deps): update dependency google-cloud-storage to v2.3.0 (#345)
renovate-bot Apr 13, 2022
7ffb94b
chore(python): add nox session to sort python imports (#347)
gcf-owl-bot[bot] Apr 21, 2022
c80c653
chore(deps): update dependency pytest to v7.1.2 (#350)
renovate-bot Apr 25, 2022
1e790f6
chore(deps): update dependency backoff to v2 (#351)
renovate-bot Apr 26, 2022
bafe4bf
chore(deps): update dependency backoff to v2.0.1 (#353)
renovate-bot Apr 27, 2022
2f1ffd5
chore(deps): update dependency pillow to v9.1.1 (#359)
renovate-bot May 18, 2022
3f686a6
fix: require python 3.7+ (#452)
gcf-owl-bot[bot] Jul 10, 2022
2e04e09
chore(deps): update all dependencies (#444)
renovate-bot Jul 16, 2022
3635ba1
chore(deps): update all dependencies (#461)
renovate-bot Aug 2, 2022
89bf17f
chore(deps): update all dependencies (#463)
renovate-bot Aug 5, 2022
4cfae14
chore(deps): update all dependencies (#466)
renovate-bot Aug 9, 2022
b9b3563
chore(deps): update dependency google-cloud-vision to v3.1.1 (#471)
renovate-bot Aug 16, 2022
b2d7484
chore(deps): update dependency pytest to v7.1.3 (#480)
renovate-bot Sep 6, 2022
42eeaae
chore: detect samples tests in nested directories (#484)
gcf-owl-bot[bot] Sep 13, 2022
869f21b
chore(deps): update dependency google-cloud-vision to v3.1.2 (#488)
renovate-bot Sep 16, 2022
9e80372
chore(deps): update dependency google-cloud-vision to v3.1.3 (#492)
renovate-bot Oct 3, 2022
d914ee5
chore(deps): update dependency backoff to v2.2.1 (#493)
renovate-bot Oct 6, 2022
df00ead
chore(deps): update dependency google-cloud-vision to v3.1.4 (#496)
renovate-bot Oct 10, 2022
e103806
chore(deps): update dependency pytest to v7.2.0 (#497)
renovate-bot Oct 26, 2022
8974dc2
chore(deps): update dependency pillow to v9.3.0 (#499)
renovate-bot Oct 31, 2022
4e4d440
Merge remote-tracking branch 'migration/main' into python-vision-migr…
arbrown Nov 14, 2022
25dc0ff
Update company name
arbrown Nov 15, 2022
beeb6ea
Remove extra verbiage from copyright header
arbrown Nov 15, 2022
1dcaa73
Fix copyright lines
arbrown Nov 15, 2022
3657f19
Remove comma
arbrown Nov 15, 2022
3324786
Fix copyright header
arbrown Nov 15, 2022
e97630f
Remove trailing spaces
arbrown Nov 15, 2022
2a338d1
Add blunderbuss and CODEOWNER
arbrown Nov 15, 2022
bafccb9
Remove noxfiles
arbrown Nov 15, 2022
2001fcf
Remove noxfile
arbrown Nov 15, 2022
6e603cc
Ignore python 2.7 in noxfile_config
arbrown Nov 15, 2022
817c886
Remove remaining noxfiles
arbrown Nov 15, 2022
b13308f
Fix blunderbuss and CODEOWNERS teams
arbrown Nov 15, 2022
e5b117c
Update .github/CODEOWNERS
dandhlee Nov 15, 2022
60ecda6
Remove final noxfile
arbrown Nov 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@
/trace/**/* @ymotongpoo @GoogleCloudPlatform/python-samples-reviewers
/translate/**/* @nicain @GoogleCloudPlatform/python-samples-reviewers
/talent/**/* @GoogleCloudPlatform/python-samples-reviewers
/vision/**/* @GoogleCloudPlatform/python-samples-reviewers
/workflows/**/* @GoogleCloudPlatform/python-samples-reviewers
/kms/**/** @GoogleCloudPlatform/dee-infra @GoogleCloudPlatform/python-samples-reviewers
4 changes: 4 additions & 0 deletions .github/blunderbuss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ assign_issues_by:
- 'api: cloudkms'
to:
- GoogleCloudPlatform/dee-infra
- labels:
- 'api: vision'
to:
- GoogleCloudPlatform/python-samples-reviewers

assign_prs_by:
- labels:
Expand Down
1 change: 1 addition & 0 deletions vision/AUTHORING_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md
1 change: 1 addition & 0 deletions vision/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/CONTRIBUTING.md
2 changes: 2 additions & 0 deletions vision/snippets/crop_hints/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
output-crop.jpg
output-hint.jpg
111 changes: 111 additions & 0 deletions vision/snippets/crop_hints/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
.. This file is automatically generated. Do not edit this file directly.

Google Cloud Vision API Python Samples
===============================================================================

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=vision/cloud-client/crop_hints/README.rst


This directory contains samples for Google Cloud Vision API. `Google Cloud Vision API`_ allows developers to easily integrate vision detection features within applications, including image labeling, face and landmark detection, optical character recognition (OCR), and tagging of explicit content.

- See the `migration guide`_ for information about migrating to Python client library v0.25.1.

.. _migration guide: https://cloud.google.com/vision/docs/python-client-migration




.. _Google Cloud Vision API: https://cloud.google.com/vision/docs

Setup
-------------------------------------------------------------------------------


Authentication
++++++++++++++

This sample requires you to have authentication setup. Refer to the
`Authentication Getting Started Guide`_ for instructions on setting up
credentials for applications.

.. _Authentication Getting Started Guide:
https://cloud.google.com/docs/authentication/getting-started

Install Dependencies
++++++++++++++++++++

#. Clone python-docs-samples and change directory to the sample directory you want to use.

.. code-block:: bash

$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git

#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions.

.. _Python Development Environment Setup Guide:
https://cloud.google.com/python/setup

#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.

.. code-block:: bash

$ virtualenv env
$ source env/bin/activate

#. Install the dependencies needed to run the samples.

.. code-block:: bash

$ pip install -r requirements.txt

.. _pip: https://pip.pypa.io/
.. _virtualenv: https://virtualenv.pypa.io/

Samples
-------------------------------------------------------------------------------

Crop Hints Tutorial
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=vision/cloud-client/crop_hints/crop_hints.py,vision/cloud-client/crop_hints/README.rst




To run this sample:

.. code-block:: bash

$ python crop_hints.py

usage: crop_hints.py [-h] image_file mode

positional arguments:
image_file The image you'd like to crop.
mode Set to "crop" or "draw".

optional arguments:
-h, --help show this help message and exit





The client library
-------------------------------------------------------------------------------

This sample uses the `Google Cloud Client Library for Python`_.
You can read the documentation for more details on API usage and use GitHub
to `browse the source`_ and `report issues`_.

.. _Google Cloud Client Library for Python:
https://googlecloudplatform.github.io/google-cloud-python/
.. _browse the source:
https://github.com/GoogleCloudPlatform/google-cloud-python
.. _report issues:
https://github.com/GoogleCloudPlatform/google-cloud-python/issues


.. _Google Cloud SDK: https://cloud.google.com/sdk/
30 changes: 30 additions & 0 deletions vision/snippets/crop_hints/README.rst.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file is used to generate README.rst

product:
name: Google Cloud Vision API
short_name: Cloud Vision API
url: https://cloud.google.com/vision/docs
description: >
`Google Cloud Vision API`_ allows developers to easily integrate vision
detection features within applications, including image labeling, face and
landmark detection, optical character recognition (OCR), and tagging of
explicit content.


- See the `migration guide`_ for information about migrating to Python client library v0.25.1.


.. _migration guide: https://cloud.google.com/vision/docs/python-client-migration

setup:
- auth
- install_deps

samples:
- name: Crop Hints Tutorial
file: crop_hints.py
show_help: True

cloud_client_library: true

folder: vision/cloud-client/crop_hints
98 changes: 98 additions & 0 deletions vision/snippets/crop_hints/crop_hints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/env python

# Copyright 2017 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Outputs a cropped image or an image highlighting crop regions on an image.

Examples:
python crop_hints.py resources/cropme.jpg draw
python crop_hints.py resources/cropme.jpg crop
"""
# [START vision_crop_hints_tutorial]
# [START vision_crop_hints_tutorial_imports]
import argparse
import io

from google.cloud import vision
from PIL import Image, ImageDraw
# [END vision_crop_hints_tutorial_imports]


def get_crop_hint(path):
# [START vision_crop_hints_tutorial_get_crop_hints]
"""Detect crop hints on a single image and return the first result."""
client = vision.ImageAnnotatorClient()

with io.open(path, 'rb') as image_file:
content = image_file.read()

image = vision.Image(content=content)

crop_hints_params = vision.CropHintsParams(aspect_ratios=[1.77])
image_context = vision.ImageContext(crop_hints_params=crop_hints_params)

response = client.crop_hints(image=image, image_context=image_context)
hints = response.crop_hints_annotation.crop_hints

# Get bounds for the first crop hint using an aspect ratio of 1.77.
vertices = hints[0].bounding_poly.vertices
# [END vision_crop_hints_tutorial_get_crop_hints]

return vertices


def draw_hint(image_file):
"""Draw a border around the image using the hints in the vector list."""
# [START vision_crop_hints_tutorial_draw_crop_hints]
vects = get_crop_hint(image_file)

im = Image.open(image_file)
draw = ImageDraw.Draw(im)
draw.polygon([
vects[0].x, vects[0].y,
vects[1].x, vects[1].y,
vects[2].x, vects[2].y,
vects[3].x, vects[3].y], None, 'red')
im.save('output-hint.jpg', 'JPEG')
print('Saved new image to output-hint.jpg')
# [END vision_crop_hints_tutorial_draw_crop_hints]


def crop_to_hint(image_file):
"""Crop the image using the hints in the vector list."""
# [START vision_crop_hints_tutorial_crop_to_hints]
vects = get_crop_hint(image_file)

im = Image.open(image_file)
im2 = im.crop([vects[0].x, vects[0].y,
vects[2].x - 1, vects[2].y - 1])
im2.save('output-crop.jpg', 'JPEG')
print('Saved new image to output-crop.jpg')
# [END vision_crop_hints_tutorial_crop_to_hints]


if __name__ == '__main__':
# [START vision_crop_hints_tutorial_run_application]
parser = argparse.ArgumentParser()
parser.add_argument('image_file', help='The image you\'d like to crop.')
parser.add_argument('mode', help='Set to "crop" or "draw".')
args = parser.parse_args()

if args.mode == 'crop':
crop_to_hint(args.image_file)
elif args.mode == 'draw':
draw_hint(args.image_file)
# [END vision_crop_hints_tutorial_run_application]
# [END vision_crop_hints_tutorial]
37 changes: 37 additions & 0 deletions vision/snippets/crop_hints/crop_hints_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2017 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

import crop_hints


def test_crop(capsys):
"""Checks the output image for cropping the image is created."""
file_name = os.path.join(
os.path.dirname(__file__),
'resources/cropme.jpg')
crop_hints.crop_to_hint(file_name)
out, _ = capsys.readouterr()
assert os.path.isfile('output-crop.jpg')


def test_draw(capsys):
"""Checks the output image for drawing the crop hint is created."""
file_name = os.path.join(
os.path.dirname(__file__),
'resources/cropme.jpg')
crop_hints.draw_hint(file_name)
out, _ = capsys.readouterr()
assert os.path.isfile('output-hint.jpg')
27 changes: 27 additions & 0 deletions vision/snippets/crop_hints/noxfile_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Default TEST_CONFIG_OVERRIDE for python repos.

# You can copy this file into your directory, then it will be inported from
# the noxfile.py.

# The source of truth:
# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/noxfile_config.py

TEST_CONFIG_OVERRIDE = {
# You can opt out from the test for specific Python versions.
# Pillow 9.0.0 does not support python 3.6
"ignored_versions": ["2.7", "3.6"],
}
1 change: 1 addition & 0 deletions vision/snippets/crop_hints/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest==7.2.0
2 changes: 2 additions & 0 deletions vision/snippets/crop_hints/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
google-cloud-vision==3.1.4
pillow==9.3.0
Binary file added vision/snippets/crop_hints/resources/cropme.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading