コード例 #1
0
ファイル: main.cpp プロジェクト: azer89/PointPolygonTest
void DrawDistanceMap()
{
	// Distance Image
	double minVal; double maxVal;
	cv::minMaxLoc(_distanceMap1.GetCVImage(), &minVal, &maxVal, 0, 0, cv::Mat());
	minVal = abs(minVal); maxVal = abs(maxVal);

	for (int j = 0; j < _sz; j++)
	{
		for (int i = 0; i < _sz; i++)
		{
			float d = _distanceMap1.GetFloatValue(i, j);

			float rVal = 255 - (int)d * 255 / maxVal;
			_cvWrapper.SetPixel(_distanceMapName, i, j, MyColor(rVal, 0, 0));
		}
	}

	for (int a = 0; a < _polylines.size(); a++)
	{
		_cvWrapper.DrawPoly(_distanceMapName, _polylines[a], MyColor(255), false, 1);
	}

	_cvWrapper.ShowImage(_distanceMapName);
}
コード例 #2
0
ファイル: CTetris_Impl.cpp プロジェクト: scirelli/testForDX7
CTetris::CTetris( DISPLAYBOARD func, int cols, int rows)
{
	srand((unsigned)time(NULL));
	m_nLevel          = 1;
	DisplayBoard      = func;
	m_nNumofRows      = rows;
	m_nNumofCols      = cols;
	//m_nNumofLvls      = NUM_OF_LVLS;
	//m_nBlocksPerTet   = BLOCKS_PER_TET;
	m_nSizeofBoard    = rows*cols;
	//m_nNumofTetrads   = NUM_OF_TETRADS;
	m_nAdvanceNextLvl = ADVANCE_NEXT_LVL;
	m_ClearColor      = MyColor(0.f,0.f,0.f);
	m_bExit           = false;
	m_bPause          = false;
	m_nRowsCompleted  = 0;
	AnimRowCompletion = DefualtAnimRowCompl;
	DisplayWin        = DefualtDisplayWin;
	DisplayLose       = DefaultDisplayLose;
	m_nNextTetName    = RandomTetrad();
	m_fCurrFallDelay  = m_fFallDelay[m_nLevel];
	m_fFallDelay[0]   = FAST_FALL;
	m_nTotalRowsCompleted = 0;
	//m_NextTet      = CTetris::m_Tetrads[ m_nNextTetName ];
	//float color = RandomColor();
	//for( int j=0; j<BLOCKS_PER_TET; j++ )
	//	m_NextTet.tet[j].r = m_NextTet.tet[j].g = m_NextTet.tet[j].b = color;
	PickTetrad();
	m_npBoard  = new int[m_nSizeofBoard];
	m_pBoard   = new Block[m_nSizeofBoard];
	for(int i=0; i<m_nSizeofBoard; i++)
		m_npBoard[i] = BLOCK_STATE_EMPTY;
	for( i=1; i<NUM_OF_LVLS; i++ )
		m_fFallDelay[i] = 1.f/(float)i;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: azer89/PointPolygonTest
void DrawMainWindow()
{
	if (_currentPolyline.size() > 0)
		{ _cvWrapper.DrawPoly(_imageName, _currentPolyline, MyColor(255, 255, 0), false, 1); }
	for (int a = 0; a < _polylines.size(); a++)
		{ _cvWrapper.DrawPoly(_imageName, _polylines[a], MyColor(255), false, 1); }

	/*for (int a = 0; a < _nfWrapper._lineData.size(); a++)
	{
		_cvWrapper.DrawCircle(_imageName, _nfWrapper._lineData[a].GetMiddlePoint(), MyColor(255, 0, 0), 1);
	}*/

	_cvWrapper.DrawLine(  _imageName, _queryPt, _closestPt, MyColor(0, 0, 255), 1);
	_cvWrapper.DrawCircle(_imageName, _queryPt, MyColor(255, 0, 0), 5);
	_cvWrapper.ShowImage( _imageName);

	
}
コード例 #4
0
ファイル: main.cpp プロジェクト: azer89/PointPolygonTest
void DrawInOutMap()
{
	for (int x = 0; x < _sz; x++)
	{
		for (int y = 0; y < _sz; y++)
		{
			if (_inOutMap.GetIntegerValue(x, y) > 0)
			{
				_cvWrapper.SetPixel(_inOutName, x, y, MyColor(0, 255, 0));
			}
			else
			{
				_cvWrapper.SetPixel(_inOutName, x, y, MyColor(0, 0, 0));
			}
		}
	}

	_cvWrapper.ShowImage(_inOutName);
}
コード例 #5
0
ファイル: main.cpp プロジェクト: quetz05/Raytraicing
int main(int argc, char *argv[])
{

    World world(QColor(0,180,180));

    int samples = 1;

    Material *material = new Reflective (QColor(2,255,255), 0.4, 1, 300, 0.6);
    PinholeCamera camera(Vector3(0,0,0),Vector3(0,0,1),Vector3(0,-1,0),Vector2(1,0.75),1);


    world.add(new Sphere(Vector3(-2,-1.15,1), 2,  material));
    world.add(new Sphere(Vector3(2,-1.15,1), 2,  material));
    world.add(new Sphere(Vector3(0,3.45-1.15,1), 2,  material));
    world.add(new Sphere(Vector3(0,1.15-1.15,3.45+1), 2,  material));

    JitteredGenerator gener(0);
    SquareDistributor dist;
    Sampler distributor(gener,dist,samples,60,0);




    world.add_light(PointLight(Vector3(0,0,3.45-2), MyColor(1,1,1)));

    Raytracer tracer(5);
    QImage image;
    image = tracer.ray_trace(world, camera, QSize(800, 600), &distributor);




    QApplication a(argc, argv);
    MainWindow w;

    w.copy_world(image, world);
    w.show_image();
   // w.new_world();
    w.show();
    
    return a.exec();
}
コード例 #6
0
//The interrupt response for our phototransistor
void PhotoTransistor_InterruptResponse(void)
{
	// Clear Interrupt
	clearCaptureInterrupt(PHOTOTRANSISTOR_INTERRUPT_PARAMATERS);
	
	// Determine Capture time
	uint32_t ThisCapture = captureInterrupt(PHOTOTRANSISTOR_INTERRUPT_PARAMATERS);
	
	// Calculate period
	uint32_t Period = ((ThisCapture - LastCapture) * MICROSECONDS_DIVISOR ) / TICKS_PER_MS;
	
	//Store the Last Cpature
	LastCapture = ThisCapture;
	
	//Iterate Through the different frequency options
	for (int i = 0; i < NUMBER_BEACON_FREQUENCIES; i++)
	{
		// If the period matches a beacon period
		if (ToleranceCheck(Period, beacons[i].period, PERIOD_MEASURING_ERROR_TOLERANCE))
		{
			// If we're searching for a beacon
			if (Bucketing)
			{
				buckets[i]++;
			}
			
			// If we're supposed to align to the bucket, and the number of pulses we've seen for
			//  this beacon is greater than our threshold
			if ((AligningToBucket) && (buckets[i] >= NUMBER_PULSES_FOR_BUCKET))
			{
				// If this is the beacon corresponding to our target bucket
				if (((MyColor() == COLOR_BLUE) && (i == BEACON_INDEX_NW)) || ((MyColor() == COLOR_RED) && (i == BEACON_INDEX_SE)))
				{ 
					// stop our drive
					clearDriveAligningToBucket();
					
					// Post an aligned event
					ES_Event AlignedEvent;
					AlignedEvent.EventType = ES_ALIGNED_TO_BUCKET;
					PostMasterSM(AlignedEvent);
					
					// stop aligning
					AligningToBucket = false;
					
					// reset all buckets
					for (int j = 0; j < NUMBER_BEACON_FREQUENCIES; j++)
					{
						buckets[j] = 0;
					}
					
					// reset average information
					ResetAverage();
					
					// return to searching for beacons
					Bucketing = true;
					LastBeacon = NULL_BEACON;
					ES_Timer_StopTimer(AVERAGE_BEACONS_TIMER);
					return;
				}
			}
			// If we're not aligning to a bucket, and the number of pulses we've seen for this
			//  beacon is greater than our threshold
			else if (buckets[i] >= NUMBER_PULSES_TO_BE_ALIGNED && LastBeacon == NULL_BEACON && !AligningToBucket)
			{
				// store the beacon to be recorded
				LastBeacon = i;
				
				// reset all buckets
				for (int j = 0; j < NUMBER_BEACON_FREQUENCIES; j++)
				{
					buckets[j] = 0;
				}
				
				// restart the timer to evaluate the beacon 
				ES_Timer_InitTimer(AVERAGE_BEACONS_TIMER, AVERAGE_BEACONS_T);
				Bucketing = false;
			}
			
			// increment the sum of all encoder angles for this beacon
			sums[i] += GetPeriscopeAngle();
			
			// increment the number of pulses seen for this beacon
			numSamples[i]++;
			
			// If the evaluation timer is already running, restart it
			ES_Timer_SetTimer(AVERAGE_BEACONS_TIMER, AVERAGE_BEACONS_T);
		}
	}
		
}