Examples
Setup
-
Go to Clarifai’s website and get a free API key.
-
Go to ScratchX and hit the Load experimental extension button.
-
Use the following URL to load the extension via URL.
-
Put the API keys in the Connect to API block and execute the block to initialize the Clarifai API.
Usage
-
To search using image URL
-
Place the Search image using link block in the Scratch script.
-
Paste the image URL in the input area of the block.
-
-
To search using camera
-
Place the Search image using camera block in the Scratch script.
-
Click allow when camera permissions are prompted.
-
Note: Camera can only be accessed when on secure https domains. If you want to test the feature camera feature on ScratchX, you can start Chrome in insecure mode which will allow you to access the camera on Scratch.
- If you are on macOS, use the following command in terminal to open Chrome in insecure mode:
open -a "Google Chrome" --args --unsafely-treat-insecure-origin-as-secure="http://scratchx.org/" --user-data-dir
- Untested: If you are on windows, use the following command in command prompt:
chrome.exe --unsafely-treat-insecure-origin-as-secure="http://scratchx.org/" --user-data-dir
- If you are on macOS, use the following command in terminal to open Chrome in insecure mode:
-
-
To search using base64 image data
-
Place the Search image using DataURI block in the Scratch script.
-
Paste the base64 image data in the input area of the block.
-
-
Using results
-
To get the count of results
- Use the Image results count reporter block
-
To get each result from results
- Use the Get result x from results reporter block and put a value for x where x is an index from 0 to count of results - 1.
-