亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? childview.cpp

?? 實時視頻跟蹤源碼
?? CPP
字號:
// ChildView.cpp : implementation of the CChildView class
//

#include "stdafx.h"
#include "Tracker.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "ChildView.h"
#include "TrackDlg.h"

#include <math.h>

#include <list>

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

typedef struct QSEG_ {
    POINT head;
    UINT length;
} QSEG, *LPQSEG;

// CChildView

BYTE CChildView::bThreshold = 250;
DWORD CChildView::dwRectangle = 0;
DWORD CChildView::dwSegment = 0;

CChildView::CChildView()
{
}

CChildView::~CChildView()
{
}


BEGIN_MESSAGE_MAP(CChildView, CWnd)
	ON_WM_PAINT()
    ON_COMMAND(ID_DEVICE_REFRESH, OnDeviceRefresh)
    ON_COMMAND_RANGE(ID_DEVICE_NAME, ID_DEVICE_NAME+CVideoCapWnd::m_dwDeviceMax, OnDeviceName)
    ON_COMMAND(ID_CAPTURE_SOURCE, OnCaptureSource)
    ON_COMMAND(ID_CAPTURE_FORMAT, OnCaptureFormat)
    ON_COMMAND(ID_CAPTURE_DISPLAY, OnCaptureDisplay)    
    ON_WM_SIZE()
    ON_COMMAND_RANGE(ID_CAPTURE_100, ID_CAPTURE_200, OnCaptureZoom)
    ON_COMMAND(ID_TRACK_BRIGHTNESS, OnTrackBrightness)
    ON_COMMAND(ID_TRACK_STOP, OnTrackStop)
    ON_COMMAND(ID_CAPTURE_STOP, OnCaptureStop)
END_MESSAGE_MAP()



// CChildView message handlers

BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs) 
{
	if (!CWnd::PreCreateWindow(cs))
		return FALSE;

	cs.dwExStyle |= WS_EX_CLIENTEDGE;
	cs.style &= ~WS_BORDER;
	cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, 
		::LoadCursor(NULL, IDC_ARROW), reinterpret_cast<HBRUSH>(COLOR_WINDOW+1), NULL);

	return TRUE;
}

void CChildView::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	
	// Do not call CWnd::OnPaint() for painting messages
}

void CChildView::OnDeviceRefresh()
{
    /* -- Get device menu. --*/
    CMenu *mDev = AfxGetMainWnd()->GetMenu()->GetSubMenu(3);
    
    MENUITEMINFO miInfo;    
    do
    {
        /* -- Find position of separator. -- */
        miInfo.cbSize = sizeof(MENUITEMINFO);
        miInfo.fMask = MIIM_TYPE;
        mDev->GetMenuItemInfo(0, &miInfo, TRUE);
        /* -- Delete all entries before separator. -- */
        if (miInfo.fType != MFT_SEPARATOR) {
            mDev->DeleteMenu(0, MF_BYPOSITION);
        }
    }   while (miInfo.fType != MFT_SEPARATOR);    
  
    /* -- Put device names before separator. -- */
    CString strDevName, strDevVer; 
    for (DWORD i=0; i<m_theVideoCapWnd.m_dwDeviceMax; ++i) {
        m_theVideoCapWnd.GetDriverDescription(i, strDevName, strDevVer);
        if (strDevName.GetLength()) {
            mDev->InsertMenu(0, MF_BYPOSITION, ID_DEVICE_NAME+i, strDevName);
        }
    }    
}

