Esempio n. 1
0
myException::myException(int errCode,const string& errMsg)
{
	initVars();
	errorCode = errCode;
	if (errMsg[0] ) 
		errorMsg.append(errMsg);
}
/**
 * Do the following:
 * 1) Allocate space for arrays
 * 2) Fill those arrays with the provided features
 *
 * @param vector<Feature>
 * @return void
 */
void Observation::SparseRep::fillWith(const std::vector<Feature> &features)
{
    initVars(); //! 1) Allocate space for arrays

    cv::Mat tmpNumFeats(yValsVec.size(), xValsVec.size(), CV_64FC1, cv::Scalar::all(0));
    cv::Mat tmpMargProbs(yValsVec.size(), xValsVec.size(), CV_64FC1, cv::Scalar::all(0));
    cv::Mat tmpDepths(yValsVec.size(), xValsVec.size(), CV_64FC1, cv::Scalar::all(0));

    //! 2) fill sparse data
    for (std::vector<Feature>::const_iterator it = features.begin(); it != features.end(); ++it)
    {
        size_t xPos = std::distance(xValsVec.begin(), std::find(xValsVec.begin(), xValsVec.end(), it->x));
        size_t yPos = std::distance(yValsVec.begin(), std::find(yValsVec.begin(), yValsVec.end(), it->y));

        // compute word frequency, use for tf-idf
        wordFreqs[it->wordId] = (double)words.count(it->wordId)/features.size();

        tmpNumFeats.at<double>(yPos, xPos) = 1;
        tmpMargProbs.at<double>(yPos, xPos) = log(it->invFreq()*wordFreqs[it->wordId]); // tf-idf
        //tmpMargProbs.at<double>(yPos, xPos) = it->pMarg() == 0 ? 0 : log(it->pMarg());
        tmpDepths.at<double>(yPos, xPos) = it->depth;
    }

    // integral images for efficient computation
    cv::integral(tmpNumFeats, cumNumFeats);
    cv::integral(tmpMargProbs, cumMargProbs);
    cv::integral(tmpDepths, cumDepths, cumDepthVars);
}
int main(int argc, char **argv)
{
	if(argc < 2){
		printf("No input file given");
		exit(0);
	}
	K = 5;
    readBinary(argv[1]);
    //readFile("uniform_data_16_1000.csv");
    
    initVars();
    threshold = 0.001;
    //printf("Centroids at start:\n");
    //printCentroids();
    //printf("Starting k-Means\n");
    //printDatapoints();
    //time_t start = time(NULL);
    double startTime = get_wall_time();
    kMeans();
    double endTime = get_wall_time();
    printf("%.2f\n", endTime-startTime);
    
    printDatapointClusters();
    
    return 0;
    
}
Esempio n. 4
0
bool MorkParser::open(const QString &path)
{
    initVars();

    QFile MorkFile(path);

    // Open file
    if (!MorkFile.exists() ||
            !MorkFile.open(QIODevice::ReadOnly)) {
        mError = FailedToOpen;
        return false;
    }

    // Check magic header
    QByteArray MagicHeader = MorkFile.readLine();

    if (!MagicHeader.contains(MorkMagicHeader)) {
        mError = UnsupportedVersion;
        return false;
    }

    mMorkData = MorkFile.readAll();
    MorkFile.close();

    // Parse mork
    return parse();
}
Esempio n. 5
0
bool MorkParser::open( const string &path )
{
	initVars();
	std::string line;
	std::ifstream infile(path.c_str(), std::ios_base::in);
	if(!infile.is_open())
	{
		error_ = FailedToOpen;
		return false;
	}

	while (getline(infile, line, '\n'))
	{
		morkData_.append(line);
		morkData_.append("\n");
	}

/*  
	// Check magic header
	QByteArray MagicHeader = MorkFile.readLine();

	if ( !MagicHeader.contains( MorkMagicHeader ) )
	{
		error_ = UnsupportedVersion;
		return false;
	}
*/

	// Parse mork
	return parse();
}
Esempio n. 6
0
SipAccount::SipAccount(const std::string & username,const std::string & userid,
	const std::string & password, const std::string & realm,
	const std::string & registerservername, unsigned registerserverport,
	const std::string & SIPproxyservername, unsigned SIPproxyserverport,
	bool rememberPasswod, bool enablePIM, bool rememberUsername, bool autoLoginVoxOx) 
{
	initVars();

	setProtocol( EnumIMProtocol::IMProtocolSIP );
	_identity					= userid;
	_username					= username;
	_realm						= realm;
	_password					= password;
	_imPassword					= password;			//VOXOX - JRT - 2009.09.25 - SIP/Jabber password separation. Will get actual password from SSO.
	_registerServerHostname		= registerservername;
	_registerServerPort			= registerserverport;
	_sipProxyServerHostname		= SIPproxyservername;
	_sipProxyServerPort			= SIPproxyserverport;
	_enablePIM					= enablePIM;
	_rememberPassword			= rememberPasswod;
	_rememberUsername			= rememberUsername;
	_autoLoginVoxOx				= autoLoginVoxOx;

	//VOXOX - JRT - 2009.09.07 - These are already set in new initVars().
//	_voicemail					= "*98";
//	_discoveringNetwork			= false;
//	_lastNetworkDiscoveryState	= NetworkDiscoveryStateError;
//	_initSuccessful				= false;

//	_initTimerCounter			= 0;
//	_initTimer.lastTimeoutEvent += boost::bind(&SipAccount::initLastTimeoutEventHandler, this);
}
Esempio n. 7
0
int main(int argc, char *argv[])
{

#ifndef TMR_ENABLE_BACKGROUND_READS
  errx(1, "This sample requires background read functionality.\n"
          "Please enable TMR_ENABLE_BACKGROUND_READS in tm_config.h\n"
          "to run this code.\n");
  return -1;
#else
/*  if (argc < 2)
  {
    errx(1, "Please provide reader URL, such as:\n"
           "tmr:///com4\n"
           "tmr://my-reader.example.com\n");
  }*/
  initVars();
//  printReaderConfig();
  setupReader("tmr:///dev/ttyACM0");
  getReaderConfig();
//  printReaderConfig();
  exportReaderConfig();
  printReaderConfig();
  TMR_destroy(rp);
  return 0;
#endif /* TMR_ENABLE_BACKGROUND_READS */
}
Esempio n. 8
0
QtUMItem::QtUMItem(CWengoPhone & cWengoPhone, const QString & contactId, const QString & id, const QString & groupId, const QString & displayName, const QString & groupName, QString avatarData, QPixmap normalStatusPixmap, QPixmap hoverStatusPixmap, QObject * parent, bool bGroup, bool isSelected )
	:  QObject(parent),
	_cWengoPhone(cWengoPhone)
{
	initVars();

	_isAGroupItem  = bGroup;
	_id = id;
	_contactId = contactId;//VOXOX CHANGE by Rolando - 2009.10.23 
	_groupKey  = groupId;					//VOXOX - JRT - 2009.08.09 - Multiple groups.
	_key	   = id + groupId;		//VOXOX - JRT - 2009.08.10 - Multiple groups.
	_groupName = groupName;//VOXOX CHANGE by Rolando - 2009.08.21 
	_displayName = displayName;//VOXOX CHANGE by Rolando - 2009.08.31
	_avatarData = avatarData;//VOXOX CHANGE by Rolando - 2009.08.31 
	_normalStatusPixmap = normalStatusPixmap;//VOXOX CHANGE by Rolando - 2009.10.26
	_hoverStatusPixmap = hoverStatusPixmap;//VOXOX CHANGE by Rolando - 2009.10.26

	_isSelected = isSelected;//VOXOX CHANGE by Rolando - 2009.09.29

	_isNetworkIconUnderMouse = false;//VOXOX CHANGE by Rolando - 2009.10.26 

	if(_groupKey != ""){//VOXOX CHANGE by Rolando - 2009.09.25 
		_isAGroupItem = true;//VOXOX CHANGE by Rolando - 2009.09.25 
	}
	else{
		_isAGroupItem = false;	//VOXOX CHANGE by Rolando - 2009.09.25 
	}

	_contactNetworkMenu = new QtContactNetworkMenu(_contactId.toStdString(),_cWengoPhone , NULL);//VOXOX CHANGE by Rolando - 2009.10.23 
	

	
}
Esempio n. 9
0
/**
   \brief Completes writing the stream, closes it, release resources.
**/
bool QVideoEncoder::close()
{
   if(!isOk())
      return false;

   av_write_trailer(pFormatCtx);

   // close_video

   avcodec_close(pVideoStream->codec);
   freeFrame();
   freeOutputBuf();


   /* free the streams */

   for(unsigned i = 0; i < pFormatCtx->nb_streams; i++)
   {
      av_freep(&pFormatCtx->streams[i]->codec);
      av_freep(&pFormatCtx->streams[i]);
   }

   // Close file
   avio_close(pFormatCtx->pb);

   // Free the stream
   av_free(pFormatCtx);

   initVars();
   return true;
}
Esempio n. 10
0
ElideLabel::ElideLabel(QString const &text,
                       QWidget *parent,
                       Qt::WindowFlags flags)
  : QFrame{parent, flags}
  , m_text{text}
{
  initVars();
}
  KeyboardOp(ros::NodeHandle &nh)
  {
    rosNode = nh;
    rosNode = ros::NodeHandle("");

    setupClientServices();
    initVars();
  }
Esempio n. 12
0
QtUMGroup::QtUMGroup(const QString & groupId, const QString & groupName, QObject * parent)
	:  QObject(parent)
{
	initVars();

	_id = groupId;	
	_groupName = groupName;//VOXOX CHANGE by Rolando - 2009.08.21 	
		
}
Esempio n. 13
0
extern ssize_t send(int sockfd, const void *buf, size_t len, int flags){
	if(newsend == NULL){
		if(initVars()){
			fprintf(stderr, "init failure\n");
			exit(EXIT_FAILURE);
		}
	}

	return newsend(sockfd, buf, len, flags);
}
Esempio n. 14
0
void main() {
    initVars();
    
	Init_Registers();
    initPorts();
    
    unsigned char loop=1;
    LCD_initialize();
    while (loop>0) {
        loop += 1;
        
		LCD_Clear();
		//waitForKey();           // attendi che il pin venga messo a massa
        
        // MY_delay_s(1);
		LORETO_LED  = pinRA1;
		// pinRA4  = pinRA1;
        
		if (loop%2 == 0) {
			LCD_gotoRC(0, 0);
			LCD_printRom(romStr, 0);            //DEBUG
			// waitForKey();           // attendi che il pin venga messo a massa
            delay_s(1);
			
			LCD_gotoRC(1, 0);
			LCD_printStr("Loreto");
            delay_s(1);
			// waitForKey();           // attendi che il pin venga messo a massa
			

			LCD_gotoRC(1, 12);
			LCD_printStr("Ale");
            delay_s(1);
			// waitForKey();           // attendi che il pin venga messo a massa
		}
		else {
			LCD_gotoRC(1, 0);
			LCD_printRom(romStr, 0);            //DEBUG
            delay_s(1);
			// waitForKey();           // attendi che il pin venga messo a massa
			
			LCD_gotoRC(0, 0);
			LCD_printStr("Loreto");
            delay_s(1);
			// waitForKey();           // attendi che il pin venga messo a massa
		}
        
        LCD_Clear();
        LCD_printfAt(0,0,   "Dec Number:%02d", 12345);            //DEBUG
        LCD_printfAt(1,0,   "Hex Number:%02X", 12345);            //DEBUG
        delay_s(1);
        
    }
    
} // end main()
Esempio n. 15
0
Common::Error MohawkEngine_Riven::run() {
	MohawkEngine::run();

	// Let's try to open the installer file (it holds extras.mhk)
	// Though, we set a low priority to prefer the extracted version
	if (_installerArchive.open("arcriven.z"))
		SearchMan.add("arcriven.z", &_installerArchive, 0, false);

	_gfx = new RivenGraphics(this);
	_console = new RivenConsole(this);
	_saveLoad = new RivenSaveLoad(this, _saveFileMan);
	_externalScriptHandler = new RivenExternal(this);
	_optionsDialog = new RivenOptionsDialog(this);
	_scriptMan = new RivenScriptManager(this);
	_cursor = new RivenCursorManager();

	_rnd = new Common::RandomSource();
	g_eventRec.registerRandomSource(*_rnd, "riven");

	initVars();

	// Open extras.mhk for common images
	_extrasFile = new MohawkArchive();

	if (!_extrasFile->open("extras.mhk"))
		error("Could not open extras.mhk");

	// Start at main cursor
	_cursor->setCursor(kRivenMainCursor);

	// Let's begin, shall we?
	if (getFeatures() & GF_DEMO) {
		// Start the demo off with the videos
		changeToStack(aspit);
		changeToCard(6);
	} else if (ConfMan.hasKey("save_slot")) {
		// Load game from launcher/command line if requested
		uint32 gameToLoad = ConfMan.getInt("save_slot");
		Common::StringArray savedGamesList = _saveLoad->generateSaveGameList();
		if (gameToLoad > savedGamesList.size())
			error ("Could not find saved game");
		_saveLoad->loadGame(savedGamesList[gameToLoad]);
	} else {
		// Otherwise, start us off at aspit's card 1 (the main menu)
        changeToStack(aspit);
		changeToCard(1);
	}

	
	while (!_gameOver && !shouldQuit())
		handleEvents();

	return Common::kNoError;
}
Esempio n. 16
0
EDA_ITEM::EDA_ITEM( const EDA_ITEM& base )
{
    initVars();
    m_StructType = base.m_StructType;
    m_Parent     = base.m_Parent;
    m_Flags      = base.m_Flags;

    // A copy of an item cannot have the same time stamp as the original item.
    SetTimeStamp( GetNewTimeStamp() );
    m_Status     = base.m_Status;
}
int main (int argc, char *argv[]){
	if (InitCVIRTE (0, argv, 0) == 0)
		return -1;	/* out of memory */
	if ((panelHdl = LoadPanel(0, "MainPanel.uir", MainPanel)) < 0)
		return -1;
	initVars(); //init variables
	DisplayPanel (panelHdl);
	RunUserInterface();
	cleanGarbage();
	return 0;
}
Esempio n. 18
0
/**
 * Init the manager. returns 1 (true) if successfully initialized.
 * Must be called before using any method.
 */
