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

📄 main.c

📁 学习跟踪的好程序
💻 C
📖 第 1 页 / 共 5 页
字号:
					break;
				}
				gTkResult.FGImage = NULL;
				gTkResult.FGMask = NULL;
				gTkResult.ObjMask = NULL;

				gTrackerIndex=gTrackerSelect;
				
				if (gbClickInitFlag==TRUE){			
					img_RewindVideo();
					gbTrackMood=FALSE;					
				}
			}
			return 0L;

		case ID_BROWSEBACK:
			//no response in batch mood
			if (gBatchFlag==TRUE) return 0;

			//browse back
			giPlayFlag = 2; 

			//clear track box in tracking
			if (gbReplayFlag==FALSE){			
				gbClickInitFlag = FALSE;
				gbTrackMood=FALSE;
			}
			
			return 0L;

		case ID_TRACKFWD:
			//no response in batch mood
			if (gBatchFlag==TRUE) return 0;

			//track forward	
			giPlayFlag = 1; 
			gbTrackMood=TRUE;

			return 0L;

		case ID_STEPFWD:
			//no response in batch mood
			if (gBatchFlag==TRUE) return 0;

			giPlayFlag = 0;
			gbTrackMood=TRUE;
			
			//step to next frame	
			img_StepOneFrame(iio_GetFrameNo()+1);			

			return 0L;

		case ID_STOP:
			giPlayFlag = 0;					
			gbBatchStopFlag = TRUE;
			return 0L;

		case ID_REWIND:		
			//no response in batch mood
			if (gBatchFlag==TRUE) return 0;
			
			img_RewindVideo();
			gbTrackMood=FALSE;
			
			return 0L;

			
		case ID_KLT:
			//no response in batch mood
			if (gBatchFlag==TRUE) return 0;

			gbKltFlag = !gbKltFlag;	
			if (gbKltFlag==TRUE){
				Functions[10].style = BS_PUSHBUTTON; //enable predict
			}
			else{
				gbAutoPredictFlag = FALSE;
				Functions[10].style = BS_PUSHBUTTON|WS_DISABLED; //disalbe predict
			}
			DrawButtons(hwndCtl, 0, TRUE);

			return 0L;

		case ID_LOG:		
			//no response in batch mood
			if (gBatchFlag==TRUE) return 0;
			
			if (gbLogFlag==TRUE){	
				//turn off log flag
				gbLogFlag = FALSE;
				return 0L;
			}
			else{
				//turn on Log flag
				gbLogFlag = TRUE;

				//rewind video
				giPlayFlag = 0;
				gbTrackMood=FALSE;

				//reset track Rect
				gRectCurrent = gRectInit;			
				
				//rewind to intial frame
				img_StepOneFrame(giFrameInitial);								
				
				//initialize Histogram Tracker
				giClickCount = 4;
				img_ProcessLClick_Poly();

				//initial klt tracker
				klt_TrackInit(gcImgCurrentHalf);

				//reset predict
				gbPredictFlag = FALSE;
				gPosCount = 0;
			}

			return 0L;

		case ID_PLAYLOG:
			//no response in batch mood
			if (gBatchFlag==TRUE) return 0;

			if (giSeqType!=1){ //if not trk file
				return 0L;
			}
			//only work in trk sequence 

			//rewind to intial frame
			giPlayFlag = 0;	
			gbTrackMood=FALSE;
			img_StepOneFrame(giFrameInitial);				

			gbReplayFlag = !gbReplayFlag;
			if (gbReplayFlag==FALSE){				
				//enable Log button if Replay Log files is false
				//Functions[8].style = BS_PUSHBUTTON; //enable Log

				//create click region if opened a track file
				giClickCount=4;				
				img_ProcessLClick_Poly();
			}
			else{ 
				//Disable Log button if Replay Log files is true
				//Functions[8].style = BS_PUSHBUTTON|WS_DISABLED; //disalbe Log

				gbClickInitFlag = TRUE;
				img_RewindVideo();				
			}
			DrawButtons(hwndCtl, 0, TRUE);
			
			return 0L;
			
		case ID_PREDICT:	
			//no response in batch mood
			if (gBatchFlag==TRUE) return 0;
			
			gbAutoPredictFlag = !gbAutoPredictFlag;
			//Turn off predict mood if auto predict is off
			if (gbAutoPredictFlag==FALSE){			
				gbPredictFlag=FALSE;
			}
			return 0L;

		case ID_DEBUG:
			gDebugWinFlag = !gDebugWinFlag;
			if (gDebugWinFlag==TRUE)
				ShowWindow(hwndCtl2,SW_SHOWNORMAL);
			else 
				ShowWindow(hwndCtl2,SW_HIDE);
			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)); 

			//init verions
			//initial RATIO 			
			switch(gLogVersion) {
			case 1:
				CheckRadioButton(hwndDlg, IDC_RADIO_LOGV1, IDC_RADIO_LOGV5, IDC_RADIO_LOGV1);
				break;
			case 2:
				CheckRadioButton(hwndDlg, IDC_RADIO_LOGV1, IDC_RADIO_LOGV5, IDC_RADIO_LOGV2);
				break;
			case 3:
				CheckRadioButton(hwndDlg, IDC_RADIO_LOGV1, IDC_RADIO_LOGV5, IDC_RADIO_LOGV3);
				break;
			case 4:
				CheckRadioButton(hwndDlg, IDC_RADIO_LOGV1, IDC_RADIO_LOGV5, IDC_RADIO_LOGV4);
				break;
			case 5:
				CheckRadioButton(hwndDlg, IDC_RADIO_LOGV1, IDC_RADIO_LOGV5, IDC_RADIO_LOGV5);
				break;
			}

			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);

							//GET Log version
							if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_LOGV1) == BST_CHECKED)
								gLogVersion=1;
							else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_LOGV2) == BST_CHECKED){
								gLogVersion=2;
							}
							else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_LOGV3) == BST_CHECKED){
								gLogVersion=3;
							}
							else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_LOGV4) == BST_CHECKED){
								gLogVersion=4;
							}
							else{
								gLogVersion = 5;
							}
							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_TRACKER9, IDC_RADIO_TRACKER1);
				break;
			case 2:
				CheckRadioButton(hwndDlg, IDC_RADIO_TRACKER1, IDC_RADIO_TRACKER9, IDC_RADIO_TRACKER2);
				break;
			case 3:
				CheckRadioButton(hwndDlg, IDC_RADIO_TRACKER1, IDC_RADIO_TRACKER9, IDC_RADIO_TRACKER3);
				break;		
			case 4:
				CheckRadioButton(hwndDlg, IDC_RADIO_TRACKER1, IDC_RADIO_TRACKER9, IDC_RADIO_TRACKER4);
				break;		
			case 5:
				CheckRadioButton(hwndDlg, IDC_RADIO_TRACKER1, IDC_RADIO_TRACKER9, IDC_RADIO_TRACKER5);
				break;
			case 6:
				CheckRadioButton(hwndDlg, IDC_RADIO_TRACKER1, IDC_RADIO_TRACKER9, IDC_RADIO_TRACKER6);
				break;		
			case 7:
				CheckRadioButton(hwndDlg, IDC_RADIO_TRACKER1, IDC_RADIO_TRACKER9, IDC_RADIO_TRACKER7);
				break;		
			case 8:
				CheckRadioButton(hwndDlg, IDC_RADIO_TRACKER1, IDC_RADIO_TRACKER9, IDC_RADIO_TRACKER8);
				break;	
			case 9:
				CheckRadioButton(hwndDlg, IDC_RADIO_TRACKER1, IDC_RADIO_TRACKER9, IDC_RADIO_TRACKER9);
				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;
					else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_TRACKER4) == BST_CHECKED)
						gTrackerSelect=4;
					else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_TRACKER5) == BST_CHECKED)
						gTrackerSelect=5;
					else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_TRACKER6) == BST_CHECKED)
						gTrackerSelect=6;
					else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_TRACKER7) == BST_CHECKED)
						gTrackerSelect=7;
					else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_TRACKER8) == BST_CHECKED)
						gTrackerSelect=8;
					else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_TRACKER9) == BST_CHECKED)
						gTrackerSelect=9;

                    EndDialog(hwndDlg, wParam); 
                    return TRUE; 
				case IDCANCEL: 
					gTrackerSelect = gTrackerIndex;
                    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;

				default: //click on others				
					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; 
} 

⌨️ 快捷键说明

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