Exemple #1
0
bool Snake::collision(Score& _hScore)
{
	// Snake eats the bait
	if(Pixels[0]->getFrontDot() == food.getFrontDot())
	{
		_hScore.addScore();
		_hScore.levelControl();
		addPixel();
		feedRefresh();
	}


	// If the snake hits the tail
	for(int i=1; i<numberOfPixel; i++)
	{
		if(	Pixels[0]->getFrontDot() == Pixels[i]->getFrontDot() )
			return true;
	}


	// If the snake hits the wall
	if(		Pixels[0]->getFrontDot().getX() >= 0 && Pixels[0]->getFrontDot().getX() < 800
		&&	Pixels[0]->getFrontDot().getY() >= 0 && Pixels[0]->getFrontDot().getY() < 540 )
	{
		return false;
	}
	else
		return true;
}
Exemple #2
0
	void thresholdingTracker(LPFImage magnitude, LPFImage output, float low, float high) {
		LPPIXELS lpCandidates = NULL;
		PIXEL current, newPixel;
		int ret;
		int y, x;
		zero(output);
//		printf("magnitude->height= %d, magnitude->width= %d\n", magnitude->height, magnitude->width);
//		fflush(stdout);

		for (y = 0; y < magnitude->height; y++) {
			for (x = 0; x < magnitude->width; x++) {
				if (magnitude->pixels[y*magnitude->width+x] >= high && output->pixels[y*magnitude->width+x] != 1) {

					newPixel.x = x;newPixel.y = y;
					addPixel(&lpCandidates, &newPixel);

//					candidates.add(new Pixel(x, y));
					while (!isEmptyPixelList(lpCandidates)) {
						 ret = pollFirst(&lpCandidates, &current);

                         if (ret == 0 || current.x < 0 || current.x > magnitude->width || current.y < 0 || current.y > magnitude->height)
//						if (current.x < 0 || current.x > magnitude.width || current.y < 0 || current.y > magnitude.height)
							continue;
						if (output->pixels[current.y*output->width+current.x] == 1)
							continue;
						if (magnitude->pixels[current.y*magnitude->width+current.x] < low)
							continue;

						output->pixels[current.y*output->width+current.x] = 1;
						newPixel.x = x - 1;newPixel.y = y - 1;addPixel(&lpCandidates, &newPixel);
						newPixel.x = x;newPixel.y = y - 1;addPixel(&lpCandidates, &newPixel);
						newPixel.x = x + 1;newPixel.y = y - 1;addPixel(&lpCandidates, &newPixel);
						newPixel.x = x - 1;newPixel.y = y;addPixel(&lpCandidates, &newPixel);
						newPixel.x = x + 1;newPixel.y = y;addPixel(&lpCandidates, &newPixel);
						newPixel.x = x - 1;newPixel.y = y + 1;addPixel(&lpCandidates, &newPixel);
						newPixel.x = x;newPixel.y = y + 1;addPixel(&lpCandidates, &newPixel);
						newPixel.x = x + 1;newPixel.y = y + 1;addPixel(&lpCandidates, &newPixel);
//						candidates.add(new Pixel(x - 1, y - 1));
//						candidates.add(new Pixel(x, y - 1));
//						candidates.add(new Pixel(x + 1, y - 1));
//						candidates.add(new Pixel(x - 1, y));
//						candidates.add(new Pixel(x + 1, y));
//						candidates.add(new Pixel(x - 1, y + 1));
//						candidates.add(new Pixel(x, y + 1));
//						candidates.add(new Pixel(x + 1, y + 1));
					}
				}
			}
		}
//	    printf("isEmptyPixelList(lpCandidates)= %d",isEmptyPixelList(lpCandidates));
//		freeCandidatesList(lpCandidates);
	}
