Unattended Hazard Detection Solution with Azure Percept

Published Jan 18 2022 08:31 AM 2,024 Views
Regular Visitor

pt127_0-1642113558906.png

 

Workplace safety is a concern that spans every industry and geography. While there are many innovations in this space, many challenges still remain for organizations. One of these challenges is the fact that many aspects of workplace safety are difficult to measure, monitor, and enforce compliance.

 

Azure Percept provides a set of capabilities that may help organizations address some of these workplace safety challenges. Most notably, the Azure Percept dev kit makes it easy to implement advanced vision AI by providing a platform with development tools, modular components, and a robust messaging infrastructure that can bring object detection and processing capabilities to the edge. These capabilities allow organizations to more easily build solutions that can address situations which are easy to detect visually, but difficult to measure with conventional hardware.

 

The solution, developed by KPMG as part of an Azure Percept Bootcamp, explores a scenario involving a fictional organization named Worldwide Widgets. Worldwide Widgets operates several regional distribution centers and would like to automate the enforcement of their safety protocols in order to provide a safe working environment for their employees and reduce the financial and operational risk that may result from a safety incident.

 

Use Case

 

Worldwide Widgets would like to explore the possibility of using the Azure Percept dev kit in a proof of concept to monitor compliance with one of their safety regulations. The organization requires that loading docks are kept clear of obstructions while the dock is not in use. Lately, Worldwide Widgets observed an increase in situations where the docks in one of their facilities were not cleared after use. Obstructions were being left behind after loading trailers for distribution, and these obstructions present an ongoing safety hazard. Worldwide Widgets is a rapidly growing organization and its distribution staff is always busy, which makes it difficult to monitor compliance with this regulation. The organization would like to automate this task to allow its employees to focus on shipping products safely and on time.

 

A successful proof of concept will use Azure Percept to meet the following goals:

  • Identify obstructions and people in a loading dock using models deployed at the edge
  • Stream simple telemetry to the Azure cloud
  • Apply analytical models and rules to detect situations where obstructions have been left unattended and the inferred severity of the violation
  • Communicate inferred safety violations on a dashboard

Additionally, a successful solution must minimize false positives. The solution should only identify situations where obstructions have truly been left unattended. Since this is an active loading dock, pallets, boxes, tools, and equipment will be detected while the dock is actively in use, but the solution must be able to distinguish between active loading scenarios and idle time. The solution should not alert when obstructions are detected when the dock is in active use.

 

Solution

 

The overall architecture for the solution is shown below.

Component ArchitectureComponent Architecture

 

The solution uses Azure Percept to detect the presence of obstructions and people from a live video stream of the loading dock. The solution processes this feed directly on the Azure Percept dev kit using an object recognition model developed in Azure Cognitive Services and deployed over the air to the Azure Percept dev kit. This object detection model is trained to identify obstructions and persons at the loading dock. The device processes live video stream on the device at the edge, and streams telemetry to deployed business logic, the Count Module, installed on the device. This module reduces the model inferrence output to a simple count of detected objects. The output from the Count Module is streamed to Azure IoT Hub.

 

Azure IoT Hub aggregates this streaming telemetry and pipes it to Azure Stream Analytics for processing and smoothing. Azure Stream Analytics will smooth the telemetry by averaging the telemetry over tumbling windows in order to reduce the sensitivity of the system. Azure Stream Analytics then writes the smoothed telemetry to an Azure SQL Database for persistence and visualization.

 

Once the smoothed telemetry data has been persisted to Azure SQL Database, the solution uses Power BI in order to visualize the data and present a live compliance dashboard. The solution applies a set of rules to monitor compliance. If the solution identifies an out of compliance scenario, the dashboard will indicate the type, location, and severity of the violation. Additionally, the dashboard will track compliance trends.

This data flow is summarized below.

Data FlowData Flow

 

Implementation

 

This solution is implemented as a proof of concept using a residential garage as a substitute for a loading dock. After all, just like a safe loading dock is important for an efficient warehouse, a clean garage is part of an efficiently operating home. The specifics of the project implementation are described below.

 

Object Detection Model

