forked from CarlosP-MS/CognitiveServicesTutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageMapper.cs
More file actions
39 lines (33 loc) · 1.04 KB
/
ImageMapper.cs
File metadata and controls
39 lines (33 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Microsoft.Azure.Search.Models;
namespace PictureBot.Models
{
public class ImageMapper
{
public static SearchHit ToSearchHit(SearchResult hit)
{
var searchHit = new SearchHit
{
Key = (string)hit.Document["rid"],
Title = (string)hit.Document["FileName"],
PictureUrl = (string)hit.Document["BlobUri"],
Description = (string)hit.Document["Caption"]
};
object Tags;
if (hit.Document.TryGetValue("Tags", out Tags))
{
searchHit.PropertyBag.Add("Tags", Tags);
}
object NumFaces;
if (hit.Document.TryGetValue("NumFaces", out NumFaces))
{
searchHit.PropertyBag.Add("NumFaces", NumFaces);
}
object Faces;
if (hit.Document.TryGetValue("Faces", out Faces))
{
searchHit.PropertyBag.Add("Faces", Faces);
}
return searchHit;
}
}
}