Skip to content

Instantly share code, notes, and snippets.

View easonlai's full-sized avatar

Eason Lai easonlai

  • Microsoft
  • Hong Kong
View GitHub Profile
{
"name": "log_analytics_data_movement",
"properties": {
"activities": [
{
"name": "log_analytics_data_movement",
"type": "Copy",
"dependsOn": [],
"policy": {
"timeout": "7.00:00:00",
# Define the variables
$log_Analytics_Workspace_Resource_Group_Name = 'PLEASE_ENTER_YOUR_OWNED_LOG_ANALYTICS_WORKSPACE_RESOURCE_GROUP_NAME'
$log_Analytics_Workspace_Name = 'PLEASE_ENTER_YOUR_OWNED_LOG_ANALYTICS_WORKSPACE_NAME'
$log_Analytics_Export_Rule_Name = 'PLEASE_ENTER_RULE_NAME_TO_BE_CREATE'
$storageAccountResourceId = 'PLEASE_ENTER_YOUR_OWNED_BLOB_STORAGE_RESOURCE_PROPERTIES'
# Create new rule for Log Analytics export Container Insight and AKS related logs into Blob Storage
az monitor log-analytics workspace data-export create --resource-group $log_Analytics_Workspace_Resource_Group_Name --workspace-name $log_Analytics_Workspace_Name --name dnilaw01tostore01 --tables Heartbeat ContainerInventory ContainerImageInventory ContainerLog ContainerLogV2 ContainerNodeInventory ContainerServiceLog KubeEvents KubeHealth KubeMonAgentEvents KubeNodeInventory KubePodInventory KubeServices --destination $storageAccountResourceId
# Check newly created export rule
k = cv2.waitKey(1)
if k%256 == 27:
# ESC pressed
print("Escape hit, closing...")
break
# Release camera
cam.release()
# Close all camera windows
# Show CV2 circle points overlay on camera stream
cv2.imshow('face_landmarks', pupilLeft)
cv2.imshow('face_landmarks', pupilRight)
cv2.imshow('face_landmarks', noseTip)
cv2.imshow('face_landmarks', mouthLeft)
cv2.imshow('face_landmarks', mouthRight)
cv2.imshow('face_landmarks', eyebrowLeftOuter)
cv2.imshow('face_landmarks', eyebrowLeftInner)
cv2.imshow('face_landmarks', eyeLeftInner)
cv2.imshow('face_landmarks', eyeLeftTop)
# Define CV2 circle points by face landmarks x y position
pupilLeft = cv2.circle(frame,(int(pupilLeft['x']), int(pupilLeft['y'])), 8, (0, 0, 255), -1)
pupilRight = cv2.circle(frame,(int(pupilRight['x']), int(pupilRight['y'])), 8, (0, 0, 255), -1)
noseTip = cv2.circle(frame,(int(noseTip['x']), int(noseTip['y'])), 8, (0, 0, 255), -1)
mouthLeft = cv2.circle(frame,(int(mouthLeft['x']), int(mouthLeft['y'])), 8, (0, 0, 255), -1)
mouthRight = cv2.circle(frame,(int(mouthRight['x']), int(mouthRight['y'])), 8, (0, 0, 255), -1)
eyebrowLeftOuter = cv2.circle(frame,(int(eyebrowLeftOuter['x']), int(eyebrowLeftOuter['y'])), 8, (0, 0, 255), -1)
eyebrowLeftInner = cv2.circle(frame,(int(eyebrowLeftInner['x']), int(eyebrowLeftInner['y'])), 8, (0, 0, 255), -1)
eyeLeftInner = cv2.circle(frame,(int(eyeLeftInner['x']), int(eyeLeftInner['y'])), 8, (0, 0, 255), -1)
eyeLeftTop = cv2.circle(frame,(int(eyeLeftTop['x']), int(eyeLeftTop['y'])), 8, (0, 0, 255),
# Measure value between Left eye bottom and top position
eyeLeftvalue = int(eyeLeftBottom['y']) - int(eyeLeftTop['y'])
# Define distance value for left eye blinking
eyeLeftcloseValue = 20
# Show Left Eye Blinking message if distance between top and bottom is lower than defined value
if eyeLeftvalue < eyeLeftcloseValue:
eyeLeftvalueMsg = cv2.putText(frame, "Left Eye Blinking", (50, 50), cv2.FONT_HERSHEY_TRIPLEX, 1, (0, 0, 255), 1, cv2.LINE_AA)
cv2.imshow('face_landmarks', eyeLeftvalueMsg)
# Measure value between Right eye bottom and top position
# Parse collected face landmarks into variables
for face in faces:
flm = face['faceLandmarks']
pupilLeft = flm['pupilLeft']
pupilRight = flm['pupilRight']
noseTip = flm['noseTip']
mouthLeft = flm['mouthLeft']
mouthRight = flm['mouthRight']
eyebrowLeftOuter = flm['eyebrowLeftOuter']
eyebrowLeftInner = flm['eyebrowLeftInner']
# While loop to continuously process the video frames
while True:
ret, frame = cam.read()
if not ret:
print("failed to grab frame")
break
cv2.imshow("face", frame)
# Post video frames to Azure Face Service to obtain face landmarks
image = cv2.imencode('.jpg', frame)[1].tostring()
subscription_key = KEY
# Initialize camera by CV2
cam = cv2.VideoCapture(0)
cv2.namedWindow("face")
img_counter = 0
# Define Azure Face Service key and endpoint
KEY = "PLEASE_ENTER_YOUR_OWN_AZURE_FACE_SERVICE_KEY"
ENDPOINT = "https://PLEASE_ENTER_YOUR_OWN_AZURE_FACE_SERVICE_ENDPOINT_NAME.cognitiveservices.azure.com/"
# Define the Face Service client
face_client = FaceClient(ENDPOINT, CognitiveServicesCredentials(KEY))