Setup

1

Create an API key

First create an API key using the instructions in API keys

2

Install the client

Next install the AskVideos client if using Python. Or consult the REST API reference for other frameworks.

3

Create an index

Next, create an index. For this tutorial, we will use an index with the name ‘test_index’

In this tutorial, we will index instagram videos from a restaurant and video clips that contain food that is on the menu! We will explore searching via text, images and video.

Indexing videos from instagram

index_name = 'instagram_example_index'
channel_name = 'vallatable'
client.index_from_instagram(index_name, channel_name, num_videos=10)

Finding food

A typical social media video for a restaurant includes B-roll of food interspersed with various promotional content including text.

We don’t care about those things because we’re hungry. We only want the find the parts that have food in them. So for our first query, we’ll just search for ‘food’.

query = 'food'
results = client.search_videos(index_name, food)

Finding specific food

Now suppose we have a craving for a specific kind of food, let’s say some noodles, we can search for that instead.

query = 'noodles'
results = client.search_videos(index_name, food)

As food names get more specific or complex, the task of identifying food becomes harder. However since the AskVideos API can do image or video queries, we can leverage that instead to identify the food that we want.

In this example, we have a dish called “Pak Mor Cashew”.

Let’s see if we can find the right parts of the video given this image.


image_path = '/path/to/pak_mor_cashew.jpg'

results = client.search_by_image(
            index_name,
            image_path=image_path,
            top_k=10)

What we don’t want

Sometimes, these videos have text on them or contain footage of people talking. We can remove those by adding a negative query.

This is simple to do with the AskVideos query spec. Simply provide a comma separated list with ’-’ in front of the negative queries e.g.

# Search for noodles but no people
query = 'noodles,-person'
results = client.search_videos(index_name, food)

Building an app

With these building blocks, we can build a simple but powerful application to tag items in videos!

Next steps

Check out our other examples or dive deeper into the api