void CChildView::OnDeviceName(UINT nID)
{
    /* -- Get device index by subtracting the offset. -- */
    nID = nID - ID_DEVICE_NAME;
    
    CString strErr;
        
    /* -- Create the capture window if we haven't done do. -- */
    if (m_theVideoCapWnd.m_hWnd == NULL) {
        m_theVideoCapWnd.CreateCaptureWindow(CString(""), WS_CHILD | WS_VISIBLE, CRect(0,0,0,0), this, 0);
        if (m_theVideoCapWnd.m_hWnd == NULL) {
            strErr.LoadString(IDS_ERR_CAPWND);
            MessageBox(strErr);
            return;
        }
    }
   
    /* -- Attempt to connect to driver. -- */
    if (m_theVideoCapWnd.DriverConnect(nID) == FALSE) {
        strErr.LoadString(IDS_ERR_CONNECT);
        MessageBox(strErr);
        return;
    }

    /* -- Retrieve device parameters. -- */
    CAPTUREPARMS capParms;        
    if (m_theVideoCapWnd.CaptureGetSetup(&capParms, sizeof(CAPTUREPARMS)) == FALSE) {
        strErr.LoadString(IDS_ERR_GETSETUP);
        MessageBox(strErr);
        return;
    }
    
    /* -- Want separate thread. -- */
    capParms.fYield = TRUE;
    /* -- Do not abort when left mouse button is clicked. -- */
    capParms.fAbortLeftMouse = FALSE;
    /* -- Do not abort when right mouse button is clicked. -- */
    capParms.fAbortRightMouse = FALSE;
    
    /* -- Update device parameters. -- */
    if (m_theVideoCapWnd.CaptureSetSetup(&capParms, sizeof(CAPTUREPARMS)) == FALSE) {
        strErr.LoadString(IDS_ERR_SETSETUP);
        MessageBox(strErr);
        return;
    }

    /* -- Get current state of capture window. -- */
    CAPSTATUS capStat;    
    if (m_theVideoCapWnd.GetStatus(&capStat, sizeof(CAPSTATUS)) == FALSE) {
        strErr.LoadString(IDS_ERR_GETSTAT);
        MessageBox(strErr);
        return;
    }
    
    m_theVideoCapWnd.SetWindowPos(NULL, 0, 0, capStat.uiImageWidth, capStat.uiImageHeight, SWP_NOMOVE | SWP_NOZORDER);
    GetParentFrame()->SetWindowPos(NULL, 0, 0, capStat.uiImageWidth, capStat.uiImageHeight, SWP_NOMOVE);
    
    /* -- Set preview rate. -- */                
    if (m_theVideoCapWnd.PreviewRate(33) == FALSE) {
        strErr.LoadString(IDS_ERR_PREVRATE);
        MessageBox(strErr);
        return;
    }
    
    /* -- Turn on scaling. -- */
    if (m_theVideoCapWnd.PreviewScale(TRUE) == FALSE) {
        strErr.LoadString(IDS_ERR_PREVSCALE);
        MessageBox(strErr);
        return;
    }
    
    /* -- Start preview. -- */
    if (m_theVideoCapWnd.Preview(TRUE) == FALSE) {
        strErr.LoadString(IDS_ERR_PREV);
        MessageBox(strErr);
        return;
    }
}

void CChildView::OnCaptureSource()
{
    CString strErr;

    /* -- Retrieve device capabilities. -- */
    CAPDRIVERCAPS capCap;
    if (m_theVideoCapWnd.DriverGetCaps(&capCap, sizeof(CAPDRIVERCAPS)) == FALSE) {
        strErr.LoadString(IDS_ERR_GETCAPS);
        MessageBox(strErr);
        return;
    }
    
    /* -- Check if device supports video source dialog. -- */
    if (capCap.fHasDlgVideoSource) {
        if (m_theVideoCapWnd.DlgVideoSource() == FALSE) {
            strErr.LoadString(IDS_ERR_SOURCE);
            MessageBox(strErr);
        }
    }
    else {
        strErr = "Device does not support video source dialog.";
        MessageBox(strErr);
    }    
}

void CChildView::OnCaptureFormat()
{
    CString strErr;
    
    /* -- Retrieve device capabilities. -- */
    CAPDRIVERCAPS capCap;
    if (m_theVideoCapWnd.DriverGetCaps(&capCap, sizeof(CAPDRIVERCAPS)) == FALSE) {
        strErr.LoadString(IDS_ERR_GETCAPS);
        MessageBox(strErr);
        return;
    }
    
    /* -- Check if device supports video format dialog. -- */
    if (capCap.fHasDlgVideoFormat) {
        if (m_theVideoCapWnd.DlgVideoFormat() == FALSE) {
            strErr.LoadString(IDS_ERR_FORMAT);
            MessageBox(strErr);
        }
    }
    else {
        strErr = "Device does not support video format dialog.";
        MessageBox(strErr);
    }
}

void CChildView::OnCaptureDisplay()
{
    CString strErr;
    
    /* -- Retrieve device capabilities. -- */    
    CAPDRIVERCAPS capCap;
    if (m_theVideoCapWnd.DriverGetCaps(&capCap, sizeof(CAPDRIVERCAPS)) == FALSE) {
        strErr.LoadString(IDS_ERR_GETCAPS);
        MessageBox(strErr);
        return;
    }
    
    /* -- Check if device supports video display dialog. -- */
    if (capCap.fHasDlgVideoDisplay) {
        if (m_theVideoCapWnd.DlgVideoDisplay() == FALSE) {
            strErr.LoadString(IDS_ERR_DISPLAY);
            MessageBox(strErr);
        }
    }
    else {
        strErr = "Device does not support video display dialog.";
        MessageBox(strErr);
    }
}

