Image search
An image can be used in a search in two different ways, either via uploading a new image-file from the users device or by using the asset-id of an image that was previously added to the Partium system, for example via a previous search attempt during the same search session. You can only use one of these options at a time. Also it is not possible to use multiple images in the same search-session.
To refine the area of the image where the system should search in, you can add a crop area to the search request.
Search with image-file
To upload a new image-file from the system, you have to create an object of type JsPfile, which needs to be initialized with the image in Blob format:
Partium.search.performSearch(
{
organizationName: '<organization-name>',
searchLanguage: '<search-language-code>',
searchImage: new JsPFile( imageBlob ),
}
)
If you want to use an image search throughout a search session, make sure to only use searchImage with a file for initially adding the image to the search session. For the following requests use the same image via it's asset-id in searchImageAssetId. This will make your search faster and save you bandwidth, because otherwise the image will be uploaded again with every request.
You can find the asset-id inside the searchInput-object of the search response.
Search with asset-id
Whenever you have previously uploaded an image to Partium, you can use the searchImageAssetId parameter for performing an image search with that image. This is especially relevant for search sessions, where you want to add other search modalities after an image search, so you don't have to reupload the image every time.
Partium.search.performSearch(
{
organizationName: '<organization-name>',
searchLanguage: '<search-language-code>',
searchSessionId: '<search-session-id>',
searchImageAssetId: '<search-image-asset-id>',
}
)
Add crop area to image search
Adding a crop area to the image search can be useful to get better results, for example if the object of interest is only in a small area of the image or multiple parts are visible and the search should only focus on one of them. If no crop area is specified, the whole content of the image will be used for the search.
The crop area can be added to the search inputs along with a search image file or search image asset-id:
Partium.search.performSearch(
{
organizationName: '<organization-name>',
searchLanguage: '<search-language-code>',
searchImage: new JsPFile( imageBlob ),
searchImageCropArea: { x1: 0.1, y1: 0.2, x2: 0.5, y2: 0.8 },
}
)
x1/y1, x2/y2 are the top left and bottom right coordinates of the crop area in percent, where 0 is 0% and 1 is 100%. For example, the following image has a crop area of { x1: 0.25, y1: 0.2, x2: 0.8, y2: 0.7 }
:
