⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 seqprocessdlg.cpp

📁 在人脸检测的基础之上,对嘴部的运动表情进行分析,进行语音模拟.
💻 CPP
📖 第 1 页 / 共 4 页
字号:
// SeqProcessDlg.cpp : implementation file
//

#include "stdafx.h"
#include "SeqProcess.h"
#include "SeqProcessDlg.h"
#include "Matrix.h"
#include "FnMatrix.h"
#include "FnImage.h"
#include "FnBitmap.h"
#include "FnMath.h"
#include <math.h>
#include "DlgDraw.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();
	
	// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA
	
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL
	
	// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSeqProcessDlg dialog

CSeqProcessDlg::CSeqProcessDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSeqProcessDlg::IDD, pParent)
{

	//{{AFX_DATA_INIT(CSeqProcessDlg)
	m_currentframe = 0;
	m_fromframe = 0;
	m_toframe = 0;
	m_posX = 0.0;
	m_posY = 0.0;
	m_startframe = 0;
	m_endframe = 0;
	m_check_frame = FALSE;
	m_editWeight1 = 0.0;
	m_editWeight2 = 0.0;
	m_editGradDir = 0.0;
	m_editGradMag = 0.0;
	m_editLap = 0.0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CSeqProcessDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSeqProcessDlg)
	DDX_Control(pDX, IDC_LIST_Size2, m_listSize2);
	DDX_Control(pDX, IDC_LIST_Size1, m_listSize1);
	DDX_Control(pDX, IDC_SLIDER_FRAMENUM, m_sliderframe);
	DDX_Text(pDX, IDC_EDIT_CURRENTFRAME, m_currentframe);
	DDV_MinMaxInt(pDX, m_currentframe, 0, 9999);
	DDX_Text(pDX, IDC_EDIT_FROMFRAME, m_fromframe);
	DDV_MinMaxInt(pDX, m_fromframe, 0, 9999);
	DDX_Text(pDX, IDC_EDIT_TOFRAME, m_toframe);
	DDX_Text(pDX, IDC_EDIT_POSX, m_posX);
	DDX_Text(pDX, IDC_EDIT_POSY, m_posY);
	DDX_Text(pDX, IDC_EDIT_FRAME_START, m_startframe);
	DDV_MinMaxInt(pDX, m_startframe, 0, 9999);
	DDX_Text(pDX, IDC_EDIT_FRAME_END, m_endframe);
	DDV_MinMaxInt(pDX, m_endframe, 0, 9999);
	DDX_Check(pDX, IDC_CHECK_FRAME_MODE, m_check_frame);
	DDX_Text(pDX, IDC_EDIT_Weight1, m_editWeight1);
	DDX_Text(pDX, IDC_EDIT_Weight2, m_editWeight2);
	DDX_Text(pDX, IDC_EDIT_GradDir, m_editGradDir);
	DDX_Text(pDX, IDC_EDIT_GradMag, m_editGradMag);
	DDX_Text(pDX, IDC_EDIT_LAP, m_editLap);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSeqProcessDlg, CDialog)
//{{AFX_MSG_MAP(CSeqProcessDlg)
ON_WM_SYSCOMMAND()
ON_WM_DESTROY()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_BACKWARD, OnButtonBackward)
ON_BN_CLICKED(IDC_BUTTON_FORWARD, OnButtonForward)
ON_BN_CLICKED(IDC_BUTTON_HOME, OnButtonHome)
ON_BN_CLICKED(IDC_BUTTON_END, OnButtonEnd)
ON_BN_CLICKED(IDC_BUTTON_STOP, OnButtonStop)
ON_EN_CHANGE(IDC_EDIT_CURRENTFRAME, OnChangeEditCurrentframe)
ON_EN_KILLFOCUS(IDC_EDIT_CURRENTFRAME, OnKillfocusEditCurrentframe)
ON_EN_CHANGE(IDC_EDIT_FROMFRAME, OnChangeEditFromframe)
ON_EN_KILLFOCUS(IDC_EDIT_FROMFRAME, OnKillfocusEditFromframe)
ON_EN_CHANGE(IDC_EDIT_TOFRAME, OnChangeEditToframe)
ON_EN_KILLFOCUS(IDC_EDIT_TOFRAME, OnKillfocusEditToframe)
ON_COMMAND(ID_FILE_LOADSEQUENCE, OnFileLoadsequence)
ON_COMMAND(ID_FILE_EXIT, OnFileExit)
ON_WM_HSCROLL()
ON_WM_TIMER()
ON_BN_CLICKED(IDC_CHECK_FRAME_MODE, OnCheckFrameMode)
ON_COMMAND(ID_PARAMETERS_DISPLAY, OnParametersDisplay)
	ON_COMMAND(ID_FILE_OPEN_BMP, OnFileOpenBmp)
	ON_COMMAND(ID_DENEME_PROCESSIMAGE, OnDenemeProcessImage)
	ON_WM_MOUSEMOVE()
	ON_BN_CLICKED(IDC_BUTTON_DENEME, OnButtonDeneme)
	ON_WM_LBUTTONDOWN()
	ON_WM_RBUTTONDOWN()
	ON_COMMAND(ID_FILE_SAVEAS, OnFileSaveas)
	ON_COMMAND(ID_DENEME_SEEDTRACK, OnDenemeSeedtrack)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSeqProcessDlg message handlers