The object detection model was trained using Azure Cognitive Services and deployed to the Azure Percept device using images captured in the simulated loading dock. Azure Percept Studio works with the Azure Percept dev kit to streamline this training process by using the Azure Percept dev kit to automatically capture and upload training images at a regular interval. These images are tagged and the object detection model can be trained, refined, and deployed using a no-code user interface.

Documentation for the training procedure is available here.

A sample video of the model applied against a video stream is provided below.

 

 

Count Module

The count module was modified from the example code provided here. CountModule/main.py was modified to include the following code to count people and obstructions.

 

print(f'inference list: {inference_list}')
count_ppl = 0
count_obs = 0

if isinstance(inference_list, list) and inference_list:
    now = datetime.fromtimestamp(int(inference_list[0]['timestamp'][:-9]))
   count_ppl = len([x for x in inference_list if x["label"] == "person"])
   count_obs = len([x for x in inference_list if x["label"] == "obstruction"])

 

and the telemetry payload is generated with the following code

 

json_data = {
    'date': f'{now}', 
    'people_count': count_ppl,
    'obstruction_count': count_obs
}

 

Stream Analytics

An Azure Stream Analytics job is used to process telemetry data as it arrives in Azure IoT Hub. The stream analytics job uses the following query. sql-database-target and iot-hub-source are configured in Azure Stream Analytics to point to the solution’s Azure IoT Hub and a table in Azure SQL Database.

 

SELECT
    AVG(people_count) as people_count,
    AVG(obstruction_count) as obstruction_count,
    MAX(date) as ts
INTO
    [sql-database-target]
FROM
    [iot-hub-source]
WHERE
    people_count IS NOT NULL
GROUP BY TumblingWindow(second, 60) 

 

This query will average the reported person and obstruction counts over 60 second tumbling windows as the data arrives in Azure IoT Hub. The data is then written to a table in Azure SQL Database.

 

Power BI Dashboard

Power BI is configured to use the targeted Azure SQL Database table for reporting. The dashboard tracks the output and identifies situations where the average counts in a tumbling window indicate that obstructions are detected without the presence of workers. When these conditions occur, the dashboard will report the presence of unattended hazards in the loading dock. The dashboard also infers the severity of the violation based on factors including the number of obstructions, elapsed time unattended, and scheduled dock usage.

 

The dashboard tracks compliance performance on daily, weekly, and monthly windows. The type, location, and severity of violations are reported on a facility map

 

Power BI Alerting DashboardPower BI Alerting Dashboard

 

Summary

 

Even though this scenario represents an overly simplified representation of a complex workplace safety use case, it can be considered a starting point for a more sophisticated solution. The Azure Percept dev kit, and the corresponding Azure services allow an organization to quickly bring powerful object recognition and processing capabilities to live video streams at the edge. These capabilities enable an organization to monitor, analyze, and quickly take action to address potential workplace safety incidents using data that was previously difficult to gather using conventional means.    

 

Resources for learning more about Azure Percept:

 