bool IND_SpriterManager::init() {
	end();
	initVars();

	g_debug->header("Initializing SpriterManager", 5);

	_ok = true;

	g_debug->header("SpriterManager OK", 6);

	return _ok;
}
Esempio n. 19
0
Camera::Camera(GLFWwindow *window) {
	m_window = window;
	getWindowDimensions();
	centerMouse();

	initVars();

	setCenter(glm::vec3(0, 0, 5));
	setLookAt(glm::vec3(0, 0, 4));
	setUp(glm::vec3(0, 1, 0));
	setRight(glm::vec3(1, 0, 0));
	updateViewMatrix();
}
Esempio n. 20
0
extern int connect(int sockfd, const struct sockaddr *addr,
		                   socklen_t addrlen){
	if(newconnect == NULL){
		if(initVars()){
			fprintf(stderr, "init failure\n");
			exit(EXIT_FAILURE);
		}
	}

	int ret = newconnect(sockfd, addr, addrlen);

	return ret;
}
Esempio n. 21
0
int main(void) {
    config_clock();
    initVars();
    config_uart1();
    config_timer1();
    config_timer2();
    
    while(1) {
        if(final_send.getGraphData)
            sendGraphData();
        sendDatax();
    }
    return 1;
}
/**
 * Init
 */
