Extract Images Features and Add Them to Search Context Introduction
This article explain how to extract features from image sources (storage, url or/and features collection) and add them to features index. The API URL is:
POST /imaging/ai/imageSearch/{searchContextId}/features
Resource URI
Swagger UI lets you call Aspose.Imaging REST APIs directly from the browser. The description of the APIs and their parameters are also given there.
cURL Example
SDKs
Using an SDK (API client) is the quickest way for a developer to speed up the development. An SDK takes care of a lot of low-level details of making requests and handling responses and lets you focus on writing code specific to your particular project. Check out our GitHub repository for a complete list of Aspose.Imaging SDKs along with working examples, to get you started in no time.
SDK Examples
.NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
protected void AddImageFeaturesToSearchContext(string storageSourcePath, bool isFolder = false)
{
var request = isFolder
? new CreateImageFeaturesRequest(this.SearchContextId, imageId: null, imagesFolder: storageSourcePath, storage: null)
: new CreateImageFeaturesRequest(this.SearchContextId, imageId: storageSourcePath, storage: null);
this.ImagingApi.CreateImageFeatures(request);
}
Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String APP_KEY = ""; // Get AppKey and AppSID from https:dashboard.aspose.cloud/
String APP_SID = ""; // Get AppKey and AppSID from https:dashboard.aspose.cloud/
String DATA_PATH = "src/main/resources/";
ImagingApi imagingApi = new ImagingApi(APP_KEY, APP_SID);
try {
// The search context identifier.
String searchContextId = "5728a4ed-12bb-4b4a-8dce-38295735549f";
// Input image
String imageName = "WaterMark.bmp";
File inputFile = new File(DATA_PATH + imageName);
byte[] imageData = new byte[(int) inputFile.length()];
FileInputStream inputStream = new FileInputStream(inputFile);
inputStream.read(imageData);
String imageId = null; //The image identifier
String imagesFolder = null; // Images folder
String folder = null;
String storage = null; // We are using default Cloud Storage
PostSearchContextExtractImageFeaturesRequest postSearchContextExtractImageFeaturesRequest =
new PostSearchContextExtractImageFeaturesRequest(searchContextId, imageData, imageId, imagesFolder,
folder, storage);
imagingApi.postSearchContextExtractImageFeatures(postSearchContextExtractImageFeaturesRequest);
} catch (Exception e) {
System.out.println(e.getMessage());
}