C ++ development of face and gender recognition tutorial (19) -- interface beautification
In this blog post, we will complete the ending of "C ++ development of facial recognition". The main content is divided into two parts: add video tentative function and interface standardization.
One video pause function
Strictly speaking, this video's tentative function is a legacy problem of video face gender recognition. It should have been added to the C ++ development face gender recognition tutorial (16)-video face gender recognition blog, here, we will add it. The specific function is to control the program through a "pause" button during face detection and gender recognition of videos collected by cameras, start and interrupt the implementation program.
1.1 add controls
According to the previous ideas, we need to add a button control again to implement this pause function. However, we carefully observe that there is a "Next" button in the dialog box, it seems that this button is not fully utilized, so here we use a small trick to reuse the video pause function on this "Next" button, that is, when the program works in the single image mode, this button is used to read and process the next image. When the program works in the video stream mode, this button is used to pause and continue.
1.2 button display text Switch Control
Since this button is used as multiple functions, it is naturally required to display several different text information to prompt the user for the currently available operations. First, the default button displays "pause". You can change the properties of the button control to achieve this purpose:
Next, you need to change the text displayed by the button according to the current working mode. When you click the "image folder" button, the "Next" button should be displayed ", therefore, you need to add the button text control code to the event processing function OnBnClickedButtonImagefile () corresponding to the "image folder" button:
SetDlgItemTextA (IDC_BUTTON_NextImage, "Next"); // refresh the control
Similarly, when you click the "open video" button, the "pause" text should be displayed. Therefore, the OnBnClickedButton1Video () event processing function corresponding to the "open video" button must be used () add a similar button text control code in:
SetDlgItemTextA (IDC_BUTTON_NextImage, "Suspend"); // refresh the control
1.3 video Suspension Control
Next, you can pause the video. Double-click the pause button to go to its corresponding event trigger function. It is found that there is only one code GetNextBigImg () to read the next image. Next, we need to improve this function. Here we first provide the overall code corresponding to the Event-triggered function, which will be explained later:
Void metadata: OnBnClickedButtonNextimage () {static int count = 0; if (m_boolModelFlag = FALSE) {if (count % 2 = 0) {SetDlgItemTextA (IDC_BUTTON_NextImage, "Start"); KillTimer (1); count = 1 ;}else {SetDlgItemTextA (IDC_BUTTON_NextImage, "Suspend"); SetTimer (, NULL); count = 0 ;}} else {GetNextBigImg ();}}
First, you need to determine the current working mode. If the image mode (m_boolModelFlag is true), call the GetNextBigImg () function to implement the "Next" function, otherwise, the "pause" and "start" functions are implemented. A static variable count is used to control the state transition between "pause" and "start". For the implementation of the "pause" and "start" functions, the KillTimer function is destroyed) and re-create a timer (SetTimer), which is why the timer was selected for frame processing of the video stream. OK. The logic is reasonable when you run the program and each function works properly.
Ii. UI beautification
So far, all our programming work has been completed. The next step is to beautify the interface, adjust the layout of the space, and add appropriate text descriptions. First, add a Static Text comment to the three edit boxes to indicate the meaning of the data displayed in the edit box:
Then, add a Group Box to explain the functional areas, and add a static text Box "double-click here to convert mode" to prompt users to switch the image reading mode by double-clicking, the final result is as follows:
Haha, It's just thirty days.