void BlockCornerDetector::compute(const IplImage* src, vector<CvPoint2D32f>& corners) {
	OpenCVCornerDetector* pcd = new OpenCVCornerDetector(corners_count, quality_level, min_distance);
	CvSize size = cvGetSize(src);
	int xsize = size.width / nxslice;
	int ysize = size.height / nyslice;
	IplImage* nsrc = cvCloneImage(src);
	for (int i = 0; i < nxslice; i++) {
		for (int j = 0; j < nyslice; j++) {
			vector<CvPoint2D32f> block_corners;
			cvSetImageROI(nsrc, cvRect(i * xsize, j * ysize, xsize, ysize));
			pcd->compute(nsrc, block_corners);
			addCorners(block_corners, i * xsize, j * ysize, corners);
		}
	}
	cvReleaseImage(&nsrc);
	delete pcd;
}
Пример #2
0
static int createPreviews(create_previews_args *args)
{
	unsigned int tile_count = 0;
	unsigned int tile_total = 0;
	double progress_total;
	char overlay_text[50];
	
	for (int i = 0; i < args->runs; i++) tile_total += (args->experiments[i].seg * args->experiments[i].seg * 15);
	progress_total = tile_total;
	
	for (unsigned int run = 0; run < args->runs; run++) {
		unsigned int seg = args->experiments[run].seg;
		unsigned int tiles = seg * seg * 15;
		
		previews[run] = malloc(tiles * sizeof(SDL_Surface*) );
		
		if (previews[run] == NULL) {
			// malloc(...) error
			fprintf(stderr, "Error allocating preview memory for run %d.\n", run);
			return 1;
		}
		
		sprintf(overlay_text, "%c", run + 65); // +65 for A..F
		
		for (unsigned int tile = 0; tile < tiles; tile++) {
			previews[run][tile] = addOverlayLetter(
												   addCorners(
															  scaleSurface(
																		   makeTile(tileset[run][tile], seg),
																		   args->preview_size
																		   )
															  ), // scaleSurfaceBlended takes too long!
												   overlay_text
												   );
			tile_count++;
			*args->progress = tile_count / progress_total;
		}
	}
	
	return 0;
}
Пример #3
0
int main(void)
{	
	int linesInPropertyFile = 0;
	struct property **arrayForProperties = 0;
	struct player **arrayForPlayers = 0;
	int totalLinesInPropFile = 0;
	int amntPlayers = 0;
	int *cornerPositions = malloc(sizeof(int) * SIDES);
	
	//Open /dev/urandom for rollDice
	FILE *propertyFile = fopen("/home/jordan/Documents/Programming/Monopoly Project/properties","rb");
	if(propertyFile == NULL)
	{
		puts("ERROR: error in opening file(s)");
		return 1;
	}
	linesInPropertyFile = amountOfLines(propertyFile,&totalLinesInPropFile);
	/*//DEBUG
	printf("%d is contained within \"linesInPropertyFile\"\n",linesInPropertyFile);*/
	if(createArrayOfPtrs(linesInPropertyFile,(void ***)&arrayForProperties))
	{
		puts("ERROR: error from createArrayOfPointers() :: non-zero returned");
		return 1;
	}
	/*//DEBUG
	printf("Outside Pointer: %p\n",arrayForProperties);*/
	
	if(makeArryOfPropertyPtrs(linesInPropertyFile,arrayForProperties))
	{
		puts("ERROR: error from createArrayOfPointersForProperties() :: non-zero returned");
		return 1;
	}
	if(FillArryPropertyData(arrayForProperties,linesInPropertyFile,propertyFile))
	{
		puts("ERROR: error from FillArryPropertyData() :: non-zero returned");
	}
	if(setupTmpPropertyNames(arrayForProperties,linesInPropertyFile))
	{
		puts("ERROR: error from setupTmpPropertyNames() :: non-zero returned");
	}
	if(setupPlayers(&arrayForPlayers,&amntPlayers))
	{
		puts("ERROR: error from setupPlayers() :: non-zero returned");
	}
	setFourCorners(linesInPropertyFile,cornerPositions);
	addCorners(linesInPropertyFile,cornerPositions,&arrayForProperties);
	//Set up GrahicalLoop thread.
	pthread_t glThread;
	volatile int isRunning = 1;
	void* data[4];
	data[0] = (void*)arrayForProperties;
	data[1] = (void*)arrayForPlayers;
	data[2] = (void*)&linesInPropertyFile;
	data[3] = (void*)&isRunning;
	pthread_create(&glThread,NULL,graphicalMain,(void *)data);
	
	if(gameLoop(arrayForProperties,arrayForPlayers,linesInPropertyFile,amntPlayers,cornerPositions,&isRunning))
	{
		puts("ERROR: error from gameLoop() :: non-zero returned");
	}
	
	
	//DEBUG
	/*printf("array: %p\n",arrayForProperties);
	printf("*array: %p\n",*arrayForProperties);
	printf("Lines W/O comments: %d Total lines comments: %d\n\n",linesInPropertyFile,totalLinesInPropFile);
	int i = 0;
	for(i = 0;i < 4;i++)
	{
		printf("CORNER POSITION #%d: %d\n",i,cornerPositions[i]);
	}
	for(i = 0;i < linesInPropertyFile;i++)
	{
		printf("NAME: %s\n",(arrayForProperties[i])->name);
		printf("MONEY: %d\n",(arrayForProperties[i])->value);
	}
	puts("");
	for(i = 0;i < amntPlayers;i++)
	{
		printf("NAME: %s\n",(arrayForPlayers[i])->id);
		printf("MONEY: %d\n",(arrayForPlayers[i])->money);
	}*/
	
	//free allocated memory
	int i = 0;
	for(i = 0;i < linesInPropertyFile + SIDES;i++)
	{
		if((arrayForProperties[i])->type != 1)
		{
			free((arrayForProperties[i])->name);
		}
		free(arrayForProperties[i]);
	}
	free(arrayForProperties);
	for(i = 0;i < amntPlayers;i++)
	{
		free((arrayForPlayers[i])->id);
		free(arrayForPlayers[i]);
	}
	free(arrayForPlayers);
	//Close FILE stream for /dev/urandom
	fclose(propertyFile);
	return 0;
}