Exemple #1
0
bool LinkageWorker::Run()
{
    if (!OnInitialize()) {
        return false;
    }

    HealthTimer *health = new HealthTimer(this);
    if (!RegisterTimer(1000000000LL, health, true)) {
        delete health;
        return false;
    }

    bool result = true;
    while (!_quit) {
        if (!ev_run(_loop, 0)) {
            CLOG.Error("Linkage: ev_run() returned false.");
            result = false;
            break;
        }
    }

    OnShutdown();

    for (events_t::iterator p = _events.begin(); p != _events.end(); ++p) {
        DoRelease(p->second, false);
    }

    for (timers_t::iterator p = _timers.begin(); p != _timers.end(); ++p) {
        DoRelease(*p, false);
    }

    _events.clear();
    _timers.clear();
    return result;
}
Exemple #2
0
void Actor::Initialize() {
	OnInitialize();

	EachChildren([](Actor& actor) {
		actor.Initialize();
	});
}
int main(int argc, char** argv) {

	// Initialize the window and the GL components
	if (!OnInitInstance() || !GL_Initialize()) {
		return 1;
	}

	// Initialize the application
	OnInitialize();

	while(mAppRunning == true) {
		MSG message = {0};
		bool result = PeekMessage(&message, 0, 0, 0, PM_REMOVE);
	
		if (result == true) {
			TranslateMessage(&message);
			DispatchMessage(&message);
		}
	
		OnFrame();
	}

	system("pause");
	OnDestroyInstance();
	return 0;
}
BOOL CTextInfoForm::DoCreateDialog(CWnd* parent)
{
	BOOL ret = Create(IDD, parent);

	if (!ret) return FALSE;

    // prepare titlebar
	title.ModifyStyle(0, WS_CLIPCHILDREN);
	title.ModifyStyleEx(0, WS_EX_CONTROLPARENT);

    CRect	rc;
	rc.SetRect(0, 0, 60, 23);
    btn_copy.Create(_T("&Copy"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP, rc, &title, IDC_BUTTON_COPYTEXT);
    btn_copy.SetWindowPos(NULL, 4, 4, rc.Width(), rc.Height(), SWP_SHOWWINDOW | SWP_NOZORDER);
    btn_copy.SetFont(GetFont());

    btn_save.Create(_T("&Save"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP, rc, &title, IDC_BUTTON_SAVE);
    btn_save.SetWindowPos(NULL, 8 + rc.Width(), 4, rc.Width(), rc.Height(), SWP_SHOWWINDOW | SWP_NOZORDER);
    btn_save.SetFont(GetFont());

    rc.SetRect(0, 0, 150, 23);
    combo_reporttype.Create(WS_TABSTOP | WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST, rc, &title, IDC_COMBO_REPORTTYPE);
    combo_reporttype.SetFont(GetFont());

	// Force a second resize to give the combo box a chance to position itself once it's fully created
	// Would not be an issue if the setup above was done in OnInitDialog...
	SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE);		// resize down to zero
	SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOZORDER);		// resize down to zero
	RestorePosition();								// then restore position or set default position

	OnInitialize();

	return TRUE;
};
Exemple #5
0
_CLASS_GEN(Algorithm)::_CLASS_GEN(Algorithm)() {
    mIsBusy = false;
    mSettings = nullptr;
    mLogger = nullptr;

    OnInitialize();
}
Exemple #6
0
/////////////////////////////////////////////////////////////////////
// 
// Function:    Execute
//
// Description: 
//
/////////////////////////////////////////////////////////////////////
UINT BOINCCABase::Execute()
{
    UINT    uiReturnValue = 0;

    OnInitialize();

    if      ( TRUE == MsiGetMode( m_hMSIHandle, MSIRUNMODE_SCHEDULED ) )
    {
        uiReturnValue = OnInstall();
    }
    else if ( TRUE == MsiGetMode( m_hMSIHandle, MSIRUNMODE_COMMIT ) )
    {
        uiReturnValue = OnCommit();
    }
    else if ( TRUE == MsiGetMode( m_hMSIHandle, MSIRUNMODE_ROLLBACK ) )
    {
        uiReturnValue = OnRollback();
    }
    else
    {
        uiReturnValue = OnExecution();
    }

    OnCleanup();

    return uiReturnValue;
}
Exemple #7
0
void CApplication::Initialize(const char* pAppName, int hInstance,
		int iWinWidth, int iWinHeight) {
	// Initialize error log
	CLog::Get()->Initialize();

	// Write to log
	CLog::Get()->Write(ELogMessageType_MESSAGE,
			"[Application] Initializing: %s...", pAppName);
	glutInitWindowSize(iWinWidth, iWinHeight);
	glutInitWindowPosition(0, 0);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

	// Cache the windows dimension
	mWinWidth = iWinWidth;
	mWinHeight = iWinHeight;

	mWindow = glutCreateWindow(pAppName);
	glutSetCursor(GLUT_CURSOR_NONE);

	// Do any additional initialization here
	OnInitialize();
	// Write to log
	CLog::Get()->Write(ELogMessageType_MESSAGE, "[Application] %s initialized",
			pAppName);
}
Exemple #8
0
int __stdcall ModuleEntry (
		int nFunctionID,
		void *pParams
		)
{
	switch ( nFunctionID ) {

	case FID_INITIALIZE:
		return OnInitialize ((StartupInfo*)pParams);

	case FID_FINALIZE:
		return OnFinalize ();

	case FID_QUERYARCHIVE:
		return OnQueryArchive ((QueryArchiveStruct*)pParams);

	case FID_STARTOPERATION:
		return OnStartOperation ((OperationStruct*)pParams);

	case FID_ENDOPERATION:
		return OnEndOperation ((OperationStruct*)pParams);

	case FID_GETARCHIVEMODULEINFO:
		return OnGetArchiveModuleInfo ((ArchiveModuleInfo*)pParams);

	case FID_GETARCHIVEITEM:
		return OnGetArchiveItem((GetArchiveItemStruct*)pParams);

	case FID_FREEARCHIVEITEM:
		return OnFreeArchiveItem((FreeArchiveItemStruct*)pParams);

	case FID_EXTRACT:
		return OnExtract ((ExtractStruct*)pParams);

	case FID_TEST:
		return OnTest ((TestStruct*)pParams);

	case FID_GETDEFAULTCOMMAND:
		return OnGetDefaultCommand ((GetDefaultCommandStruct*)pParams);
	
	case FID_DELETE:
		return OnDelete ((DeleteStruct*)pParams);

	case FID_ADD:
		return OnAdd ((AddStruct*)pParams);

	case FID_CREATEARCHIVE:
	case FID_OPENARCHIVE:
		return OnOpenCreateArchive ((OpenCreateArchiveStruct*)pParams);

	case FID_CONFIGUREFORMAT:
		return OnConfigureFormat((ConfigureFormatStruct*)pParams);

	case FID_CLOSEARCHIVE:
		return OnCloseArchive((CloseArchiveStruct*)pParams);
	}

	return NAERROR_NOTIMPLEMENTED;
}
Exemple #9
0
void Scene::Initialize()
{
	if (!m_IsInitialized)
	{
		OnInitialize();
		m_IsInitialized = true;
	}
}
Exemple #10
0
void WorldPlugin::Initialize(World *world, std::string name, std::string type,
                             YAML::Node &plugin_reader,
                             YamlReader &world_config) {
  world_ = world;
  name_ = name;
  type_ = type;
  world_config_ = world_config;
  plugin_type_ = PluginType::World;
  OnInitialize(plugin_reader);
}
BOOL CDecPerformanceForm::DoCreateDialog(CWnd* parent)
{
    BOOL ret = Create(IDD, parent);
    if (!ret) return FALSE;

    // prepare titlebar
    title.ModifyStyle(0, WS_CLIPCHILDREN);
    title.ModifyStyleEx(0, WS_EX_CONTROLPARENT);

    OnInitialize();
    return TRUE;
};
void HCriticalPaths::Initialize(int pathsLimit)
{
    m_initialized = true;
    if(m_ld->Timing.ncpLimit < pathsLimit)
        Grow(pathsLimit);
    m_ld->Timing.cpFirstPointIdx[0] = 0;
    m_ld->Timing.cpAfterLastPointIdx[0] = 0;
    m_ld->Timing.cpExtractionType[0] = PathExtractionType_Arrival;

    m_ld->Timing.ncpEnd = 1;
    OnInitialize(pathsLimit);
}
Exemple #13
0
bool CProtocolCore::Initialize()
{
/*
	m_pStopState = new StateStop;
	m_pPausedState = new StatePaused;
	m_pPlayingState = new StatePlaying;

	m_pCurrState = m_pStopState;
*/

	return OnInitialize();
}
Exemple #14
0
int __stdcall PluginEntry (
		int nFunctionID,
		void *pParams
		)
{
	switch ( nFunctionID ) {

	case FID_INITIALIZE:
		return OnInitialize ((StartupInfo*)pParams);

	case FID_FINALIZE:
		return OnFinalize ();

	case FID_QUERYARCHIVE:
		return OnQueryArchive ((QueryArchiveStruct*)pParams);

	case FID_OPENARCHIVE:
		return OnOpenArchive ((OpenArchiveStruct*)pParams);

	case FID_CLOSEARCHIVE:
		return OnCloseArchive ((CloseArchiveStruct*)pParams);

	case FID_FINALIZEARCHIVE:
		return OnFinalizeArchive ((AceArchive*)pParams);

	case FID_GETARCHIVEPLUGININFO:
		return OnGetArchivePluginInfo ((ArchivePluginInfo*)pParams);

	case FID_GETARCHIVEITEM:
		return OnGetArchiveItem ((GetArchiveItemStruct*)pParams);

	case FID_GETARCHIVEFORMAT:
		return OnGetArchiveFormat ((GetArchiveFormatStruct*)pParams);

	case FID_EXTRACT:
		return OnExtract ((ExtractStruct*)pParams);

	case FID_GETDEFAULTCOMMAND:
		return OnGetDefaultCommand ((GetDefaultCommandStruct*)pParams);

	case FID_ADD:
		return OnAdd ((AddStruct*)pParams);

	case FID_DELETE:
		return OnDelete ((DeleteStruct*)pParams);

	case FID_CREATEARCHIVE:
		return OnCreateArchive ((CreateArchiveStruct*)pParams);
	}

	return NAERROR_NOTIMPLEMENTED;
}
Exemple #15
0
APP_ERRORS CApplication::Run()
{
    MakeWindow();
    initVideoModes();
    if( !m_Renderer.Initialize(m_Window) )
    {
        m_Quit = true;
        m_error = FAILED_INIT_RENDERER;
    }
    OnInitialize();
    MainLoop();

    return m_error;
}
//---------------------------------------------------------------------
void BaseTween::Initialize()
{
	if(m_currentTime + m_dt >= m_delay)
	{
		OnInitialize();
		m_flags.ChangeMask(eIsInit, true);
		m_flags.ChangeMask(eIsIteratingStep, true);
		m_step = 0;
		m_dt -= (m_delay - m_currentTime);
		m_currentTime = 0.0f;
		CallCallback(eTweenBegin);
		CallCallback(eTweenStart);
	}
}
Exemple #17
0
bool IService::initialize(const std::map<std::string, std::string> &entries)
{
    std::map<std::string, std::string>::const_iterator it = entries.find("NetworkPoolSize");

    if (it != entries.end())
        m_thread_count = atoi(it->second.c_str());

    OnConfigure(entries);

    if (!OnInitialize())
        return false;

    return true;
}
int main(int argc, char* argv[])
{
	lua_State*	L = luaL_newstate();
	luaL_openlibs(L);
	gLuaLibOpenGL.Initialize(L);

	auxInitDisplayMode(AUX_SINGLE | AUX_RGBA);
	auxInitPosition(1366 - 550, 50, 500, 500);
	auxInitWindow("Lua bind OpenGL");
	OnInitialize();
	auxReshapeFunc(OnWindowSize);
  auxMainLoop(OnRend);

	lua_close(L);
	return 0;
}
BOOL CFileTypesForm::DoCreateDialog(CWnd* parent)
{
	BOOL ret = Create(IDD, parent);
	if (!ret) return FALSE;

	// prepare titlebar
	title.ModifyStyle(0, WS_CLIPCHILDREN);
	title.ModifyStyleEx(0, WS_EX_CONTROLPARENT);

	// create buttons
	CRect	rc;
	rc.SetRect(0, 0, 60, 23);
    btn_copy.Create(_T("&Copy"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP, rc, &title, IDC_BUTTON_COPY);
	btn_copy.SetFont(GetFont());
    btn_copy.SetWindowPos(NULL, 4, 4, rc.Width(), rc.Height(), SWP_SHOWWINDOW | SWP_NOZORDER);

	btn_reload.Create(_T("&Reload"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP, rc, &title, IDC_BUTTON_CLEAR);
    btn_reload.SetWindowPos(NULL, 8 + rc.Width(), 4, rc.Width(), rc.Height(), SWP_SHOWWINDOW | SWP_NOZORDER);
	btn_reload.SetFont(GetFont());

    pages[0] = page_protocols   = new CPageFileTypes(_T("Protocols"));
    pages[1] = page_extensions  = new CPageFileTypes(_T("Extensions"));
    pages[2] = page_bytes       = new CPageFileTypes(_T("Bytes"));

    // we need to set WS_EX_CONTROLPARENT for the tabs
	tab.ModifyStyleEx(0, WS_EX_CONTROLPARENT);

    TCITEM tci;
    tci.mask = TCIF_TEXT;
    tci.iImage = -1;

    for (DWORD i=0; i<pageCount; i++)
    {
        if (pages[i])
        {
            pages[i]->Create(CPageFileTypes::IDD, &tab);
            tci.pszText =  (LPTSTR)(LPCTSTR)CString(pages[i]->title);
            tab.InsertItem(i, &tci);
        }
    }

    OnTabChanged(NULL, NULL);

    OnInitialize();

	return TRUE;
}
Exemple #20
0
int __stdcall ModuleEntry (
		int nFunctionID,
		void *pParams
		)
{
	switch ( nFunctionID ) {

	case FID_INITIALIZE:
		return OnInitialize ((StartupInfo*)pParams);

	case FID_FINALIZE:
		return OnFinalize ();

	case FID_QUERYARCHIVE:
		return OnQueryArchive ((QueryArchiveStruct*)pParams);

	case FID_OPENARCHIVE:
		return OnOpenArchive ((OpenArchiveStruct*)pParams);

	case FID_CLOSEARCHIVE:
		return OnCloseArchive ((CloseArchiveStruct*)pParams);

	case FID_FINALIZEARCHIVE:
		return OnFinalizeArchive ((RarArchive*)pParams);

	case FID_GETARCHIVEMODULEINFO:
		return OnGetArchiveModuleInfo ((ArchiveModuleInfo*)pParams);

	case FID_GETARCHIVEITEM:
		return OnGetArchiveItem ((GetArchiveItemStruct*)pParams);

	case FID_FREEARCHIVEITEM:
		return OnFreeArchiveItem((FreeArchiveItemStruct*)pParams);

	case FID_EXTRACT:
		return OnExtract ((ExtractStruct*)pParams);

	case FID_TEST:
		return OnTest ((TestStruct*)pParams);

	case FID_GETDEFAULTCOMMAND:
		return OnGetDefaultCommand ((GetDefaultCommandStruct*)pParams);
	}

	return NAERROR_NOTIMPLEMENTED;
}
Exemple #21
0
int __stdcall ModuleEntry (
		int nFunctionID,
		void *pParams
		)
{
	switch ( nFunctionID ) {

	case FID_INITIALIZE:
		return OnInitialize ((StartupInfo*)pParams);

	case FID_FINALIZE:
		return OnFinalize ();

	case FID_QUERYARCHIVE:
		return OnQueryArchive ((QueryArchiveStruct*)pParams);

	case FID_OPENARCHIVE:
		return OnOpenArchive ((OpenCreateArchiveStruct*)pParams);

	case FID_CLOSEARCHIVE:
		return OnCloseArchive ((CloseArchiveStruct*)pParams);

	case FID_GETARCHIVEMODULEINFO:
		return OnGetArchiveModuleInfo ((ArchiveModuleInfo*)pParams);

	case FID_GETARCHIVEITEM:
		return OnGetArchiveItem ((GetArchiveItemStruct*)pParams);

	case FID_FREEARCHIVEITEM:
		return OnFreeArchiveItem((FreeArchiveItemStruct*)pParams);
		
	case FID_EXTRACT:
		return OnExtract ((ExtractStruct*)pParams);

	case FID_STARTOPERATION:
		return OnStartOperation((OperationStruct*)pParams);

	case FID_ENDOPERATION:
		return OnEndOperation((OperationStruct*)pParams);

	case FID_GETARCHIVEINFO:
		return OnGetArchiveInfo((ArchiveInfoStruct*)pParams);
	}

	return NAERROR_NOTIMPLEMENTED;
}
void InkCollector::Initialize()
{
  // Possibly, we can use mConnectionPoint for checking,
  // But if errors exist (perhaps COM object is unavailable),
  // Initialize() will be called more times.
  static bool sInkCollectorCreated = false;
  if (sInkCollectorCreated) {
    return;
  }
  sInkCollectorCreated = true;

  // COM could get uninitialized due to previous initialization.
  mComInitialized = SUCCEEDED(::CoInitialize(nullptr));

  // Set up instance of InkCollectorEvent.
  mInkCollectorEvent = new InkCollectorEvent();

  // Set up a free threaded marshaler.
  if (FAILED(::CoCreateFreeThreadedMarshaler(mInkCollectorEvent, getter_AddRefs(mMarshaller)))) {
    return;
  }

  // Create the ink collector.
  if (FAILED(::CoCreateInstance(CLSID_InkCollector, NULL, CLSCTX_INPROC_SERVER,
                                IID_IInkCollector, getter_AddRefs(mInkCollector)))) {
    return;
  }

  // Set up connection between sink and InkCollector.
  RefPtr<IConnectionPointContainer> connPointContainer;

  // Get the connection point container.
  if (SUCCEEDED(mInkCollector->QueryInterface(IID_IConnectionPointContainer,
                                              getter_AddRefs(connPointContainer)))) {

    // Find the connection point for Ink Collector events.
    if (SUCCEEDED(connPointContainer->FindConnectionPoint(__uuidof(_IInkCollectorEvents),
                                                          getter_AddRefs(mConnectionPoint)))) {

      // Hook up sink to connection point.
      if (SUCCEEDED(mConnectionPoint->Advise(mInkCollectorEvent, &mCookie))) {
        OnInitialize();
      }
    }
  }
}
void HPlacementRows::Initialize(int rowsLimit)
{
  CHECKIFINITIALIZED();

  Grow(rowsLimit);
  m_ld->DetailedPlacement.rowName[0] = "NULL";
  m_ld->DetailedPlacement.rowSite[0] = 0;
  m_ld->DetailedPlacement.rowSiteOrient[0] = Orientation_Default;
  m_ld->DetailedPlacement.rowStepX[0] = 0;
  m_ld->DetailedPlacement.rowStepY[0] = 0;
  m_ld->DetailedPlacement.rowX[0] = 0;
  m_ld->DetailedPlacement.rowXSitesNum[0] = 0;
  m_ld->DetailedPlacement.rowY[0] = 0;
  m_ld->DetailedPlacement.rowYSitesNum[0] = 0;
  m_ld->DetailedPlacement.rowNextRow[0] = 0;
  m_ld->DetailedPlacement.rowPreviousRow[0] = 0;

  m_ld->DetailedPlacement.nRows = 1;
  OnInitialize(rowsLimit);
}
Exemple #24
0
//============================================================
// <T>服务器加载操作。</T>
//
// @return 处理结果
//============================================================
TResult FServer::Launch(){
   // 构造
   MO_INFO("'%s' server construct.", (TCharC*)_name);
   OnConstruct();
   // 加载所有设置
   MO_INFO("'%s' server load config.", (TCharC*)_name);
   OnLoadConfig();
   // 初始化
   MO_INFO("'%s' server initialize.", (TCharC*)_name);
   OnInitialize();
   // 加载所有模块
   MO_INFO("'%s' server load modules.", (TCharC*)_name);
   OnLoadModules();
   // 加载所有监视器
   MO_INFO("'%s' server load monitors.", (TCharC*)_name);
   OnLoadMonitors();
   // 加载所有服务
   MO_INFO("'%s' server load services.", (TCharC*)_name);
   OnLoadServices();
   return ESuccess;
}
Exemple #25
0
	void Application::Run() {
		// Initialization
		Initialize();
		OnInitialize();

		// Main Loop
		while (!mQuit) {

			// Update simulation sub-systems.
			mGameClock.Update();
			mRenderer->Update();
			mAnimationSystem.Update();

			// Update the application.
			OnUpdate();
		}
		
		// Shutdown
		OnShutdown();
		Shutdown();
	}
Exemple #26
0
// this is the main message handler for the program
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
        case WM_DESTROY:
        {
			::exit(0);
            PostQuitMessage(0);
            return 0;
        } 
        case WM_SIZE:
        {
			// If the device is not NULL and the WM_SIZE message is not a
			// SIZE_MINIMIZED event, resize the device's swap buffers to match
			// the new window size.
			if( d3ddev != NULL && wParam != SIZE_MINIMIZED )
			{
				OnRelease();

				ScreenX					= LOWORD(lParam);	
				ScreenY					= HIWORD(lParam);
				d3dpp.BackBufferWidth  = LOWORD(lParam);
				d3dpp.BackBufferHeight = HIWORD(lParam);

				//if(
				d3ddev->Reset( &d3dpp )
                // == D3DERR_INVALIDCALL )
                //{
                   //error
                //}
				;
				OnInitialize(false);
			}
        }
		break;
    }

    return DefWindowProc (hWnd, message, wParam, lParam);
}
Exemple #27
0
bool LinkageWorker::Run()
{
    if (!OnInitialize()) {
        return false;
    }

    HealthTimer *health = new HealthTimer(this);
    if (!RegisterTimer(1000000000LL, health, true)) {
        delete health;
        return false;
    }

    _running_thread_id = get_current_thread_id();
    LOG(VERBOSE) << "Linkage: enter event loop [" << _running_thread_id << "]";
    bool result = true;
    while (!_quit) {
        if (!ev_run(_loop, 0)) {
            CLOG.Error("Linkage: ev_run() returned false.");
            result = false;
            break;
        }
    }
    LOG(VERBOSE) << "Linkage: leave event loop [" << _running_thread_id << "]";
    _running_thread_id = 0;

    OnShutdown();

    for (events_t::iterator p = _events.begin(); p != _events.end(); ++p) {
        DoRelease(p->second, false);
    }

    for (timers_t::iterator p = _timers.begin(); p != _timers.end(); ++p) {
        DoRelease(*p, false);
    }

    _events.clear();
    _timers.clear();
    return result;
}
BOOL CLookupForm::DoCreateDialog(CWnd* parent)
{
	BOOL ret = Create(IDD, parent);
	if (!ret) return FALSE;

    // prepare titlebar
	m_title.ModifyStyle(0, WS_CLIPCHILDREN);
	m_title.ModifyStyleEx(0, WS_EX_CONTROLPARENT);

    CRect	rc;
	rc.SetRect(0, 0, 60, 23);
    m_btnSearch.Create(_T("&Search"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP, rc, &m_title, IDC_BUTTON_SEARCH);
    m_btnSearch.SetFont(GetFont());
    rc.SetRect(0, 0, 250, 23);
    m_editSearch.Create(ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, rc, &m_title, IDC_EDIT_SEARCH);
    m_editSearch.SetFont(GetFont());
    m_editSearch.SetFocus();

	OnInitialize();

	return TRUE;
};
Exemple #29
0
/*!
  Initialise the tracking by extracting KLT keypoints on the provided image.

  \param I : Grey level image used as input. This image should have only 1 channel.
  \param mask : Image mask used to restrict the keypoint detection area.
  If mask is NULL, all the image will be considered.

  \exception vpTrackingException::initializationError : If the image I is not
  initialized, or if the image or the mask have bad coding format.
*/
void vpKltOpencv::initTracking(const IplImage *I, const IplImage *mask)
{
  if (!I) {
    throw(vpException(vpTrackingException::initializationError,  "Image Not initialized")) ;
  }

  if (I->depth != IPL_DEPTH_8U || I->nChannels != 1)  {
    throw(vpException(vpTrackingException::initializationError,  "Bad Image format")) ;
  }

  if (mask) {
    if (mask->depth != IPL_DEPTH_8U || I->nChannels != 1) 	{
      throw(vpException(vpTrackingException::initializationError,  "Bad Image format")) ;
    }
  }

  //Creation des buffers
  CvSize Sizeim, SizeI;
  SizeI = cvGetSize(I);
  bool b_imOK = true;
  if(image != NULL){
    Sizeim = cvGetSize(image);
    if(SizeI.width != Sizeim.width || SizeI.height != Sizeim.height) b_imOK = false;
  }
  if(image == NULL || prev_image == NULL || pyramid==NULL || prev_pyramid ==NULL || !b_imOK){
    reset();
    image = cvCreateImage(cvGetSize(I), 8, 1);image->origin = I->origin;
    prev_image = cvCreateImage(cvGetSize(I), IPL_DEPTH_8U, 1);
    pyramid = cvCreateImage(cvGetSize(I), IPL_DEPTH_8U, 1);
    prev_pyramid = cvCreateImage(cvGetSize(I), IPL_DEPTH_8U, 1);
  }else{
    swap_temp = 0;
    countFeatures = 0;
    countPrevFeatures = 0;
    flags = 0;
    initialized = 0;
    globalcountFeatures = 0;
  }

  initialized = 1;

  //Import
  cvCopy(I, image, 0);

  //Recherche de points d'interets
  countFeatures = maxFeatures;
  countPrevFeatures = 0;
  IplImage* eig = cvCreateImage(cvGetSize(image), 32, 1);
  IplImage* temp = cvCreateImage(cvGetSize(image), 32, 1);
  cvGoodFeaturesToTrack(image, eig, temp, features,
                        &countFeatures, quality, min_distance,
                        mask, block_size, use_harris, harris_free_parameter);
  cvFindCornerSubPix(image, features, countFeatures, cvSize(win_size, win_size),
                     cvSize(-1,-1),cvTermCriteria(CV_TERMCRIT_ITER|
                                                  CV_TERMCRIT_EPS,20,0.03));
  cvReleaseImage(&eig);
  cvReleaseImage(&temp);

  if (OnInitialize)
    OnInitialize(_tid);

  //printf("Number of features at init: %d\n", countFeatures);
  for (int boucle=0; boucle<countFeatures;boucle++)  {
    featuresid[boucle] = globalcountFeatures;
    globalcountFeatures++;
    
    if (OnNewFeature){
      OnNewFeature(_tid, boucle, featuresid[boucle], features[boucle].x,
                   features[boucle].y);
    }
  }
}
Exemple #30
0
void Node::Initialize() {

    OnInitialize();
}