Beispiel #1
0
// --------------------------------------------------------------------------
// ARDrone::startVideoRecord(Enable/Disable)
// Description  : Start or stop recording video.
//                This function is only for AR.Drone 2.0
//                You should set a USB key with > 100MB to your drone
// Return value : NONE
// --------------------------------------------------------------------------
void ARDrone::setVideoRecord(bool activate)
{
    // AR.Drone 2.0
    if (version.major == ARDRONE_VERSION_2) {
        // Finalize video
        finalizeVideo();

        // Enable/Disable video recording
        if (mutexCommand) pthread_mutex_lock(mutexCommand);
        sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", ++seq, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
        if (activate) sockCommand.sendf("AT*CONFIG=%d,\"video:video_on_usb\",\"TRUE\"\r",  ++seq);
        else          sockCommand.sendf("AT*CONFIG=%d,\"video:video_on_usb\",\"FALSE\"\r", ++seq);
        if (mutexCommand) pthread_mutex_unlock(mutexCommand);
        msleep(100);

        // Output video with MP4_360P_H264_720P_CODEC / H264_360P_CODEC
        if (mutexCommand) pthread_mutex_lock(mutexCommand);
        sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", ++seq, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
        if (activate) sockCommand.sendf("AT*CONFIG=%d,\"video:video_codec\",\"%d\"\r", ++seq, 0x82);
        else          sockCommand.sendf("AT*CONFIG=%d,\"video:video_codec\",\"%d\"\r", ++seq, 0x81);
        if (mutexCommand) pthread_mutex_unlock(mutexCommand);
        msleep(100);

        // Initialize video
        initVideo();
    }
}
Beispiel #2
0
kmain() {
	int i,num;
	
	/* CARGA DE IDT CON LA RUTINA DE ATENCION DE IRQ0    */
	setup_IDT_entry (&idt[0x08], 0x08, (dword)&_int_08_hand, ACS_INT, 0);
	setup_IDT_entry (&idt[0x09], 0x08, (dword)&_int_09_hand, ACS_INT, 0);
	setup_IDT_entry (&idt[0x80], 0x08, (dword)&_int_80_hand, ACS_INT, 0);
	/* Carga de IDTR    */
	idtr.base = 0;
	idtr.base +=(dword) &idt;
	idtr.limit = sizeof(idt)-1;

	_lidt (&idtr);

	_Cli();

	/* Habilito interrupcion de timer tick*/
	//_mascaraPIC1(INT_08 & INT_09 & INT_80);
	_mascaraPIC1(0x00);
	_mascaraPIC2(NONE);
	_Sti();
	
	initKeyBoard();
	initVideo();
	initShell();
	doubleFlagsFix(1.1);
	while (1) {
		updateShell();
	}
	
}
Beispiel #3
0
void *videoThread(void *argc)
{
	initVideo();
	while(connected)
	    video_decode();
	closeVideo();
}
//////////////////////////////////////////////////////////////////////////////
// Set video codec to use
//////////////////////////////////////////////////////////////////////////////
void CCustomDrone::SetVideoCodec(eVideoCodec VideoCodec)
{
	if (version.major == ARDRONE_VERSION_2) 
	{
        // Finalize video
        finalizeVideo();

		if (mutexCommand) pthread_mutex_lock(mutexCommand);;

        // Output video with selected codec
        sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
        sockCommand.sendf("AT*CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, VideoCodec);
        
		if (mutexCommand) pthread_mutex_unlock(mutexCommand);;
		
		msleep(100);

        // Initialize video
		if(0 == initVideo())
		{
			DoLog("Failed to restart video after codec change, watchdog should catch this", MSG_ERROR);
			// TODO: change watchdog way
			//bNeedVideoRestart = true;
		}
    }
}
Beispiel #5
0
CoreInterface::CoreInterface()
{
    EngineInitializer i = makeInit();
    core = new EngineCore(i);
    initVideo();
    initStorage();
}
Beispiel #6
0
void
MainMenu::optionsBackButtonClicked(Button* )
{
    getConfig()->save();
    if( getConfig()->videoX != SDL_GetVideoSurface()->w || getConfig()->videoY != SDL_GetVideoSurface()->h)
    {
        if( getConfig()->restartOnChangeScreen )
        {
            quitState = RESTART;
            running = false;
        }
        else
        {
            //SDL_IGNORE to avoid forth and back jumping resolution
            SDL_EventState(SDL_VIDEORESIZE, SDL_IGNORE);
            initVideo( getConfig()->videoX, getConfig()->videoY);
            currentMenu->resize(getConfig()->videoX, getConfig()->videoY);
            SDL_EventState(SDL_VIDEORESIZE, SDL_ENABLE);
            gotoMainMenu();
        }
    }
    else if( currentLanguage != getConfig()->language )
    {
        unsetenv("LINCITY_LANG");
        quitState = RESTART;
        running = false;
    }
    else
    {
        gotoMainMenu();
    }
}
Beispiel #7
0
int kickoff() {
	initVideo();	
	putStr("Hello World! - Team Virtua!!!\n");
	
 	installDescriptorTables();
	installTimer();
	installKeyboard();	
    initializePaging();    
	putStr("Hello, paging world! - Team Virtua !!!\n");	

	enableInterrupts();	

	
	// u32 end_addr = (u32)&end;
	// u32 *ptr = (u32 *)end_addr;		
	
	// while(1) {
		// putStr("End Address : ");
		// putHex(end_addr);
		// putStr(" ");
		// putHex((u32)ptr);
		// putStr(" : ");
		// putNum(*ptr);
		// putStr("\n");
		// ptr++;	
	// }
			
    putStr("Gotcha!!!\n");

    for (;;);
	return 0;	
}
Beispiel #8
0
int main() {
    /* Turn on the 2D graphics core. */
    powerOn(POWER_ALL_2D);

    /*
     *  Configure the VRAM and background control registers.
     *
     *  Place the main screen on the bottom physical screen. Then arrange the
     *  VRAM banks. Next, confiure the background control registers.
     */
    lcdMainOnBottom();
    initVideo();
    initBackgrounds();

    /* Set up a few sprites. */
    SpriteInfo spriteInfo[SPRITE_COUNT];
    OAMTable *oam = new OAMTable();
    initOAM(oam);
    initSprites(oam, spriteInfo);

    /* Display the backgrounds. */
    displayStarField();
    displayPlanet();
    displaySplash();

    /* Make the ship object. */
    static const int SHUTTLE_OAM_ID = 0;
    SpriteEntry * shipEntry = &oam->oamBuffer[SHUTTLE_OAM_ID];
    SpriteRotation * shipRotation = &oam->matrixBuffer[SHUTTLE_OAM_ID];
    Ship * ship = new Ship(&spriteInfo[SHUTTLE_OAM_ID]);

    /* Accelerate the ship for a little while to make it move. */
    for (int i = 0; i < 10; i++) {
        ship->accelerate();
    }

    for (;;) {
        /* Update the game state. */
        ship->moveShip();

        /* Update sprite attributes. */
        MathVector2D<float> position = ship->getPosition();
        shipEntry->x = (int)position.x;
        shipEntry->y = (int)position.y;
        rotateSprite(shipRotation, -ship->getAngleDeg());

        /*
         *  Update the OAM.
         *
         *  We have to copy our copy of OAM data into the actual OAM during
         *  VBlank (writes to it are locked during other times).
         */
        swiWaitForVBlank();
        updateOAM(oam);
    }

    return 0;
}
Beispiel #9
0
void initSubsystems(int argc, const char *argv[]) {
	initFilesystem(argc, argv);
	initScripting();
	init_c_interface();
	initConfiguration(argc, argv);
	initGame();
	initVideo();
	initAudio();
	initInput();
}
Beispiel #10
0
void Tracker :: setup()
{
	initVideo();
	initVideoGrabber();
	initVideoPlayer();
	
	cameraRadius = 200;
	updateCameraPos( videoSmlRect.width * 0.5, videoSmlRect.height * 0.5 );
	
	bUpdateCameraPos	= false;
}
void InstagramView::loadVideo(){
	ofRegisterURLNotification(this);
	size_t found = _args.videoUrl.find_last_of("/\\");
	string videoFileName = _args.videoUrl.substr(found + 1);
	
	// Before loading check if we already have the file
	ofFile file = ofFile(videoFileName);
	if(file.exists() && Settings::instance()->getCache()){
		initVideo(videoFileName);
	}else{
		ofSaveURLAsync(_args.videoUrl, videoFileName);
	}
}
Beispiel #12
0
void RobotDecoder::open(const GuiResourceId robotId, const reg_t plane, const int16 priority, const int16 x, const int16 y, const int16 scale) {
	if (_status != kRobotStatusUninitialized) {
		close();
	}

	initStream(robotId);

	_version = _stream->readUint16();

	// TODO: Version 4 for PQ:SWAT demo?
	if (_version < 5 || _version > 6) {
		error("Unsupported version %d of Robot resource", _version);
	}

	debugC(kDebugLevelVideo, "Opening version %d robot %d", _version, robotId);

	initPlayback();

	_audioBlockSize = _stream->readUint16();
	_primerZeroCompressFlag = _stream->readSint16();
	_stream->seek(2, SEEK_CUR); // unused
	_numFramesTotal = _stream->readUint16();
	const uint16 paletteSize = _stream->readUint16();
	_primerReservedSize = _stream->readUint16();
	_xResolution = _stream->readSint16();
	_yResolution = _stream->readSint16();
	const bool hasPalette = (bool)_stream->readByte();
	_hasAudio = (bool)_stream->readByte();
	_stream->seek(2, SEEK_CUR); // unused
	_frameRate = _normalFrameRate = _stream->readSint16();
	_isHiRes = (bool)_stream->readSint16();
	_maxSkippablePackets = _stream->readSint16();
	_maxCelsPerFrame = _stream->readSint16();

	// used for memory preallocation of fixed cels
	_maxCelArea.push_back(_stream->readSint32());
	_maxCelArea.push_back(_stream->readSint32());
	_maxCelArea.push_back(_stream->readSint32());
	_maxCelArea.push_back(_stream->readSint32());
	_stream->seek(8, SEEK_CUR); // reserved

	if (_hasAudio) {
		initAudio();
	} else {
		_stream->seek(_primerReservedSize, SEEK_CUR);
	}

	_priority = priority;
	initVideo(x, y, scale, plane, hasPalette, paletteSize);
	initRecordAndCuePositions();
}
Beispiel #13
0
int main(int argc, char *argv[]) {
	initVideo();

	for (;;)
	{
		swiWaitForVBlank();
		scanKeys();
		if (keysDown() & KEY_START)
			break;
	}

	deinitVideo();
	return 0;
}
Beispiel #14
0
int init()
{
    fprintf(stderr, "Test Stuff " VERSION "\n");

    if(initVideo())
        return 1;

    if(loadImages())
        return 1;

    kpCreateSpace();
    SDL_WM_SetCaption("Test Stuff", 0);
    fprintf(stderr, "INIT OK. Entering the main loop.\n");
    return 0;
}
// --------------------------------------------------------------------------
// ARDrone::open(IP address of AR.Drone)
// Description  : Initialize the AR.Drone.
// Return value : SUCCESS: 1  FAILURE: 0
// --------------------------------------------------------------------------
int ARDrone::open(const char *ardrone_addr)
{
    // Initialize FFmpeg
    av_register_all();
    avformat_network_init();
    av_log_set_level(AV_LOG_QUIET);

    // Save IP address
    strncpy(ip, ardrone_addr, 16);

    // Get version information
    if (!getVersionInfo()) return 0;
    printf("AR.Drone Ver. %d.%d.%d\n", version.major, version.minor, version.revision);

	//// getVersionInfo() takes too long before realising the drone is not connected
	//// it call tcp open, which makes a socket and tries to connect to it
	//// using the connect method, which has too big of a timeout.
	//// making a smaller, 5 sec timeout before checking the verison to see if drone connected.
	//// if not, return 0
	//if (!version.major) {
	//	// create timeout and wait 5 sec
	//	printf("Waiting for drone to connect...\n");
	//	msleep(5000);
	//	// check again
	//	if (!version.major) return 0;
	//}

    // Initialize AT command
    if (!initCommand()) return 0;

    // Initialize Navdata
    if (!initNavdata()) return 0;

    // Initialize Video
    if (!initVideo()) return 0;

    // Wait for updating state
    //msleep(500);

    // Get configurations
    if (!getConfig()) return 0;

    // Reset emergency
    resetWatchDog();
    resetEmergency();

    return 1;
}
Beispiel #16
0
kmain() {

	int i, num;

	/* Borra la pantalla. */

	/* CARGA DE IDT CON LA RUTINA DE ATENCION DE IRQ0    */

	setup_IDT_entry(&idt[0x08], 0x08, (dword) & _int_08_hand, ACS_INT, 0);

	/* CARGA DE IDT CON LA RUTINA DE ATENCION DE IRQ1    */

	setup_IDT_entry(&idt[0x09], 0x08, (dword) & _int_09_hand, ACS_INT, 0);

	/* CARGA DE IDT CON LA RUTINA DE ATENCION DE int80h    */

	setup_IDT_entry(&idt[0x80], 0x08, (dword) & _int_80_hand, ACS_INT, 0);
	
	
//TODO: CARGAR LA PAG DE TABLAS

	/* Carga de IDTR */

	idtr.base = 0;
	idtr.base += (dword) & idt;
	idtr.limit = sizeof(idt) - 1;

	_lidt(&idtr);

	_Cli();

	/* Habilito interrupcion de timer tick*/
	_mascaraPIC1(0xFC);
	_mascaraPIC2(0xFF);
	_Sti();

	startKeyboard();
	initVideo();
	shellStart();

	/* KeepAlive loop */
	while (1) {
		// Main del shell
		shellMain();
	}

}
int main()
{
	initTimers();
	initVideo();
	sound_initAC97();
	mouse_init();
	initInterrupts();
	isNewGame = true;
	initGameScreen();

	PIT_startRecurringTimer(XPAR_PIT_0_BASEADDR, CLOCK_FREQ_HZ / INTERRUPTS_PER_SECOND);

	while(1) // Program never ends.
		if(low_priority_intc_status != 0)
			lowPriorityInterruptHandler();

	cleanup_platform();
	return 0;
}
void InstagramView::urlResponse(ofHttpResponse & response){
	ofUnregisterURLNotification(this);

	if(response.status != 200){
		return;
	}
	
	if(response.request.url == _args.imageUrl){
		initImage(response.request.name);
	}
	
	if(response.request.url == _args.videoUrl){
		initVideo(response.request.name);
	}
	
	if(response.request.url == _args.profilePictureUrl){
		initProfileImage(response.request.name);
	}
}
Beispiel #19
0
void testApp :: setup()
{
	ofSetFrameRate( 30 );
	ofSetVerticalSync( true );
	
	smoothing = false;
	
	initRenderArea();
	initFieldConfig();
	initFields();
	initVideo();
	initDebug();
	initBlendModes();
	initGui();
	initAudio();
	initTriggers();
	
	tileSaver.init( 10, 0, true );
	screenGrabUtil.setup( "movie/trigfield", &renderArea );
}
Beispiel #20
0
// --------------------------------------------------------------------------
// ARDrone::stopVideoRecord()
// Stop recording video.
// This function is only for AR.Drone 2.0
// Return value NONE
// --------------------------------------------------------------------------
void ARDrone::stopVideoRecord(void)
{
    if (version.major == ARDRONE_VERSION_2) {
        // Finalize video
        finalizeVideo();

        // Disable video record
        sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
        sockCommand.sendf("AT*CONFIG=%d,\"video:video_on_usb\",\"FALSE\"\r", seq++);
        Sleep(100);

        // Output video with 360P
        sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
        sockCommand.sendf("AT*CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, 0x81);
        Sleep(100);

        // Initialize video
        initVideo();
    }
}
Beispiel #21
0
// --------------------------------------------------------------------------
// ARDrone::open(IP address of AR.Drone)
// Description  : Initialize the AR.Drone.
// Return value : SUCCESS: 1  FAILURE: 0
// --------------------------------------------------------------------------
int ARDrone::open(const char *ardrone_addr)
{
    #if _WIN32
    // Initialize WSA
    WSAData wsaData;
    WSAStartup(MAKEWORD(1,1), &wsaData);
    #endif

    // Initialize FFmpeg
    av_register_all();
    avformat_network_init();
    av_log_set_level(AV_LOG_QUIET);

    // Save IP address
    strncpy(ip, ardrone_addr, 16);

    // Get version information
    if (!getVersionInfo()) return 0;
    printf("AR.Drone Ver. %d.%d.%d\n", version.major, version.minor, version.revision);

    // Get configurations
    if (!getConfig()) return 0;

    // Initialize AT command
    if (!initCommand()) return 0;

    // Initialize Navdata
    if (!initNavdata()) return 0;

    // Initialize Video
    if (!initVideo()) return 0;

    // Wait for updating state
    msleep(500);

    // Reset emergency
    resetWatchDog();
    resetEmergency();

    return 1;
}
Beispiel #22
0
int		init(char *pFont, char *pSize) {
	int nSize = 0;
	char *pEnd;

	if (initVideo() < 0)
		return -1;
	if (pSize != NULL) {
		nSize = strtol(pSize, &pEnd, 10);
		if (nSize < 0 || nSize > 256 || *pEnd != '\0') {
			fprintf(stderr, "%s: invalid size font\n", gProgName);
			usage();
		}
	}
	gVars.nSize = nSize;
	gVars.pFont = TTF_OpenFont(pFont, nSize);
	if (gVars.pFont == NULL) {
		fprintf(stderr, "SDL_ttf: %s\n", TTF_GetError());
		return -1;
	}
	return 0;
}
Beispiel #23
0
void DevChannelHK::onGetDecData(char* pBuf, int nSize, FRAME_INFO* pFrameInfo) {
	//InfoL << pFrameInfo->nType;
	switch (pFrameInfo->nType) {
	case T_YV12: {
		if (!m_bVideoSeted) {
			m_bVideoSeted = true;
			VideoInfo video;
			video.iWidth = pFrameInfo->nWidth;
			video.iHeight = pFrameInfo->nHeight;
			video.iFrameRate = pFrameInfo->nFrameRate;
			initVideo(video);
		}
		char *yuv[3];
		int yuv_len[3];
		yuv_len[0] = pFrameInfo->nWidth;
		yuv_len[1] = pFrameInfo->nWidth / 2;
		yuv_len[2] = pFrameInfo->nWidth / 2;
		int dwOffset_Y = pFrameInfo->nWidth * pFrameInfo->nHeight;
		yuv[0] = pBuf;
		yuv[2] = yuv[0] + dwOffset_Y;
		yuv[1] = yuv[2] + dwOffset_Y / 4;
		inputYUV(yuv, yuv_len, pFrameInfo->nStamp);
	}
		break;
	case T_AUDIO16: {
		if (!m_bAudioSeted) {
			m_bAudioSeted = true;
			AudioInfo audio;
			audio.iChannel = pFrameInfo->nWidth;
			audio.iSampleBit = pFrameInfo->nHeight;
			audio.iSampleRate = pFrameInfo->nFrameRate;
			initAudio(audio);
		}
		inputPCM(pBuf, nSize, pFrameInfo->nStamp);
	}
		break;
	default:
		break;
	}
}
Beispiel #24
0
void VideoThread::run()
{
	
	m_killed = false;
	initVideo();
	
	//m_readTimer->start();
	if(!m_startPaused)
		play();
	
	if(m_seekOnStart > 0)
		seek(m_seekOnStart, 0);
	
	//exec();
	while(!m_killed)
	{
// 		qDebug() << "VideoThread::run() mark4";
		if(m_status == Running)
			readFrame();
		//qDebug() << "VideoThread::run() mark5: "<<m_frameQueue.size();
		msleep(qMax(m_nextDelay,10));
	}
}
Beispiel #25
0
// --------------------------------------------------------------------------
// ARDrone::open(IP address of AR.Drone)
// Description  : Initialize the AR.Drone.
// Return value : SUCCESS: 1  FAILURE: 0
// --------------------------------------------------------------------------
int ARDrone::open(const char *ardrone_addr)
{
    // Initialize WSA
    WSAData wsaData;
    WSAStartup(MAKEWORD(1,1), &wsaData);

    // Save IP address
    strncpy(ip, ardrone_addr, 16);

    // Get version informations
	// version.major = 2;
    if (!getVersionInfo()) return 0;
    
	printf("AR.Drone Ver. %d.%d.%d\n", version.major, version.minor, version.revision);

    // Initialize AT Command
    // if (!initCommand()) return 0;

    // Initialize Config
    if (!initConfig()) return 0;

    // Initialize Navdata
    // if (!initNavdata()) return 0;

    // Initialize Video
    if (!initVideo()) return 0;

    // Wait for updating state
    Sleep(500);

    // Reset emergency
    // resetWatchDog();
    // resetEmergency();

    return 1;
}
//_______________________________________________
uint8_t ADM_ogmWrite::save(const char *name)
{

uint8_t *bufr;
uint32_t len,flags;
uint8_t error=0;


		_fd=fopen(name,"wb");
		if(!_fd)
		{
                        GUI_Error_HIG(QT_TR_NOOP("File error"), QT_TR_NOOP("Cannot open \"%s\" for writing."), name);
			return 0;
		}

		videoStream=new ogm_page(_fd,1);
	
		encoding_gui=new DIA_encoding(25000);
                encoding_gui->setContainer("OGM");
		//______________ Write headers..._____________________
		
		if(!initVideo(name))
		{
			fclose(_fd);
			_fd=NULL;
                        GUI_Error_HIG(QT_TR_NOOP("Could not initialize video"), NULL);
			return 0;
		
		}
		if(!initAudio())
		{
			fclose(_fd);
			_fd=NULL;
                        GUI_Error_HIG(QT_TR_NOOP("Could not initialize audio"), NULL);
			return 0;
		
		}

		encoding_gui->setFps(_fps1000);
		encoding_gui->reset();
		// ___________________Then body_______________________
                uint32_t j=0;
		for( j=0;j<_togo && !error;j++)
		{
			if(!encoding_gui->isAlive())
			{
				error=1;
				continue;
			}
			if(!writeVideo(j)) error=1;
			if(!writeAudio(j)) error=1;
		}
                if(abs(j-_togo)<3 && error) error=0; // might be caused by late B frame
		delete encoding_gui;
		encoding_gui=NULL;
		//________________ Flush______________________
		videoStream->flush();
		endAudio();
		//deleteAudioFilters();
		// ____________Close____________________
		fclose(_fd);
		_fd=NULL;

	return !error;
}
// ************************************************************
int main( void)
{
//    double t;
    short v, i, j;
    char start;
    char roll;
    char s[32], kj;

    // init offsets
    x0 = 125;
    y0 = 100;
    z0 = 200;
    
    // hardware and video initialization 
    MMBInit();
    initVideo();
    initMatrix( mw, AOFFS, BOFFS, GOFFS, x0, y0, z0);
        
    // 3. main loop
    while( 1)
    {
        roll = 1;
        start = 0;
        gClearScreen();          
    
        // splash screen
        setColor( 2);  // red
        AT(8, 1); putsV( "Rubik's Cube Demo");
        AT(8, 3); putsV( "   LDJ v1.0");
        AT(8, 5); putsV( " for PIC32MX4 MMB");
        copyV();                        // update visible screen
        while( !MMBReadKey());
        srand( ReadCoreTimer());
             
        // clear all objects
        objc = MAXOBJ;
        pyc = MAXPOLY;
        pc = MAXP;
        
        // init all objects angles
        for( i=0; i<MAXOBJ; i++)
            a[i] = b[i] = g[i] = 0;
     
        // create the rubik cube
        newCube();
        
        // init cursor and define grid
        qx = 1; qy = 1;
        initGrid();        
        
        while ( roll)
        {
            // paint cube in current position (with cursor)
            gClearScreen();                 // clear the hidden screen
            for( i=objc; i<MAXOBJ; i++)
            {
                initMatrix( mo, 0, 0, 0, 0, 0, 0);
                drawObject( mo, i);
            }
            drawCursor( qx, qy);
            copyV();
            
            // read the joystick and rotate center rows 
            kj = MMBGetKey();
            
            if ( kj & 0x80)         // long pressure 
            {
                switch( kj & 0x7F){
                  case JOY_RIGHT:   // rotate whole cube
                        rotateCube( 0, +1, 0);
                    break;
                  case JOY_LEFT:    // rotate whole cube
                        rotateCube( 0, -1, 0);
                    break;
                  case JOY_UP:      // rotate whole cube
                        rotateCube( -1, 0, 0);
                    break;
                  case JOY_DOWN:    // rotate whole cube
                        rotateCube( +1, 0, 0);
                    break;
                  case JOY_SELECT:  // rotate face counter clockwise
                        rotateRow( 0, 0, 1, 2, +1);
                    break;
                }
            }
            else                    // short pressure
            {                       
                switch( kj){
                  case JOY_RIGHT:   // rotate only the current row 
                    if (qx == 2)
                        rotateRow( 0, 1, 0, qy, +1);
                    else qx++;
                    break;
                  case JOY_LEFT:    // rotate only the current row 
                    if (qx == 0)
                        rotateRow( 0, 1, 0, qy, -1);
                    else qx--;
                    break;
                  case JOY_UP:      // rotate only the current row 
                    if (qy == 2)
                        rotateRow( 1, 0, 0, qx, -1);
                    else qy++;
                    break;
                  case JOY_DOWN:    // rotate only the current row 
                    if (qy == 0)
                        rotateRow( 1, 0, 0, qx, +1);
                    else qy--;
                    break;
                  case JOY_SELECT:  // rotate face clockwise
                        rotateRow( 0, 0, 1, 2, -1);
                    break;
                } // switch
            } // short pressure     
        } //roll        
    } // main loop
} // main
Beispiel #28
0
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    //SET CLOCK
    this->clock = new QTimer(0);
    connect(this->clock, SIGNAL(timeout()), this, SLOT(process()));

    //INITIATE CAMERA
    videoInput = NULL;
    initVideo();

    //START CLOCK (PÓS CÂMERA SER INICIALIZADA)
    this->clock->start(50);
    //lança evento timeout() a cada 500 milisegundos


    //COLOTS TRACKBARS

    connect(this, SIGNAL(rangeChanged()), this, SLOT(findThresholdImg()));

    ui->ColorMinChannelOption->addItem("hue");
    ui->ColorMinChannelOption->addItem("saturation");
    ui->ColorMinChannelOption->addItem("value");

    ui->ColorMaxChannelOption->addItem("hue");
    ui->ColorMaxChannelOption->addItem("saturation");
    ui->ColorMaxChannelOption->addItem("value");

    //DEFINE COLOR BUTTOM
    /*
    Orange  0-22
    Yellow 22- 38
    Green 38-75
    Blue 75-130
    Violet 130-160
    Red 160-179*/
    ui->DefinedColorOption->addItem("Laranja");
    ui->DefinedColorOption->addItem("Amarelo");
    ui->DefinedColorOption->addItem("Verde");
    ui->DefinedColorOption->addItem("Azul");
    ui->DefinedColorOption->addItem("Roxo");
    ui->DefinedColorOption->addItem("Vermelho");

    minCorHSV[0] = 100;
    minCorHSV[1] = 0;
    minCorHSV[2] = 0;

    maxCorHSV[0] = 179;
    maxCorHSV[1] = 255;
    maxCorHSV[2] = 255;

    this->updateColorTrackBars();
    emit rangeChanged();

    //numero de falhas iniiais zerado
    //sera usado para controlar erros de abertura de camera
    numberOfFailure = 0;

    //BUTÃO PARA BORRA IMAGEM
    //orem : 3 5 7 9 11 13 21 31
    ui->SizeOfGaussian->addItem("3");//0
    ui->SizeOfGaussian->addItem("5");//1
    ui->SizeOfGaussian->addItem("7");
    ui->SizeOfGaussian->addItem("9");//3
    ui->SizeOfGaussian->addItem("11");
    ui->SizeOfGaussian->addItem("13");//5
    ui->SizeOfGaussian->addItem("21");
    ui->SizeOfGaussian->addItem("31");//7
    ui->SizeOfGaussian->addItem("51");
    ui->SizeOfGaussian->addItem("61");//9
    ui->SizeOfGaussian->addItem("71");
    ui->SizeOfGaussian->setCurrentIndex(7);

    pastHistoryMaxSize = 100;

    int RaioInicial = 30;
    Raio = RaioInicial;
    ui->raioValueLabel->setText(QString::number(RaioInicial));
    ui->raioSlider->setValue(RaioInicial);

    //variáveis para modo de rocord
    imageCounter = 0;
    ui->baseNameLineEdit->setText("./images/");
    frames_imprimidos = 0;
    frame_control = 0;

    control_storeInstantFuture = false;
    iteration_recording = 0;

    number_of_objects = 0;

    number_of_shots_to_take = 30;


}
Beispiel #29
0
// 初始化Video环境
JNIEXPORT jint JNICALL Java_cn_edu_hust_buildingtalkback_jni_NativeInterface_initVideo
		(JNIEnv *env, jclass clazz, jint width, jint height)
{
	return initVideo(width, height);
}
Beispiel #30
0
void Init::initGame() {
	initVideo();
	updateConfig();

	if (!_vm->isDemo()) {
		if (_vm->_dataIO->hasFile(_vm->_startStk))
			_vm->_dataIO->openArchive(_vm->_startStk, true);
	}

	_vm->_util->initInput();

	_vm->_video->initPrimary(_vm->_global->_videoMode);
	_vm->_global->_mouseXShift = 1;
	_vm->_global->_mouseYShift = 1;

	_palDesc = new Video::PalDesc;

	_vm->validateVideoMode(_vm->_global->_videoMode);

	_vm->_global->_setAllPalette = true;
	_palDesc->vgaPal = _vm->_draw->_vgaPalette;
	_palDesc->unused1 = _vm->_draw->_unusedPalette1;
	_palDesc->unused2 = _vm->_draw->_unusedPalette2;
	_vm->_video->setFullPalette(_palDesc);

	for (int i = 0; i < 10; i++)
		_vm->_draw->_fascinWin[i].id = -1;

	_vm->_draw->_winCount = 0;

	for (int i = 0; i < 8; i++)
		_vm->_draw->_fonts[i] = 0;

	if (_vm->isDemo()) {
		doDemo();
		delete _palDesc;
		_vm->_video->initPrimary(-1);
		cleanup();
		return;
	}

	Common::SeekableReadStream *infFile = _vm->_dataIO->getFile("intro.inf");
	if (!infFile) {

		for (int i = 0; i < 4; i++)
			_vm->_draw->loadFont(i, _fontNames[i]);

	} else {

		for (int i = 0; i < 8; i++) {
			if (infFile->eos())
				break;

			Common::String font = infFile->readLine();
			if (infFile->eos() && font.empty())
				break;

			font += ".let";

			_vm->_draw->loadFont(i, font.c_str());
		}

		delete infFile;
	}

	if (_vm->_dataIO->hasFile(_vm->_startTot)) {
		_vm->_inter->allocateVars(Script::getVariablesCount(_vm->_startTot.c_str(), _vm));

		strcpy(_vm->_game->_curTotFile, _vm->_startTot.c_str());

		_vm->_sound->cdTest(1, "GOB");
		_vm->_sound->cdLoadLIC("gob.lic");

		// Search for a Coktel logo animation or image to display
		if (_vm->_dataIO->hasFile("coktel.imd")) {
			_vm->_draw->initScreen();
			_vm->_draw->_cursorIndex = -1;

			_vm->_util->longDelay(200); // Letting everything settle

			VideoPlayer::Properties props;
			int slot;
			if ((slot = _vm->_vidPlayer->openVideo(true, "coktel.imd", props)) >= 0) {
				_vm->_vidPlayer->play(slot, props);
				_vm->_vidPlayer->closeVideo(slot);
			}

			_vm->_draw->closeScreen();
		} else if (_vm->_dataIO->hasFile("coktel.clt")) {
			Common::SeekableReadStream *stream = _vm->_dataIO->getFile("coktel.clt");
			if (stream) {
				_vm->_draw->initScreen();
				_vm->_util->clearPalette();

				stream->read((byte *)_vm->_draw->_vgaPalette, 768);
				delete stream;

				int32 size;
				byte *sprite = _vm->_dataIO->getFile("coktel.ims", size);
				if (sprite) {
					_vm->_video->drawPackedSprite(sprite, 320, 200, 0, 0, 0,
							*_vm->_draw->_frontSurface);
					_vm->_palAnim->fade(_palDesc, 0, 0);
					_vm->_util->delay(500);

					delete[] sprite;
				}

				_vm->_draw->closeScreen();
			}
		}

		_vm->_game->start();

		_vm->_sound->cdStop();
		_vm->_sound->cdUnloadLIC();

	}

	delete _palDesc;
	_vm->_dataIO->closeArchive(true);
	_vm->_video->initPrimary(-1);
	cleanup();
}