void CChildView::OnSize(UINT nType, int cx, int cy)
{
    CWnd::OnSize(nType, cx, cy);

    // TODO: Add your message handler code here
    
    /* -- Centralize the video capture window. -- */
    if (m_theVideoCapWnd.m_hWnd != NULL) {
        CRect paRect, cpRect;
        GetClientRect(&paRect);
        m_theVideoCapWnd.GetClientRect(&cpRect);
        m_theVideoCapWnd.SetWindowPos(NULL, 0, 0, paRect.Width(), paRect.Height(), SWP_NOMOVE | SWP_NOZORDER);
    }
    else {
        /* -- Resize the child window. -- */
        GetParentFrame()->SetWindowPos(NULL, 0, 0, 200, 200, SWP_NOMOVE);
    }
}

void CChildView::OnCaptureZoom(UINT nID)
{
    if (m_theVideoCapWnd.m_hWnd != NULL) {
        /* -- Get current state of capture window. -- */
        CAPSTATUS capStat;    
        if (m_theVideoCapWnd.GetStatus(&capStat, sizeof(CAPSTATUS))) {
            UINT nZoom = nID - ID_CAPTURE_100 + 1;
            UINT nWidth = capStat.uiImageWidth * nZoom;
            UINT nHeight = capStat.uiImageHeight * nZoom;
            m_theVideoCapWnd.SetWindowPos(NULL, 0, 0, nWidth, nHeight, SWP_NOMOVE | SWP_NOZORDER);
            CMDIChildWnd *pChild = DYNAMIC_DOWNCAST(CMDIChildWnd, GetParentFrame());
            pChild->MDIRestore();
            GetParentFrame()->SetWindowPos(NULL, 0, 0, nWidth, nHeight, SWP_NOMOVE);
        }
        else {
            CString strErr;
            strErr.LoadString(IDS_ERR_GETSTAT);
            MessageBox(strErr);
        }
    }
}

LRESULT CChildView::FrameCallbackProc(HWND hWnd, LPVIDEOHDR lpVideoHdr)
{
    CVideoCapWnd theVideoCapWnd; 
    CAPSTATUS capStat;
    
    theVideoCapWnd.Attach(hWnd);
    
    if (theVideoCapWnd.GetStatus(&capStat, sizeof(CAPSTATUS))) {
    
        UINT nWidth = capStat.uiImageWidth;
        UINT nHeight = capStat.uiImageHeight;
        LPBYTE lpData = lpVideoHdr->lpData;
        
        ASSERT(lpVideoHdr->dwBytesUsed == nWidth * nHeight * 3);
        
        if (dwRectangle)
        {
            BYTE Y; int index; bool init = false; 
                          
            /* -- Variables used by simple tracking algorithm. -- */
            POINT pTop, pBottom, pLeft, pRight;
            
            for (int i=0; i<nHeight; ++i) {
                for (int j=0; j<nWidth; ++j) {
                    index = 3*(i*nWidth+j);
                    Y = floor(0.299*lpData[index+2] + 0.587*lpData[index+1] + 0.114*lpData[index] + 0.5);

                    if (Y > bThreshold) {
                        if (init) {
                            if (pLeft.x > j) {
                                pLeft.x = j;
                                pLeft.y = i;
                            }
                            if (pRight.x < j) {
                                pRight.x = j;
                                pRight.y = i;
                            }
                            pBottom.x = j;
                            pBottom.y = i;
                        }
                        else {
                            pTop.x = pBottom.x = pLeft.x = pRight.x = j;
                            pTop.y = pBottom.y = pLeft.y = pRight.y = i;
                            init = true;
                        }
                    }
                }
            }

            /* -- Data regarding object being tracked stored, do something simple about it.  -- */
            if (init) {
                for (int i=pLeft.x; i<=pRight.x; ++i) {
                    // -- For pTop.y and pBottom.y --
                    index = 3*((pTop.y)*nWidth + i);
                    lpData[index]   = 0;
                    lpData[index+1] = 0;
                    lpData[index+2] = 255;

                    index = 3*((pBottom.y)*nWidth + i);
                    lpData[index]   = 0;
                    lpData[index+1] = 0;
                    lpData[index+2] = 255;
                }

                for (int i=pTop.y; i<=pBottom.y; ++i) {
                    // -- For pLeft.x and pRight.x --
                    index = 3*((i)*nWidth + pLeft.x);
                    lpData[index]   = 0;
                    lpData[index+1] = 0;
                    lpData[index+2] = 255;

                    index = 3*((i)*nWidth + pRight.x);
                    lpData[index]   = 0;
                    lpData[index+1] = 0;
                    lpData[index+2] = 255;
                }
            }
        }
    
        else if (dwSegment)
        {
            BYTE Y; int index;        

            /* -- Variables used by the new tracking algorithm. -- */
            QSEG segment;
            std::list<QSEG> object;

            for (int i=0; i<nHeight; ++i) {
                segment.length = 0;
                for (int j=0; j<nWidth; ++j) {
                    index = 3*(i*nWidth+j);
                    Y = floor(0.299*lpData[index+2] + 0.587*lpData[index+1] + 0.114*lpData[index] + 0.5);

                    if (Y > bThreshold) {
                        if (segment.length == 0) {
                            segment.head.x = j;
                            segment.head.y = i;
                        }
                        ++segment.length;
                    }
                }
                if (segment.length) {
                    object.push_back(segment);
                }
            }
            
            /* -- Data regarding object being tracked stored, do something simple about it.  -- */            
            for (std::list<QSEG>::iterator i=object.begin(); i!=object.end(); ++i) {
                index = 3*((*i).head.y*nWidth + (*i).head.x);
                lpData[index]   = 255;
                lpData[index+1] = 0;
                lpData[index+2] = 255;                
               
                index = 3*((*i).head.y*nWidth + (*i).head.x + (*i).length);
                lpData[index]   = 255;
                lpData[index+1] = 0;
                lpData[index+2] = 255;
            }
        }    
    }    

    theVideoCapWnd.Detach();
    
    return 0;
}

