📄 mixgaussdemoview.cpp
字号:
// MixGaussDemoView.cpp : implementation of the CMixGaussDemoView class
//
#include "stdafx.h"
#include "MixGaussDemo.h"
#include "MixGaussDemoDoc.h"
#include "MixGaussDemoView.h"
#include "GrimsonBG.h"
#define INIT_FRAMES 150
#ifdef _DEBUG
#define DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMixGaussDemoView
IMPLEMENT_DYNCREATE(CMixGaussDemoView, CView)
BEGIN_MESSAGE_MAP(CMixGaussDemoView, CView)
//{{AFX_MSG_MAP(CMixGaussDemoView)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_GAUSSIAN, OnGaussian)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMixGaussDemoView construction/destruction
CMixGaussDemoView::CMixGaussDemoView()
{
// TODO: add construction code here
MixModel = NULL;
}
CMixGaussDemoView::~CMixGaussDemoView()
{
if (MixModel)
delete MixModel;
}
BOOL CMixGaussDemoView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMixGaussDemoView drawing
void CMixGaussDemoView::OnDraw(CDC* pDC)
{
CMixGaussDemoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
if (MixModel)
{
MixModel->m_lCurrentFrame = 0;
if(MixModel->GetRGBXImage(imgSrcRGBX))
MixModel->Display32bit(GetDC(), imgSrcRGBX, 0, 0);
}
}
/////////////////////////////////////////////////////////////////////////////
// CMixGaussDemoView printing
BOOL CMixGaussDemoView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMixGaussDemoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMixGaussDemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMixGaussDemoView diagnostics
#ifdef _DEBUG
void CMixGaussDemoView::AssertValid() const
{
CView::AssertValid();
}
void CMixGaussDemoView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMixGaussDemoDoc* CMixGaussDemoView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMixGaussDemoDoc)));
return (CMixGaussDemoDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMixGaussDemoView message handlers
void CMixGaussDemoView::OnFileOpen()
{
// TODO: Add your command handler code here
if (MixModel)
{
delete MixModel ;
MixModel = NULL ;
}
MixModel = new GrimsonBG();
if (!MixModel->OpenAndInitialize())
{
AfxMessageBox("File open or File format or Frame size error!");
delete MixModel ;
MixModel = NULL ;
}
Invalidate();
}
void CMixGaussDemoView::OnGaussian()
{
// TODO: Add your command handler code here
if (MixModel)
{
MixModel->BackgroundInit(3,0.8,0.3, 320, 240,1,1,DATA_RGB);
MixModel->m_lCurrentFrame = 0;
while (MixModel->GetRGBXImage(imgSrcRGBX))
{
// the original RGB image
MixModel->Display32bit(GetDC(), imgSrcRGBX, 0, 0);
//MixModel->SaveScreen(320, 240);
// detect the background, method 1
MixModel->DetectionMoveRegion(MixModel->m_ucRgbTemp,MixModel->m_ucBackgroundPic,MixModel->m_ucImgResultMorp);
MixModel->Display8bit(GetDC(), MixModel->m_ucImgResultMorp, 0, 240);
MixModel->VerticalMorp(MixModel->m_ucImgResultMorp, 0);
// MixModel->SaveScreen(GetDC(),320,240);
MixModel->Label(MixModel->m_ucImgResultMorp, MixModel->m_bResultone, 320, 240, MixModel->m_sRegionInfo, MixModel->m_crResultPosition);
MixModel->Display8bitPseudoColor(GetDC(), MixModel->m_bResultone, 320, 240);
MixModel->ComputeCentroid(MixModel->m_bResultone, MixModel->m_sRegionInfo, MixModel->m_crResultPosition, MixModel->m_sCentroid);
MixModel->ComputeProjection(MixModel->m_bResultone, MixModel->m_sRegionInfo, MixModel->m_crResultPosition, 0, MixModel->m_sXProject, MixModel->m_sYProject);
MixModel->FindBestRectangleAll(GetDC(),MixModel->m_bResultone, MixModel->m_sRegionInfo, MixModel->m_crResultPosition, MixModel->m_bOutputInfo, MixModel->m_crRectangleAll);
MixModel->ChangeColorModeltoYUV(MixModel->m_ucRgbTemp, MixModel->m_byYuvTemp);
MixModel->ComputeColorDistribution(MixModel->m_byYuvTemp, 3, MixModel->m_bResultone);
// MixModel->FindBestMatching2(GetDC(),320, 0);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -