WhatsApp Chat Sentiment Analysis in R

Analyse Face Using Microsoft Cognitive Services | R Programming

Detect, identify, analyze, organize, and tag faces in photos

Objective: Analyse the face of Leonardo DiCaprio Using Microsoft Face API

Step 1 Generate a Microsoft Azure Face API Key and endpoint URL using this Link

Step 2 Install and activate required package in R


Step 3 Run following commands in R

#Make sure the URL is matching with your endpoint URL
>face_api_url <- "https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceLandmarks=true&returnFaceAttributes=age,gender,headPose,smile,facialHair,glasses"

#Define the path of the Image
>body_image <- upload_file("/Users/teamplanetanalytics/Desktop/image.jpg")
>API_Key <- "4f789dfa25bb425faa66a039b86f97b6"

>result <- POST(face_api_url, body = body_image, add_headers(.headers = c("Content-Type"="application/octet-stream", "Ocp-Apim-Subscription-Key" = API_Key)))
>API_Output <- content(result)

>Output_Face_Attributes <- data.frame(words = unlist(APi_Output))

Step 4 Save the output in CSV format

>write.csv(Output_Face_Attributes,file = "Faceattributes.csv")