コード例 #1
0
ファイル: questao05.c プロジェクト: jucimarjr/pca
int main(int argc, const char *argv[])
{
    int v[5000], x, n;
    clock_t ti1, tf1, ti2, tf2;
    printf("digite o tamanho do vetor:\n");
    scanf("%d",&n);
    array_creator(n, v);
 
    printf("digite o termo a ser procurado:\n");
    scanf("%d",&x);
    ti1 = clock();
    busca_binaria(x, n, v);
    tf1 = clock();
    printf("Tempo da busca binária: ");
    tempo(ti1, tf1);
    
    ti2 = clock();
    busca_sequencial(n, v, x);
    tf2 = clock();
    printf("Tempo da busca sequencial: ");
    tempo(ti2,tf2);



    return 0;
}
コード例 #2
0
ファイル: midi.cpp プロジェクト: PyroXFire/ZeldaClassic
void get_midi_info(MIDI *midi, midi_info *mi)
{
    dword max_dt = 0;
    mi->tempo_changes = 0;
    bool gottempo = false;
    
    if(midi==NULL)
        goto done;
        
    for(int i=0; midi->track[i].len>0; i++)
    {
        byte *data = midi->track[i].data;
        
        if(data==NULL)
            break;
            
        dword total_dt=0;
        mi->event=0;
        mi->running_status = 0;
        // tempo info should only be in first track, but sometimes it isn't
        bool gettempo = (i==0)||(!gottempo);
        
        while(!eot(mi) && data - midi->track[i].data < midi->track[i].len)
        {
            parse_mtrk(&data,mi);
            total_dt += mi->dt;
            
            if(gettempo && mi->event==0xFF && mi->type==0x51 && mi->tempo_changes<MAX_TEMPO_CHANGES)
            {
                mi->tempo[mi->tempo_changes] = tempo(mi->buf);
                int tempo_c = mi->tempo_c[mi->tempo_changes] = beats(total_dt,midi->divisions);
                
                if(mi->tempo_changes==0 && tempo_c!=0)              // make sure there is a tempo at beat 0
                {
                    mi->tempo_c[0] = 0;
                    mi->tempo_c[1] = tempo_c;
                    mi->tempo[1] = mi->tempo[0];
                    mi->tempo_changes++;
                }
                
                mi->tempo_changes++;
                gottempo=true;
            }
        }
        
        max_dt = zc_max(max_dt,total_dt);
    }
    
done:

    if(mi->tempo_changes==0)                                  // then guess
    {
        mi->tempo_changes=1;
        mi->tempo[0]=120.0;
        mi->tempo_c[0]=0;
    }
    
    mi->len_beats = (midi==NULL) ? 0 : beats(max_dt,midi->divisions);
    mi->len_sec = (midi==NULL) ? 0 : runtime(mi->len_beats,mi);
}
コード例 #3
0
ファイル: bass_player.cpp プロジェクト: jeyboy/playo3
void BassPlayer::playPreproccessing() {
    emit statusChanged(media_title, LoadedMedia);

    BASS_CHANNELINFO info;
    if (BASS_ChannelGetInfo(chan, &info))
        channelsCount(info.chans);
    else
        channelsCount(2);

    if (eq_in_use) registerEQ();

    #ifdef BASS_USE_TEMPO
        applyTempoToChannel();
        newTempoProcessing(tempo());
    #endif

    setSampleRateQuality();
    newVolumeProcessing(volume());
    newPanProcessing(pan());

    if (BASS_ChannelPlay(chan, true)) { // stalled with big sized video files
        playPostprocessing(is_paused);

        syncHandle = BASS_ChannelSetSync((HSYNC)chan, BASS_SYNC_END, 0, &endTrackSync, this);
        syncDownloadHandle = BASS_ChannelSetSync(chan, BASS_SYNC_DOWNLOAD, 0, &endTrackDownloading, this);

//        BASS_SYNC_STALL
//        mixtime only	Sync when playback of the channel is stalled/resumed.
//        param : not used. data : 0 = stalled, 1 = resumed.
    } else {
        proceedErrorState();
        qCritical() << "IS NOT PLAYED";
    }
}
コード例 #4
0
ファイル: MyBigInt.cpp プロジェクト: romaonishuk/cpp_Projects
MyBigInt generatePrime()
{
	stringstream ss;
	MyBigInt tempo("0");
	srand(static_cast<unsigned int>(time(NULL)));
	//	genering num_of_bits bits.
	ss << 1;
	for (int i = 0; i < num_of_bits - 1; i++) {
		int p = rand() % 2;
		if (p) {
			ss << i;
			tempo.set_value(tempo + (static_cast<MyBigInt>("2") ^ ss.str()));
			ss.str("");
		}
	}

	//	Searching for a prime number
	MyBigInt t(tempo);
	while (true) {
		if (Miller_Rabin(t) == "0") {
			tempo.set_value(tempo + static_cast<MyBigInt>("1"));
			cout << "Generating" << endl;
			t.set_value(tempo);
		}
		else {
			return tempo;
		}

	}
	return tempo;
}
コード例 #5
0
ファイル: PartFilter.cpp プロジェクト: cmollare/IK_PF
S3DModel* PartFilter::computeMMSE()
{
	std::vector<Eigen::Quaterniond*, Eigen::aligned_allocator<Eigen::Quaterniond*> > orient = mModelMMSE->getOrientationVec();
	std::vector<Eigen::Translation3d*, Eigen::aligned_allocator<Eigen::Translation3d*> > offset = mModelMMSE->getOffsetVector();
	for (int i=0 ; i<mOrientationVec[0].size() ; i++)
	{
		std::vector<double> quat(4, 0);
		Eigen::Vector3d tempo(0, 0, 0);
		for (int j=0 ; j<mModels.size() ; j++)
		{
			Eigen::Vector3d offs = mOffsetVec[j][i]->vector();
			tempo += mCurrentWeights[j]*offs;
			quat[0] += mCurrentWeights[j]*mOrientationVec[j][i]->w();
			quat[1] += mCurrentWeights[j]*mOrientationVec[j][i]->x();
			quat[2] += mCurrentWeights[j]*mOrientationVec[j][i]->y();
			quat[3] += mCurrentWeights[j]*mOrientationVec[j][i]->z();
		}
		(*orient[i]) = Eigen::Quaterniond(quat[0], quat[1], quat[2], quat[3]);
		orient[i]->normalize();
		(*offset[i]) = Eigen::Translation3d(tempo);
	}
	
	this->saveMMSE();
	this->saveObservations();
	
	return mModelMMSE;
}
コード例 #6
0
void main(void) {
    clock_int_48MHz();
        while (1) {
        nivel_alto(vermelho_pedestre);
        nivel_baixo(vermelho_carro);

        nivel_alto(verde_carro);
        tempo(10000);
        nivel_baixo(verde_carro);

        if (flag_pedestre) {
            nivel_alto(amarelo_carro);
            tempo_ms(1000);
            nivel_baixo(amarelo_carro);

            nivel_alto(vermelho_carro);
            nivel_baixo(vermelho_pedestre);

            nivel_alto(verde_pedestre);
            tempo_ms(5000);
            nivel_baixo(verde_pedestre);
            flag_pedestre = 0;
        }
    }
}
コード例 #7
0
ファイル: main.c プロジェクト: ddearauj/brickbreaker
void display(void){
    
    tempo(&lastFrameTime, &elapsedTime);
    preformCheck(&onGame, &winlose, bloco, bola);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    drawAll(onGame, bloco, &xbarra, k, &elapsedTime, &bola, preStart, winlose);
    glutSwapBuffers();
    
}
コード例 #8
0
ファイル: HexV04.c プロジェクト: henriquegemignani/ime
/* Com essa função, o programa fica sabendo em que time vai jogar.
  BRANCO: tenta fazer a linha na vertical (cima para baixo). Além
          disso, o time branco sempre começa o jogo.
	  PRETO: tenta fazer a linha na horizontal (esquerda para direita) */
