@NewGene Technologies Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
.
To perform the FaceDetect Operation from console application, you can leverage the below sample code:
Note: Please update the {Region} of your face resource and the subscription key in below code:
string _url = "https://{REGION}.cognitiveservices.azure.com/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=headpose,mask,qualityforrecognition&recognitionModel=recognition_04&returnRecognitionModel=false&detectionModel=detection_03&faceIdTimeToLive=86400";
string _key = "XXXXXXXXXXXX"; // Replace with your subscription key
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(_url);
wr.ContentType = "application/json";
wr.Method = "POST";
wr.Headers.Add("Ocp-Apim-Subscription-Key", _key);
// Define the request body as a JSON string
string jsonRequestBody = @"{
""url"": ""https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50.jpg""
}";
// Convert the JSON request body to a byte array
byte[] postData = System.Text.Encoding.UTF8.GetBytes(jsonRequestBody);
Stream rs = wr.GetRequestStream();
rs.Write(postData, 0, postData.Length);
rs.Close();
HttpWebResponse wresp = (HttpWebResponse)wr.GetResponse();
// Read and display the response content
using (StreamReader streamReader = new StreamReader(wresp.GetResponseStream()))
{
string responseStr = streamReader.ReadToEnd();
Console.WriteLine("Response:");
Console.WriteLine(responseStr);
}
wresp.Close();
Console.ReadLine();
.
Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.
**
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.