bool DebugApi::init() {
	initVars();

	// File
#if LOG_REDIRECT_TO_CONSOLE
	_count = &std::cout;
#else
    _count = new ofstream("debug.log", ios::out);
#endif //LOG_REDIRECT_TO_CONSOLE
	// Time
	time_t mT;							
	time(&mT);							 
	struct tm *mPetm = localtime(&mT);				

	// :D

	*_count << endl;

	*_count << "                         ''~``                          " << endl;
	*_count << "                        ( o o )                         " << endl;
	*_count << "+------------------.oooO--(_)--Oooo.------------------+ " << endl;
	*_count << "|                                                     | " << endl;
	*_count << "|                .-------------------.                | " << endl;
	*_count << "|                | I N D I E  L I B  |                | " << endl;
	*_count << "|                .-------------------.                | " << endl;
	*_count << "|                    .oooO                            | " << endl;
	*_count << "|                    (   )   Oooo.                    | " << endl;
	*_count << "+---------------------\\ (----(   )--------------------+" << endl;
	*_count << "                       \\_)    ) /                      " << endl;
	*_count << "                             (_/                        " << endl;
    *_count << "Indielib version: "<<IND_VERSION.major<<"."<<IND_VERSION.minor<<"."<<IND_VERSION.revision;
	*_count << endl;
	*_count << endl;
	*_count << "[Init time]:" << " (";

	// Date
	string days [7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thrusday", "Friday", "Saturday"};
	string months [12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

	// Date
	*_count << days [mPetm->tm_wday].c_str() << ", " << mPetm->tm_mday << " of " << months [mPetm->tm_mon].c_str() << " " << mPetm->tm_year + 1900 << ")" << endl << endl;

	//Start timer
	_timer->start();

	_ok = true;

	return _ok;
}
/**
This function returns 1 (true) if the adminstrator is successfully initialized.
Must be called before using any method.
*/
bool IND_TmxMapManager::init(IND_Render* render) {
	end();
	initVars();

	g_debug->header("Initializing TmxMapManager", DebugApi::LogHeaderBegin);
	g_debug->header("Preparing TmxMapManager", DebugApi::LogHeaderOk);
	_render = render;
	_ok = true;

	g_debug->header("TmxMapManager OK", 6);
	
	//TODO: REGISTER ERROR HANDLERS FOR FREEIMAGE

	return _ok;
}
Esempio n. 24
0
void init()
{
	wdt_start(wdt_250ms);
	initProc();
	initVars();
	initParams();
#ifndef _DEBUG_
	lcd_init(LCD_DISP_ON);
	//init_lcd_simbols();
#ifdef _DEMO_VERSION_
	SplashScreen();
#endif // _DEMO_VERSION_
#endif // _DEBUG_
	SetMenu(&mPrograms);
}
/**
 * Init
 */
bool DebugApi::init() {
	end();
	initVars();

	// File
	_count = new ofstream("debug.log", ios::out);

	// Time
	time_t mT;							// TODO: these 
	time(&mT);							//       lines 
	struct tm *mPetm = localtime(&mT);				//       probably needs cleeanup, but im not sure /Michael

	// :D

	*_count << endl;

	*_count << "                         ''~``                          " << endl;
	*_count << "                        ( o o )                         " << endl;
	*_count << "+------------------.oooO--(_)--Oooo.------------------+ " << endl;
	*_count << "|                                                     | " << endl;
	*_count << "|                .-------------------.                | " << endl;
	*_count << "|                | I N D I E  L I B  |                | " << endl;
	*_count << "|                .-------------------.                | " << endl;
	*_count << "|                    .oooO                            | " << endl;
	*_count << "|                    (   )   Oooo.                    | " << endl;
	*_count << "+---------------------\\ (----(   )--------------------+" << endl;
	*_count << "                       \\_)    ) /                      " << endl;
	*_count << "                             (_/                        " << endl;
    *_count << "Indielib version: "<<IND_VERSION.major<<"."<<IND_VERSION.minor<<"."<<IND_VERSION.revision;
	*_count << endl;
	*_count << endl;
	*_count << "[g_debug.log]:" << " (";

	// Date
	string days [7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thrusday", "Friday", "Saturday"};
	string months [12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

	// Date
	*_count << days [mPetm->tm_wday].c_str() << ", " << mPetm->tm_mday << " of " << months [mPetm->tm_mon].c_str() << " " << mPetm->tm_year + 1900 << ")" << endl << endl;

	//Start timer
	_timer.start();

	_ok = true;

	return _ok;
}
Esempio n. 26
0
bool MinigameBbAnt::run(bool fromMainGame) {

	memset(_objects, 0, sizeof(_objects));
	
	_numbersAnim = getAnimation(167);
	
	_backgroundSpriteIndex = 303;
	_titleScreenSpriteIndex = 304;

	_fromMainGame = fromMainGame;

	_hiScore = 0;
	if (!_fromMainGame)
		_hiScore = loadHiscore(kMinigameBbAnt);

	_gameState = 0;
	_gameResult = false;
	_gameDone = false;
	initObjects();
	initVars();
	
	_spriteModule = new SpriteModule();
	_spriteModule->load("bbant/bbant.000");

	Palette palette = _spriteModule->getPalette();
	_vm->_screen->setPalette(palette);
	
	loadSounds();

	_gameTicks = 0;
	playSound(12, true);
	
	while (!_vm->shouldQuit() &&!_gameDone) {
		_vm->updateEvents();
		update();
	}
	
	_vm->_sound->unloadSounds();

	if (!_fromMainGame)
		saveHiscore(kMinigameBbAnt, _hiScore);

	delete _spriteModule;

	return _gameResult;
}
Esempio n. 27
0
PreviewPlot2D::PreviewPlot2D(QWidget* parent, const char *name, Qt::WidgetAttribute wflags):
        WorkshopTool(parent, name, wflags)
{
	pWin->setCaption(name);
	view_back = new Q3HBox(pWin);
	view_back->setFrameStyle( Q3Frame::StyledPanel | Q3Frame::Sunken );

	initTool();
	initPlot();
	initVars();
	//initActions();
	//initToolBar();
	
	connect(this, SIGNAL(newMeasure(int)), SLOT(onNewMeasure(int)));
	//connect(this, SIGNAL(rmMeasure(int)), SLOT(onDelMeasure(int)));
	pWin->show();
}
/*!
\b parameters:

\arg \b pImageManager           Pointer to IND_ImageManager correctly initialized
\arg \b pRender                 Pointer to IND_Render correctly initialized

\b Operation:

This function returns 1 (true) when the manager is correctly initialized.
It should be called before using any method.
*/
bool IND_SurfaceManager::init(IND_ImageManager *pImageManager, IND_Render *pRender) {
	end();
	initVars();

	g_debug->header("Initializing SurfaceManager", 5);

	// Checking IND_Render
	if (pRender->isOK()) {
		g_debug->header("Checking IND_Render", 1);
		_render = pRender;
	} else {
		g_debug->header("IND_Render is not correctly initialized", 2);
		_ok = false;
		return _ok;
	}

	// Checking IND_ImageManager
	if (pImageManager->isOK()) {
		g_debug->header("Checking IND_ImageManager", 1);
		_imageManager = pImageManager;

		// Texture Builder
#ifdef INDIERENDER_DIRECTX
		_textureBuilder = new DirectXTextureBuilder(pImageManager, _render);
#endif

#ifdef INDIERENDER_GLES_IOS
		_textureBuilder = new GLESIOSTextureBuilder(pImageManager, _render);
#endif

#ifdef INDIERENDER_OPENGL
		_textureBuilder = new OpenGLTextureBuilder(pImageManager, _render);
#endif
		_ok = true;

		g_debug->header("SurfaceManager OK", 6);
	} else {
		g_debug->header("ImageManager is not correctly initialized", 2);
		_ok = false;
	}

	return _ok;
}
Esempio n. 29
0
CDLType::CDLType(CDLType *ct)
{
  initVars();
  // make a deep copy of *ct here
  baseKind = ct->baseKind;
  ADTflag = ct->ADTflag;
  vectorFlag = ct->vectorFlag;

  dimension = ct->dimension;
  bitSize = ct->bitSize;

  enumList = ct->enumList;
  cons = ct->cons;
  table = ct->table;

  baseType = ct->baseType;
  baseName = ct->baseName;
  
}
/**
 * Init. Returns 1 (true) if the administrator is successfully initialized.
 * Must be called before using any method.
 * @param pRender		TODO: describtion.
 */
bool IND_3dMeshManager::init(IND_Render *pRender) {
	end();
	initVars();

	// Checking IND_render
	if (pRender->isOK()) {
		g_debug->header("Checking IND_Render", 1);
		_render = pRender;
		_ok = true;
	} else {
		g_debug->header("IND_Render is not correctly initialized", 2);
		_ok = false;
		return _ok;
	}

	g_debug->header("Initializing IND_3dMeshManager", 5);
	g_debug->header("IND_3dMeshManager OK", 6);

	return _ok;
}