Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Alturos.Yolo.Model;
using Alturos.Yolo.WebService.Contract;
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Description;

Expand Down Expand Up @@ -37,6 +39,40 @@ public IHttpActionResult Detect(byte[] imageData)
}
}

/// <summary>
/// Upload image as multi-part from data
/// This example can be tested with pastman. http://localhost:8080//ObjectDetection//Upload
/// Select Body->form data
/// Then select "file" from the key box before typing in (any) key name. Then select your image file in the value.
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("Upload")]
[ResponseType(typeof(YoloItem[]))]
public async Task<IHttpActionResult> Detect()
{
// Get the HTTP request
//HttpRequestMessage httpRequest = this.Request;
var provider = new MultipartMemoryStreamProvider();
await Request.Content.ReadAsMultipartAsync(provider);

// Get the first value from the form
var file = provider.Contents[0];

// Read file as bytes
var imageData = await file.ReadAsByteArrayAsync();
try
{
// Pass byte array to wrapper
var items = this._objectDetection.Detect(imageData);
return Ok(items);
}
catch (Exception exception)
{
return InternalServerError(exception);
}
}

/// <summary>
/// Detect object positions
/// </summary>
Expand Down