%3CLINGO-SUB%20id%3D%22lingo-sub-3061351%22%20slang%3D%22en-US%22%3EUnattended%20Hazard%20Detection%20Solution%20with%20Azure%20Percept%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3061351%22%20slang%3D%22en-US%22%3E%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pt127_0-1642113558906.png%22%20style%3D%22width%3A%20552px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F339553i641EFF1C5152427F%2Fimage-dimensions%2F552x279%3Fv%3Dv2%22%20width%3D%22552%22%20height%3D%22279%22%20role%3D%22button%22%20title%3D%22pt127_0-1642113558906.png%22%20alt%3D%22pt127_0-1642113558906.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWorkplace%20safety%20is%20a%20concern%20that%20spans%20every%20industry%20and%20geography.%20While%20there%20are%20many%20innovations%20in%20this%20space%2C%20many%20challenges%20still%20remain%20for%20organizations.%20One%20of%20these%20challenges%20is%20the%20fact%20that%20many%20aspects%20of%20workplace%20safety%20are%20difficult%20to%20measure%2C%20monitor%2C%20and%20enforce%20compliance.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fazure-percept%2F%23product-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSTRONG%3EAzure%20Percept%3C%2FSTRONG%3E%3C%2FA%3E%20provides%20a%20set%20of%20capabilities%20that%20may%20help%20organizations%20address%20some%20of%20these%20workplace%20safety%20challenges.%20Most%20notably%2C%20the%20%3CSTRONG%3EAzure%20Percept%3C%2FSTRONG%3E%20dev%20kit%20makes%20it%20easy%20to%20implement%20advanced%20vision%20AI%20by%20providing%20a%20platform%20with%20development%20tools%2C%20modular%20components%2C%20and%20a%20robust%20messaging%20infrastructure%20that%20can%20bring%20object%20detection%20and%20processing%20capabilities%20to%20the%20edge.%20These%20capabilities%20allow%20organizations%20to%20more%20easily%20build%20solutions%20that%20can%20address%20situations%20which%20are%20easy%20to%20detect%20visually%2C%20but%20difficult%20to%20measure%20with%20conventional%20hardware.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20solution%2C%20%3CSTRONG%3Edeveloped%20by%20KPMG%20as%20part%20of%20an%20Azure%20Percept%20Bootcamp%3C%2FSTRONG%3E%2C%20explores%20a%20scenario%20involving%20a%20fictional%20organization%20named%20%3CEM%3EWorldwide%20Widgets%3C%2FEM%3E.%20%3CEM%3EWorldwide%20Widgets%3C%2FEM%3E%20operates%20several%20regional%20distribution%20centers%20and%20would%20like%20to%20automate%20the%20enforcement%20of%20their%20safety%20protocols%20in%20order%20to%20provide%20a%20safe%20working%20environment%20for%20their%20employees%20and%20reduce%20the%20financial%20and%20operational%20risk%20that%20may%20result%20from%20a%20safety%20incident.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-335485783%22%20id%3D%22toc-hId-336585973%22%3EUse%20Case%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3EWorldwide%20Widgets%3C%2FEM%3E%20would%20like%20to%20explore%20the%20possibility%20of%20using%20the%20%3CSTRONG%3EAzure%20Percept%3C%2FSTRONG%3E%20dev%20kit%20in%20a%20proof%20of%20concept%20to%20monitor%20compliance%20with%20one%20of%20their%20safety%20regulations.%20The%20organization%20requires%20that%20loading%20docks%20are%20kept%20clear%20of%20obstructions%20while%20the%20dock%20is%20not%20in%20use.%20Lately%2C%20%3CEM%3EWorldwide%20Widgets%3C%2FEM%3E%20observed%20an%20increase%20in%20situations%20where%20the%20docks%20in%20one%20of%20their%20facilities%20were%20not%20cleared%20after%20use.%20Obstructions%20were%20being%20left%20behind%20after%20loading%20trailers%20for%20distribution%2C%20and%20these%20obstructions%20present%20an%20ongoing%20safety%20hazard.%20%3CEM%3EWorldwide%20Widgets%3C%2FEM%3E%20is%20a%20rapidly%20growing%20organization%20and%20its%20distribution%20staff%20is%20always%20busy%2C%20which%20makes%20it%20difficult%20to%20monitor%20compliance%20with%20this%20regulation.%20The%20organization%20would%20like%20to%20automate%20this%20task%20to%20allow%20its%20employees%20to%20focus%20on%20shipping%20products%20safely%20and%20on%20time.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20successful%20proof%20of%20concept%20will%20use%20%3CSTRONG%3EAzure%20Percept%3C%2FSTRONG%3E%20to%20meet%20the%20following%20goals%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EIdentify%20obstructions%20and%20people%20in%20a%20loading%20dock%20using%20models%20deployed%20at%20the%20edge%3C%2FLI%3E%0A%3CLI%3EStream%20simple%20telemetry%20to%20the%20Azure%20cloud%3C%2FLI%3E%0A%3CLI%3EApply%20analytical%20models%20and%20rules%20to%20detect%20situations%20where%20obstructions%20have%20been%20left%20unattended%20and%20the%20inferred%20severity%20of%20the%20violation%3C%2FLI%3E%0A%3CLI%3ECommunicate%20inferred%20safety%20violations%20on%20a%20dashboard%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EAdditionally%2C%20a%20successful%20solution%20must%20minimize%20false%20positives.%20The%20solution%20should%20only%20identify%20situations%20where%20obstructions%20have%20truly%20been%20left%20unattended.%20Since%20this%20is%20an%20active%20loading%20dock%2C%20pallets%2C%20boxes%2C%20tools%2C%20and%20equipment%20will%20be%20detected%20while%20the%20dock%20is%20actively%20in%20use%2C%20but%20the%20solution%20must%20be%20able%20to%20distinguish%20between%20active%20loading%20scenarios%20and%20idle%20time.%20The%20solution%20should%20not%20alert%20when%20obstructions%20are%20detected%20when%20the%20dock%20is%20in%20active%20use.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1471968680%22%20id%3D%22toc-hId--1470868490%22%3ESolution%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20overall%20architecture%20for%20the%20solution%20is%20shown%20below.%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Component%20Architecture%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F339555iE52F532EA3BD351D%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22pt127_1-1642113681834.png%22%20alt%3D%22Component%20Architecture%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EComponent%20Architecture%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20solution%20uses%20%3CSTRONG%3EAzure%20Percept%3C%2FSTRONG%3E%20to%20detect%20the%20presence%20of%20obstructions%20and%20people%20from%20a%20live%20video%20stream%20of%20the%20loading%20dock.%20The%20solution%20processes%20this%20feed%20directly%20on%20the%20%3CSTRONG%3EAzure%20Percept%3C%2FSTRONG%3E%20dev%20kit%20using%20an%20object%20recognition%20model%20developed%20in%20%3CSTRONG%3EAzure%20Cognitive%20Services%3C%2FSTRONG%3E%20and%20deployed%20over%20the%20air%20to%20the%20%3CSTRONG%3EAzure%20Percept%3C%2FSTRONG%3E%20dev%20kit.%20This%20object%20detection%20model%20is%20trained%20to%20identify%20obstructions%20and%20persons%20at%20the%20loading%20dock.%20The%20device%20processes%20live%20video%20stream%20on%20the%20device%20at%20the%20edge%2C%20and%20streams%20telemetry%20to%20deployed%20business%20logic%2C%20the%20%3CEM%3ECount%20Module%3C%2FEM%3E%2C%20installed%20on%20the%20device.%20This%20module%20reduces%20the%20model%20inferrence%20output%20to%20a%20simple%20count%20of%20detected%20objects.%20The%20output%20from%20the%20%3CEM%3ECount%20Module%3C%2FEM%3E%20is%20streamed%20to%20%3CSTRONG%3EAzure%20IoT%20Hub%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAzure%20IoT%20Hub%3C%2FSTRONG%3E%20aggregates%20this%20streaming%20telemetry%20and%20pipes%20it%20to%20%3CSTRONG%3EAzure%20Stream%20Analytics%3C%2FSTRONG%3E%20for%20processing%20and%20smoothing.%20%3CSTRONG%3EAzure%20Stream%20Analytics%3C%2FSTRONG%3E%20will%20smooth%20the%20telemetry%20by%20averaging%20the%20telemetry%20over%20tumbling%20windows%20in%20order%20to%20reduce%20the%20sensitivity%20of%20the%20system.%20%3CSTRONG%3EAzure%20Stream%20Analytics%3C%2FSTRONG%3E%20then%20writes%20the%20smoothed%20telemetry%20to%20an%20%3CSTRONG%3EAzure%20SQL%20Database%3C%2FSTRONG%3E%20for%20persistence%20and%20visualization.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20the%20smoothed%20telemetry%20data%20has%20been%20persisted%20to%20%3CSTRONG%3EAzure%20SQL%20Database%3C%2FSTRONG%3E%2C%20the%20solution%20uses%20%3CSTRONG%3EPower%20BI%3C%2FSTRONG%3E%20in%20order%20to%20visualize%20the%20data%20and%20present%20a%20live%20compliance%20dashboard.%20The%20solution%20applies%20a%20set%20of%20rules%20to%20monitor%20compliance.%20If%20the%20solution%20identifies%20an%20out%20of%20compliance%20scenario%2C%20the%20dashboard%20will%20indicate%20the%20type%2C%20location%2C%20and%20severity%20of%20the%20violation.%20Additionally%2C%20the%20dashboard%20will%20track%20compliance%20trends.%3C%2FP%3E%0A%3CP%3EThis%20data%20flow%20is%20summarized%20below.%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Data%20Flow%22%20style%3D%22width%3A%20520px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F339554iA827D29B04A65576%2Fimage-dimensions%2F520x589%3Fv%3Dv2%22%20width%3D%22520%22%20height%3D%22589%22%20role%3D%22button%22%20title%3D%22pt127_2-1642113681835.png%22%20alt%3D%22Data%20Flow%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EData%20Flow%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1015544153%22%20id%3D%22toc-hId-1016644343%22%3EImplementation%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20solution%20is%20implemented%20as%20a%20proof%20of%20concept%20using%20a%20residential%20garage%20as%20a%20substitute%20for%20a%20loading%20dock.%20After%20all%2C%20just%20like%20a%20safe%20loading%20dock%20is%20important%20for%20an%20efficient%20warehouse%2C%20a%20clean%20garage%20is%20part%20of%20an%20efficiently%20operating%20home.%20The%20specifics%20of%20the%20project%20implementation%20are%20described%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1706105627%22%20id%3D%22toc-hId-1707205817%22%3EObject%20Detection%20Model%3C%2FH3%3E%0A%3CP%3EThe%20object%20detection%20model%20was%20trained%20using%20%3CSTRONG%3EAzure%20Cognitive%20Services%3C%2FSTRONG%3E%20and%20deployed%20to%20the%20%3CSTRONG%3EAzure%20Percept%3C%2FSTRONG%3E%20device%20using%20images%20captured%20in%20the%20simulated%20loading%20dock.%20%3CSTRONG%3EAzure%20Percept%3C%2FSTRONG%3E%20%3CSTRONG%3EStudio%3C%2FSTRONG%3E%20works%20with%20the%20%3CSTRONG%3EAzure%20Percept%20%3C%2FSTRONG%3Edev%20kit%20to%20streamline%20this%20training%20process%20by%20using%20the%20%3CSTRONG%3EAzure%20Percept%20%3C%2FSTRONG%3Edev%20kit%20to%20automatically%20capture%20and%20upload%20training%20images%20at%20a%20regular%20interval.%20These%20images%20are%20tagged%20and%20the%20object%20detection%20model%20can%20be%20trained%2C%20refined%2C%20and%20deployed%20using%20a%20no-code%20user%20interface.%3C%2FP%3E%0A%3CP%3EDocumentation%20for%20the%20training%20procedure%20is%20available%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-percept%2Ftutorial-nocode-vision%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EA%20sample%20video%20of%20the%20model%20applied%20against%20a%20video%20stream%20is%20provided%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20style%3D%22position%3A%20relative%3B%20left%3A%2012.5%25%3B%20padding-bottom%3A%2042.3%25%3B%20padding-top%3A%200px%3B%20height%3A%200%3B%20overflow%3A%20hidden%3B%20min-width%3A%20320px%3B%20max-width%3A%2075%25%3B%22%3E%3CIFRAME%20src%3D%22https%3A%2F%2Fwww.youtube-nocookie.com%2Fembed%2FgizNWMj1R6E%3Fcontrols%3D0%26amp%3Bautoplay%3Dfalse%26amp%3BWT.mc_id%3Diot-c9-niner%22%20frameborder%3D%220%22%20allowfullscreen%3D%22allowfullscreen%22%20style%3D%22position%3A%20absolute%3B%20top%3A%200%3B%20left%3A%200%3B%20width%3A%20100%25%3B%20height%3A%20100%25%3B%22%20class%3D%22video-iframe%22%20title%3D%22Video%20of%20the%20model%20detecting%20unattended%20hazards%22%20widget_referrer%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Finternet-of-things%22%3E%3C%2FIFRAME%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--101348836%22%20id%3D%22toc-hId--100248646%22%3ECount%20Module%3C%2FH3%3E%0A%3CP%3EThe%20count%20module%20was%20modified%20from%20the%20example%20code%20provided%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fleannhuang%2Fpeople-counting-with-azure-percept-vision%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%20%3CSPAN%20class%3D%22VerbatimChar%22%3E%3CSPAN%3ECountModule%2Fmain.py%3C%2FSPAN%3E%3C%2FSPAN%3E%20was%20modified%20to%20include%20the%20following%20code%20to%20count%20people%20and%20obstructions.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Eprint(f'inference%20list%3A%20%7Binference_list%7D')%0Acount_ppl%20%3D%200%0Acount_obs%20%3D%200%0A%0Aif%20isinstance(inference_list%2C%20list)%20and%20inference_list%3A%0A%20%20%20%20now%20%3D%20datetime.fromtimestamp(int(inference_list%5B0%5D%5B'timestamp'%5D%5B%3A-9%5D))%0A%20%20%20count_ppl%20%3D%20len(%5Bx%20for%20x%20in%20inference_list%20if%20x%5B%22label%22%5D%20%3D%3D%20%22person%22%5D)%0A%20%20%20count_obs%20%3D%20len(%5Bx%20for%20x%20in%20inference_list%20if%20x%5B%22label%22%5D%20%3D%3D%20%22obstruction%22%5D)%0A%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eand%20the%20telemetry%20payload%20is%20generated%20with%20the%20following%20code%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Ejson_data%20%3D%20%7B%0A%20%20%20%20'date'%3A%20f'%7Bnow%7D'%2C%20%0A%20%20%20%20'people_count'%3A%20count_ppl%2C%0A%20%20%20%20'obstruction_count'%3A%20count_obs%0A%7D%0A%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1908803299%22%20id%3D%22toc-hId--1907703109%22%3EStream%20Analytics%3C%2FH3%3E%0A%3CP%3EAn%20%3CSTRONG%3EAzure%20Stream%20Analytics%3C%2FSTRONG%3E%20job%20is%20used%20to%20process%20telemetry%20data%20as%20it%20arrives%20in%20%3CSTRONG%3EAzure%20IoT%20Hub%3C%2FSTRONG%3E.%20The%20stream%20analytics%20job%20uses%20the%20following%20query.%20%3CSPAN%20class%3D%22VerbatimChar%22%3E%3CSPAN%3Esql-database-target%3C%2FSPAN%3E%3C%2FSPAN%3E%20and%20%3CSPAN%20class%3D%22VerbatimChar%22%3E%3CSPAN%3Eiot-hub-source%3C%2FSPAN%3E%3C%2FSPAN%3E%20are%20configured%20in%20%3CSTRONG%3EAzure%20Stream%20Analytics%3C%2FSTRONG%3E%20to%20point%20to%20the%20solution%E2%80%99s%20%3CSTRONG%3EAzure%20IoT%20Hub%3C%2FSTRONG%3E%20and%20a%20table%20in%20%3CSTRONG%3EAzure%20SQL%20Database%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3ESELECT%0A%20%20%20%20AVG(people_count)%20as%20people_count%2C%0A%20%20%20%20AVG(obstruction_count)%20as%20obstruction_count%2C%0A%20%20%20%20MAX(date)%20as%20ts%0AINTO%0A%20%20%20%20%5Bsql-database-target%5D%0AFROM%0A%20%20%20%20%5Biot-hub-source%5D%0AWHERE%0A%20%20%20%20people_count%20IS%20NOT%20NULL%0AGROUP%20BY%20TumblingWindow(second%2C%2060)%20%0A%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20query%20will%20average%20the%20reported%20person%20and%20obstruction%20counts%20over%2060%20second%20tumbling%20windows%20as%20the%20data%20arrives%20in%20%3CSTRONG%3EAzure%20IoT%20Hub%3C%2FSTRONG%3E.%20The%20data%20is%20then%20written%20to%20a%20table%20in%20%3CSTRONG%3EAzure%20SQL%20Database%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-578709534%22%20id%3D%22toc-hId-579809724%22%3EPower%20BI%20Dashboard%3C%2FH3%3E%0A%3CP%3EPower%20BI%20is%20configured%20to%20use%20the%20targeted%20%3CSTRONG%3EAzure%20SQL%20Database%3C%2FSTRONG%3E%20table%20for%20reporting.%20The%20dashboard%20tracks%20the%20output%20and%20identifies%20situations%20where%20the%20average%20counts%20in%20a%20tumbling%20window%20indicate%20that%20obstructions%20are%20detected%20without%20the%20presence%20of%20workers.%20When%20these%20conditions%20occur%2C%20the%20dashboard%20will%20report%20the%20presence%20of%20unattended%20hazards%20in%20the%20loading%20dock.%20The%20dashboard%20also%20infers%20the%20severity%20of%20the%20violation%20based%20on%20factors%20including%20the%20number%20of%20obstructions%2C%20elapsed%20time%20unattended%2C%20and%20scheduled%20dock%20usage.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20dashboard%20tracks%20compliance%20performance%20on%20daily%2C%20weekly%2C%20and%20monthly%20windows.%20The%20type%2C%20location%2C%20and%20severity%20of%20violations%20are%20reported%20on%20a%20facility%20map%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Power%20BI%20Alerting%20Dashboard%22%20style%3D%22width%3A%20561px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F339559i72192285FF1AF697%2Fimage-dimensions%2F561x310%3Fv%3Dv2%22%20width%3D%22561%22%20height%3D%22310%22%20role%3D%22button%22%20title%3D%22pt127_4-1642114609967.png%22%20alt%3D%22Power%20BI%20Alerting%20Dashboard%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EPower%20BI%20Alerting%20Dashboard%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-568206430%22%20id%3D%22toc-hId-569306620%22%3ESummary%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEven%20though%20this%20scenario%20represents%20an%20overly%20simplified%20representation%20of%20a%20complex%20workplace%20safety%20use%20case%2C%20it%20can%20be%20considered%20a%20starting%20point%20for%20a%20more%20sophisticated%20solution.%20The%20%3CSTRONG%3EAzure%20Percept%3C%2FSTRONG%3E%20dev%20kit%2C%20and%20the%20corresponding%20%3CSTRONG%3EAzure%20%3C%2FSTRONG%3Eservices%20allow%20an%20organization%20to%20quickly%20bring%20powerful%20object%20recognition%20and%20processing%20capabilities%20to%20live%20video%20streams%20at%20the%20edge.%20These%20capabilities%20enable%20an%20organization%20to%20monitor%2C%20analyze%2C%20and%20quickly%20take%20action%20to%20address%20potential%20workplace%20safety%20incidents%20using%20data%20that%20was%20previously%20difficult%20to%20gather%20using%20conventional%20means.%3CSPAN%3E%26nbsp%3B%20%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EResources%20for%20learning%20more%20about%20Azure%20Percept%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fmyignite.microsoft.com%2Fsessions%2F5c3beea5-c996-43cc-b8ae-0ac51e84c41d%3Fsource%3Dsessions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3EThe%20cutting%20edge%20of%20AI%3A%20Discover%20the%20possibilities%20with%20Azure%20Percept%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fazure-percept%2F%23product-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3EAzure%20Percept%20%7C%20Edge%20Computing%20Solution%20%7C%20Microsoft%20Azure%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-percept%2Foverview-ai-models%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3EExplore%20pre-built%20AI%20models%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-percept%2Foverview-azure-percept-dk%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3EAzure%20Percept%20product%20overview%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fwww.youtube.com%2Fchannel%2FUCa8_TsUuotIMuzkLzGNQPIg%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%3CSPAN%3EAzure%20Percept%20videos%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-3061351%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20I%20built%20a%20working%20prototype%20of%20computer%20vision%20workplace%20safety%20solution%20in%20just%20a%20few%20hours%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pt127_0-1642113558906.png%22%20style%3D%22width%3A%20552px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F339553i641EFF1C5152427F%2Fimage-dimensions%2F552x279%3Fv%3Dv2%22%20width%3D%22552%22%20height%3D%22279%22%20role%3D%22button%22%20title%3D%22pt127_0-1642113558906.png%22%20alt%3D%22pt127_0-1642113558906.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3061351%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20IoT%20Edge%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20IoT%20Hub%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Percept%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Percept%20DK%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Percept%20Studio%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20IoT%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Jan 14 2022 09:07 PM
Updated by: