Skip to content

DO NOT MERGE vision: v1 logo detection samples #3094

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion video/cloud-client/analyze/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
google-cloud-videointelligence==1.13.0
google-cloud-videointelligence==1.14.0
google-cloud-storage==1.26.0
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

import io

# [START video_detect_logo_beta]
# [START video_detect_logo]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we try not to do this as it will break docs. Prefer to create a new GA file rather than rename beta files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah dang good point. Do we then follow up and delete the beta files?


from google.cloud import videointelligence_v1p3beta1
from google.cloud.videointelligence_v1p3beta1 import enums
from google.cloud import videointelligence
from google.cloud.videointelligence import enums


def sample_annotate_video(local_file_path="resources/googlework_tiny.mp4"):
"""Performs asynchronous video annotation for logo recognition on a local file."""

client = videointelligence_v1p3beta1.VideoIntelligenceServiceClient()
client = videointelligence.VideoIntelligenceServiceClient()

with io.open(local_file_path, "rb") as f:
input_content = f.read()
Expand Down Expand Up @@ -104,4 +104,4 @@ def sample_annotate_video(local_file_path="resources/googlework_tiny.mp4"):
)


# [END video_detect_logo_beta]
# [END video_detect_logo]
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# [START video_detect_logo_gcs_beta]
# [START video_detect_logo_gcs]

from google.cloud import videointelligence_v1p3beta1
from google.cloud.videointelligence_v1p3beta1 import enums
from google.cloud import videointelligence
from google.cloud.videointelligence import enums


def sample_annotate_video(
input_uri="gs://cloud-samples-data/video/googlework_tiny.mp4",
):

client = videointelligence_v1p3beta1.VideoIntelligenceServiceClient()
client = videointelligence.VideoIntelligenceServiceClient()

features_element = enums.Feature.LOGO_RECOGNITION
features = [features_element]
Expand Down Expand Up @@ -101,4 +101,4 @@ def sample_annotate_video(
)


# [END video_detect_logo_gcs_beta]
# [END video_detect_logo_gcs]
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

import os

import video_detect_logo_gcs_beta
import video_detect_logo_gcs

RESOURCES = os.path.join(os.path.dirname(__file__), "resources")


def test_sample_annotate_video(capsys):
input_uri = "gs://cloud-samples-data/video/googlework_tiny.mp4"

video_detect_logo_gcs_beta.sample_annotate_video(input_uri=input_uri)
video_detect_logo_gcs.sample_annotate_video(input_uri=input_uri)

out, _ = capsys.readouterr()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

import os

import video_detect_logo_beta
import video_detect_logo

RESOURCES = os.path.join(os.path.dirname(__file__), "resources")


def test_sample_annotate_video(capsys):
local_file_path = os.path.join(RESOURCES, "googlework_tiny.mp4")

video_detect_logo_beta.sample_annotate_video(local_file_path=local_file_path)
video_detect_logo.sample_annotate_video(local_file_path=local_file_path)

out, _ = capsys.readouterr()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ def sample_async_batch_annotate_images(
{"type": enums.Feature.Type.LABEL_DETECTION},
{"type": enums.Feature.Type.IMAGE_PROPERTIES},
]

# Each requests element corresponds to a single image. To annotate more
# images, create a request element for each image and add it to
# the array of requests
requests = [{"image": image, "features": features}]
gcs_destination = {"uri": output_uri}

# The max number of responses to output in each JSON file
batch_size = 2
output_config = {"gcs_destination": gcs_destination, "batch_size": batch_size}
output_config = {"gcs_destination": gcs_destination,
"batch_size": batch_size}

operation = client.async_batch_annotate_images(requests, output_config)

Expand Down