void inicializaJogo(int time) {
  int i, j;
  for( i = 0; i < 14; i++ )
    for( j = 0; j < 14; j++ )
      tab[i][j] = 0;
  numJogada = numOponente = 0;
  corDoTime = time;
  srand(tempo(NULL));
  /* TODO: iniciar seed de random. *//*Done*/
}
コード例 #9
0
ファイル: tempo.cpp プロジェクト: SSMN/MuseScore
void TempoMap::setPause(int tick, qreal pause)
      {
      iTEvent e = find(tick);
      if (e != end())
            e->second.pause = pause;
      else {
            qreal t = tempo(tick);
            insert(std::pair<const int, TEvent> (tick, TEvent(t, pause, TEMPO_FIX)));
            }
      normalize();
      }
コード例 #10
0
QAbstractSpinBox::StepEnabled qtractorTempoSpinBox::stepEnabled (void) const
{
	StepEnabled flags = StepNone;
	const float fTempo = tempo();
	const unsigned short iBeatsPerBar = beatsPerBar();
	const unsigned short iBeatDivisor = beatDivisor();
	if (fTempo > 1.0f && iBeatsPerBar > 2 && iBeatDivisor > 1)
		flags |= StepDownEnabled;
	if (fTempo < 1000.0f && iBeatsPerBar < 128 && iBeatDivisor < 8)
		flags |= StepUpEnabled;
	return flags;
}
コード例 #11
0
ファイル: Ay_Emu.cpp プロジェクト: HipsterLion/SRB2
void Ay_Emu::cpu_out_misc( cpu_time_t time, unsigned addr, int data )
{
	if ( !cpc_mode )
	{
		switch ( addr & 0xFEFF )
		{
		case 0xFEFD:
			spectrum_mode = true;
			apu_addr = data & 0x0F;
			return;
		
		case 0xBEFD:
			spectrum_mode = true;
			apu.write( time, apu_addr, data );
			return;
		}
	}
	
	if ( !spectrum_mode )
	{
		switch ( addr >> 8 )
		{
		case 0xF6:
			switch ( data & 0xC0 )
			{
			case 0xC0:
				apu_addr = cpc_latch & 0x0F;
				goto enable_cpc;
			
			case 0x80:
				apu.write( time, apu_addr, cpc_latch );
				goto enable_cpc;
			}
			break;
		
		case 0xF4:
			cpc_latch = data;
			goto enable_cpc;
		}
	}
	
	debug_printf( "Unmapped OUT: $%04X <- $%02X\n", addr, data );
	return;
	
enable_cpc:
	if ( !cpc_mode )
	{
		cpc_mode = true;
		change_clock_rate( cpc_clock );
		set_tempo( tempo() );
	}
}
コード例 #12
0
void qtractorTempoSpinBox::stepBy ( int iSteps )
{
#ifdef CONFIG_DEBUG_0
	qDebug("qtractorTempoSpinBox[%p]::stepBy(%d)", this, iSteps);
#endif

	QLineEdit *pLineEdit = QAbstractSpinBox::lineEdit();
	const int iCursorPos = pLineEdit->cursorPosition();
	const QString& sText = pLineEdit->text();
	if (iCursorPos < sText.section(' ', 0, 0).length() + 1) {
		const QChar& decp = QLocale().decimalPoint();
		if (iCursorPos > sText.section(decp, 0, 0).length())
			setTempo(tempo() + 0.1f * float(iSteps));
		else
			setTempo(tempo() + float(iSteps));
	}
	else
	if (iCursorPos > sText.section('/', 0, 0).length())
		setBeatDivisor(int(beatDivisor()) + iSteps);
	else
		setBeatsPerBar(int(beatsPerBar()) + iSteps);
}
コード例 #13
0
ファイル: Visao.cpp プロジェクト: oscar-neiva/vision-tracking
Cor Visao::gravaCor(){        
    Cor cor = Cor();

    while (true){ 
        clock_t start=tempo();  

        cam >> imagem;

        cvtColor(imagem, imagemHSV, COLOR_BGR2HSV); 

        imshow("Imagem Normal", imagem); 
        moveWindow("Imagem Normal", 0, 0);  

        inRange(imagemHSV, Scalar(pontos[0]-variacaoH, pontos[1]*(1-variacao), pontos[2]*(1-variacao)),
         Scalar(pontos[0]+variacaoH, pontos[1]*(1+variacao), pontos[2]*(1+variacao)), imagemTratada); 
        
        //medianBlur(imagemTratada, imagemTratada, 3);     

        imshow("Calibragem", imagemTratada); 
        moveWindow("Calibragem", 640, 0);

        setMouseCallback("Imagem Normal", corPixel, 0);

        char key =  waitKey(1);    
        if (key == 27){
            for (int i=0; i<10; i++){
                destroyAllWindows();
                waitKey(1);  
            }
            break; 
        }
        if (clique == true){
            cor.corH = pontos[0];
            cor.corS = pontos[1];
            cor.corV = pontos[2];

            if (key == 32){ 
                for (int i=0; i<10; i++){
                    destroyAllWindows();
                    waitKey(1);  
                }
                cout << "Cor Calibrada" << endl;
                clique = false;
                pontos[0] = 0; pontos[1] = 0; pontos[2] = 0;  
                break; 
            }            
        }        
    }
    return cor;
}
コード例 #14
0
ファイル: Gym_Emu.cpp プロジェクト: IamusNavarathna/lv3proj
void Gym_Emu::set_tempo_( double t )
{
	if ( t < min_tempo )
	{
		set_tempo( min_tempo );
		return;
	}
	
	if ( stereo_buf.sample_rate() )
	{
		double denom = tempo() * 60;
		clocks_per_frame = (int) (clock_rate / denom);
		resampler.resize( (int) (sample_rate() / denom) );
	}
}
コード例 #15
0
ファイル: Tempo_Point.C プロジェクト: 0mk/non
int
Tempo_Point::handle ( int m )
{
    Logger log( this );

    if ( m == FL_PUSH && Fl::event_button3() && ! ( Fl::event_state() & ( FL_ALT | FL_CTRL | FL_SHIFT ) ) )
    {
        float t = _tempo;
        edit( &t );
        tempo( t );
        return 0;
    }

    return Sequence_Point::handle( m );
}
コード例 #16
0
ファイル: simulator.cpp プロジェクト: bezout/libhelico
int simulator()
{
  struct Screen { size_t width = 70, height = 25 ; } screen;

  Scene scene(screen.width*10,screen.height);

  loop(0,scene.width-screen.width,[&](auto i)
  {
    scene.update();
    std::cout << scene.to_string(i,i+screen.width);
    tempo(60);
    up_to_n_lines(screen.height);
  });

  return EXIT_SUCCESS;
}
コード例 #17
0
void main(void) {
    clock_int_48MHz();
    TRISB = 0b00000000;
    TRISA = 0b000000;
    TRISC = 0b000;
    nivel_baixo(amarelo_carro);
    nivel_baixo(verde_carro);
    nivel_baixo(verde_pedestre);

    while (1) {
        nivel_alto(vermelho_pedestre);
        nivel_baixo(vermelho_carro);
        nivel_alto(verde_carro);
        tempo(5000);
        nivel_baixo(verde_carro);

        if (flag_pedestre) {
            nivel_alto(amarelo_carro);
            tempo_ms(1000);
            nivel_baixo(amarelo_carro);
            nivel_alto(vermelho_carro);
            nivel_baixo(vermelho_pedestre);
            nivel_alto(verde_pedestre);

            for (i = 20; i >= 0; i--) {
                for (z = 0; z < 100; z++) {
                    dezena = i / 10;
                    unidade = i % 10;
                    nivel_baixo(pin_dezena);
                    nivel_alto(pin_unidade);
                    PORTB = seg[dezena];
                    tempo_ms(5);
                    nivel_baixo(pin_unidade);
                    nivel_alto(pin_dezena);
                    PORTB = seg[unidade];
                    tempo_ms(5);
                }
            }
            nivel_baixo(verde_pedestre);
            PORTB = apagado;
            flag_pedestre = 0;
        }
    }
}
コード例 #18
0
ファイル: Clock.cpp プロジェクト: JonathanOhara/Tumbu
//-------------------------------------------------------------------------------------
std::string Clock::getClockFormated(){
	int minutes = hours * 60 ;
	int numberOfHours = minutes / 60,
		numberOfMinutes = minutes % 60;

	Ogre::String tempo("Time: ");

	if(numberOfHours < 10){
		tempo.append("0");
	}

	tempo.append( Ogre::StringConverter::toString(numberOfHours) ).append(":");
	if(numberOfMinutes < 10){
		tempo.append("0");
	}
	tempo.append( Ogre::StringConverter::toString(numberOfMinutes) );

	return tempo.c_str();
}
コード例 #19
0
ファイル: Nsf_Emu.cpp プロジェクト: Lin20/projectpmr
blargg_err_t Nsf_Emu::load_( Data_Reader& in )
{
	assert( offsetof (header_t,unused [4]) == header_size );
	RETURN_ERR( rom.load( in, header_size, &header_, 0 ) );
	
	set_track_count( header_.track_count );
	RETURN_ERR( check_nsf_header( &header_ ) );
	
	if ( header_.vers != 1 )
		set_warning( "Unknown file version" );
	
	// sound and memory
	blargg_err_t err = init_sound();
	if ( err )
		return err;
	
	// set up data
	nes_addr_t load_addr = get_le16( header_.load_addr );
	init_addr = get_le16( header_.init_addr );
	play_addr = get_le16( header_.play_addr );
	if ( !load_addr ) load_addr = rom_begin;
	if ( !init_addr ) init_addr = rom_begin;
	if ( !play_addr ) play_addr = rom_begin;
	if ( load_addr < rom_begin || init_addr < rom_begin )
	{
		const char* w = warning();
		if ( !w )
			w = "Corrupt file (invalid load/init/play address)";
		return w;
	}
	
	rom.set_addr( load_addr % bank_size );
	int total_banks = rom.size() / bank_size;
	
	// bank switching
	int first_bank = (load_addr - rom_begin) / bank_size;
	for ( int i = 0; i < bank_count; i++ )
	{
		unsigned bank = i - first_bank;
		if ( bank >= (unsigned) total_banks )
			bank = 0;
		initial_banks [i] = bank;
		
		if ( header_.banks [i] )
		{
			// bank-switched
			memcpy( initial_banks, header_.banks, sizeof initial_banks );
			break;
		}
	}
	
	pal_only = (header_.speed_flags & 3) == 1;
	
	#if !NSF_EMU_EXTRA_FLAGS
		header_.speed_flags = 0;
	#endif
	
	set_tempo( tempo() );
	
	return setup_buffer( (long) (clock_rate_ + 0.5) );
}
コード例 #20
0
ファイル: MyBigInt.cpp プロジェクト: romaonishuk/cpp_Projects
//
//		ГОСТ 30.310-95 - генерація простих чисел.
//		Всі позначення змінних і пунктів взяті безпосередньо із ГОСТа.
//
void Gost()
{
	srand(static_cast<unsigned int>(time(NULL)));
	stringstream ss;
	MyBigInt N("0");	//пункт 9:
	MyBigInt Ps("2");
	int s = 0,
		i = 0;
	double t = num_of_bits;

//	пункт 1:
	//unsigned int y0 = rand();
	unsigned int y0 = 24265;
	//int c = rand();
	int c = 7341;
	if (c % 2 == 0) c += 1;

//	пункт 2:	
	while (t >= 17) {
		t /= 2;
		i++;
	}
	s = i;
	s--;
	
//	пункт 3: Ps - поідеї найменше число n-bit	
	ss << static_cast<int>(t - 1);	
	Ps.set_value(Ps^ss.str());
	ss.str("");
	
	MyBigInt tempo(Ps);
	while (true) {
		if (Miller_Rabin(tempo) == "0") {
			Ps.set_value(Ps + static_cast<MyBigInt>("1"));
			tempo.set_value(Ps);
		}
		else {
			system("cls");
			break;
		}
	}

//	пункт 4:
	int m = s;

//	пункт 5:
Jump5:
	double rm = t / 16;

//	пункт 6 - 7 - 8:
Jump6:
	ss << y0;
	MyBigInt Ym(ss.str());
	ss.str("");
	for (int i = 0; i < rm; i++) {
		y0 = (19381 * y0 + c) % 65536;
		ss << y0;
		Ym.set_value(Ym + static_cast<MyBigInt>(ss.str()));
		ss.str("");
	}
	ss << y0;
	Ym.set_value(Ym - static_cast<MyBigInt>(ss.str()));
	//Ym.set_value(Ym * (static_cast<MyBigInt>("2") ^ "161"));
	ss.str("");

	//	пункт 9:
	stringstream ko;
	ko << (2 * t) - 1;
	N.set_value((static_cast<MyBigInt>("2") ^ ko.str()));
	ss.str("");
	ss << 16 << rm;
	N.set_value(N + (
		((static_cast<MyBigInt>("2") ^ ko.str()) * Ym)
		));
	if (N % static_cast<MyBigInt>("2") == "0")
		N.set_value(N + "1");
	ss.str("");
	ko.str("");

//	пункт 10:
	int k = 0;
	ss << k;

//	пункт 11:
Jump11:
	MyBigInt Pm((N + ss.str()));
	ss.str("");

// пункт 12:
	ss << 2 * t;
	cout << Pm.get_value() << endl;
	if (Pm > (static_cast<MyBigInt>("2") ^ ss.str())) {
		ss.str("");
		goto Jump6;
	}
	ss.str("");

// пункт 13:
	ss << k;
	cout << static_cast<MyBigInt>("2").Gorner((Ps * (N + ss.str())), Pm).get_value() << " " << static_cast<MyBigInt>("2").Gorner((N + ss.str()), Pm).get_value() << " " << Pm.get_value()<< endl;
	if (static_cast<MyBigInt>("2").Gorner((Ps * (N + ss.str())), Pm) == "1" && static_cast<MyBigInt>("2").Gorner((N + ss.str()), Pm) != "1") {
		system("pause");
		m = m - 1;
		t = t * 2;
// пункт 14:
		if (m >= 0) {
			goto Jump5;
		}
		else {
			system("cls");
			cout << "Victory bitch!" << endl;
			system("pause");
		}
	}
	else {
		k = k + 2;
		goto Jump11;
	}
}
コード例 #21
0
int main(int argc, char ** argv)
{

	string gauss = "Gaussino";
	string canny = "Canny";
	string hough = "Hough";
	string binarizar = "Binarizar";
	string Otsu = "Otsu";
	string image_name = "";
	int number;
	Point min, max, start;

	ofstream myfile;

	myfile.open("data.txt");

	myfile << "ESCREVE QUALQUER COISA\n";
	

	clock_t t1, t2, t3, t4;
	double threshold1, threshold2, thres, minLength, maxGap;
	bool f1, f2, f3, f4, f5, f6, f7, f8, f9;
	string Result;
	ostringstream convert;
	//int i;
	float temp;

	//for (i = 1;  i <= 6; i++){

		//number = i;
		//convert << number;
		//Result = convert.str();
		//image_name = "a" + Result + ".JPG";
		image_name = "a2.JPG";
		//number++;
		//cout << number << endl;
		cout << image_name;


		myfile << image_name;
		myfile << "\n";

		t1 = clock();
		f1 = false;
		f2 = true;
		f3 = false;
		f4 = false;
		f5 = false;
		f6 = true;
		f7 = true;
		if (f7 == true){
			threshold1 = 10;
			threshold2 = 19;
		}
		f8 = false;
		f9 = true;
		if (f9 == true){
			thres = 10;// 40
			minLength = 20; //50
			maxGap = 30; //80

			/*
			CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );

			if ( !capture ) {
			fprintf( stderr, "ERROR: capture is NULL \n" );
			getchar();
			return -1;
			}
			string original = "original.jpg";
			string foto ="img";

			IplImage* frame = cvQueryFrame( capture );
			Mat img(frame);
			Mat I, I1, imge;
			cvtColor(img,imge,CV_RGB2GRAY);
			imge.convertTo(I, CV_8U);
			equalizeHist(I,I1);
			Mat aux = I1;
			savePictures(I1, original, foto);

			*/

			//realiza a leitura e carrega a imagem para a matriz I1
			// a imagem tem apenas 1 canal de cor e por isso foi usado o parametro CV_LOAD_IMAGE_GRAYSCALE
			Mat lara = imread("lara.JPG", CV_LOAD_IMAGE_GRAYSCALE);
			Mat I = imread(image_name, CV_LOAD_IMAGE_GRAYSCALE);
			if (I.empty())
				return -1;
			resize(I, I, lara.size(), 1.0, 1.0, INTER_LINEAR);
			Mat I1;
			//Mat aux = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE); 
			equalizeHist(I, I1);


			Mat aux, original;

			aux = I1;

			//ShowImage(I, I1);
			// verifica se carregou e alocou a imagem com sucesso
			if (I1.empty())
				return -1;

			// tipo Size contem largura e altura da imagem, recebe o retorno do metodo .size()
			//imSize = I1.size();

			// Cria uma matriz do tamanho imSize, de 8 bits e 1 canal

			Mat I2 = Mat::zeros(I1.size(), CV_8UC1);


			if (f2 == true) {
				t2 = clock();
				for (int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2)
					GaussianBlur(I1, I1, Size(i, i), 0, 0, BORDER_DEFAULT);
				//ShowImage(aux, I1);
				cout << "Guassiano tempo : ";
				temp = tempo(t2);
				savePictures(I1, image_name, gauss);
				myfile << "Gauss: ";
				myfile << temp;
				myfile << "\n";

			}

			if (f1 == true){
				t2 = clock();
				binarizacao(I1, 125);
				//ShowImage(aux, I1);
				cout << "binarizacao : ";
				temp = tempo(t2);
				savePictures(I1, image_name, binarizar);
				myfile << "Binarizacao: ";
				myfile << temp;
				myfile << "\n";


			}




			if (f3 == true){
				t2 = clock();
				inversao(I1);
				cout << "inversao : ";
				tempo(t2);

			}


			if (f4 == true){
				adaptiveThreshold(I1, I1, 255, ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 7, 0);
			}


			if (f5 == true)
				Laplacian(I1, I1, 125, 1, 1, 0, BORDER_DEFAULT);



			if (f7 == true){
				t2 = clock();
				Canny(I1, I2, threshold1, threshold2, 3, false);
				cout << "canny : ";
				temp = tempo(t2);
				savePictures(I2, image_name, canny);
				myfile << "Canny: " + (int)(temp * 1000);
				myfile << "\n";
			}



			if (f9 == true){
				t2 = clock();
				Hough(I2, aux, thres, minLength, maxGap);
				cout << "hough : ";
				temp = tempo(t2);
				savePictures(aux, image_name, hough);
				myfile << "Hough: ";
				myfile << temp;
				myfile << "\n";
			}

			if (f6 == true){
				t2 = clock();
				threshold_type = THRESH_BINARY;

				threshold(aux, I1, 9, max_BINARY_value, threshold_type);
				cout << "Threshold : ";
				//savePictures(aux, image_name, Otsu);
				temp = tempo(t2);
				myfile << "Threshold/OTSU: ";
				myfile << temp;
				myfile << "\n";
			}


			string name = Otsu + image_name;
			imwrite(name, aux);
			ShowImage(I1, aux);

			t2 = clock();
			max = maxPoint(aux);
			min = minPoint(aux);

			/*start.y = (max.y + min.y) / 2;
			start.x = (max.x + min.x) /2;*/

			start.x = max.x;
			start.y = max.y;

			Point end;

			end.x = start.x;
			end.y = aux.size().height;

			
			MyLine(I, start, end, image_name, 0.3);
			temp = tempo(t2);
			ShowImage(I, aux);

			myfile << "Rota: ";
			myfile << temp;
			myfile << "\n";

			temp = tempo(t1);
			cout << "Final time : ";
			myfile << "Final Time: ";
			myfile << temp;
			myfile << "\n";




			//float angle = Angle(aux, min, 5);

			//cout << angle; 

			

		}

	//}

		
		
		
		myfile.close();
		//ShowImage(aux, I1);

		//imwrite(argv[2], I2); // salva imagem I2 no arquivo definido pelo usuario em argv[2]
	//}
		return 0;
}
コード例 #22
0
ファイル: Ay_Emu.cpp プロジェクト: yulizi1937/modo_android
blargg_err_t Ay_Emu::start_track_( int track )
{
    RETURN_ERR( Classic_Emu::start_track_( track ) );

    byte* const mem = core.mem();

    memset( mem + 0x0000, 0xC9, 0x100 ); // fill RST vectors with RET
    memset( mem + 0x0100, 0xFF, 0x4000 - 0x100 );
    memset( mem + core.ram_addr, 0x00, core.mem_size - core.ram_addr );

    // locate data blocks
    byte const* const data = get_data( file, file.tracks + track * 4 + 2, 14 );
    if ( !data )
        return BLARGG_ERR( BLARGG_ERR_FILE_CORRUPT, "file data missing" );

    byte const* const more_data = get_data( file, data + 10, 6 );
    if ( !more_data )
        return BLARGG_ERR( BLARGG_ERR_FILE_CORRUPT, "file data missing" );

    byte const* blocks = get_data( file, data + 12, 8 );
    if ( !blocks )
        return BLARGG_ERR( BLARGG_ERR_FILE_CORRUPT, "file data missing" );

    // initial addresses
    unsigned addr = get_be16( blocks );
    if ( !addr )
        return BLARGG_ERR( BLARGG_ERR_FILE_CORRUPT, "file data missing" );

    unsigned init = get_be16( more_data + 2 );
    if ( !init )
        init = addr;

    // copy blocks into memory
    do
    {
        blocks += 2;
        unsigned len = get_be16( blocks );
        blocks += 2;
        if ( addr + len > core.mem_size )
        {
            set_warning( "Bad data block size" );
            len = core.mem_size - addr;
        }
        check( len );
        byte const* in = get_data( file, blocks, 0 );
        blocks += 2;
        if ( len > (unsigned) (file.end - in) )
        {
            set_warning( "File data missing" );
            len = file.end - in;
        }
        //dprintf( "addr: $%04X, len: $%04X\n", addr, len );
        if ( addr < core.ram_addr && addr >= 0x400 ) // several tracks use low data
            dprintf( "Block addr in ROM\n" );
        memcpy( mem + addr, in, len );

        if ( file.end - blocks < 8 )
        {
            set_warning( "File data missing" );
            break;
        }
    }
    while ( (addr = get_be16( blocks )) != 0 );

    // copy and configure driver
    static byte const passive [] = {
        0xF3,       // DI
        0xCD, 0, 0, // CALL init
        0xED, 0x5E, // LOOP: IM 2
        0xFB,       // EI
        0x76,       // HALT
        0x18, 0xFA  // JR LOOP
    };
    static byte const active [] = {
        0xF3,       // DI
        0xCD, 0, 0, // CALL init
        0xED, 0x56, // LOOP: IM 1
        0xFB,       // EI
        0x76,       // HALT
        0xCD, 0, 0, // CALL play
        0x18, 0xF7  // JR LOOP
    };
    memcpy( mem, passive, sizeof passive );
    int const play_addr = get_be16( more_data + 4 );
    if ( play_addr )
    {
        memcpy( mem, active, sizeof active );
        mem [ 9] = play_addr;
        mem [10] = play_addr >> 8;
    }
    mem [2] = init;
    mem [3] = init >> 8;

    mem [0x38] = 0xFB; // Put EI at interrupt vector (followed by RET)

    // start at spectrum speed
    change_clock_rate( spectrum_clock );
    set_tempo( tempo() );

    Ay_Core::registers_t r = { };
    r.sp = get_be16( more_data );
    r.b.a     = r.b.b = r.b.d = r.b.h = data [8];
    r.b.flags = r.b.c = r.b.e = r.b.l = data [9];
    r.alt.w = r.w;
    r.ix = r.iy = r.w.hl;

    core.start_track( r, play_addr );

    return blargg_ok;
}
コード例 #23
0
ファイル: Ay_Emu.cpp プロジェクト: yulizi1937/modo_android
inline void Ay_Emu::enable_cpc()
{
    change_clock_rate( cpc_clock );
    set_tempo( tempo() );
}
コード例 #24
0
ファイル: Ay_Emu.cpp プロジェクト: HipsterLion/SRB2
blargg_err_t Ay_Emu::start_track_( int track )
{
	RETURN_ERR( Classic_Emu::start_track_( track ) );
	
	memset( mem.ram + 0x0000, 0xC9, 0x100 ); // fill RST vectors with RET
	memset( mem.ram + 0x0100, 0xFF, 0x4000 - 0x100 );
	memset( mem.ram + ram_start, 0x00, sizeof mem.ram - ram_start );
	memset( mem.padding1, 0xFF, sizeof mem.padding1 );
	memset( mem.ram + 0x10000, 0xFF, sizeof mem.ram - 0x10000 );
	
	// locate data blocks
	byte const* const data = get_data( file, file.tracks + track * 4 + 2, 14 );
	if ( !data ) return "File data missing";
	
	byte const* const more_data = get_data( file, data + 10, 6 );
	if ( !more_data ) return "File data missing";
	
	byte const* blocks = get_data( file, data + 12, 8 );
	if ( !blocks ) return "File data missing";
	
	// initial addresses
	cpu::reset( mem.ram );
	r.sp = get_be16( more_data );
	r.b.a = r.b.b = r.b.d = r.b.h = data [8];
	r.b.flags = r.b.c = r.b.e = r.b.l = data [9];
	r.alt.w = r.w;
	r.ix = r.iy = r.w.hl;
	
	unsigned addr = get_be16( blocks );
	if ( !addr ) return "File data missing";
	
	unsigned init = get_be16( more_data + 2 );
	if ( !init )
		init = addr;
	
	// copy blocks into memory
	do
	{
		blocks += 2;
		unsigned len = get_be16( blocks ); blocks += 2;
		if ( addr + len > 0x10000 )
		{
			set_warning( "Bad data block size" );
			len = 0x10000 - addr;
		}
		check( len );
		byte const* in = get_data( file, blocks, 0 ); blocks += 2;
		if ( len > blargg_ulong (file.end - in) )
		{
			set_warning( "Missing file data" );
			len = file.end - in;
		}
		//debug_printf( "addr: $%04X, len: $%04X\n", addr, len );
		if ( addr < ram_start && addr >= 0x400 ) // several tracks use low data
			debug_printf( "Block addr in ROM\n" );
		memcpy( mem.ram + addr, in, len );
		
		if ( file.end - blocks < 8 )
		{
			set_warning( "Missing file data" );
			break;
		}
	}
	while ( (addr = get_be16( blocks )) != 0 );
	
	// copy and configure driver
	static byte const passive [] = {
		0xF3,       // DI
		0xCD, 0, 0, // CALL init
		0xED, 0x5E, // LOOP: IM 2
		0xFB,       // EI
		0x76,       // HALT
		0x18, 0xFA  // JR LOOP
	};
	static byte const active [] = {
		0xF3,       // DI
		0xCD, 0, 0, // CALL init
		0xED, 0x56, // LOOP: IM 1
		0xFB,       // EI
		0x76,       // HALT
		0xCD, 0, 0, // CALL play
		0x18, 0xF7  // JR LOOP
	};
	memcpy( mem.ram, passive, sizeof passive );
	unsigned play_addr = get_be16( more_data + 4 );
	//debug_printf( "Play: $%04X\n", play_addr );
	if ( play_addr )
	{
		memcpy( mem.ram, active, sizeof active );
		mem.ram [ 9] = play_addr;
		mem.ram [10] = play_addr >> 8;
	}
	mem.ram [2] = init;
	mem.ram [3] = init >> 8;
	
	mem.ram [0x38] = 0xFB; // Put EI at interrupt vector (followed by RET)
	
	memcpy( mem.ram + 0x10000, mem.ram, 0x80 ); // some code wraps around (ugh)
	
	beeper_delta = int (apu.amp_range * 0.65);
	last_beeper = 0;
	apu.reset();
	next_play = play_period;
	
	// start at spectrum speed
	change_clock_rate( spectrum_clock );
	set_tempo( tempo() );
	
	spectrum_mode = false;
	cpc_mode      = false;
	cpc_latch     = 0;
	
	return 0;
}
コード例 #25
0
ファイル: msrcv.c プロジェクト: autch/mucc
void parse_msr( void )
{
	while ( 1 ) {
		int f;
		char *p = gettoken( &f );
		//char a;
		if ( !p ) break;
		//a = *p;
		if ( f & TT_LABEL ) {
			int n = strlen(p);
			if ( p[n-1] == ':' ) p[n-1] = 0;
			RegLabel( p );
		}
		else if ( f & TT_NUMBER ) {
			cgout1( getnum( p ) );
		}
		else if ( f & TT_STRING ) {
			int i, n = strlen( p );
			if ( n > 2 && p[0] == p[n-1] ) n--;
			for ( i = 1; i < n; i++ ) cgout1( p[i] );
		}
		else if ( f & TT_OTHER ) {
			HASHDATA *phd = SearchHash( p );
			if ( phd ) {
				if ( phd->type == TYPE_RESERVED )
					switch ( phd->value ) {
						case RSV_ADRS:
							adrs();
							break;
						case RSV_ADRSM:
							adrsm();
							break;
						case RSV_ADRSD:
							adrsd();
							break;
						case RSV_INCLUDE:
							include();
							break;
						case RSV_GOTO:
							_goto();
							break;
						case RSV_TEMPO:
							tempo();
							break;
						case RSV_PARTN:
							partn();
							break;
						case RSV_PHRASE:
							phrase();
							break;
				}
				else if ( phd->type & TYPE_DIRECTCODE ) {
					cgout1( phd->value );
				}
			}
			else {
				error( "Unkown commands '%s'.", p );
			}
		}
		else if ( f & TT_MML ) {
			parse_mml_line( -1, p );
		}
	}
}