I have image in the form of byte[] data and code to pass byte data to get response from client. I need help in putting them together
I tried to use the code where I have my byte data but the async operations created a lot of confusion
"data" contains the byte[] data
private async void InitializeVideoFeedModule()
{
//Must in UI thread
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
{
//Raw data and decoded data listener
if (videoParser == null)
{
videoParser = new DJIVideoParser.Parser();
videoParser.Initialize( delegate (byte[] data)
{
return DJISDKManager.Instance.VideoFeeder.ParseAssitantDecodingInfo(0, data);
});
}
}
}
code to pass byte data and get response
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Prediction-Key", "XXXXX");
// Prediction URL - replace this example URL with valid Prediction URL.
string sequenceURL = "https://abc/dcr/xyz";
HttpResponseMessage response;
using (var content = new ByteArrayContent(data))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
response = await client.PostAsync(sequenceURL, content);
var output = await response.Content.ReadAsStringAsync();
Console.WriteLine(output);
JObject json = JObject.Parse(output);
}
The delegate object and async operations are causing conflicts when I use them together.