ImgesRequest.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace KdanCommon.GoogleCloud.Data.Vision
  8. {
  9. public partial class ImgesRequest
  10. {
  11. [JsonProperty("requests")]
  12. public ImageRequest[] Requests { get; set; }
  13. public ImgesRequest(List<string> inputContents, string[] languageHints = null)
  14. {
  15. Requests = new ImageRequest[inputContents.Count];
  16. for (int i = 0; i < inputContents.Count; i++)
  17. {
  18. Requests[i] = new ImageRequest()
  19. {
  20. Image = new Image()
  21. {
  22. Content = inputContents[i]
  23. },
  24. Features = new Feature[]
  25. {
  26. new Feature()
  27. {
  28. Type = "TEXT_DETECTION"
  29. }
  30. },
  31. ImageContext = new ImageContext()
  32. {
  33. LanguageHints = languageHints
  34. }
  35. };
  36. }
  37. }
  38. }
  39. public partial class ImageRequest
  40. {
  41. [JsonProperty("image")]
  42. public Image Image { get; set; }
  43. [JsonProperty("features")]
  44. public Feature[] Features { get; set; }
  45. [JsonProperty("imageContext")]
  46. public ImageContext ImageContext { get; set; }
  47. }
  48. public partial class Feature
  49. {
  50. [JsonProperty("type")]
  51. public string Type { get; set; }
  52. }
  53. public partial class Image
  54. {
  55. [JsonProperty("content")]
  56. public string Content { get; set; }
  57. }
  58. public partial class ImageContext
  59. {
  60. [JsonProperty("languageHints")]
  61. public string[] LanguageHints { get; set; }
  62. }
  63. }