Esempio n. 1
0
static void readLabels(struct customPp *cpp, int dataStart, Chopper chopper,
	char **row, int colCount, struct labeledFile *fileList)
/* Read in first nonempty line of file and fill in labels from it. */
{
char *line;
int colsRead;
int i;
struct labeledFile *fileEl;
if ((line = customFactoryNextRealTilTrack(cpp)) == NULL)
    errAbort("%s is empty", cpp->fileStack ? cpp->fileStack->fileName : "input");
colsRead = chopper(line, row, colCount);
if (colCount != colsRead)
    {
    if (cpp->fileStack)
	errAbort("Expecting %d words line %d of %s got %d", 
	    colCount, cpp->fileStack->lineIx, cpp->fileStack->fileName, colsRead);
    else
    	errAbort("Expecting %d words got %d", 
	    colCount, colsRead);
    }
for (i=dataStart, fileEl = fileList; i < colCount; i++, fileEl = fileEl->next)
    {
    char *label = row[i];
    if (!allWhite(label))
	fileEl->label = cloneString(row[i]);
    }
}
Esempio n. 2
0
bool theLineIsLost( ){

	if(allWhite( )){
		return true;
	}else{
		// if(allBlack( )){
		// 	return true;
		// }else{
			return false;
		// }
	}
}
Esempio n. 3
0
void calibrate(uint32_t val){

	uint32_t nrOfCalibrations = 16;

	float percent = whitePercent;
	whitePercent = 0.3;

	if(allWhite( )){

		for(uint16_t i=0;i<nrOfSensors;i++){
			ADC_MIN[i]=0;
		}

		for(uint32_t i = 0; i < nrOfCalibrations; i++){
			readAdc( );
			for(uint32_t j = 0; j < nrOfSensors; j++){
				ADC_MIN[j] += ADC_avgBuff[j];
			}
		}

		for(uint16_t i=0;i<nrOfSensors;i++){
			ADC_MIN[i]=ADC_MIN[i]/nrOfCalibrations;
			ADC_DIF[i] = ADC_MAX[i] - ADC_MIN[i];
		}

	}else{

		GPIO_ToggleBits(GPIOD, GPIO_Pin_14);

		for(uint16_t i=0;i<nrOfSensors;i++){
			ADC_MAX[i]=0;
		}

		for(uint32_t i = 0; i < nrOfCalibrations; i++){
			readAdc( );
			for(uint32_t j = 0; j < nrOfSensors; j++){
				ADC_MAX[j] += ADC_avgBuff[j];
			}
		}

		for(uint16_t i=0;i<nrOfSensors;i++){
			ADC_MAX[i]=ADC_MAX[i]/nrOfCalibrations;
			ADC_DIF[i] = ADC_MAX[i] - ADC_MIN[i];
		}	
	}

	whitePercent = percent;
}
Esempio n. 4
0
// Fills obstacleGrid (one-dim array of size COL_SIZE * ROW_SIZE) with bools
// trues in the sea of falses. true means there's an obstacle.
void ImageProcessor::mapObstacles( Mat & image, bool * obstacleGrid )
{
	Mat square;
	Mat img = image;
	for( int rowid = 0; rowid < COL_SIZE; rowid++ )
	{
		for( int colid = 0; colid < ROW_SIZE; colid++ )
		{
			// the little square from the image that defines 1 "space" or cell of the big image
			square = img(Rect(colid*PIXELS_PER_SQUARE, rowid*PIXELS_PER_SQUARE, PIXELS_PER_SQUARE, PIXELS_PER_SQUARE));

			// set false if no obstacles there (all white).
			// so if anything in the little square is black, there's the edge of an obstacle.
			obstacleGrid[rowid*ROW_SIZE + colid] = !allWhite(square);
		}
	}
}