With the maturity of face recognition technology, “face brushing” has gradually become the main field of biometric technology application in the new era. In order to cater to and meet the modern market demand, EasyCVR face recognition is also constantly optimized. At present, AI detection and capture recognition can be carried out on people, cars and objects in video surveillance scenes.

In the EasyCVR face recognition, if there is a face in the recognition area can be directly recognized, if there is no face in the next frame, then the EasyCVR player screen will display the face recognition box, as follows:

However, it is unreasonable for this box to appear when there is no recognition of the content, so we need to remove this box, and set it to only face will appear the box, no face will not show the box.

After using EasyStreamClient to pull THE RTSP stream, initialize the decoder first and decode the I frame into YUV (operation below).

The picture below shows face recognition and feature extraction:

The figure below shows feature extraction. The X axis, Y axis, width and height extracted by feature are all saved in the variable of Rect. Convert the values in Rect into SEI frames, which are passed to the front end to draw the red box of the face.

Int (ret.size)>0 “, so only detected face back to the front rendering, if there is no face to transfer empty data to the front end, will cause only the drawing box did not cancel the box operation.

Here we need to add an else operation in the program “int(ret.size)>0”, cancel each recognized face in a frame, and then give the front end, so that the box of the player will disappear.

else {
   if client.Flag {
      client.Flag = false
      s := PacketSei{}
      s.Rect = make([]RectSei, int(ret.size))
      s.Rect = append(s.Rect, RectSei{
         X: 0,
         Y: 0,
         W: 0,
         H: 0,
      })
      extJson, _ := json.Marshal(s)
      base64Str := base64.StdEncoding.EncodeToString(extJson)
      //FIXME:debug code
      base64Str = string(extJson)
      GenSei(uintptr(unsafe.Pointer(&result.sei[0])), &result.seiLen, base64Str)

      v := cvrdo.Face{
         AiBase: cvrdo.AiBase{
            ID:         0,
            Name:       "",
            ParentID:   int(client.ChannelId),
            CreateTime: time.Now(),
            UpdateTime: time.Now(),
         },
      }
      v.AiBase.Name = ""
      v.Timestamp = 0
      v.ConfidenceLevel = 0
      result.face = append(result.face, v)
   }
}
Copy the code