Configure Hard Hat Detection Alarm

Hard hat detection function detects people who are not wearing hard hats in a specific region. You can configure the arming schedule and linkage actions to be taken when the hard hat detection alarms are triggered. For people who are not wearing hard hat, you can also link face picture libraries with the hard hat detection to recognize these people and know their names.

  • Make sure you have called NET_DVR_Init to initialize the development environment.

  • Make sure you have called NET_DVR_Login_V40 to log in to the device.

  • Make sure you have set the analysis engine mode to hard hat detection.

Figure 1 Programming Flow of Configuring Hard Hat Detection Alarm

  1. Perform one of the following operations to get the intelligent capability of the device and check whether the hard hat detection is supported by the device.
    • Call NET_DVR_STDXMLConfig to transmit the request URI: GET /ISAPI/Intelligent/capabilities. The intelligent capability is returned in the message XML_IntelliCap by lpOutputParam.

      If the node <isSupportSafetyHelmetDetection> is returned and its value is "true", it indicates that the hard hat detection is supported, and then you can continue to perform the following steps. Otherwise, the hard hat detection is not supported by the device, please end this task.

    • Call NET_DVR_GetDeviceAbility, set the capability type (dwAbilityType) to "VCA_DEV_ABILITY" (macro definition value: 0x100) to get the intelligent device capability.

      The intelligent device capability is returned in the structure NET_VCA_DEV_ABILITY by pOutBuf, and the related member is bySafetyHelmetDetection.

  2. Optional: Call NET_DVR_STDXMLConfig to transmit the request URI: GET /ISAPI/Intelligent/channels/<ID>/safetyHelmetDetection/capabilities for getting the configuration capability of hard hat detection and knowing the configuration details or notices.

    The configuration capability is returned in the message XML_SafetyHelmetDetectionCap by lpOutputParam.

  3. Call NET_DVR_STDXMLConfig to transmit the request URI: PUT /ISAPI/Intelligent/channels/<ID>/safetyHelmetDetection and set lpInputParam to XML_SafetyHelmetDetection for setting the parameters of hard hat detection.
    Note:

    Before setting parameters, you can get the default or configured parameters for reference by calling NET_DVR_STDXMLConfig to transmit the request URI: GET /ISAPI/Intelligent/channels/<ID>/safetyHelmetDetection. And the parameters are returned in the message XML_SafetyHelmetDetection by lpOutputParam.

  4. Optional: Call NET_DVR_STDXMLConfig to transmit the request URI: PUT /ISAPI/Intelligent/channels/<ID>/safetyHelmetDetection/advanceConfiguration and set lpInputParam to XML_AdvanceConfiguration for setting advanced parameters of hard hat detection.
    Note:
  5. Optional: Call NET_DVR_GetSTDAbility, set the dwAbilityType to "NET_DVR_GET_SAFETY_HELMET_SCHEDULE_CAPABILITIES" (value: 3988), and set condition parameter lpCondBuffer in the structure NET_DVR_STD_ABILITY to 4-byte channel No. for getting the arming schedule configuration capability of hard hat detection alarms.

    The arming schedule configuration capability (XML_Cap_Schedule) is returned by the output parameter lpOutBuffer in the structure NET_DVR_STD_ABILITY.

  6. Optional: Call NET_DVR_GetSTDConfig with "NET_DVR_GET_SAFETY_HELMET_SCHEDULE" (command No.: 3989) and set the condition parameter IpCondBuffer in the structure NET_DVR_STD_CONFIG to 4-byte channel No. for getting the default or configured arming schedule parameters for reference.

    The arming schedule parameters (NET_DVR_EVENT_SCHEDULE) are returned by the output parameter lpOutBuffer in the structure NET_DVR_STD_CONFIG.

  7. Call NET_DVR_SetSTDConfig with "NET_DVR_SET_SAFETY_HELMET_SCHEDULE" (command No.: 3990), set the condition parameter IpCondBuffer and input parameter lpInBuffer in the structure NET_DVR_STD_CONFIG to 4-byte channel No. and NET_DVR_EVENT_SCHEDULE respectively for setting the arming schedule.
  8. Optional: Call NET_DVR_GetSTDAbility, set the dwAbilityType to "NET_DVR_GET_EVENT_TRIGGERS_CAPABILITIES" (value: 3501), and set condition parameter lpCondBuffer in the structure NET_DVR_STD_ABILITY to NULL for getting the alarm linkage configuration capability of hard hat detection alarms.

    The alarm linkage configuration capability (XML_EventTriggersCap) is returned by the output parameter lpOutBuffer in the structure NET_DVR_STD_ABILITY.

  9. Optional: Call NET_DVR_GetSTDConfig with "NET_DVR_GET_SAFETY_HELMET_TRIGGER" (command No.: 3986) and set the condition parameter IpCondBuffer in the structure NET_DVR_STD_CONFIG to the channel No. for getting the default or configured alarm linkage parameters for reference.

    The alarm linkage parameters (NET_DVR_EVENT_TRIGGER) are returned by the output parameter lpOutBuffer in the structure NET_DVR_STD_CONFIG.

  10. Call NET_DVR_SetSTDConfig with "NET_DVR_SET_SAFETY_HELMET_TRIGGER" (command No.: 3987), set the condition parameter IpCondBuffer and input parameter lpInBuffer in the structure NET_DVR_STD_CONFIG to the channel No. and NET_DVR_EVENT_TRIGGER respectively for setting alarm linkages.
    Note:

    The above detection parameters, arming schedule, and alarm linkages can be configured by logging in to the device via web browser.

  11. Optional: Set the uploading message type (lCommand) in the alarm callback function (MSGCallBack) to "COMM_VCA_ALARM" (macro definition value: 0x4993) for receiving hard hat detection alarms in arming mode (see Receive Alarm/Event in Arming Mode for details) or listening mode (see Receive Alarm/Event in Listening Mode for details).

    The hard hat detection alarms are uploaded in the message JSON_EventNotificationAlert_safetyHelmetDetection.

  12. Optional: Call NET_DVR_STDXMLConfig to transmit the request URI: POST /ISAPI/Intelligent/channels/<ID>/safetyHelmetDetection/search?format=json and set lpInputParam to JSON_SearchDescription for searching for hard hat detection events.
    Note:

    To check whether searching for hard hat detection events is supported, you can check whether the node <SearchDescriptionCap> exists in the configuration capability message of hard hat detection XML_SafetyHelmetDetectionCap.

    The search results are returned in the message JSON_SearchResult by lpOutputParam.

Call NET_DVR_Logout and NET_DVR_Cleanup to log out of the device and release resources.