예제 #1
0
void OpticalFlow::create(cvg_int imageWidth, cvg_int imageHeight, cvg_int numFeatures) {
	destroy();
	try {
		currentFrame = cvCreateImage(cvSize(imageWidth, imageHeight), IPL_DEPTH_8U, 1);
		if (currentFrame == NULL) throw cvgException("[OpticalFlow] Cannot create image");
		lastFrame = cvCreateImage(cvSize(imageWidth, imageHeight), IPL_DEPTH_8U, 1);
		if (lastFrame == NULL) throw cvgException("[OpticalFlow] Cannot create image");
		eigImage = cvCreateImage(cvSize(imageWidth, imageHeight), IPL_DEPTH_8U, 1);
		if (eigImage == NULL) throw cvgException("[OpticalFlow] Cannot create image");
		tempImage = cvCreateImage(cvSize(imageWidth, imageHeight), IPL_DEPTH_8U, 1);
		if (tempImage == NULL) throw cvgException("[OpticalFlow] Cannot create image");
		pyramid1 = cvCreateImage(cvSize(imageWidth, imageHeight), IPL_DEPTH_8U, 1);
		if (pyramid1 == NULL) throw cvgException("[OpticalFlow] Cannot create image");
		pyramid2 = cvCreateImage(cvSize(imageWidth, imageHeight), IPL_DEPTH_8U, 1);
		if (pyramid2 == NULL) throw cvgException("[OpticalFlow] Cannot create image");

		maxNumFeatures = numFeatures;
		lastFrameFeatures = new CvPoint2D32f[numFeatures];
		lastFrameFeaturesCopy = new CvPoint2D32f[numFeatures];
		newFeatures = new CvPoint2D32f[numFeatures];
		foundFeatures = new char[numFeatures];
		errorFeatures = new float[numFeatures];

		firstRun = true;
		enableDebug(false, NULL);
	} catch (cvgException &e) {
		destroy();
		throw e;
	}
}
예제 #2
0
void Context::postInit()
{
	assert(!m_Limits);
	// Must only be called once!

	glewExperimental = GL_TRUE; //GL_FALSE;
	GLenum e = glewInit();
	if(e != GLEW_OK)
	{
		LogWarning("GLEW Error: %s", glewGetErrorString(e));
	}

	m_Limits = new Limits(this);

	Log(
		"Using OpenGL %s\n"
		"Vendor: %s\n"
		"Renderer: %s\n"
		"GLSL: %s\n"
		"GLEW: %s\n",

		glGetString(GL_VERSION),
		glGetString(GL_VENDOR),
		glGetString(GL_RENDERER),
		glGetString(GL_SHADING_LANGUAGE_VERSION),
		glewGetString(GLEW_VERSION)
	);

	enableDebug(true);

	m_Textures = new StrongRef<Texture>[limits().maxCombinedTextureUnits];
	m_Samplers = new StrongRef<Sampler>[limits().maxCombinedTextureUnits];
	m_Attributes = new VertexAttribute[limits().maxVertexAttributes];
	selectTextureUnit(0); // Cause -1 is illogical and introduces errors with some functions
}
예제 #3
0
int main(int argc, char **argv)
{
	long i;
	graph G;
	char debugFlag = 0;

	debugFlag=0;

	MPI_Init(&argc, &argv);
	MPI_Comm_rank (MPI_COMM_WORLD, &mpi_id);        /* get current process id */
	MPI_Comm_size (MPI_COMM_WORLD, &mpi_size);        /* get number of processes */

	inputCheck(argc, argv);

	if(mpi_id == 0)
	{
		if(N == 1){
			generateTestGraph(&G);
		} else {
			generateGraph(N, randInit, &G, debugFlag);
		}
	} else {
		if(N == 1)
			N = 6;
		generateEmptyGraph(N, &G);
	}
	N = G.N;

	if(debugFlag){
		enableDebug(N);
	}

	if((debugFlag == 1) && (mpi_id == 0) ){
		printf("Using graph\n");
		printGraph(&G);
	}

	if(mpi_id == 0) printf("\nTesting with max 2 Threads\n");
	testScheduler(2,&G, debugFlag);

	if(mpi_id == 0) printf("\nTesting with max 4 Threads\n");
	testScheduler(4,&G, debugFlag);

	if(mpi_id == 0) printf("\nTesting with max 8 Threads\n");
	testScheduler(8,&G, debugFlag);

//	omp_set_num_threads(4);
//	omp_set_schedule(omp_sched_static, 2);
//	dijkstra(&G, 0, 0);
//	char *b;
//	b = malloc(G.N * 5);
//	if(b == NULL) {perror("malloc"); exit(EXIT_FAILURE); }
//	sprintf(b,"\nLowest distances!\nD=[");
//	for(i = 0; i<G.N; i++){
//		sprintf(&b[strlen(b)], "%d,", G.D[i]);
//	}
//	printf("%s]\n", b);

	MPI_Finalize();
	return EXIT_SUCCESS;
}
예제 #4
0
void timer_tb::source(void) {
	int temp_intr = 0;
	const int temp_cmp_data = 50;
	enableDebug();
	addr.write(0);
	read_en.write(0);
	write_en.write(0);
	enable.write(0);
	data_in.write(0);
	rst.write(0);
	wait();
	rst.write(1);
	wait();

	// Generate signals here

	//Write the compare value for the timer
	addr.write(0x8);
	read_en.write(0);
	write_en.write(1);
	data_in.write(50); //50 clock cycles
	enable.write(1);
	wait();

	addr.write(0x0);
	data_in.write(0x7); // Enable timer enable Overflow interrupt and compare interrupts
	wait();
	enable.write(0);

	int i = 0;
	while(true) {
		wait();
		++i;
		if(i >1500) {
			break;
		}

		if(1 == intr1.read()) {
			temp_intr |= (1<<TMR_INTR_OV);
		}

		if(1 == intr0.read()) {
			temp_intr |= (1<<TMR_INTR_CMP);
			// Read back the compare value register
			addr.write(0x8);
			read_en.write(1);
			write_en.write(0);
			enable.write(1);
			wait();
			wait(); // Added one more wait statement since read below was not returning correct value.
			int temp = data_out.read();
			// Modify the register
			//cout << "Temp: " << temp << endl;
			temp += temp_cmp_data;
			//cout << "Timer cmp: " << temp << endl;
			wait();
			// Write back the register
			addr.write(0x8);
			read_en.write(0);
			write_en.write(1);
			data_in.write(temp);
			wait();
			enable.write(0);
			wait();
		}
		// Clear the interrupts
		if(intr1.read() || intr0.read()) {
			addr.write(0xC);
			read_en.write(0);
			write_en.write(1);
			enable.write(1);
			data_in.write(temp_intr);
			wait();
			enable.write(0);
		}
		temp_intr = 0;

	}
	sc_stop(); // stopping the simulation.
}
예제 #5
0
void timer_tb::source(void) {
	enableDebug(); // This will enable the logs on the console
	read_en.write(0);
	write_en.write(0);
	enable.write(1);
	rst.write(1);
	wait();
	rst.write(0);
	wait();
	rst.write(1);
	addr.write(0x8);
	read_en.write(0);
	write_en.write(1);
	data_in.write(100); // Writing some value in timer_cmp register
	wait();
	addr.write(0x0);
	read_en.write(0);
	write_en.write(1);
	data_in.write(0x7); // Enable the timer interrupts
	wait();
	enable.write(0);
	wait(18415, SC_NS);
	enable.write(1);
	wait();
	addr.write(0x4);
	read_en.write(1);
	write_en.write(0);
	wait();
	wait();
	cout << "@" << sc_time_stamp() << " Timer Val: " << data_out.read() << endl;
	wait(1520, SC_NS);
	cout << "@" << sc_time_stamp() << " Timer Val: " << data_out.read() << endl;
	// Stop the timer
	addr.write(0x0);
	write_en.write(1);
	read_en.write(0);
	data_in.write(0);
	wait();
	//wait();
	//cout << "@" << sc_time_stamp() << endl;
	wait(500, SC_NS);
	// Read the timer val register
	addr.write(0x4);
	read_en.write(1);
	write_en.write(0);
	wait();
	wait();
	cout << "@" << sc_time_stamp() << " Timer Val: " << data_out.read() << endl;
	wait(500, SC_NS);
	// Enable the timer again.
	addr.write(0x0);
	read_en.write(0x0);
	write_en.write(1);
	read_en.write(0);
	data_in.write(0x7);
	//cout << "@" << sc_time_stamp() << endl;
	// Read the timer_val register.
	wait(8980, SC_NS);
	addr.write(0x4);
	read_en.write(1);
	write_en.write(0);
	wait();
	wait();
	cout << "@" << sc_time_stamp() << " Timer Val: " << data_out.read() << endl;
	wait();
	addr.write(0x8);
	write_en.write(1);
	read_en.write(0);
	data_in.write(40);
	//cout << "@" << sc_time_stamp() << endl;
	wait(10000, SC_NS);
	disableDebug();
	//cout << "@" << sc_time_stamp() << endl;
	wait(960000, SC_NS);
	enableDebug();
	//cout << "@" << sc_time_stamp() << endl;
	wait(740, SC_NS);
	addr.write(0x4);
	read_en.write(1);
	write_en.write(0);
	wait();
	wait();
	cout << "@" << sc_time_stamp() << " Timer Val: " << data_out.read() << endl;
	wait(9250, SC_NS);
	disableDebug();
	cout << "@" << sc_time_stamp() << endl;
	wait(98990, SC_US);
	cout << "@" << sc_time_stamp() << endl;
	sc_stop();
}
예제 #6
0
void QuickInterpreter::init()
{
    m_dynamic_slots = new QSMetaObject(this);

    qsa_setup_meta_objects();
    debuggerEngine()->clear();

    staticGlobals.clear();

    staticGlobals << QString::fromLatin1("NaN")
                  << QString::fromLatin1("undefined")
                  << QString::fromLatin1("Infinity")
                  << QString::fromLatin1("Application");

    // add some common objects to the Global object
    QSObject global(env()->globalObject());
    QSClass *objClass = env()->objectClass();

    wrpClass = new QSWrapperClass(objClass);
    ptrClass = new QSPointerClass(objClass);
    varClass = new QSVariantClass(objClass);
    appClass = new QSApplicationClass(objClass);
    global.put(QString::fromLatin1("Application"), appClass->createWritable());

    pntClass = new QSPointClass(objClass, this);
    registerType(pntClass);
    sizClass = new QSSizeClass(objClass, this);
    registerType(sizClass);
    rctClass = new QSRectClass(objClass, this);
    registerType(rctClass);
    baClass = new QSByteArrayClass(objClass);
    registerType(baClass);
#ifndef QSA_NO_GUI
    colClass = new QSColorClass(objClass);
    registerType(colClass);
    fntClass = new QSFontClass(objClass);
    registerType(fntClass);
    pixClass = new QSPixmapClass(objClass, this);
    registerType(pixClass);
    palClass = new QSPaletteClass(objClass);
    registerType(palClass);
    colGrpClass = new QSColorGroupClass(objClass);
    registerType(colGrpClass);
#endif

    enableDebug(); // adds "debug" function which uses qDebug()
//     //
    env()->globalClass()->addMember(QString::fromLatin1("connect"), QSMember(qsa_connect));
    env()->globalClass()->addMember(QString::fromLatin1("disconnect"), QSMember(qsa_disconnect));
    env()->globalClass()->addMember(QString::fromLatin1("startTimer"), QSMember(qsStartTimer));
    env()->globalClass()->addMember(QString::fromLatin1("killTimer"), QSMember(qsKillTimer));
    env()->globalClass()->addMember(QString::fromLatin1("killTimers"), QSMember(qsKillTimers));

    QMap<QString,QObject*> statDescr = factory->staticDescriptors();
    QMap<QString,QString> instDescr = factory->instanceDescriptors();

    QList<QString> features = instDescr.keys();
    for (QList<QString>::ConstIterator it = features.begin();
	  it != features.end(); ++it) {
        if (env()->globalClass()->definedMembers()->contains(*it)) {
            qWarning("QSObjectFactory: Trying to register existing class: '%s'", (*it).toLatin1().constData());
            continue;
        }
	QSObject staticInst;
	if(statDescr.contains(*it)) { // has static?
	    QObject *sinst = statDescr[ *it ];
	    Q_ASSERT(sinst);
	    staticInst = wrap(sinst);
	    statDescr.remove(*it);
	}
	QSObjectConstructor *constr =
	    new QSObjectConstructor(objClass, *it);
	QSFactoryObjectProxy *ptype =
	    new QSFactoryObjectProxy(env()->typeClass(), staticInst, constr);
        constr->setFactoryObjectProxy(ptype);
	QSObject proxy(ptype, env()->typeClass()->createTypeShared(constr));
	env()->globalClass()->addStaticVariableMember(constr->identifier(),
						       proxy,
						       AttributeExecutable);
    }

    for(QMap<QString,QObject*>::ConstIterator sit = statDescr.begin();
	 sit != statDescr.end(); ++sit) {
        if (env()->globalClass()->definedMembers()->contains(sit.key())) {
            qWarning("QSObjectFactory: Trying to register existing class: '%s'", sit.key().toLatin1().constData());
            continue;
        }
	QSObject staticInst;
	QObject *sinst = statDescr[ sit.key() ];
	Q_ASSERT(sinst);
	staticInst = wrap(sinst);
	env()->globalClass()->addStaticVariableMember(sit.key(), staticInst, AttributeNone);
    }
}
예제 #7
0
void MY_Scene_Base::toggleDebug(){
	isDebugEnabled() ? disableDebug() : enableDebug();
}