Exemple #3
0
void renderTexture::grapicalPrintf(char* str,   void* fontData, int rasterposx, int rasterposy)
{
    unsigned char c;
    int x = 0;
    int xx = 0;

    while ((c = (unsigned char) * str++))
    {

        x = xx;
        unsigned char* fontPtr = (unsigned char*) fontData;
        char ch = c - 32;

        int sx = ch % 16;
        int sy = ch / 16;


        for (int i = sx * 16; i < (sx * 16 + 16); i++)
        {
            int y = 0;

            for (int j = sy * 16; j < (sy * 16 + 16); j++)
            {
                unsigned char packedColor = (fontPtr[i * 3 + 255 * 256 * 3 - (256 * j) * 3]);
                //float colorf = packedColor ? 0.f : 1.f;
                float colorf = packedColor / 255.f; // ? 0.f : 1.f;
                btVector4 rgba(colorf, colorf, colorf, 1.f);
                //if (colorf)
                {
                    //setPixel(rasterposx+x,rasterposy+y,rgba);
                    addPixel(rasterposx + x, rasterposy + y, rgba);
                }
                //bit >>=1;
                y++;
            }

            x++;
        }

        //xx+=16;
        xx += 10;
    }
}
Exemple #4
0
void MainWindow::setupConnections()
{
	int		i;

	/*
		Andrea修改
	*/
	//connect( openButton,		  SIGNAL(clicked()), this, SLOT( launchBMPImport() ) );  測試用 

    connect( openBMP,			 	SIGNAL(clicked()),						this,       			SLOT(launchBMPImport()) );						// 按下open BMP  可以讀取圖檔  Andrea
    connect( openBMP_2,			 	SIGNAL(clicked()),						this,       			SLOT(launchBMPImport()) );						// 按下open BMP  可以讀取圖檔  Andrea    2號用在measure
	connect( progress,				SIGNAL(signalImage(int,QImage)),		this,					SLOT(displayImage(int,QImage)) );				// 輸出畫面到顯示視窗

	connect( filedata,			 	SIGNAL(svgChanged(QString)),			pivDisplay_3,			SLOT(displaySVG(QString)) );					// 丟svg的方式顯示圖片 (svg暫存在硬碟)   丟到視窗三去做顯示

	connect( ScaleW,			 	SIGNAL(valueChanged(int)),				settings,    			SLOT(set_scale_w(int)) );						// 設定 Gauss filter scale w
	connect( ScaleL,			 	SIGNAL(valueChanged(int)),				settings,    			SLOT(set_scale_l(int)) );						// 設定 Gauss filter scale l
	connect( measureX,			 	SIGNAL(valueChanged(int)),				settings,    			SLOT(set_measure_X(int)) );						// 設定 Measure的座標X
	connect( measureY,			 	SIGNAL(valueChanged(int)),				settings,    			SLOT(set_measure_Y(int)) );						// 設定 Measure的座標Y
	connect( this,               	SIGNAL(doprocess()),                	process,				SLOT(processBatch()) );							// 進行process的動作
	connect( DoFilter,			 	SIGNAL(clicked()),						this,					SLOT(blob()) );									// 按下按鈕 開始執行blob detector  (包含subblob  watershed)
	connect( ChannelButton,			SIGNAL(clicked()),						this,					SLOT(channel()) );								// 抽取指定顏色的通道 
	connect( FFTJunctionButton,   	SIGNAL(clicked()),						this,					SLOT(FFTJunctionProcess()) );					// 按下按鈕 開始執行 FFT Junction Detector
	connect( SteerJunctionButton, 	SIGNAL(clicked()),						this,					SLOT(SteerJunctionProcess()) );					// 按下按鈕 開始執行 Steer Junction Detector
	connect( EdgeButton,		  	SIGNAL(clicked()),						this,					SLOT(EdgeProcess()) );							// 按下按鈕 開始執行 Subpixel Edge
	connect( CornerButton,		  	SIGNAL(clicked()),						this,					SLOT(CornerProcess()) );						// 按下Corner的按鈕 進行subpixel的Corner計算
	
	//connect( process,			  	SIGNAL(imageThrow(QImage)),				pivDisplay,				SLOT(displayBMP(QImage)) );						// 計算好 Gauss Filter 將資料丟給顯示
	connect( process,			  	SIGNAL(signalsGress(int)),				filterProgress,			SLOT(setValue(int)) );							// 設定進度條
	connect( process,			  	SIGNAL(signalsGress(int)),				measureProgress,		SLOT(setValue(int)) );							// 設定進度條
	connect( process,			  	SIGNAL(signalTabText(int,QString)),		this,					SLOT(setTabText(int,QString)) );				// 設定進度條

	connect( blobCombo,			  	SIGNAL(currentIndexChanged(int)),		this,					SLOT(setBlobmethod(int)) );						// 設定現在執行的是哪一個blob detector
	connect( waterCheck,		  	SIGNAL(stateChanged(int)),				this,					SLOT(setHighlight(int)) );						// 設定是否要反白
	connect( waterCombo,		  	SIGNAL(currentIndexChanged(int)),		this,					SLOT(setWatershed(int)) );						// 設定哪個watershed方法  4.8 4.1 mser


	// 把訊息印到除錯訊息的地方   append  or   setText
	connect( filedata,   			SIGNAL(debugSignal(QString)),     		text_debug,				SLOT(append(QString)) );
	connect( process,    			SIGNAL(debugSignal(QString)),     		text_debug,				SLOT(append(QString)) );
	connect( progress,	 			SIGNAL(debugSignal(QString)),	   		text_debug,				SLOT(append(QString)) );

	// 這邊跟顯示畫面 pointlist有關
	for( i = 0; i < 2; i++ )
		connect( display[i],			SIGNAL(mousePressed(PIXEL)),			this,					SLOT(addPixel(PIXEL)) );					// 點擊畫面 更新資料
	connect( progress,				SIGNAL(updateWidgeB()),					pointList[1],			SLOT(updatePointList()) );						// 將資料顯示到 point list (output)
	//connect( pointList[0],			SIGNAL(cellClicked(int,int)),			this,					SLOT(removePointList(int,int)) );				// 點擊 point list (input) 刪除點資料
	// 陰影檢測用 改成點擊到的時候顯示該區域到顯示區
	connect( pointList[0],			SIGNAL(cellClicked(int,int)),			this,					SLOT(view_square(int,int)) );
	connect( removeButton,			SIGNAL(clicked()),						this,					SLOT(remove_square()) );						// 移除某個square
	connect( clearButton,			SIGNAL(clicked()),						this,					SLOT(clearData()) );							// 按下clear按鈕  清空資料
	connect( inhenceCheck,			SIGNAL(stateChanged(int)),				settings,				SLOT(setInhence(int)) );						// 設定inhencement  判斷是抓單點陰影 還是整段的陰影 (應付noise很強 跟noise不強的case)
	connect( saveCheck,				SIGNAL(stateChanged(int)),				settings,				SLOT(setSaved(int))	);							// 設定是否要將結果輸出到檔案 (image部分)
	connect( batchCheck,			SIGNAL(stateChanged(int)),				settings,				SLOT(setBatch(int)) );							// 設定是否為批次作業
	
    // Importing
   // connect(importButton,			SIGNAL(clicked()),						this,					SLOT(launchImageImport()));
   // connect(filedata,				SIGNAL(imagesImported()),				this,					SLOT(notifyFolderChange()));

    connect(vectorListWidget, SIGNAL(fileClicked(int)), this, SLOT(vectorClicked(int)));

    // The following should be moved into settings
    //
    connect(colourButtonFiltered, SIGNAL(clicked()), this, SLOT(chooseFilteredColour()));
    connect(colourButtonUnfiltered, SIGNAL(clicked()), this, SLOT(chooseUnfilteredColour()));
    connect(scaleSpin, SIGNAL(valueChanged(double)), settings, SLOT(setVectorScale(double)));
    connect(subSpin, SIGNAL(valueChanged(double)), settings, SLOT(setVectorSub(double)));

    // Process tab
    connect(hSizeCombo, SIGNAL(activated(int)), settings, SLOT(setIntLengthX(int)));
    connect(vSizeCombo, SIGNAL(activated(int)), settings, SLOT(setIntLengthY(int)));
    connect(hSpaceSpin, SIGNAL(valueChanged(int)), settings, SLOT(setDeltaX(int)));
    connect(vSpaceSpin, SIGNAL(valueChanged(int)), settings, SLOT(setDeltaY(int)));


    // DoingPIV
    connect(outputFolderEdit, SIGNAL(textEdited(QString)), this, SLOT(setOutput()));
    connect(outputFolderButton, SIGNAL(clicked()), this, SLOT(chooseOutputFolder()));
    connect(outputFormatCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setOutput()));


    connect(batchButton, SIGNAL(clicked()), process, SLOT(launchBatchWindow()));
    connect(process, SIGNAL(batchProcessed()), this, SLOT(batchDone()));


	//for( i = 0; i < displaySize; i++ )
	//	connect(display[i],   	SIGNAL(mousePressed(PIXEL)),			this,			SLOT(updatePositionPixel(PIXEL)));				// Andrea修改  點一下滑鼠,把RGB資訊輸入進去.


	/*connect(pivDisplay,   	SIGNAL(mousePressed(QPointF)),			this,			SLOT(uptdaePositionRGB(QPointF)));				// Andrea修改  點一下滑鼠,把RGB資訊輸入進去.
	connect(pivDisplay_2,  	SIGNAL(mousePressed(QPointF)),			this,			SLOT(uptdaePositionRGB(QPointF)));				// Andrea修改  點一下滑鼠,把RGB資訊輸入進去.   用在視窗2
	connect(pivDisplay,   	SIGNAL(mousePressed(QPointF)),			this,			SLOT(updatePositionXY(QPointF)));				// Andrea修改  點一下滑鼠,把座標輸入進去.
	connect(pivDisplay_2,  	SIGNAL(mousePressed(QPointF)),			this,			SLOT(updatePositionXY(QPointF)));				// Andrea修改  點一下滑鼠,把座標輸入進去.   用在視窗2*/



	//connect(pivDisplay,   	SIGNAL(mousePressed(QPointF)),			pivDisplay,		SLOT(mark_XY(QPointF)));						// Andrea修改  點一下滑鼠, 在上面標記點
	//connect(pivDisplay_2,  	SIGNAL(mousePressed(QPointF)),			pivDisplay_2,	SLOT(mark_XY(QPointF)));						// Andrea修改  點一下滑鼠, 在上面標記點    用在視窗2



	connect(this,			SIGNAL(set_measure_X(int)),				measureX,		SLOT(setValue(int) ) );							// 設定 X 座標的spinbox
	connect(this,			SIGNAL(set_measure_Y(int)),				measureY,		SLOT(setValue(int) ) );							// 設定 Y 座標的spinbox
	

}