void CChildView::OnTrackBrightness()
{
    // TODO: Add your command handler code here
    CTrackDlg dlg;
    if (dlg.DoModal()) {
        bThreshold = atoi(dlg.m_strBrightness);        
        if (dlg.m_blRectangle == BST_CHECKED) {
            dwRectangle = 1;
            dwSegment = 0;
        }
        else if (dlg.m_blSegment == BST_CHECKED) {
            dwRectangle = 0;
            dwSegment = 1;
        }
        else {
            dwRectangle = 0;
            dwSegment = 0;
        }
        m_theVideoCapWnd.SetCallbackOnFrame(FrameCallbackProc);        
    }
}

void CChildView::OnTrackStop()
{
    // TODO: Add your command handler code here
    m_theVideoCapWnd.SetCallbackOnFrame((FrameCallback)(NULL));    
}

void CChildView::OnCaptureStop()
{
    // TODO: Add your command handler code here
    m_theVideoCapWnd.DriverDisconnect();
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人免费高清视频| 欧美日本韩国一区二区三区视频| 欧美高清在线一区二区| 欧美自拍偷拍一区| 国产成人免费视频网站 | 欧美三级在线播放| 色8久久精品久久久久久蜜| 北岛玲一区二区三区四区| 精品一区二区三区在线观看| 图片区小说区区亚洲影院| 亚洲精品第一国产综合野| 亚洲国产高清不卡| 美腿丝袜亚洲综合| 美国精品在线观看| 日本韩国欧美在线| 亚洲国产成人一区二区三区| 麻豆精品一二三| 欧美精品久久99久久在免费线 | 91蝌蚪国产九色| 色噜噜偷拍精品综合在线| 欧美国产乱子伦| 国模冰冰炮一区二区| 成人午夜视频网站| 欧美精品一区视频| 国产女主播一区| 一区二区三区产品免费精品久久75| 亚洲一区在线电影| 裸体在线国模精品偷拍| 欧美精品1区2区| 丝袜亚洲另类欧美| 国产mv日韩mv欧美| 欧美一a一片一级一片| 欧美成人a在线| 亚洲视频一区二区在线| 亚洲午夜在线视频| 国产一区二区三区高清播放| 99久久久精品| 精品日韩欧美一区二区| 免费一级片91| 色综合天天在线| 9191国产精品| 亚洲国产精华液网站w| 丰满亚洲少妇av| 亚洲人妖av一区二区| 午夜精品福利视频网站| 欧美日韩一区中文字幕| 婷婷成人综合网| 日韩午夜精品电影| 尤物av一区二区| 欧美色图激情小说| 久久精品国产99国产| 在线欧美一区二区| 午夜精品一区二区三区免费视频 | 天堂一区二区在线| 欧美成人一区二区三区片免费| 久久精品国产一区二区| 久久久国产一区二区三区四区小说| 亚洲国产综合91精品麻豆| 91 com成人网| 狠狠色丁香久久婷婷综| 国产精品国产自产拍高清av王其| 日本女人一区二区三区| 欧美丝袜自拍制服另类| 久久精品99国产精品日本| 国产精品色哟哟网站| 国产盗摄视频一区二区三区| 亚洲欧洲综合另类| 日韩一级黄色大片| av在线不卡网| 日韩综合在线视频| 国产精品免费观看视频| 欧美日韩国产经典色站一区二区三区| 久久疯狂做爰流白浆xx| 亚洲免费在线看| 精品免费国产二区三区| 91在线国产福利| 国产在线看一区| 亚洲国产成人av| 国产精品欧美久久久久一区二区| 欧美日韩成人在线| 99久久伊人久久99| 精品系列免费在线观看| 亚洲高清免费在线| 国产精品护士白丝一区av| 欧美电影免费观看高清完整版在线观看 | 岛国精品在线播放| 日韩电影一区二区三区| 亚洲视频一区二区在线| 2020国产精品久久精品美国| 国产一区在线精品| 亚洲www啪成人一区二区麻豆 | 成人黄色一级视频| 国产精品成人一区二区艾草| 日韩欧美激情四射| 欧美日本国产一区| 在线观看国产日韩| 色综合一个色综合| 北条麻妃一区二区三区| 国产乱理伦片在线观看夜一区| 国产精品视频看| 国产无一区二区| 91极品视觉盛宴| 91在线丨porny丨国产| 成人黄色电影在线| 国产xxx精品视频大全| 国产一区二区精品久久| 裸体健美xxxx欧美裸体表演| 日韩精品久久理论片| 亚洲成人福利片| 亚洲成人久久影院| 亚洲成人av一区| 亚洲国产精品久久久久秋霞影院| 亚洲色大成网站www久久九九| 国产精品毛片a∨一区二区三区| 国产亚洲欧美日韩俺去了| 久久久亚洲精华液精华液精华液| 日韩精品影音先锋| www成人在线观看| 久久女同互慰一区二区三区| 2023国产精品自拍| 337p粉嫩大胆色噜噜噜噜亚洲| 欧美精品一区二区三区在线| 精品国产成人在线影院| 久久一区二区三区四区| 国产亚洲一区字幕| 中文字幕亚洲不卡| 91精品国产一区二区| 成人高清视频免费观看| www.欧美精品一二区| 一本到不卡精品视频在线观看 | 日韩欧美aaaaaa| 精品成人a区在线观看| 久久精品欧美日韩精品| 日韩毛片高清在线播放| 亚洲综合久久久| 男女男精品视频网| 精品国一区二区三区| 精品裸体舞一区二区三区| 色噜噜偷拍精品综合在线| 免费久久99精品国产| 国产一二精品视频| 极品少妇xxxx偷拍精品少妇| 亚洲午夜免费视频| 亚洲日本va午夜在线影院| 亚洲图片欧美视频| 蜜臀久久99精品久久久画质超高清| 五月天精品一区二区三区| 久久精品国产精品亚洲综合| 国产成人福利片| 91在线小视频| www国产精品av| 亚洲国产精品精华液2区45| 亚洲欧美另类久久久精品| 视频一区二区国产| 懂色av一区二区三区免费观看| 在线视频中文字幕一区二区| 日韩精品中午字幕| 亚洲天堂网中文字| 美腿丝袜亚洲综合| 一本大道av一区二区在线播放| 555夜色666亚洲国产免| 国产精品免费aⅴ片在线观看| 午夜免费久久看| 成人午夜在线播放| 69p69国产精品| 中文字幕日本不卡| 久久激五月天综合精品| 在线视频中文字幕一区二区| 久久久久久97三级| 亚洲国产cao| 91麻豆国产福利精品| 日韩精品影音先锋| 亚洲国产精品人人做人人爽| 国产一区二区在线免费观看| 欧美日韩视频一区二区| 国产精品久久久久影院老司| 免费成人在线视频观看| 欧美日韩亚洲综合在线| 自拍偷在线精品自拍偷无码专区| 美女www一区二区| 欧美亚洲图片小说| 亚洲欧美一区二区三区久本道91| 激情小说亚洲一区| 91麻豆精品国产91久久久资源速度 | 国产黄人亚洲片| 欧美精品一卡二卡| 亚洲乱码中文字幕| 成人在线一区二区三区| 精品久久久久久久久久久久久久久 | 国产高清一区日本| 337p亚洲精品色噜噜狠狠| 最新不卡av在线| 成人精品视频.| 久久久不卡影院| 麻豆精品精品国产自在97香蕉 | 精品第一国产综合精品aⅴ| 五月综合激情网| 欧美视频一区二区三区在线观看 | 日韩一级大片在线观看| 日韩电影免费在线看|