示例#1
0
void PGNReadFromFile (const char *file)
/****************************************************************************
 *
 *  To read a game from a PGN file.
 *
 ****************************************************************************/
{
   FILE *fp;

   fp = fopen (file, "r");
   if (fp == NULL)
   {
      printf ("Cannot open file %s\n", file);
      return;
   }
   yyin = fp;
   
   InitVars ();

   data_dest = DEST_GAME;
   (void) yylex();

   fclose (fp);
   ShowBoard ();
   TTClear ();
}
示例#2
0
int
TnmInit(Tcl_Interp *interp, int safe)
{

#ifdef USE_TCL_STUBS
    if (Tcl_InitStubs(interp, "8.4", 0) == NULL) {
	return TCL_ERROR;
    }
#endif
    
    if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 0) == NULL) {
        return TCL_ERROR;
    }

    if (Tcl_PkgProvide(interp, "Tnm", TNM_VERSION) != TCL_OK) {
        return TCL_ERROR;
    }

    Tcl_RegisterObjType(&tnmUnsigned64Type);
    Tcl_RegisterObjType(&tnmUnsigned32Type);
    Tcl_RegisterObjType(&tnmOctetStringType);
    Tcl_RegisterObjType(&tnmIpAddressType);

    InitVars(interp);
    TnmInitDns(interp);
    if (InitCmds(interp, safe) != TCL_OK) {
	return TCL_ERROR;
    }
    if (TnmSmxInit(interp) != TCL_OK) {
	return TCL_ERROR;
    }

    return SourceInitFiles(interp);
}
void InitMex() {
	// Use exceptions so that MATLAB doesn't die
	AssertionManager::SetExceptionMode();

	// Configure logging via mexPrintf
	LogManager::SetLogSink(new MatlabSink);  // memory will be managed by LogManager

	// Find homedir
	fs::path homedir;
	try {
		homedir = getenv("HOME");
	} catch (const std::exception& ex) {
		mexErrMsgTxt("Could not read HOME environment variable.\n");
	}

	// chdir to intended path
	const fs::path basedir = homedir / "Code/indoor_context";  // ugly hack
	const fs::path workingdir = basedir / "build";
	try {
		fs::current_path(workingdir);
	} catch (...) {
		string message = string("Could not chdir to") + workingdir.string() + "\n";
		mexErrMsgTxt(message.c_str());
	}

	// Load vars
	InitVars((basedir/"config/common.cfg").string());
}
示例#4
0
/*!
\b Parameters:

\arg \b pRender					Pointer to IND_Render

\b Operation:   

This function returns 1(true) if the manager is initialized satisfactorily. 
It must be called before using any method.
*/
bool IND_Entity3dManager::Init (IND_Render *pRender)
{
	End ();
	InitVars ();

	Debug->Header ("Initializing Entity3dManager", 5);
	Debug->Header ("Preparing Entity3dManager", 1);

	mOk = true;

	// Checking IND_Render
	if (pRender->IsOk())
	{
		Debug->Header ("Checking IND_Render", 1);
		mRender = pRender;	
	}
	else
	{
		Debug->Header ("IND_Render is not correctly itialized", 2);
		mOk = false;
		return mOk;
	}

	Debug->Header ("Entity3dManager OK", 6);

	return mOk;
}
int main(int argc, char **argv) {
	InitVars(argc, argv, "../heh.cfg");

	// Read image
	ImageRGB<byte> imagergb;
	ImageF image;
	ReadImage(argv[1], imagergb);
	ImageCopy(imagergb, image);

	// Run segmentation
	MatI seg(image.GetHeight(), image.GetWidth());
	if (argc >= 3) {
		ReadMatrix(argv[2], seg);
	} else {
		FHSegmenter segmenter(image.GetWidth(), image.GetHeight());
		segmenter.Compute(image, seg, 1, 50, 150);
	}
	//DREPORT(seg);

	// Compute features
	HehFeatureGen gen;
	gen.Compute(imagergb, image, seg);

	for (int i = 0; i < gen.features.size(); i++) {
		DREPORT(i);
		SCOPED_INDENT;
		const HehFeature& f = gen.features[i];
		DLOG << f;
	}

	return 0;
}
示例#6
0
int WINAPI WinMain(	HINSTANCE	hInstance,			// Instance
					HINSTANCE	hPrevInstance,		// Previous Instance
					LPSTR		lpCmdLine,			// Command Line Parameters
					int			nCmdShow)			// Window Show State
{
	MSG		msg;									// Windows Message Structure
	BOOL	done=FALSE;								// Bool Variable To Exit Loop

	// Ask The User Which Screen Mode They Prefer
	if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
	{
		fullscreen=FALSE;							// Windowed Mode
	}

	InitVars();                                     // Initialize Variables

	// Create Our OpenGL Window
	if (!CreateGLWindow("Magic Room",640,480,16,fullscreen))
	{
		return 0;									// Quit If Window Was Not Created
	}

	while(!done)									// Loop That Runs While done=FALSE
	{
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	// Is There A Message Waiting?
		{
			if (msg.message==WM_QUIT)				// Have We Received A Quit Message?
			{
				done=TRUE;							// If So done=TRUE
			}
			else									// If Not, Deal With Window Messages
			{
				TranslateMessage(&msg);				// Translate The Message
				DispatchMessage(&msg);				// Dispatch The Message
			}
		}
		else										// If There Are No Messages
		    if (active)
			{
				// Draw The Scene.  Watch For ESC Key And Quit Messages From DrawGLScene()
				if (keys[VK_ESCAPE])	// Active?  Was There A Quit Received?
				{
					done=TRUE;							// ESC or DrawGLScene Signalled A Quit
				}
				else									// Not Time To Quit, Update Screen
				{
					idle();                             // Advance Simulation
					DrawGLScene();                      // Draw Scene
					SwapBuffers(hDC);					// Swap Buffers (Double Buffering)
				}
	
				if (!ProcessKeys()) return 0;
			}
	}

	// Shutdown
	KillGLWindow();									// Kill The Window
    glDeleteTextures(4,texture);
	return (msg.wParam);							// Exit The Program
}
示例#7
0
CWave::CWave( const char *lpszResID, HINSTANCE hInstance )
{

	InitVars();
	Load( lpszResID, hInstance );

}
示例#8
0
CWave::CWave( const char *lpszFilename )
{

	InitVars();
	Load( lpszFilename );

}
示例#9
0
CWave::CWave( int nResID, HINSTANCE hInstance )
{

	InitVars();
	Load( nResID, hInstance );

}
示例#10
0
/**
   \brief Constructor - opens directly a video
**/
QVideoDecoder::QVideoDecoder(QString file)
{
   InitVars();
   initCodec();

   ok = openFile(file.toStdString().c_str());
}
示例#11
0
void QVideoDecoder::close()
{
   if(!ok)
      return;

   // Free the RGB image
   if(buffer)
      delete [] buffer;

   // Free the YUV frame
   if(pFrame)
      av_free(pFrame);

   // Free the RGB frame
   if(pFrameRGB)
      av_free(pFrameRGB);

   // Close the codec
   if(pCodecCtx)
      avcodec_close(pCodecCtx);

   // Close the video file
   if(pFormatCtx)
      av_close_input_file(pFormatCtx);

   InitVars();
}
示例#12
0
int main(int argc, char **argv) {
	InitVars(argc, argv);
	if (argc != 2) {
		DLOG << "Usage: sweep_lines FRAME_ID";
		exit(-1);
	}

	string sequence = "lab_kitchen1";
	int frame_id = atoi(argv[1]);

	Map map;
	proto::TruthedMap gt_map;
	string path = GetMapPath(sequence);
	LoadXmlMapWithGroundTruth(path, map, gt_map);

	Frame* f = map.GetFrameByIdOrDie(frame_id);
	DLOG << "Loading image...";
	f->LoadImage();
	DLOG << "Loaded image.";

	GuidedLineDetector line_detector;
	line_detector.Compute(f->image);

	IsctGeomLabeller sweeper;
	sweeper.Compute(f->image, line_detector.detections);

	sweeper.OutputOrientViz("out/orients.png");

	return 0;
}
示例#13
0
/*!
\b Parameters:

\arg \b pImageManager			Pointer to the manager IND_ImageManager correctly initialized
\arg \b pSurfaceManager			Pointer to the manager IND_SurfaceManager correctly initialized

\b Operation:

This function returns 1 (true) if the adminstrator is successfully initialized.
Must be called before using any method.
*/
bool IND_FontManager::Init (IND_ImageManager *pImageManager, IND_SurfaceManager *pSurfaceManager)
{
	End ();
	InitVars ();	

	Debug->Header ("Initializing FontManager", 5);

	// Checking IND_SurfaceManager
	if (pSurfaceManager->IsOk())
	{
		Debug->Header ("SurfaceManager Ok", 1);
		mSurfaceManager = pSurfaceManager;

		Debug->Header ("ImageManager Ok", 1);
		mImageManager = pImageManager;

		mOk = true;

		Debug->Header ("FontManager OK", 6);
	}
	else
	{
		Debug->Header ("SurfaceManager is not correctly initalized", 2);
		mOk = false;
	}

	return mOk;
}
示例#14
0
// Открыть диалог с подтверждением параметров создания/закрытия/пересоздания консоли
int CRecreateDlg::RecreateDlg(RConStartArgsEx* apArgs, bool abDontAutoSelCmd /*= false*/)
{
	if (!this)
	{
		_ASSERTE(this);
		return IDCANCEL;
	}

	mb_DontAutoSelCmd = abDontAutoSelCmd;

	if (mh_Dlg && IsWindow(mh_Dlg))
	{
		DisplayLastError(L"Close previous 'Create dialog' first, please!", -1);
		return IDCANCEL;
	}

	DontEnable de;

	gpConEmu->SkipOneAppsRelease(true);

	//if (!gpConEmu->mh_RecreatePasswFont)
	//{
	//	gpConEmu->mh_RecreatePasswFont = CreateFont(

	//}

	mn_DlgRc = IDCANCEL;
	mp_Args = apArgs;

	mh_Parent = (apArgs->aRecreate == cra_EditTab && ghOpWnd) ? ghOpWnd : ghWnd;

	#ifdef _DEBUG
	if ((mh_Parent == ghWnd) && gpConEmu->isIconic())
	{
		_ASSERTE(FALSE && "Window must be shown before dialog!");
	}
	#endif

	InitVars();

	bool bPrev = gpConEmu->SetSkipOnFocus(true);
	CDpiForDialog::Create(mp_DpiAware);
	// Modal dialog (CreateDialog)
	int nRc = CDynDialog::ExecuteDialog(IDD_RESTART, mh_Parent, RecreateDlgProc, (LPARAM)this);
	UNREFERENCED_PARAMETER(nRc);
	gpConEmu->SetSkipOnFocus(bPrev);

	FreeVars();

	//if (gpConEmu->mh_RecreatePasswFont)
	//{
	//	DeleteObject(gpConEmu->mh_RecreatePasswFont);
	//	gpConEmu->mh_RecreatePasswFont = NULL;
	//}

	gpConEmu->SkipOneAppsRelease(false);

	return mn_DlgRc;
}
示例#15
0
//______________________________________________________________________________
void AnalysisManager::Init(){

        string fn = "samc.root"; 
        fFile     = new TFile(fn.c_str(),"RECREATE");  

	InitVars();
	InitTree();
}
示例#16
0
DecodeThread::DecodeThread(QObject *parent) :
    QThread(parent)
{
    vthread = NULL;
    videoMutex = NULL;
    audioMutex = NULL;
    InitVars();
}
void idChoiceWindow::PostParse() {
	idWindow::PostParse();
	UpdateChoicesAndVals();
	InitVars();
	UpdateChoice();
	UpdateVars( false );
	flags |= WIN_CANFOCUS;
}
示例#18
0
void PGNReadFromFile (const char *file)
/****************************************************************************
 *
 *  To read a game from a PGN file.
 *
 ****************************************************************************/
{
   FILE *fp;
   char s[100], c, wmv[8], bmv[8];
   int moveno;
   leaf *p;

   fp = fopen (file, "r");
   if (fp == NULL)
   {
      printf ("Cannot open file %s\n", file);
      return;
   }

   /* Skip all the tags */
   do
   {
      if ((c = fgetc (fp)) == '[')
         fgets (s, 100, fp);
   } while (c == '[');
   ungetc (c, fp);

   InitVars ();
   while (!feof (fp))
   {
      c = fgetc(fp);
      if (c == '*') break;
      ungetc (c, fp);
      fscanf (fp, "%d. %7s %7s ", &moveno, wmv, bmv);
      p = ValidateMove (wmv);
      if (!p)
      {
	 printf ("Illegal move %d. %s\n", moveno, wmv);
	 break;
      }
      MakeMove (white, &p->move);
      strcpy (Game[GameCnt].SANmv, wmv);
      if (*bmv == '*' ) break;
      p = ValidateMove (bmv);
      if (!p)
      {
	 printf ("Illegal move %d. ... %s\n", moveno, bmv);
	 break;
      }
      MakeMove (black, &p->move);
      strcpy (Game[GameCnt].SANmv, bmv);
   }
   printf ("%d\n", GameCnt);
   fclose (fp);
   ShowBoard ();
   TTClear ();
   return;
}
示例#19
0
// Открыть диалог с подтверждением параметров создания/закрытия/пересоздания консоли
int CRecreateDlg::RecreateDlg(RConStartArgs* apArgs)
{
	if (!this)
	{
		_ASSERTE(this);
		return IDCANCEL;
	}

	if (mh_Dlg && IsWindow(mh_Dlg))
	{
		DisplayLastError(L"Close previous 'Create dialog' first, please!", -1);
		return IDCANCEL;
	}
	
	DontEnable de;

	gpConEmu->SkipOneAppsRelease(true);

	//if (!gpConEmu->mh_RecreatePasswFont)
	//{
	//	gpConEmu->mh_RecreatePasswFont = CreateFont(

	//}

	mn_DlgRc = IDCANCEL;
	mp_Args = apArgs;

	mh_Parent = (apArgs->aRecreate == cra_EditTab && ghOpWnd) ? ghOpWnd : ghWnd;

	#ifdef _DEBUG
	if ((mh_Parent == ghWnd) && gpConEmu->isIconic())
	{
		_ASSERTE(FALSE && "Window must be shown before dialog!");
	}
	#endif

	InitVars();

	bool bPrev = gpConEmu->SetSkipOnFocus(true);
	int nRc = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_RESTART), mh_Parent, RecreateDlgProc, (LPARAM)this);
	UNREFERENCED_PARAMETER(nRc);
	gpConEmu->SetSkipOnFocus(bPrev);

	FreeVars();

	//if (gpConEmu->mh_RecreatePasswFont)
	//{
	//	DeleteObject(gpConEmu->mh_RecreatePasswFont);
	//	gpConEmu->mh_RecreatePasswFont = NULL;
	//}

	gpConEmu->SkipOneAppsRelease(false);

	return mn_DlgRc;
}
示例#20
0
void CInterpreter::FreeVars( void )
{
	variable_v::iterator	vi;

	for ( vi = m_vars.begin(); vi != m_vars.end(); vi++ )
	{
		delete (*vi);
	}

	InitVars();
}
示例#21
0
void cmd_new(void)
{
  InitVars ();
  NewPosition ();
  /* Protocol specification for ANALYZE says "new" does not end analysis */
  if (!(flags & ANALYZE))
    CLEAR (flags, MANUAL);
  CLEAR (flags, THINK);
  myrating = opprating = 0;
  SetDataToEngine( token[0] );
}
示例#22
0
文件: WaitDlg.cpp 项目: 3rdexp/fxfile
void CWaitDialog::EndWait(void)
{
	if (m_hThread != NULL)
	{
		m_bDone = TRUE;
		PostMessage(m_hwndWait, WM_CLOSE, 0, 0);
		WaitForSingleObject(m_hThread, INFINITE);
		CloseHandle(m_hThread);
	}
	InitVars();
}
示例#23
0
MatrSolver::MatrSolver(int size)
{
    InitVars(size);
    InitRand();
    InitMatr();
    SetMtx(matr, b_matr, n);
    PrintMtx(matr, n);
    std::cout << "Матрица В: " << std::endl;
    PrintVector(b_matr, n);
    //Solve();
}
示例#24
0
/*
==================
Init
==================
*/
bool ImageCutter::Init (IND_ImageManager *pImageManager, int pMaxTextureSize)
{
	End ();
	InitVars ();

	mImageManager = pImageManager;
	mMaxTextureSize = pMaxTextureSize;

	mOk = true;
	return mOk;
}
int main(int argc, char **argv) {
	// InitVars is part of base. We need because of the vars in dp_payoffs.cpp
	InitVars(argc, argv);

	// Declare the supported options.
	po::options_description desc("Allowed options");
	desc.add_options()
    ("help", "produce help message")
		("features", po::value<string>()->required(), "file containing payoff features")
		("weights", po::value<string>(), "feature weights")
    ("corner_penalty", po::value<float>()->required(), "per-corner penalty")
    ("occlusion_penalty", po::value<float>()->required(),
		 "additional penalty for occluding corners")
    ("with_gradient", "also compute gradient")
    ("logit", "use logistic likelihood (default is Gaussian)")
    ("delta", po::value<double>()->default_value(kDefaultDelta),
		 "Window size for finite differences.")
		;

	// Parse options
	po::variables_map opts;
	try {
		po::store(po::parse_command_line(argc, argv, desc), opts);
		po::notify(opts);
	} catch (const po::required_option& ex) {
		cout << "Missing required option: " << ex.get_option_name() << "\n" << desc << "\n";
		return -1;
	}
	if (opts.count("help")) {
    cout << desc << "\n";
    return -1;
	}
	if (opts.count("with_gradient")) {
		cout << "GRADIENTS NOT IMPLEMENTED";
		return -1;
	}

	// Read command line arguments
	ManhattanHyperParameters params;
	params.corner_penalty = opts["corner_penalty"].as<float>();
	params.occlusion_penalty = opts["occlusion_penalty"].as<float>();
	params.weights = stream_to<VecF>(opts["weights"].as<string>());

	// Evaluate the likelihood
	double loglik = EvaluateLikelihood(params,
																		 opts["features"].as<string>(),
																		 opts.count("logit_likelihood")>0);

	// Done. Print with high precision so matlab can read with high precision.	
	DLOG << format("%.18e ") % loglik;

	return 0;
}
示例#26
0
/*
*************************
Init
*************************
*/
bool DebugApi::Init ()
{

	End ();
	InitVars ();
#if 0
	// File
	std::string f1="/IndieLibX.debug.log";
	std::string f2=stx_convertpath(f1);
	const char* f3=f2.c_str();
	
	mCout = new ofstream (f3, ios::out);
#endif
	// Time
	time_t mT;
	time (&mT);
	struct tm *mPetm = localtime (&mT);

	// :D

	
	LOG_PRINT("\n");
	LOG_PRINT("                         ''~``                         \n");
	LOG_PRINT("                        ( o o )                        \n");
	LOG_PRINT("+------------------.oooO--(_)--Oooo.------------------+\n");
	LOG_PRINT("|                                                     |\n");
	LOG_PRINT("|                ®-------------------®                |\n");
	LOG_PRINT("|                | I N D I E  L I B  |                |\n");
	LOG_PRINT("|                ®-------------------®                |\n");
	LOG_PRINT("|                    .oooO                            |\n");
	LOG_PRINT("|                    (   )   Oooo.                    |\n");
	LOG_PRINT("+---------------------\\ (----(   )--------------------+\n");
	LOG_PRINT("                       \\_)    ) /                      \n");
	LOG_PRINT("                             (_/                       \n");
	LOG_PRINT("\n");
	LOG_PRINT("\n");
	

	LOG_PRINT("[Debug.log]: (\n");

	// Date
    const char *mDs [7] = {"Sunday","Monday","Tuesday","Wednesday","Thrusday","Friday","Saturday"};
    const char *mMs [12] = {"January","February","March","April","May","June","July","August","September","October","November","December"};

	// Date
	LOG_PRINT("%s%d%s%d", mDs [mPetm->tm_wday], mPetm->tm_mday, mMs [mPetm->tm_mon], mPetm->tm_year+1900);
	LOG_PRINT("\n");
	LOG_PRINT("\n");

	mOk = true;

	return mOk;
}
int main(int argc, char **argv) {
	InitVars();

	PTAMM::ATANCamera cam(GV3::get<Vec2>("Map.DefaultImageSize"),
												GV3::get<Vec5>("Map.DefaultCameraParameters"));

	DREPORT(cam.Project(makeVector(0, 0)));
	DREPORT(cam.Project(makeVector(3, 1.7)));
	DREPORT(cam.Project(makeVector(-1, 2.5)));
	DREPORT(cam.UnProject(makeVector(0, 0)));
	DREPORT(cam.UnProject(makeVector(1, -1.5)));

	return 0;
}
示例#28
0
bool cCardClientRadegast::Login(void)
{
  Logout();
  if(!so.Connect(hostname,port)) return false;
  PRINTF(L_CC_LOGIN,"%s: connected to %s:%d",name,hostname,port);

  InitVars();
  unsigned char buff[512];
  char hello[32];
  snprintf(hello,sizeof(hello),"rdgd/vdr-sc-%s",ScVersion);
  StartMsg(buff,0x90);			// RDGD_MSG_CLIENT_HELLO
  AddNano(buff,1,strlen(hello),(unsigned char *)hello);	// RDGD_NANO_DESCR
  if(!Send(buff) || Recv(buff,sizeof(buff))<0) return false;
  if(buff[0]==0x91) {
    PRINTF(L_CC_RDGD,"got server hello, assuming V4 mode");
    StartMsg(buff,0x94);		// RDGD_MSG_CLIENT_CAP_REQ;
    int n;
    if(!Send(buff) || (n=Recv(buff,sizeof(buff)))<0) return false;
    if(buff[0]==0x95) {
      LBSTARTF(L_CC_LOGIN);
      LBPUT("radegast: got caps");
      int caid;
      for(int l=GetNanoStart(buff); l<n; l+=buff[l+1]+2) {
        switch(buff[l]) {
          case 0xE2:
            LBPUT(" VERS %s",(char *)&buff[l+2]);
            break;
          case 0xE4: // CAP_NANO_CAID
            if(numCaids>=MAXCAIDS) { l=n; break; } //stop processing
            caid=(buff[l+2]<<8)+buff[l+3];
            LBPUT(" CAID %04X",caid);
            caids[numCaids++]=caid;
            // XXX we should have EMM processing setup here, but as we don't
            // XXX get any ua/sa we cannot filter EMM anyways
            break;
          case 0xE5: // CAP_NANO_PROVID
            for(int i=0; i<buff[l+1]; i+=3)
              LBPUT("/%02X%02X%02X",buff[l+2+i],buff[l+2+i+1],buff[l+2+i+2]);
            break;
          }
        }
      LBEND();
      }
    }
  else PRINTF(L_CC_RDGD,"no server hello, assuming old mode");
  if(emmProcessing && !emmAllowed) 
    PRINTF(L_CC_EMM,"%s: EMM disabled from config",name);
  CaidsChanged();
  return true;
}
示例#29
0
void D3GridRouter:: LocalProcMsg(comID id)
{
    ComlibPrintf("%d local procmsg called\n", MyPe);
    
    LPMsgCount++;
    PeGrid->ExtractAndDeliverLocalMsgs(MyPe, container);
    
    if (LPMsgCount==LPMsgExpected) {
	PeGrid->Purge();
	InitVars();
        routerStage = 0;
        ComlibPrintf("%d:Round Done\n", CkMyPe());
	Done(id);
    }
}
示例#30
0
static int OnSystemModulesLoaded(WPARAM wParam,LPARAM lParam)
{
/*	if (ServiceExists(MS_DOS_SERVICE))
		gbDosServiceExist = TRUE; */
	if (ServiceExists(MS_VARS_FORMATSTRING))
		gbVarsServiceExist = TRUE;
	InitVars();
	void CleanThread();
	if(gbDelAllTempory || gbDelExcluded)
		boost::thread *thr = new boost::thread(&CleanThread);
	
	// Folders plugin support
	hStopSpamLogDirH = FoldersRegisterCustomPathT(LPGEN("StopSpam"), LPGEN("StopSpam Logs"), FOLDER_LOGS);
	return 0;
}