void key_press(unsigned char key, int x, int y) { switch(key) { case 's': case 'S': shot = capturePoints(); if(gameState != STATE_CALIBRATE) calculateCoor(); shot[0] = 0; shot[1] = 0; isShotFired = true; if(gameState == STATE_PLAY) checkAllHits(); else if(gameState == STATE_HIGHSCORES) checkKeyboardTargets(); break; case 'r': case 'R': playSound1(); gameState = STATE_START; break; case 'q': case 'Q': stopCamera(); releaseSounds(); exit(0); } }
unsigned char* V4LinuxCamera::getFrame() { if (cameraID==-1) return NULL; int frame = 0; v4l_mmap.frame = frame; ioctl(cameraID, VIDIOCSYNC, &frame); if(ioctl(cameraID, VIDIOCMCAPTURE, &v4l_mmap)<0) { stopCamera(); closeCamera(); return NULL; } camBuffer = camBuffer + v4l_buf.offsets[frame]; if (camBuffer==NULL) return NULL; switch (colour) { case false: if (v4l_mmap.format==VIDEO_PALETTE_YUYV) yuyv2gray(this->width, this->height, camBuffer, buffer); else if (v4l_mmap.format==VIDEO_PALETTE_UYVY) uyvy2gray(this->width, this->height, camBuffer, buffer); else if (v4l_mmap.format==VIDEO_PALETTE_YUV420P) return camBuffer; return buffer; break; case true: //ccvt_420p_bgr24(width, height, camBuffer, buffer); break; } return buffer; }
void StereoNode::timerCallback(const ros::TimerEvent& event) { if (force_streaming_ || (l_pub_stream_.getNumSubscribers() > 0) || (r_pub_stream_.getNumSubscribers() > 0)) { startCamera(); } else { stopCamera(); } }
void player_pain (edict_t *self, edict_t *other, float kick, int damage) { // player pain is handled at the end of the frame in P_DamageFeedback // if we're in a camera, get out if (self->client->zCameraTrack) { stopCamera(self); } }
/* ================= Cmd_PutAway_f ================= */ void Cmd_PutAway_f (edict_t *ent) { ent->client->showscores = false; ent->client->showhelp = false; ent->client->showinventory = false; if (ent->client->zCameraTrack) stopCamera(ent); }
void PouringWindow::HideWindow() { stopCamera(); currentPour = NULL; ui->cameraDisplay->clear(); updateTimer.stop(); MainWindow::Instance->ShowWindow(); if (isHidden()) return; hide(); }
ViewFinderWrapper::~ViewFinderWrapper() { m_processor->deleteLater(); stopViewFinder(); stopCamera(); }
bool V4LinuxCamera::resetCamera() { return (stopCamera() && startCamera()); }
bool FolderCamera::resetCamera() { return (stopCamera() && startCamera()); }
int main(void) { int cam_mode,cam_x1,cam_y1,cam_width,cam_heigth,cam_zx,cam_zy; if(getSelector() == 0) return; char c; int i;//buff_length; //int wait_cam; //defining the position of the several inputs and outputs (motors are outputs) in the respective SFR //the SFR are programed as structures, so accessing to an input/output implies only acessing to the field of the structure corresponding to the SFR that was //assigned to that input/output (see epuck_ports.h and p30f6014.h to understand the SFR assignment) e_init_port(); e_init_motors(); //important to enable uart interface e_init_uart1(); e_init_ad_scan(ALL_ADC); e_calibrate_ir(); //initial configuration of the camera cam_x1=(ARRAY_WIDTH/Z_WIDTH-WIDTH)/2; cam_y1=(ARRAY_HEIGHT/Z_HEIGHT-HEIGHT)/2; cam_width=WIDTH; cam_heigth=HEIGHT; cam_zx=Z_WIDTH; cam_zy=Z_HEIGHT; cam_mode=MODE; if(cam_mode==GREY_SCALE_MODE) cam_size=cam_width*cam_heigth; else cam_size=cam_width*cam_heigth*2; //not waiting for camera wait_cam=0; e_activate_agenda(updateFlag, 500);//500//1000 e_activate_agenda(readValues, 10); e_start_agendas_processing(); keepFinding = 0; e_set_led(4,1); keepFinding = 1; int s = getSelector(); while(s==getSelector()); /*while(1){ sprintf(b1,"%i\n",e_get_calibrated_prox(S_FRONT_LEFT)); e_send_uart1_char(b1,10); while(e_uart1_sending()); }*/ while(1){ while(keepFinding) { if(!cameraOn) { startCamera(); correctRobot(); } while(!captura()); //e_send_uart1_char(buffer,buff_length); //while(e_uart1_sending()); if(cameraOn > 5) processaImagem(); cameraOn++; } if(cameraOn) stopCamera(); while(!flag); flag = 0; sendInputs(); readOrder(); readOrder(); e_set_speed_left(speedLeft); e_set_speed_right(speedRight); e_set_led(4,0); } return 0; }
bool iThingCamera::resetCamera() { return (stopCamera() && startCamera()); }
void StereoNode::closeCamera() { stopCamera(); r_cam_.closeCamera(); l_cam_.closeCamera(); }
void StereoNode::reconfig(stereoConfig &config, uint32_t level) { force_streaming_ = config.force_streaming; handlePath(config.config_path); const FlashMode flash_active_mode = config.flash_polarity ? FLASH_FREERUN_ACTIVE_HI : FLASH_FREERUN_ACTIVE_LO; if (trigger_mode_ != config.trigger) { stopCamera(); TriggerMode l_trigger, r_trigger; FlashMode l_flash = FLASH_OFF; FlashMode r_flash = FLASH_OFF; switch (config.trigger) { case stereo_TGR_SOFTWARE: case stereo_TGR_HARDWARE_RISING: l_trigger = r_trigger = TRIGGER_LO_HI; break; case stereo_TGR_HARDWARE_FALLING: l_trigger = r_trigger = TRIGGER_HI_LO; break; case stereo_TGR_L_MASTER_R_RISING: l_trigger = TRIGGER_OFF; r_trigger = TRIGGER_LO_HI; l_flash = flash_active_mode; break; case stereo_TGR_L_MASTER_R_FALLING: l_trigger = TRIGGER_OFF; r_trigger = TRIGGER_HI_LO; l_flash = flash_active_mode; break; case stereo_TGR_R_MASTER_L_RISING: l_trigger = TRIGGER_LO_HI; r_trigger = TRIGGER_OFF; r_flash = flash_active_mode; break; case stereo_TGR_R_MASTER_L_FALLING: l_trigger = TRIGGER_HI_LO; r_trigger = TRIGGER_OFF; r_flash = flash_active_mode; break; case stereo_TGR_AUTO: default: config.trigger = stereo_TGR_AUTO; l_trigger = r_trigger = TRIGGER_OFF; break; } if (!(l_cam_.setTriggerMode(l_trigger) && r_cam_.setTriggerMode(r_trigger))) { ROS_ERROR("Failed to configure triggers"); l_cam_.setTriggerMode(TRIGGER_OFF); r_cam_.setTriggerMode(TRIGGER_OFF); config.trigger = stereo_TGR_AUTO; l_cam_.setFlash(FLASH_OFF); r_cam_.setFlash(FLASH_OFF); } else { l_cam_.setFlash(l_flash, config.flash_delay, config.flash_duration); r_cam_.setFlash(r_flash, config.flash_delay, config.flash_duration); } } // Latch Auto Parameters if (auto_gain_ && !config.auto_gain) { config.gain = l_cam_.getHardwareGain(); } auto_gain_ = config.auto_gain; if (auto_exposure_ && !config.auto_exposure) { config.exposure_time = l_cam_.getExposure(); } auto_exposure_ = config.auto_exposure; // Pixel Clock if (l_cam_.getPixelClock() != config.l_pixel_clock) { l_cam_.setPixelClock(&config.l_pixel_clock); } if (r_cam_.getPixelClock() != config.r_pixel_clock) { r_cam_.setPixelClock(&config.r_pixel_clock); } reconfigCam(config, level, l_cam_); reconfigCam(config, level, r_cam_); trigger_mode_ = config.trigger; if (trigger_mode_ == stereo_TGR_SOFTWARE) { timer_force_trigger_.setPeriod(ros::Duration(1 / config.frame_rate)); } if (zoom_ != config.zoom) { zoom_ = config.zoom; loadIntrinsics(l_cam_, l_msg_camera_info_); loadIntrinsics(r_cam_, r_msg_camera_info_); } l_msg_camera_info_.header.frame_id = config.l_frame_id; r_msg_camera_info_.header.frame_id = config.r_frame_id; configured_ = true; }
bool linuxfwCamera::resetCamera() { return (stopCamera() && startCamera()); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setCentralWidget(new QWidget); QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setContentsMargins(0,0,0,0); layout->setSpacing(0); layout->addWidget( ui.header = new Header( this ) ); connect( &Socket::sock(), SIGNAL(userLoggedIn(QString)), ui.header, SLOT(onUserConnected(QString)) ); connect( &Socket::sock(), SIGNAL(userLoggedOut()), ui.header, SLOT(onUserDisconnected()) ); connect( ui.header, SIGNAL(disconnectClicked()), &Socket::sock(), SLOT(logout()) ); // mettre obligatoirement ici pour corriger un petit bug d'affichage // /*temp refresh button*/ // QPushButton *refreshBtn = new QPushButton( "Refresh" ); // refreshBtn->setObjectName( "refreshBtn" ); // mainLayout->addWidget( refreshBtn ); // connect(refreshBtn, SIGNAL(clicked()), ui.header, SLOT( onRefreshClicked() ) ); QHBoxLayout* centralLayout = new QHBoxLayout( ); centralLayout->addWidget( ui.sideBar = new SideBar( this ) ); centralLayout->addWidget( ui.stackedWidget = new StackedWidget( this ) ); layout->addLayout( centralLayout ); connect(ui.sideBar, SIGNAL( currentChanged( int ) ), ui.stackedWidget, SLOT( setCurrentIndex( int ) ) ); connect(ui.sideBar, SIGNAL( currentChanged( int ) ), SLOT( loadViewData( int ) ) ); // LOG connect( &Socket::sock(), SIGNAL(clientEvent(int)), &Socket::sock(), SLOT(log(int)) ); // LIGHT BOX lightBox = new QLightBoxWidget(this); QHBoxLayout *mainLayout = new QHBoxLayout( lightBox ); QWidget *fm = new QWidget(); fm->setObjectName("connexionFrame"); mainLayout->addWidget( fm ); QGridLayout *lightBoxLayout = new QGridLayout( fm ); lightBoxLayout->setRowStretch(1, 1); settings = new QSettings("smoky.ini",QSettings::IniFormat); lightBoxLayout->addWidget( new QLabel( "IP du serveur" ), 0, 0); lightBoxLayout->addWidget( serverIpEdt = new QLineEdit(), 0, 1 ); serverIpEdt->setInputMask( "000.000.000.000; " ); serverIpEdt->setText( settings->value("serverIp").toString() ); serverIpEdt->setObjectName( "serverIpEdt" ); lightBoxLayout->addWidget( localhostCbx = new QCheckBox("localhost"), 1,1); localhostCbx->setObjectName( "localhostCbx" ); connect( localhostCbx, SIGNAL( stateChanged(int)), SLOT(onLocalhostCbx(int)) ); lightBoxLayout->addWidget( loginIndication = new QLabel(), 1, 0); loginIndication->setObjectName( "loginIndication" ); loginIndication->setText("<center><small>Placez votre visage<br>face à la caméra</small></center>"); lightBoxLayout->addWidget( loginAvatarLbl = new QLabel(""), 2, 0, 2, 1); loginAvatarLbl->setObjectName( "loginAvatarLbl" ); lightBoxLayout->addWidget( loginUserEdt = new QLineEdit(), 2, 1); loginUserEdt->setPlaceholderText("Nom d'utilisateur"); loginUserEdt->setObjectName( "loginUserEdt" ); lightBoxLayout->addWidget( loginPasswordEdt = new QLineEdit(), 3, 1); loginPasswordEdt->setObjectName( "loginPasswordEdt" ); loginPasswordEdt->setEchoMode( QLineEdit::Password ); loginPasswordEdt->setPlaceholderText("Mot de passe"); lightBoxLayout->addWidget( loginSubmitBtn = new QPushButton("Connexion"), 4, 1); loginSubmitBtn->setObjectName( "loginSubmitBtn" ); lightBoxLayout->addWidget( statLbl = new QLabel( "" ), 5,0, 1, 2 ); statLbl->setObjectName( "statLbl" ); lightBox->show(); Camera *cam = new Camera(); t = new QThread(); mTimer = new QTimer(); mTimer->setInterval(1000/24); connect(mTimer, SIGNAL(timeout()), cam, SLOT(queryFrame()) ); connect( this, SIGNAL(startWork()), cam, SLOT(openCamera()) ); connect( this, SIGNAL(startWork()), mTimer, SLOT(start()) ); connect( cam, SIGNAL(stopCamera()), mTimer, SLOT(stop()) ); connect( this, SIGNAL(stopWork()), cam, SLOT(closeCamera()) ); /*destruction*/ // connect( qApp, SIGNAL(aboutToQuit()),mTimer, SLOT(stop()) ); // connect( qApp, SIGNAL(aboutToQuit()),mTimer, SLOT(deleteLater()) ); // connect( qApp, SIGNAL(aboutToQuit()), cam, SLOT(closeCamera()) ); // connect( qApp, SIGNAL(aboutToQuit()), cam, SLOT(deleteLater()) ); connect(t, SIGNAL(finished()), cam, SLOT(deleteLater())); // connect(this, &Controller::operate, worker, &Worker::doWork); //connect( qApp, SIGNAL(aboutToQuit()), t, SLOT(quit()) ); // connect( t, SIGNAL(finished()), t, SLOT(deleteLater()) ); // user logged out connect( &Socket::sock(), SIGNAL(userLoggedOut()), SLOT(startCamera()) ); // user logged in connect( &Socket::sock(), SIGNAL(userLoggedIn(QString)), SLOT(stopCamera()) ); cam->moveToThread( t ); mTimer->moveToThread( t ); t->start( QThread::IdlePriority ); emit startWork(); connect(cam, SIGNAL(sendShot(QImage, QRect)), SLOT(onShotSent(QImage)) ); // receive shots connect( &Socket::sock(), SIGNAL(userLoggedIn(QString)), loginPasswordEdt, SLOT(clear()) ); connect( &Socket::sock(), SIGNAL(userLoggedIn(QString)), lightBox, SLOT(hide()) ); // rendre la page d'accueil connect( &Socket::sock(), SIGNAL(userLoggedOut()), SLOT(resetThings()) ); connect( &Socket::sock(), SIGNAL(invalidCred()), SLOT(onInvalidCred()) ); connect( loginSubmitBtn, SIGNAL(clicked()), SLOT(connectUser()) ); connect( &Socket::sock(), SIGNAL(connexionError(int)), SLOT(onConnexionError(int)) ); // move(QApplication::desktop()->screen()->rect().center() - this->rect().center()); /* QDesktopWidget desktop; QRect desktop_geometry = desktop.screenGeometry(); */ // resize( 780, 650 ); /*int x = desktop_geometry.width()/2 - width()/2; int y = desktop_geometry.height()/2 - height()/2; move( x, y );*/ // showMaximized(); }
//------------------------------------------------------------------------------ opencvWebcam::~opencvWebcam() { stopCamera(); }
bool macsgCamera::resetCamera() { return (stopCamera() && startCamera()); }
/* * Called for each player at the end of * the server frame and right after spawning */ void ClientEndServerFrame(edict_t *ent) { float bobtime; int i; if (!ent) { return; } current_player = ent; current_client = ent->client; /* If the origin or velocity have changed since ClientThink(), update the pmove values. This will happen when the client is pushed by a bmodel or kicked by an explosion. If it wasn't updated here, the view position would lag a frame behind the body position when pushed -- "sinking into plats" */ for (i = 0; i < 3; i++) { current_client->ps.pmove.origin[i] = ent->s.origin[i] * 8.0; current_client->ps.pmove.velocity[i] = ent->velocity[i] * 8.0; } /* If the end of unit layout is displayed, don't give the player any normal movement attributes */ if (level.intermissiontime) { // FIXME: add view drifting here? current_client->ps.blend[3] = 0; current_client->ps.fov = 90; G_SetStats (ent); if (level.fadeFrames > 0) /* FS: Zaero specific game dll changes */ { float ratio = (float)(50 - level.fadeFrames) / 50.0; SV_AddBlend (1, 1, 1, ratio, current_client->ps.blend); } return; } AngleVectors(ent->client->v_angle, forward, right, up); /* burn from lava, etc */ P_WorldEffects(); /* set model angles from view angles so other things in the world can tell which direction you are looking */ if (ent->client->v_angle[PITCH] > 180) { ent->s.angles[PITCH] = (-360 + ent->client->v_angle[PITCH]) / 3; } else { ent->s.angles[PITCH] = ent->client->v_angle[PITCH] / 3; } ent->s.angles[YAW] = ent->client->v_angle[YAW]; ent->s.angles[ROLL] = 0; ent->s.angles[ROLL] = SV_CalcRoll(ent->s.angles, ent->velocity) * 4; /* calculate speed and cycle to be used for all cyclic walking effects */ xyspeed = sqrt( ent->velocity[0] * ent->velocity[0] + ent->velocity[1] * ent->velocity[1]); if (xyspeed < 5) { bobmove = 0; current_client->bobtime = 0; /* start at beginning of cycle again */ } else if (ent->groundentity) { /* so bobbing only cycles when on ground */ if (xyspeed > 210) { bobmove = 0.25; } else if (xyspeed > 100) { bobmove = 0.125; } else { bobmove = 0.0625; } } bobtime = (current_client->bobtime += bobmove); if (current_client->ps.pmove.pm_flags & PMF_DUCKED) { bobtime *= 4; } bobcycle = (int)bobtime; bobfracsin = fabs(sin(bobtime*M_PI)); // detect hitting the floor P_FallingDamage (ent); // apply all the damage taken this frame P_DamageFeedback (ent); // determine the view offsets SV_CalcViewOffset (ent); // determine the gun offsets SV_CalcGunOffset (ent); /* determine the full screen color blend must be after viewoffset, so eye contents can be accurately determined */ SV_CalcBlend(ent); /* chase cam stuff */ if (ent->client->resp.spectator) { G_SetSpectatorStats(ent); } else { G_SetStats(ent); } G_CheckChaseStats(ent); G_SetClientEvent (ent); G_SetClientEffects (ent); G_SetClientSound (ent); G_SetClientFrame (ent); VectorCopy (ent->velocity, ent->client->oldvelocity); VectorCopy (ent->client->ps.viewangles, ent->client->oldviewangles); // clear weapon kicks VectorClear (ent->client->kick_origin); VectorClear (ent->client->kick_angles); if (!(level.framenum & 31)) { /* if the scoreboard is up, update it */ if (ent->client->showscores) { if (ent->client->zCameraTrack) /* FS: Zaero specific game dll changes */ { updateVisorHud(ent); } else { DeathmatchScoreboardMessage (ent, ent->enemy); } gi.unicast(ent, false); } /* if the help computer is up, update it */ if (ent->client->showhelp) { ent->client->pers.helpchanged = 0; HelpComputer(ent); gi.unicast(ent, false); } } // this we want to do regardless if (ent->client->zCameraTrack) /* FS: Zaero specific game dll changes */ { // decrease the visor frame time ent->client->pers.visorFrames--; if (ent->client->pers.visorFrames == 0) { stopCamera(ent); ent->client->pers.inventory[ITEM_INDEX(FindItem("Visor"))]--; ValidateSelectedItem (ent); } } /* if the inventory is up, update it */ if (ent->client->showinventory) { InventoryMessage(ent); gi.unicast(ent, false); } }
/* ================== player_die ================== */ void player_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point) { int n; // if we're in a camera, get out if (self->client->zCameraTrack) { stopCamera(self); } VectorClear (self->avelocity); self->takedamage = DAMAGE_YES; self->movetype = MOVETYPE_TOSS; self->s.modelindex2 = 0; // remove linked weapon model self->s.angles[0] = 0; self->s.angles[2] = 0; self->s.sound = 0; self->client->weapon_sound = 0; self->maxs[2] = -8; // self->solid = SOLID_NOT; self->svflags |= SVF_DEADMONSTER; if (!self->deadflag) { self->client->respawn_time = level.time + 1.0; LookAtKiller (self, inflictor, attacker); self->client->ps.pmove.pm_type = PM_DEAD; ClientObituary (self, inflictor, attacker); TossClientWeapon (self); if (deathmatch->value) Cmd_Help_f (self); // show scores } // remove powerups self->client->quad_framenum = 0; self->client->invincible_framenum = 0; self->client->breather_framenum = 0; self->client->enviro_framenum = 0; self->client->a2kFramenum = 0; // clear inventory memset(self->client->pers.inventory, 0, sizeof(self->client->pers.inventory)); if (self->health < -40) { // gib gi.sound (self, CHAN_BODY, gi.soundindex ("misc/udeath.wav"), 1, ATTN_NORM, 0); for (n= 0; n < 4; n++) ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC); ThrowClientHead (self, damage); self->takedamage = DAMAGE_NO; } else { // normal death if (!self->deadflag) { static int i; i = (i+1)%3; // start a death animation self->client->anim_priority = ANIM_DEATH; if (self->client->ps.pmove.pm_flags & PMF_DUCKED) { self->s.frame = FRAME_crdeath1-1; self->client->anim_end = FRAME_crdeath5; } else switch (i) { case 0: self->s.frame = FRAME_death101-1; self->client->anim_end = FRAME_death106; break; case 1: self->s.frame = FRAME_death201-1; self->client->anim_end = FRAME_death206; break; case 2: self->s.frame = FRAME_death301-1; self->client->anim_end = FRAME_death308; break; } gi.sound (self, CHAN_VOICE, gi.soundindex(va("*death%i.wav", (rand()%4)+1)), 1, ATTN_NORM, 0); } } self->deadflag = DEAD_DEAD; gi.linkentity (self); }
bool videoInputCamera::resetCamera() { return (stopCamera() && startCamera()); }