示例#1
0
// Display fuction used to redraw our graphics as our game runs.
void display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear frame buffer.
	
	switch(gameState)
	{
		case STATE_CALIBRATE:
			gameState = calibrateDisplay();
			break;
		case STATE_START:
			gameState = startDisplay();
			break;
		case STATE_PLAY:
			gameState = playDisplay();
			break;
		case STATE_HIGHSCORES:
			gameState = highScoreDisplay();
			break;
		case STATE_GAMEOVER:
			gameState = gameOverDisplay();
			break;
	}
	
	isShotFired = false;
	
	glFlush();
	glutSwapBuffers();
}
示例#2
0
void Application::run(void)
	{
	/* Install callbacks with the tool manager: */
	ToolManager* toolManager=getToolManager();
	toolManager->getToolCreationCallbacks().add(this,&Application::toolCreationCallback);
	toolManager->getToolDestructionCallbacks().add(this,&Application::toolDestructionCallback);
	
	/* Install Vrui callbacks: */
	setFrameFunction(frameWrapper,this);
	setDisplayFunction(displayWrapper,this);
	setSoundFunction(soundWrapper,this);
	
	/* Start the display: */
	startDisplay(0,0);
	
	/* Start the sound renderer if requested: */
	if(useSound)
		startSound(initSoundWrapper,this);
	
	/* Run the Vrui main loop: */
	mainLoop();
	
	/* Uninstall tool manager callbacks: */
	toolManager->getToolCreationCallbacks().remove(this,&Application::toolCreationCallback);
	toolManager->getToolDestructionCallbacks().remove(this,&Application::toolDestructionCallback);
	}
