Exemplo n.º 1
0
int Close_Camera (ClientData, Tcl_Interp *interp,
                  int, char **argv)
{
    view.m_started = false;
    cvcamExit();
    return TCL_OK;
}
Exemplo n.º 2
0
int main(int argc, char* argv[])
{
    module_path = GetPathFromModuleName( argv[0] );

    Tcl_Interp* g_pInterp = Tcl_CreateInterp();
    
    Tcl_SetPanicProc(WishPanic);
    Tcl_FindExecutable(argv[0]);

    MainEx(argc, argv, Tcl_AppInit, g_pInterp, "cvlkdemo.tcl");

    cvcamExit();

    return 0;
}
Exemplo n.º 3
0
int main( int argc, char** argv )
{

#ifdef USE_CVCAM
	bool cvcam=true;
#else 
	bool cvcam=false;
#endif

	
	if (cmdLine.SplitLine(argc, argv) < 1)
	{
      // no switches were given on the command line, abort
      //ShowHelp();
      //exit(-1);
	}

	std::string infile="../../../stip_online/video/walk-complex.avi";
	std::string tmp;
	int cam=-1;
	try
	{
		if( cmdLine.HasSwitch("-h") || 
			cmdLine.HasSwitch("-help") ||
			cmdLine.HasSwitch("--help"))
		{
			ShowHelp();
			exit(0);
		}

		if( cmdLine.HasSwitch("-f") && cmdLine.HasSwitch("-cam") )
		{
			std::cout<<"You can't specify both file and camera as input!"<<std::endl;
			ShowHelp();
			exit(-1);
		}

	

		if( !(cmdLine.HasSwitch("-f") || cmdLine.HasSwitch("-cam") ))
		{
			std::cout<<"no input..."<<std::endl;
			ShowHelp();
			exit(-1);
		}

		//*** input/output options
		if(cmdLine.GetArgumentCount("-f")>0) 
			infile = cmdLine.GetArgument("-f", 0);
		if(cmdLine.GetArgumentCount("-o")>0) 
			outfile = cmdLine.GetArgument("-o", 0);
	
		if(cmdLine.HasSwitch("-cam"))
			if(cmdLine.GetArgumentCount("-cam")>0)
				cam =  atoi(cmdLine.GetArgument("-cam", 0).c_str());
			else
				cam = -1;

		if(cmdLine.GetArgumentCount("-res")>0) resid =  atoi(cmdLine.GetArgument( "-res", 0 ).c_str());
		if(resid<0 || resid>4) resid=1;

		if(cmdLine.GetArgumentCount("-vis")>0) show = cmdLine.GetArgument("-vis", 0)=="yes"?true:false;
		
		//*** descriptor options
		if(cmdLine.GetArgumentCount("-dscr")>0) mshb.descriptortype = cmdLine.GetArgument("-dscr", 0);
		if(cmdLine.GetArgumentCount("-szf")>0) mshb.patchsizefactor = atof(cmdLine.GetArgument("-szf", 0).c_str());

		//*** detection options
		if(cmdLine.GetArgumentCount("-nplev")>0) mshb.nxplev=atoi(cmdLine.GetArgument("-nplev", 0).c_str());
		if(cmdLine.GetArgumentCount("-plev0")>0) mshb.initpyrlevel=atoi(cmdLine.GetArgument("-plev0", 0).c_str());
		//if(cmdLine.GetArgumentCount("-sigma")>0) hb.sig2 =  atof(cmdLine.GetArgument( "-sigma", 0 ).c_str());
		//if(cmdLine.GetArgumentCount("-tau")>0) hb.tau2 =  atof(cmdLine.GetArgument( "-tau", 0 ).c_str());
		if(cmdLine.GetArgumentCount("-kparam")>0) mshb.kparam =  atof(cmdLine.GetArgument( "-kparam", 0 ).c_str());
		if(cmdLine.GetArgumentCount("-thresh")>0) mshb.SignificantPointThresh =  atof(cmdLine.GetArgument( "-thresh", 0 ).c_str());
		if(cmdLine.GetArgumentCount("-border")>0) mshb.Border =  atoi(cmdLine.GetArgument( "-border", 0 ).c_str());

		//*** video capture options
		mshb.framemax = 100000000;
		if(cmdLine.GetArgumentCount("-framemax")>0) mshb.framemax =  atoi(cmdLine.GetArgument( "-framemax", 0 ).c_str());
		if(cmdLine.GetArgumentCount("-ff")>0) frame_begin =  atoi(cmdLine.GetArgument( "-ff", 0 ).c_str());
		if(cmdLine.GetArgumentCount("-lf")>0) frame_end =  atoi(cmdLine.GetArgument( "-lf", 0 ).c_str());
		
		
	}
	catch (...)
	{
		ShowHelp();
		exit(-1);
	}


	if(infile=="")  //prb:both can handle cam and file
	{
		if(!InitCVCAM(cam))
			return -2;
		// initialize source name string
        sourcename="CameraStream";
	} else {
		cvcam=false;
		if(!InitCapture(infile.c_str()))
			return -2;	
		// initialize source name string
        sourcename=infile;
		std::cout<<"Options summary: "<<std::endl;
		std::cout<<"  video input:     "<<sourcename<<std::endl;
		std::cout<<"  frame interval:  "<<frame_begin<<"-"<<frame_end<<std::endl;
		std::cout<<"  output file:     "<<outfile<<std::endl;
		std::cout<<"  #pyr.levels:     "<<mshb.nxplev<<std::endl;
		std::cout<<"  init.pyr.level:  "<<mshb.initpyrlevel<<std::endl;
		std::cout<<"  patch size fct.: "<<mshb.patchsizefactor<<std::endl;
		std::cout<<"  descriptor type: "<<mshb.descriptortype<<std::endl;
	}

		
        
	if(show)
	{
		//cvNamedWindow( win1,  CV_WINDOW_AUTOSIZE  );
		cvNamedWindow( win2, 0 );
	}


	//cvNamedWindow("Original");

	if(capture)
	{
    int fn=0;
    for(;;)
    {
        if (fn>=mshb.framemax) break;
        if (fn>=frame_end-frame_begin) break;

        fn++;
		frame = cvQueryFrame( capture );
			
        if( !frame )
            break;

		//CVUtil::DrawCircleFeature(frame,cvPoint(10,10),4.0);
		//CapProperties(capture);		
		//cvShowImage("Original",frame);

		dostuff(frame);
		if(show)
		{
			dovisstuff();
			//cvWaitKey();
			cvWaitKey(10);
			//if(cvWaitKey(10) >= 0 )
			//    break;
		}  
    }
	}
	std::cout<<"-> detected "<<TotalIPs<<" points"<<std::endl;

#ifdef USE_CVCAM
	if(cvcam)
	{
		cvWaitKey(0);
		cvcamExit();
	}
#endif
	
	if(capture)
		cvReleaseCapture( &capture );
	

	if(show)
	{
		cvDestroyWindow(win1);
	}

	if(gray) cvReleaseImage(&gray);
	if(vis)  cvReleaseImage(&vis);
	if(vis2)	cvReleaseImage(&vis2);
	if(vis3)	cvReleaseImage(&vis3);
	if(camimg) cvReleaseImage(&camimg);
    return 0;
}
Exemplo n.º 4
0
LRESULT CALLBACK CamDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	static bool init;
	CAMOBJ * st;
	int tmp;
	
	st = (CAMOBJ *) actobject;
    if ((st==NULL)||(st->type!=OB_CAM)) return(FALSE);	

	switch( message )
	{
		case WM_INITDIALOG:
				SetDlgItemInt(hDlg,IDC_UPDATERATE,update_rate,0);
				SetDlgItemText(hDlg,IDC_CAMSTATUS,"0");
				SetDlgItemInt(hDlg,IDC_ERROR_DIST,(int)dist_threshold,0);
				SetDlgItemInt(hDlg,IDC_ERROR_ANGLE,(int)angle_threshold,0);
				SetDlgItemInt(hDlg,IDC_THRESHOLD_TIME,threshold_time,0);
				SetDlgItemInt(hDlg,IDC_PT1X,(int)(PT1_xpos*100.0f),1);
				SetDlgItemInt(hDlg,IDC_PT1Y,(int)(PT1_ypos*100.0f),1);
				SetDlgItemInt(hDlg,IDC_PT2X,(int)(PT2_xpos*100.0f),1);
				SetDlgItemInt(hDlg,IDC_PT2Y,(int)(PT2_ypos*100.0f),1);
				
				CheckDlgButton(hDlg,IDC_AUTORESTORE,autorestore);
				CheckDlgButton(hDlg,IDC_SHOWLIVE,st->showlive);
				CheckDlgButton(hDlg,IDC_ENABLE_TRACKING,st->enable_tracking);
				CheckDlgButton(hDlg,IDC_TRACKFACE,st->trackface);

				if (st->mode==0) CheckDlgButton(hDlg,IDC_NOARCHIVE,TRUE); else
					if (st->mode==1) CheckDlgButton(hDlg,IDC_RECORDARCHIVE,TRUE); else
						if (st->mode==2) CheckDlgButton(hDlg,IDC_PLAYARCHIVE,TRUE);
				SetDlgItemText(hDlg,IDC_ARCHIVEFILE,st->videofilename);
				break;		
		case WM_CLOSE:
			    EndDialog(hDlg, LOWORD(wParam));
				return TRUE;
			break;
		case WM_COMMAND:
			switch (LOWORD(wParam)) 
			{
				case IDC_INITCAM:
					lk_init(st);
					break;
				case IDC_EXITCAM:
					lk_exit();
                    break;
				case IDC_RESET:
		            count = 0;
					break;

				case IDC_NOARCHIVE:
					  lk_exit();
					  st->mode=0;
					  lk_init(st);
					break;
				case IDC_RECORDARCHIVE:
					  lk_exit();
					  st->mode=1;

					  if (!strcmp(st->videofilename,"none"))
					  {
						 strcpy(st->videofilename,GLOBAL.resourcepath); 
						 strcat(st->videofilename,"MOVIES\\*.avi");
					  }

					  if (!open_file_dlg(hDlg,st->videofilename, FT_AVI, OPEN_SAVE))
					     strcpy(st->videofilename,"none");
					  SetDlgItemText(hDlg, IDC_ARCHIVEFILE,st->videofilename);
					  lk_init(st);

					break;
				case IDC_PLAYARCHIVE:
					  lk_exit();
					  st->mode=2;
					  if (!strcmp(st->videofilename,"none"))
					  {
						 strcpy(st->videofilename,GLOBAL.resourcepath); 
						 strcat(st->videofilename,"MOVIES\\*.avi");
					  }
					  if (!open_file_dlg(hDlg,st->videofilename, FT_AVI, OPEN_LOAD))
					     strcpy(st->videofilename,"none");
					  SetDlgItemText(hDlg, IDC_ARCHIVEFILE,st->videofilename);
					  lk_init(st);

					break;
				
				case IDC_SHOWLIVE:
					st->showlive=IsDlgButtonChecked(hDlg,IDC_SHOWLIVE);
					if (!st->showlive) cvDestroyWindow("Camera");
					else
					{ 
					  cvNamedWindow( "Camera", 1 );
					  cvSetMouseCallback( "Camera", on_mouse, 0 );
					}
                    break;
				case IDC_UPDATERATE:
					tmp=GetDlgItemInt(hDlg,IDC_UPDATERATE,NULL,0);
					if ((tmp>10)&&(tmp<1000)) update_rate=tmp;
                    break;
				case IDC_AUTORESTORE:
					autorestore=IsDlgButtonChecked(hDlg,IDC_AUTORESTORE);
                    break;
				case IDC_TRACKFACE:
					st->trackface=IsDlgButtonChecked(hDlg,IDC_TRACKFACE);
					if (st->trackface) MAX_COUNT=2; else MAX_COUNT=1;
                    break;
				case IDC_ERROR_DIST:
					dist_threshold=(float)GetDlgItemInt(hDlg, IDC_ERROR_DIST,0,0);
                    break;
				case IDC_ERROR_ANGLE:
					angle_threshold=(float)GetDlgItemInt(hDlg, IDC_ERROR_ANGLE,0,0);
                    break;
				case IDC_THRESHOLD_TIME:
					threshold_time=GetDlgItemInt(hDlg, IDC_THRESHOLD_TIME,0,0);
                    break;
				case IDC_PT1X:
					PT1_xpos=(float) GetDlgItemInt(hDlg, IDC_PT1X,0,1) / 100.0f;
					need_to_init=1;
					break;
				case IDC_PT1Y:
					PT1_ypos=(float)GetDlgItemInt(hDlg, IDC_PT1Y,0,1)/ 100.0f;
					need_to_init=1;
					break;
				case IDC_PT2X:
					PT2_xpos=(float)GetDlgItemInt(hDlg, IDC_PT2X,0,1)/ 100.0f;
					need_to_init=1;
					break;
				case IDC_PT2Y:
					PT2_ypos=(float)GetDlgItemInt(hDlg, IDC_PT2Y,0,1)/ 100.0f;
					need_to_init=1;
					break;
//				case IDC_NIGHTMODE:
//		            night_mode ^= 1;
//					break;
				case IDC_AUTOINIT:
					 need_to_init=1;
					break;
				case IDC_ENABLE_TRACKING:
					st->enable_tracking=IsDlgButtonChecked(hDlg,IDC_ENABLE_TRACKING);
					break;
				case IDC_SETTINGS:
					{
						int ncams = cvcamGetCamerasCount( ); // init cvcam
						if (ncams==0) report("no cam");
						cvcamSetProperty(0, CVCAM_PROP_ENABLE, CVCAMTRUE); //Selects the 1-st found camera
						cvcamInit();
						cvcamGetProperty(0, CVCAM_CAMERAPROPS, NULL);
						//	cvcamGetProperty(0, CVCAM_VIDEOFORMAT, NULL);
						cvcamExit();
					}
					break;
            }
			return TRUE;
			break;
		case WM_SIZE:
		case WM_MOVE:  update_toolbox_position(hDlg);
		break;
		return(TRUE);
	}
	return FALSE;
}