Face Detection - Objects detected but no metadata
AnsweredI am trying integrate opencv face detection. I have modfied the stub analytics plugin by adding detection and extraction of video frame (bgr) in method pushUncompressedVideoFrame(). I am able to detect the faces and log the data. I need guidance in passing these face boxes and displaying them in the video feed.
I have modded m_objectContexts vector and in the pushUncompressedVideoFrame(), I am pushing the detected objects and setting their bounding boxes. (have another function in abstractobject to set the position).
How can I get the objects into my VMS. I can see the list being populated, but I am not able to see the screenshot data that VMS captures and nor the object detection on the video.
Also I see that the objects generated randomly have x,y Width and Height floating point values eg. 0.112424 where as real values that I obtain are of the order of 199 166 etc.. What is the conversion factor?
-
I'm not sure if that solves your problem, but you have to convert the rectangle you are getting from OpenCV to the nx::sdk::analytics::Rect so that the coordinates are in [0, 1]. You can use this snippet (width and height are the frame dimensions):
nx::sdk::analytics::Rect convertCvRectToNxRect(cv::Rect rect, int width, int height)
{
return {
/*x*/ (float) rect.x / width,
/*y*/ (float) rect.y / height,
/*width*/ (float) rect.width / width,
/*height*/ (float) rect.height / height,
};
}
Please sign in to leave a comment.
Comments
1 comment