ImageExtractor (U-SQL)
Summary
The ImageExtractor
function from the ImageCommon
assembly is used to extract data from images that will be consumed by other cognitive functions. The current maximum size of a row is 4 MB so you will need to use images less than 4 MB in size when using ImageExtractor
.
Examples
- The examples can be executed in Visual Studio with the Azure Data Lake Tools plug-in.
- Ensure you have installed the cognitive assemblies, see Registering Cognitive Extensions in U-SQL for more information.
- The scripts can be executed locally if you first download the assemblies locally, see Enabling U-SQL Advanced Analytics for Local Execution for more information. An Azure subscription and Azure Data Lake Analytics account is not needed when executed locally.
- You will need images accessible to you ADLA or Local account.
Load images to a rowset variable
REFERENCE ASSEMBLY ImageCommon;
@images =
EXTRACT FileName string,
ImgData byte[]
FROM @"/Samples/Images/{FileName}.jpg"
USING new Cognition.Vision.ImageExtractor();
@result =
SELECT FileName FROM @images;
OUTPUT @result
TO "/ReferenceGuide/Cognition/Vision/ImageExtractor_rv.txt"
USING Outputters.Tsv();
Load images to a table
This table will be referenced in various cognitive examples
REFERENCE ASSEMBLY ImageCommon;
DROP TABLE IF EXISTS dbo.myImages;
CREATE TABLE dbo.myImages (
INDEX clx_FileName CLUSTERED(FileName ASC)
DISTRIBUTED BY HASH (FileName)
) AS EXTRACT FileName string,
ImgData byte[]
FROM @"/Samples/Images/{FileName}.jpg"
USING new Cognition.Vision.ImageExtractor();