谁能帮我解决一个vc的问题

2024-12-21 06:32:04
推荐回答(4个)
回答1:

太巧了,我正好在做面部识别的项目。不久前也遇到了你所说的问题,但是我刚刚解决了一部分,下面的程序是我自己写的,能检测驱动,但检测不到不会提示错误。搜索和识别算法也是我自己的,目前只能识别瞳孔,鼻孔和眉毛,但那些就不能告诉你了。
视频驱动部分:

下面的代码适用于新建一个基于对话框的视频图像处理模式识别程序VideoCapture。其中部分程序如下:
//头文件部分
// VideoCaptureDlg.cpp : implementation file
//

#include "stdafx.h"
#include "VideoCapture.h"
#include "VideoCaptureDlg.h"
#include "vfw.h"
#pragma comment(lib,"vfw32")
#include
#include "PointsOperation.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

////////////////////////*自定义回调函数部分,采用硬盘的文件操作,用于检验中间过程,你也可直接从内存操作*/
LRESULT CALLBACK FrameCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr)
{
FILE *in,*in1;//,*in2;
char *TempChar="E:\\1.txt";
int j;
int min=0;
int mybisize=mybiwidth*mybiheight*2;

unsigned char *p;
p=lpVHdr->lpData;
capFileSaveDIB(m_hWndVideo,"E:\\1.bmp");
in=fopen(TempChar,"w");

unsigned short points[640*3][480*3]={0};
int PX=0,PY=0;
for(PY=0,j=0;PY<=480*3-1;PY++){
for(PX=0;PX<=640*3-1;PX++,j++)
points[PX][PY]=p[j];
}
capFileSaveDIB(m_hWndVideo,"E:\\1.bmp");
for(PY=0;PY<=480*3-1;PY++){
for(PX=0;PX<=640*3-1;PX++)fprintf(in,"%d ",points[PX][PY]);

}

fclose(in);
}
return (LRESULT) TRUE ;
}

////////////////////////

///////////////////////

///////////////////////
BOOL CVideoCaptureDlg::OnInitDialog()//初始化
{
capGrabFrame(m_hWndVideo);//调用回调函数

CDialog::OnInitDialog();
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);

}
}
SetIcon(m_hIcon,TRUE);
SetIcon(m_hIcon,FALSE);
m_hWndVideo=capCreateCaptureWindow(NULL,WS_POPUP,1,1,100,100,m_hWnd,0);//创建预览窗口

//////////////设置相关参数(视频预览时的参数并不因此改变)
// CAPTUREPARMS CaptureParms;
// float FramesPerSec = 15.0;//录制时每秒帧数预设
// capCaptureGetSetup(m_hWndVideo, &CaptureParms, sizeof(CAPTUREPARMS));//获取原设置参数
// CaptureParms.fStepCaptureAt2x=TRUE;
// CaptureParms.dwRequestMicroSecPerFrame = (DWORD) (1.0e6 /FramesPerSec);//变更新参数
// int FramePSec=CaptureParms.dwRequestMicroSecPerFrame/1000;//参数单位转换
// capCaptureSetSetup(m_hWndVideo, &CaptureParms, sizeof (CAPTUREPARMS));//将参数设置成功
//////////////

if(capDriverConnect(m_hWndVideo,0))//连接驱动
{
::SetParent(m_hWndVideo,*this);
::SetWindowLong(m_hWndVideo,GWL_STYLE,WS_CHILD);
capDlgVideoFormat(m_hWndVideo);//调出捕获参数设置窗口
CRect wndRC;
m_Panel.GetClientRect(wndRC);
m_Panel.MapWindowPoints(this,wndRC);
wndRC.DeflateRect(1,1,1,1);
::SetWindowPos(m_hWndVideo,NULL,wndRC.left,wndRC.top,wndRC.Width(),wndRC.Height(),SWP_NOZORDER);
::ShowWindow(m_hWndVideo,SW_SHOW);
capPreviewRate(m_hWndVideo,100);
capPreview(m_hWndVideo,TRUE);
}
//////////////////
capSetCallbackOnFrame(m_hWndVideo, FrameCallbackProc);//注册回调函数于对话框初始化中(定义于初始化前)
BITMAPINFO bmpInfo;
capGetVideoFormat(m_hWndVideo,&bmpInfo,sizeof(BITMAPINFO));//获得bitmap参数
mybiwidth=bmpInfo.bmiHeader.biWidth;
mybiheight=bmpInfo.bmiHeader.biHeight;
//////////////////
//AfxMessageBox("go!");

return TRUE;
}

void CVideoCaptureDlg::OnCancel()
{
capDriverDisconnect(m_hWndVideo);
CDialog::OnCancel();
}

void CVideoCaptureDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}

// 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 CVideoCaptureDlg::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
{
CDialog::OnPaint();
}
}

// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CVideoCaptureDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
我也是新手,刚学VC++才两个月。如果你还有问题可以联系我。QQ:448032116 但我可能会把你拖入黑名单

回答2:

建议楼主去写博士论文了,呵呵

最简单的,图像白色的地方就是 脸,脸中又有两个黑色的眼睛^_^

回答3:

现实一点吧,百度不是万能的,建议好好利用下学校图书馆的电子资源,学校的电子图书馆对毕业设计是很有用的,出了学校IP访问那些资源都是要收费的

回答4:

人脸识别!搞没搞错,我们院长带了几个博士生都研究了很长时间,你一个人就想搞,多叫几个人。