BOOL CSeqProcessDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	// Add "About..." menu item to system menu.
	
	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);
	
	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}
	
	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	///////////////////////
	// My code starts here
	///////////////////////

	
	// Initialize dialog menu items
	InitializeFile(); // call this nowhere else
	InitializePlay();
	InitializeDraw();
	
	// Initialize dialog display items
	InitializeWindowDisplay();
	
	///////////////////////
	// My code ends here
	///////////////////////
	m_listSize1.InsertString(0,"5");
    m_listSize1.InsertString(1,"7");
	m_listSize1.InsertString(2,"9");
	m_listSize1.InsertString(3,"11");
	m_listSize1.InsertString(4,"13");
	m_listSize1.InsertString(5,"15");
    m_listSize2.InsertString(0,"5");
    m_listSize2.InsertString(1,"7");
	m_listSize2.InsertString(2,"9");
	m_listSize2.InsertString(3,"11");
	m_listSize2.InsertString(4,"13");
	m_listSize2.InsertString(5,"15");
	m_editWeight1=0.45;
	m_editWeight2=0.55;
	m_editLap=0.43;
	m_editGradMag=0.43;
	m_editGradDir=0.14;
	
	seed_point.x=-1;
	seed_point.y=-1;
	seed_point2.x=-1;
	seed_point2.y=-1;
	free_point.x=-1;
	free_point.y=-1;
	seed_count=0;
	cost_calculated=FALSE;
	finish=false;
	first=NULL;	
	return TRUE;  // return TRUE  unless you set the focus to a control
}
//----------------------------------------------------------------------------------
void CSeqProcessDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}
//-----------------------------------------------------------------------------------
void CSeqProcessDlg::OnDestroy()
{
	WinHelp(0L, HELP_QUIT);
	CDialog::OnDestroy();
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.
//---------------------------------------------------------------------------------
void CSeqProcessDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting
		
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
		
		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;
		
		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		if( currentFrame == -1)
		{
			//CClientDC dc(this);
			//dc.FillSolidRect( xPosWindow, yPosWindow, m_width, m_height, 
			//	RGB(255, 255, 255));
		}
		else
		{
			DrawCurrentImage();
			
		}
				
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CSeqProcessDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

//-------------------------------------------------------------
void CSeqProcessDlg::OnMouseMove(UINT nFlags, CPoint point) 
//-------------------------------------------------------------

{
	// TODO: Add your message handler code here and/or call default
		// Find and display the image coordinates
	int x = point.x;
	int y = point.y;
	struct Live_wire_elem* temp;
	struct Live_wire_elem* temp1;
	static struct Live_wire_elem* new_elem;
	matrix imgPrev;
	
	if(cost_calculated==TRUE) ConvertDib2Mat( imgPrev, dibSeq[0]);

    CPoint current_point;
	CClientDC  dc(this);
 
	if( ! IsWithinImageDisplay( x, y) ) 
	{
		return;
	}	
	
	FindImageCoordinates( x, y);
	// m_posX, m_posY (double) now contain the image point 
	// coordinates. They are updated every time the mouse moves.

	if(cost_calculated==TRUE)
	{
	   if((seed_point.x!=-1) && finish==false/*(seed_point2.x==-1)*/)
	   {
		    if(first==NULL)
			{
				free_point.x=m_posX;
				free_point.y=m_posY;
			//	free_point=CursorSnap(free_point,GradientMagnitude);
				new_elem=new Live_wire_elem; 
				first=new_elem;
				first->pixel=free_point;
				if(imgPrev.numbands==1)
				{
					first->red=imgPrev(free_point.y,free_point.x);
				}
				else
				{
					first->red=imgPrev(free_point.y,free_point.x,0);
					first->green=imgPrev(free_point.y,free_point.x,1);
					first->blue=imgPrev(free_point.y,free_point.x,2);
				}
				first->next=NULL;
				
			
				current_point=free_point;
				temp=first;
				while(graph_array[0][current_point.y][current_point.x].parent!=NULL)
				{
					if(current_point!=free_point)
					{
						new_elem=new Live_wire_elem; 
						temp->next=new_elem;
						temp->next->pixel=current_point;
						if(imgPrev.numbands==1)
						{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -