Design of Face Video Retrieval System (C++)

Contents
Construction of the framework of the face retrieval system 1
1. The main interface of the software 1
2. The requirements of the software 1
3. Problems that need attention in the process of software code design 2
4. Many defects in the program so far 4
5. The program The detailed design process of 4
1. The design of the input part 4
2. The design process of the detection result part 10

Construction of the framework of the face retrieval system
------FaceMFC_v1
1. The main interface of the software implementation
The main interface of the software is shown in Figure 1.1. From the main interface of the program, it can be seen that the whole system is mainly composed of two modules, including: Face input and detection module, and face recognition and retrieval module. According to the components, the whole system can be divided into six parts: including: 1. Input part, 2. Detection result, 3. Video operation, 4. Information configuration, 5. Output result, 6. Software introduction.
insert image description here

Figure 1.1 The main interface of the face retrieval system
2. Overview of software requirements The
main functional parts of the software:
(1): It can open and read any BMP or JPG image, and display the image on a fixed space. (2): It is possible to cut any image size by mouse operation on the control, and realize the display of the cut picture.
(3): Face detection can be performed on any image, including only performing face detection on the cropped area after the image is cropped.
(4): Image reloading, any image may be misoperated. At this time, the data can be restored to the original image data at the time of reading by reloading, including the emptying of the clipped data. (5): The display of image information mainly refers to some simple image information, including image width, height and bit depth.
(6): The display of the result of the face teaching plan car is to find out the face area in the provided image with detection and display it in the specified control. In this system, not all detected faces are displayed out, and cannot be dynamically displayed (it can be described later as a lack of money).
(7): Avi video files in the Xvid encoding format can be opened, and relevant information of the video files can be obtained, and can be checked by making controls, including only simple video length and width and frame rate.
(8): It can realize simple video operation, including video playing on the specified control, and can switch between pause and play modes. It can display corresponding information during playback, including the total video time length, and the dynamic time display of playback , the slide bar shows the playback progress.
(9): Face retrieval is mainly to detect the face of a frame image captured from the video, and recognize it with the face selected by the detection input. The recognition process is mainly to calculate the Euclidean distance of all faces. The default The minimum value of the distance is the result of recognition.
(10): It is possible to configure information before retrieval. This article is reproduced from http://www.biyezuopin.vip/onews.asp?id=11024, including the selection of video retrieval steps and the selection of retrieval time periods.
(11): Display the 12 results most similar to the faces to be recognized in the video, six results are displayed at a time, and the display can be selected in a cycle by pressing the "Up" and "Down" buttons.
(12): It can track the detection results, that is, find out the video frame where each retrieval result is located and the corresponding time, and you can directly view the original image in the original video.
(13): Display the related introduction of the software.
(14): All windows displaying images must realize the function of redrawing, that is, there will be no problem in displaying the original image after the window is minimized or restored after being covered.

#include "cv.h"
#include "highgui.h"
#include "cxcore.h"
#include "stdafx.h" 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
#define DEFAULT_CASCADE_NAME "C:\\Program Files\\OpenCV\\data\\haarcascades\\haarcascade_frontalface_alt2.xml"

#ifdef _EiC
#define WIN32
#endif

//int detect_and_draw( IplImage* image ,CvHaarClassifierCascade* cascade);

static CvMemStorage* storage = 0;
static CvHaarClassifierCascade* cascade = 0;
//static CvHaarClassifierCascade* cascade =  (CvHaarClassifierCascade*)cvLoad ( DEFAULT_CASCADE_NAME, 0, 0, 0 );

//void detect_and_draw( IplImage* image );

const char* cascade_name ="../debug/haarcascade_frontalface_alt2.xml";
//cascade = (CvHaarClassifierCascade*)cvLoad (cascade_name, 0, 0, 0 );
/*    "haarcascade_profileface.xml";*/

/*int detect_and_draw( IplImage* img,CvHaarClassifierCascade* cascade )
{
	storage = cvCreateMemStorage(0);
	//AfxMessageBox("hi,you!");
    int scale = 1;
    IplImage* temp = cvCreateImage( cvSize(img->width/scale,img->height/scale), 8, 3 );
    CvPoint pt1, pt2;
    int i,N=0;
	
    //cvPyrDown( img, temp, CV_GAUSSIAN_5x5 );
    cvClearMemStorage( storage );
    //cvEqualizeHist(small_img,small_img);
	//AfxMessageBox("3");
    //cvClearMemStorage( storage );
	//AfxMessageBox("4");
    if( cascade )
    {
		//AfxMessageBox("cascade Loaded!");
        CvSeq* faces = cvHaarDetectObjects( img, cascade, storage,
			1.1, 2, CV_HAAR_DO_CANNY_PRUNING,
			cvSize(40, 40));
		//AfxMessageBox("Wrong!");
		N=faces ? faces->total:0;
        for( i = 0; i < (faces ? faces->total : 0); i++ )
        {
            CvRect* r = (CvRect*)cvGetSeqElem( faces, i );
            pt1.x = r->x*scale;
            pt2.x = (r->x+r->width)*scale;
            pt1.y = r->y*scale;
            pt2.y = (r->y+r->height)*scale;
            cvRectangle( img, pt1, pt2, CV_RGB(255,0,0), 3, 8, 0 );
        }
    }
	else
	{
		AfxMessageBox(cascade_name);
	}

	

	
	cvNamedWindow("result",1);
    cvShowImage( "result", img );
	return N;
	//cvDestroyWindow("result");
	//AfxMessageBox("4");
    //cvReleaseImage( &gray );
    //cvReleaseImage( &small_img );
}*/



//把IplImage转化为CBitmap类型
HBITMAP Ipl2Bmp(IplImage *img)
{
    
    
	HBITMAP hBitmap;
	hBitmap=CreateBitmap(img->width, img->height,img->nChannels*8, 1, NULL);
	SetBitmapBits(hBitmap, img->imageSize, img->imageData);
	return hBitmap;
}



insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/newlw/article/details/127768750