Ejemplo n.º 1
0
void LHSVision::UpdateVision() //by Michael
{
	if(mXbox->GetRawButton(XBOX::XBOX_A_BUTTON) == true)	//Toggle on A button press
	{
		while(mXbox->GetRawButton(XBOX::XBOX_A_BUTTON) == true)	//Prevents multi-press
		{}
		if(send == 1)
		{
			StopCamera(1);	//Stop Cam 1
			StartCamera(2);	//Start Cam 2
			printf("\nActivating Camera 2 - Raw Image Display\n\n");
			send = 2;
		}
		else
		{
			StopCamera(2);	//Stop Cam 2
			StartCamera(1);	//Start Cam 1
			printf("\nActivating Camera 1 - Raw Image Display\n\n");
			send = 1;
		}
	}

	if(send == 1)
	{
		IMAQdxGrab(session, frame, true, NULL);
		SendToDashboard(frame);		//Send Cam 1
		Wait(.1);
	}
	else
	{
		IMAQdxGrab(session2, frame2, true, NULL);
		SendToDashboard(frame2);	//Send Cam 2
		Wait(.1);
	}
}
Ejemplo n.º 2
0
void QmitkToFRecorderWidget::OnStop()
{
  StopCamera();
  StopRecorder();

  ResetGUIToInitial();

  emit ToFCameraStopped();
}
Ejemplo n.º 3
0
Archivo: picam.cpp Proyecto: Roboy/legs
int main(int argc, const char **argv)
{
	printf("PI Cam api tester\n");
	dest = new unsigned char[HEIGHT*WIDTH*4];
	fps = 0;

	startMilliSecondTimer();
	StartCamera(WIDTH,HEIGHT,90,CameraCallback);
	sleep(30);
	StopCamera();
	delete[] dest;
}
Ejemplo n.º 4
0
int main()
{
	int ret = 0;
	void * mV4l2_ctx = NULL;
	int mCaptureFormat;
	int width = 1280;
	int height = 720;

	int number = 0;

	struct v4l2_buffer buf;
	memset(&buf, 0, sizeof(buf));
	
	mV4l2_ctx = CreateV4l2Context();

	setV4L2DeviceName(mV4l2_ctx, "/dev/video1");

	// open v4l2 camera device
	ret = OpenCamera(mV4l2_ctx);

	if (ret != 0)
	{
		LOGE("openCameraDevice failed\n");
		return ret;
	}

	StartCamera(mV4l2_ctx, &width, &height);

	while(number < 300) {

		CameraGetOneframe(mV4l2_ctx,&buf);
		CameraReturnOneframe(mV4l2_ctx,buf.index);
		LOGD("test, number: %d",number);

		number ++;
	}
	
	StopCamera(mV4l2_ctx);

	CloseCamera(mV4l2_ctx);
	DestroyV4l2Context(mV4l2_ctx);
	mV4l2_ctx = NULL;

	return 0;
}
Ejemplo n.º 5
0
static int stopcamera(AWCameraDevice *p)
{
	AWCameraDevice* camera_dev = (AWCameraDevice *)(p);
	AWCameraContext* CameraCtx = NULL;
	int err = 0;
	
	if(!camera_dev)
		return -1;

	CameraCtx = (AWCameraContext *)(camera_dev->context);

	set_state(CameraCtx, 0);

	// Wait for thread to exit;
	pthread_join(CameraCtx->thread_id, (void*) &err);

	StopCamera(CameraCtx->v4l2ctx);
	CloseCamera(CameraCtx->v4l2ctx);
	
	return 0;
}
Ejemplo n.º 6
0
Gfx_Camera::~Gfx_Camera() {
	StopCamera();
}
Ejemplo n.º 7
0
int main(int argc, char* argv[]) {
    // Initialize shared memory
    if (ipc.init(false))
        exit(1);

    // Initialize nominal beaconContainer
    parseWaypoints();
    
    // Create camera semaphore/ mutex
    sem_init(&semCam, 0, 0);
    if (pthread_mutex_init(&mutexImageData, NULL) != 0) {
        printf("\n Camera mutex init failed\n");
        exit(1);
    }
    
    // Start camera thread
    pthread_t tid;
    int err = pthread_create(&tid, NULL, &camThread, NULL);
    if (err != 0) {
        printf("\nCan't create camera thread :[%s]", strerror(err));
        exit(1);
    }
    
    lastPhotogramMicros = getMicroSec();
    
    // Main loop
    for(;;photogram++) {        
        TRACE(DEBUG, "\nPHOTOGRAM %d, milliseconds: %ld\n", photogram, getMillisSinceStart());
        
        // Update time variables
        photogramMicros = getMicroSec();
        lastPhotogramSpentTime = getSpent(photogramMicros - lastPhotogramMicros);
        microsSinceStart += lastPhotogramSpentTime;
        lastPhotogramMicros = photogramMicros;
        
        // Get drone roll, pitch and yaw
        attitudeT attitude, delayedAttitude;
        ipc.getAttitude(attitude);
        
        attitudeSignal.push(attitude, lastPhotogramSpentTime);
        delayedAttitude = attitudeSignal.getSignal();
        
        droneRoll = delayedAttitude.roll * 0.01;
        dronePitch = delayedAttitude.pitch * 0.01;
        droneYaw = delayedAttitude.yaw * 0.01;
        
        // Update estimated servo values
        rollStatusServo.update(lastPhotogramSpentTime);
        pitchStatusServo.update(lastPhotogramSpentTime);
        
        if (rollStatusServo.inBigStep() || pitchStatusServo.inBigStep()) {
            sem_wait(&semCam);
            continue;
        }
       
        // Update estimated camera roll and pitch
        roll = droneRoll + rollStatusServo.getEstimatedAngle();
        pitch = dronePitch + pitchStatusServo.getEstimatedAngle();
        
        // Switch beacon containers to preserve one history record
        if (beaconContainer == &beaconContainerA) {
            beaconContainer = &beaconContainerB;
            oldBeaconContainer = &beaconContainerA;
        }
        else {
            beaconContainer = &beaconContainerA;
            oldBeaconContainer = &beaconContainerB;
        }
        beaconContainer->clean();
  
        // Wait until new frame is received
        sem_wait(&semCam);
        
        // Where the magic happens
        findBeacons();
        groupBeacons();
        findWaypoints();
        computePosition();
    }
    StopCamera();
    printf("Finished.\n");
    
    return 0;
}