示例#3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setWindowTitle("Barcode Decoder");

    this->timer = new QTimer(this);
    //QPainter *painter = new QPainter(this);
    Camera *camera = new Camera();
    Process *process = new Process();




    process->moveToThread(&decodeThread);
    decodeThread.start();

    camera->moveToThread(&cameraThread);
    cameraThread.start();


    connect(timer , SIGNAL(timeout()) , camera , SLOT(imgRequest()) );
    connect(camera, SIGNAL(sendImg(cv::Mat)) , ui->play , SLOT(loadImg(cv::Mat)) );
    connect(camera, SIGNAL(sendImg(cv::Mat)) , process , SLOT(getImgAndProcess(cv::Mat)) );
    connect(process, SIGNAL(sendIsBarcaode(bool)) , ui->play , SLOT(slotIsBarcodeLocated(bool)) );
    connect(process, SIGNAL(sendLoc(cv::Rect)) , ui->play , SLOT(slotGetBarcodeLocation(cv::Rect)) );
    connect(process, SIGNAL(sendBarcodeImg(cv::Mat)) , this , SLOT(updateBarcodeImg(cv::Mat)) );
    connect(process, SIGNAL(sendBarcode(QString)) , this , SLOT(updateBarcode(QString)) );
    
    connect(ui->close, SIGNAL(pressed()) , ui->play, SLOT(cleanScrean()) );
    connect(ui->start, SIGNAL(pressed()) , ui->play, SLOT(startDisplay()) );
    //connect(ui->checkBox, SIGNAL(stateChanged(int)) , camera , SLOT(autofocus(int)) );
    connect(ui->focusValue, SIGNAL(sliderReleased()) , this , SLOT(getSliderValue()) );
    //connect(this , SIGNAL(focusNum(int)) , camera , SLOT(focusValue(int)) );
    connect(ui->checkBox , SIGNAL(clicked(bool)) , ui->focusValue, SLOT(setEnabled(bool)) );
    //connect(camera , SIGNAL(cameraCheck(bool)) , this , SLOT(slotCameraCheck(bool)) );
    //connect(ui->start, SIGNAL(pressed()) , camera , SLOT(autoFocusCheck()) );

    connect(ui->start, SIGNAL(pressed()) , camera , SLOT(sendID()) );
    connect(camera, SIGNAL(cameraID(int)) , this, SLOT(checkCamera(int)) );
    connect(this , SIGNAL(focusNum(int)) , this, SLOT(setCameraFocusValue(int)) );
    connect(ui->checkBox , SIGNAL(stateChanged(int)) , this , SLOT(setFocusStatus(int)) );



    //camera->autoFocusCheck();

    ui->close->setEnabled(false);
    ui->checkBox->setEnabled(false);
    ui->focusValue->setEnabled(false);

    this->cameraFocus = false;

    //this->timer->start(33);//using timer to trigger update

}
示例#4
0
void ILI9163::initializeDevice() {
    pinMode(pin_rs, OUTPUT);
    pinMode(pin_cs, OUTPUT);
    pinMode(pin_reset, OUTPUT);

    port_rs = getPortInformation(pin_rs, &mask_rs);
    port_cs = getPortInformation(pin_cs, &mask_cs);

    _dspi->begin();
    _dspi->setSpeed(10000000UL);

    digitalWrite(pin_rs, HIGH);
    digitalWrite(pin_cs, HIGH);
    digitalWrite(pin_reset, HIGH);
    delay(100);
    digitalWrite(pin_reset, LOW);
    delay(100);
    digitalWrite(pin_reset, HIGH);
    delay(100);

    startDisplay();
}
示例#5
0
文件: main.c 项目: eos1d3/OpenTCS
THD_FUNCTION(Thread2, arg)
{
    (void)arg;
    startDisplay();
}
/*=====================app_main===========================*/
int app_main()
{
	int i = 0;
	void *capturebuffer0;
	void *displaybuffer;
	int counter = 0;
	int ret = 0;
	struct v4l2_format capture_fmt;
	struct v4l2_format display_fmt;
	int capture_chroma_offset, display_chroma_offset;
	int capture_size;
	int capture_fd, display_fd;
	char outputname[15];
	char stdname[15];
	int capture_numbuffers = MAX_BUFFER, display_numbuffers = MAX_BUFFER;

	for (i = 0; i < MAX_BUFFER; i++) {
		capture_buff_info[i].start = NULL;
		display_buff_info[i].start = NULL;
	}

	/* STEP1:
	 * Initialization section
	 * Initialize capture and display devices. 
	 * Here one capture channel is opened 
	 * Display channel is opened with the same standard that is detected at
	 * capture channel. same output name as input
	 * */

	/* open capture channel 0 */
	ret = initCapture(&capture_fd, &capture_numbuffers, &capture_fmt);
	if (ret < 0) {
		printf("Error in opening capture device for channel 0\n");
		return ret;
	}

	printf(" Capture initialized\n");
	/* open display channel */
	if (display_enable) {
		ret = initDisplay(&display_fd, &display_numbuffers, &display_fmt);
		if (ret < 0) {
			printf("Error in opening display device\n");
			return ret;
		}
		printf(" Display initialized\n");
		/* run section
		 * STEP2:
		 * Here display and capture channels are started for streaming. After 
		 * this capture device will start capture frames into enqueued 
		 * buffers and display device will start displaying buffers from 
		 * the qneueued buffers */

		/* start display */
		ret = startDisplay(&display_fd);
		if (ret < 0) {
			printf("Error in starting display\n");
			return ret;
		}
		printf(" display started \n");
	}
	/* start capturing for channel 0 */
	ret = startCapture(&capture_fd);
	if (ret < 0) {
		printf("Error in starting capturing for channel 0\n");
		return ret;
	}

	printf(" capture started \n");

	/* calculate the offset from where chroma data will be stored for 
	 * both capture and display */
	capture_chroma_offset = kernel_buf_size/2;
	//display_chroma_offset = display_fmt.fmt.pix.sizeimage / 2;
	display_chroma_offset = kernel_buf_size/2;
	capture_size = capture_fmt.fmt.pix.width * capture_fmt.fmt.pix.height;

	/* One buffer is dequeued from display and capture channels.
	 * Capture buffer will be copied to display buffer.
	 * All two buffers are put back to respective channels.
	 * This sequence is repeated in loop.
	 * After completion of this loop, channels are stopped.
	 * */
	printf("Going into loopback\n");

#if 0
	sleep(10);
#else
	while (1) {
		/* get capturing buffer for channel 0 */
		capturebuffer0 = getCaptureBuffer(&capture_fd);
		if (NULL == capturebuffer0) {
			printf("Error in get capture buffer for channel 0\n");
			return ret;
		}

		/* get display buffer */
		if (display_enable) {
			displaybuffer = getDisplayBuffer(&display_fd);
			if (NULL == displaybuffer) {
				printf("Error in get display buffer\n");
				return ret;
			}

			/* Copy Luma data from capture buffer to display buffer */
			memcpy(displaybuffer, capturebuffer0, capture_size);
			/* Copy chroma data from capture buffer to display buffer
			 * from the appropriate offsets in capture buffer and 
			 * display buffer */
			memcpy(displaybuffer + display_chroma_offset,
				capturebuffer0 + capture_chroma_offset,
				capture_size);

			/* put output buffer into display queue */
			ret = putDisplayBuffer(&display_fd, display_numbuffers,
					       displaybuffer);
			if (ret < 0) {
				printf("Error in put display buffer\n");
				return ret;
			}
		}
		if (save_frame && counter == 100) {
			fwrite(capturebuffer0, 1, capture_size,
				file_fp);
			fwrite(capturebuffer0 + capture_chroma_offset,
				1, capture_size,
				file_fp); 
			fclose(file_fp);
		}

		/* put buffers in capture channels */
		ret = putCaptureBuffer(&capture_fd, capture_numbuffers,
				       capturebuffer0);
		if (ret < 0) {
			printf("Error in put capture buffer for channel 0\n");
			return ret;
		}
		counter++;


		if (print_fn)
			printf("time:%lu    frame:%u\n", (unsigned long)time(NULL), counter);

		if (stress_test && counter >= MAXLOOPCOUNT)
			break;
	}
#endif

	printf("After sleep, stop capture/display\n");
	/* stop display */
	if (display_enable) {
		ret = stopDisplay(&display_fd);
		if (ret < 0) {
			printf("Error in stopping display\n");
			return ret;
		}
	}
	/* stop capturing for channel 0 */
	ret = stopCapture(&capture_fd);
	if (ret < 0) {
		printf("Error in stopping capturing for channel 0\n");
		return ret;
	}

	/* close capture channel 0 */
	ret = releaseCapture(&capture_fd, capture_numbuffers);
	if (ret < 0) {
		printf("Error in closing capture device\n");
		return ret;
	}
	/* Free section
	 * Here channels for capture and display are close.
	 * */
	/* open display channel */
	if (display_enable) {
		ret = releaseDisplay(&display_fd, display_numbuffers);
		if (ret < 0) {
			printf("Error in closing display device\n");
			return ret;
		}
	}
	return ret;
}