📄 main.c.bak
字号:
//initialize Histogram Tracker
giClickCount = 4;
img_ProcessLClick_Poly();
//initial klt tracker
klt_TrackInit(gcImgCurrentHalf);
//reset predict
gbPredictFlag = FALSE;
gPosCount = 0;
}
return 0L;
case ID_PREDICT:
gbAutoPredictFlag = !gbAutoPredictFlag;
//Turn off predict mood if auto predict is off
if (gbAutoPredictFlag==FALSE){
gbPredictFlag=FALSE;
}
return 0L;
case ID_OPTION:
giPlayFlag = 0;
//prompt option dlg and select tracker
dlg_Option();
//if selected tracker is differenct from current tracker, rewind video and re-initialize with selected tracker
if (gTrackerSelect!=gTrackerIndex || (gTrackerSelect==1 && gbBinChange==TRUE)){
//release tracker memory
switch(gTrackerIndex) {
case 2:
//initial Meanshift Tracker
msw_TrackCleanUp();
break;
case 3:
//template matching Tracker with Correlation
temp_TrackCleanUp();
break;
default:
//tracker 1: HistogramShift - Enhanced meanshift by Foreground/Bkground
his_TrackCleanUp();
}
gTkResult.FGImage = NULL;
gTrackerIndex=gTrackerSelect;
if (gbClickInitFlag==TRUE){
img_RewindVideo();
gbTrackMood=FALSE;
}
}
return 0L;
}
break;
case WM_DESTROY:
KillTimer(hwnd, TEST_TIMER);
PostQuitMessage(0);
return 0L;
}
return(DefWindowProc(hwnd, message, wParam, lParam));
}
///////////////////////////////////////////////////////////////////////////////
BOOL dlg_LogDir()
//Promt user log dir dialog
{
//prompt log dir name
if (DialogBox(hAppInst, MAKEINTRESOURCE(IDD_DIALOG_LOGDIR), hwndCtl, (DLGPROC)dlg_LogDirProc)==IDOK)
{
//set logDir succeed
return TRUE;
}
else
{
//cancel log command
return FALSE;
}
}
///////////////////////////////////////////////////////////////////////////////
BOOL CALLBACK dlg_LogDirProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
//call back function for Log Directory dialog
{
char sLogPath[_MAX_PATH];
//char sLogDirName[_MAX_DIR];
int len;
int i;
switch (message)
{
case WM_INITDIALOG:
//calculate log dir name
io_CalcLogDirName(gLogDirName);
//initial log dir
strcpy(gLogDir, gExeLogPath);
strcat(gLogDir, "\\");
strcat(gLogDir, gLogDirName);
SetWindowText(GetDlgItem(hwndDlg, IDC_EDIT_LOGDIR), gLogDir);
SetFocus(GetDlgItem(hwndDlg, IDC_EDIT_LOGDIR));
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
//if edit is null or directory exist, reprompt
if (!GetDlgItemText(hwndDlg, IDC_EDIT_LOGDIR, sLogPath, MAX_PATH))
{
//reprompt if empty string
return FALSE;
}
else{
//check if directory exist
if (_chdir(sLogPath) == 0){ //directory exist
DialogBox(hAppInst, MAKEINTRESOURCE(IDD_DIALOG_EXIST), hwndDlg,(DLGPROC)dlg_DirExistProc);
SetFocus(GetDlgItem(hwndDlg, IDC_EDIT_LOGDIR));
return FALSE;
}
else{
//Fall through and end dialog
EndDialog(hwndDlg, wParam);
//update global log directory
strcpy(gLogDir, sLogPath);
//remember path without LogDirName
len = strlen(sLogPath);
//get reverse first "/" or "\"
for (i=len-1;i>0;i--){
if (sLogPath[i]==92 || sLogPath[i]==47){ //equal "/" or "\"
sLogPath[i] = '\0';
break;
}
}
strcpy(gExeLogPath, sLogPath);
return TRUE;
}
}
case IDCANCEL:
EndDialog(hwndDlg, wParam);
return TRUE;
}
}
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
BOOL CALLBACK dlg_DirExistProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
//call back function for Log Directory dialog
{
switch (message)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
EndDialog(hwndDlg, wParam);
return TRUE;
}
}
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
BOOL dlg_Option()
//Promt user option dialog
{
//prompt log dir name
DialogBox(hAppInst, MAKEINTRESOURCE(IDD_DIALOG_OPTION), hwndCtl, (DLGPROC)dlg_OptionProc);
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////
BOOL CALLBACK dlg_OptionProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
//call back function for option dialog
{
switch (message)
{
case WM_INITDIALOG:
//initial RATIO
switch(gTrackerIndex) {
case 1:
CheckRadioButton(hwndDlg, IDC_RADIO_TRACKER1, IDC_RADIO_TRACKER3, IDC_RADIO_TRACKER1);
break;
case 2:
CheckRadioButton(hwndDlg, IDC_RADIO_TRACKER1, IDC_RADIO_TRACKER3, IDC_RADIO_TRACKER2);
break;
case 3:
CheckRadioButton(hwndDlg, IDC_RADIO_TRACKER1, IDC_RADIO_TRACKER3, IDC_RADIO_TRACKER3);
break;
}
SetDlgItemInt(hwndDlg, IDC_EDIT_RBINS, gRbins, FALSE);
SetDlgItemInt(hwndDlg, IDC_EDIT_GBINS, gGbins, FALSE);
SetDlgItemInt(hwndDlg, IDC_EDIT_BBINS, gBbins, FALSE);
if (gTrackerIndex==1){
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_RBINS),TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_GBINS),TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_BBINS),TRUE);
}
else{
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_RBINS),FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_GBINS),FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_BBINS),FALSE);
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_TRACKER1) == BST_CHECKED){
int rbin, gbin, bbin;
gTrackerSelect=1;
rbin = GetDlgItemInt(hwndDlg,IDC_EDIT_RBINS, NULL, FALSE);
gbin = GetDlgItemInt(hwndDlg,IDC_EDIT_GBINS, NULL, FALSE);
bbin = GetDlgItemInt(hwndDlg,IDC_EDIT_BBINS, NULL, FALSE);
if (rbin!=gBbins || gbin!=gGbins || bbin!=gBbins){
gbBinChange = TRUE;
gRbins = rbin;
gGbins = gbin;
gBbins = bbin;
}
else{
gbBinChange = FALSE;
}
}
else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_TRACKER2) == BST_CHECKED)
gTrackerSelect=2;
else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_TRACKER3) == BST_CHECKED)
gTrackerSelect=3;
EndDialog(hwndDlg, wParam);
return TRUE;
case IDCANCEL:
EndDialog(hwndDlg, wParam);
return TRUE;
case IDC_RADIO_TRACKER1: //click on tracker1
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_RBINS),TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_GBINS),TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_BBINS),TRUE);
return FALSE;
case IDC_RADIO_TRACKER2: //click on tracker2
case IDC_RADIO_TRACKER3: //click on tracker3
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_RBINS),FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_GBINS),FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_BBINS),FALSE);
return FALSE;
}
}
return FALSE;
}
/*****************************************************************************
* Name: DrawButtons *
*****************************************************************************/
void DrawButtons(HWND hwnd, LPARAM lParam, int draw)
{
int i, rem;
RECT Rect;
GetClientRect(hwnd, (LPRECT)&Rect);
ButtonWidth = Rect.right/NBUTTONS;
rem = Rect.right % NBUTTONS;
if(draw)
{
/*---------------------------------------------------------------------
create the function buttons as child windows
---------------------------------------------------------------------*/
for(i=0; i<NBUTTONS; i++)
{
if(i == NBUTTONS-1)
Functions[i].hwnd = CreateWindow("button", Functions[i].text,
WS_CHILD | WS_VISIBLE | Functions[i].style,
ButtonWidth*i, 0, ButtonWidth+rem, ButtonHeight,
hwnd, (HMENU)Functions[i].id, hAppInst, NULL);
else
Functions[i].hwnd = CreateWindow("button", Functions[i].text,
WS_CHILD | WS_VISIBLE | Functions[i].style,
ButtonWidth*i, 0, ButtonWidth, ButtonHeight,
hwnd, (HMENU)Functions[i].id, hAppInst, NULL);
}
}
else
{
/*---------------------------------------------------------------------
resize the function buttons
---------------------------------------------------------------------*/
for(i=0; i<NBUTTONS; i++)
{
if(i == NBUTTONS-1)
SetWindowPos(Functions[i].hwnd,NULL,ButtonWidth*i,0,
ButtonWidth+rem,ButtonHeight,SWP_SHOWWINDOW);
else
SetWindowPos(Functions[i].hwnd,NULL,ButtonWidth*i,0,
ButtonWidth,ButtonHeight,SWP_SHOWWINDOW);
}
}
}
/*****************************************************************************
* Name: DrawButtons2 *
*****************************************************************************/
void DrawButtons2(HWND hwnd, LPARAM lParam, int draw)
{
int i, rem;
RECT Rect;
GetClientRect(hwnd, (LPRECT)&Rect);
ButtonWidth = Rect.right/NBUTTONS;
rem = Rect.right % NBUTTONS;
if(draw)
{
/*---------------------------------------------------------------------
create the function buttons as child windows
---------------------------------------------------------------------*/
for(i=0; i<NBUTTONS; i++)
{
if(i == NBUTTONS-1)
Functions2[i].hwnd = CreateWindow("button", Functions[i].text,
WS_CHILD | WS_VISIBLE | WS_DISABLED | Functions[i].style,
ButtonWidth*i, 0, ButtonWidth+rem, ButtonHeight,
hwnd, (HMENU)Functions[i].id, hAppInst, NULL);
else
Functions2[i].hwnd = CreateWindow("button", Functions[i].text,
WS_CHILD | WS_VISIBLE | WS_DISABLED | Functions[i].style,
ButtonWidth*i, 0, ButtonWidth, ButtonHeight,
hwnd, (HMENU)Functions[i].id, hAppInst, NULL);
}
}
else
{
/*---------------------------------------------------------------------
resize the function buttons
---------------------------------------------------------------------*/
for(i=0; i<NBUTTONS; i++)
{
if(i == NBUTTONS-1)
SetWindowPos(Functions2[i].hwnd,NULL,ButtonWidth*i,0,
ButtonWidth+rem,ButtonHeight,SWP_SHOWWINDOW);
else
SetWindowPos(Functions2[i].hwnd,NULL,ButtonWidth*i,0,
ButtonWidth,ButtonHeight,SWP_SHOWWINDOW);
}
}
}
/*****************************************************************************
* Name: CreateGrayPalette *
*****************************************************************************/
void CreateGrayPalette(void)
{
int i;
struct
{
WORD Version;
WORD NumberOfEntries;
PALETTEENTRY aEntries[256];
} Palette;
if (hpalette)
DeleteObject(hpalette);
Palette.Version = 0x300;
Palette.NumberOfEntries = 256;
for (i=0; i<256; ++i)
{
Palette.aEntries[i].peRed = i;
Palette.aEntries[i].peGreen = i;
Palette.aEntries[i].peBlue = i;
Palette.aEntries[i].peFlags = PC_NOCOLLAPSE;
maphead.colors[i].rgbBlue = i;
maphead.colors[i].rgbGreen= i;
maphead.colors[i].rgbRed = i;
maphead.colors[i].rgbReserved = 0;
}
hpalette = CreatePalette((LOGPALETTE *)&Palette);
}
/*****************************************************************************/
int GetImage()
/*****************************************************************************/
{
int stopFlag;
//if play mood, step one frame
switch(giPlayFlag) {
case 1: //track forward
img_StepOneFrame(iio_GetFrameNo()+1);
FrameCount++;
stopFlag = 0;
break;
case 2: //track backward
img_StepOneFrame(iio_GetFrameNo()-1);
FrameCount++;
stopFlag = 0;
break;
default:
//FrameCount = 0;
stopFlag = 1;
break;
}
//FrameCount++;
return stopFlag;
}
/*****************************************************************************
* Name: SetBitMapHead *
*****************************************************************************/
void SetBitMapHead(void)
{
// Set up bitmap header
maphead.head.biSize=sizeof(BITMAPINFOHEADER);
maphead.head.biWidth=ImageMaxX;
maphead.head.biHeight=ImageMaxY;
maphead.head.biPlanes=1;
maphead.head.biBitCount=PIXEL_TYPE&0xFF;
maphead.head.biCompression=BI_RGB;
maphead.head.biSizeImage=0;
maphead.head.biXPelsPerMeter=0;
maphead.head.biYPelsPerMeter=0;
maphead.head.biClrUsed=0;
maphead.head.biClrImportant=0;
}
/*****************************************************************************
* Name: RegisterWindowClasses *
*****************************************************************************/
void RegisterWindowClasses(HINSTANCE hInst, LPSTR szCmdLine, int sw)
{
WNDCLASS wc;
static ATOM aClass = 0;
memset(&wc,0,sizeof(wc)); /* clear stack variable */
/* register the control window class */
if(aClass == 0)
{
wc.style = CS_BYTEALIGNWINDOW | CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = CtlProc;
wc.cbClsExtra = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -