Beispiel #1
0
//called once for single image processing
bool
Decoder::processTag()
{
	if(!config->ARGS_OK ) return false;
	if(tagimage == NULL) tagimage = new Tagimage(config);
	if(!tagimage->isValid()) { 
		delete tagimage; tagimage = NULL;
		return false;
	}
	if(config->VISUAL_DEBUG) config->setDebugPixmap(new Pixmap(config->TAG_IMAGE_FILE));
	Threshold* threshold = new Threshold(config, tagimage);
	threshold->computeEdgemap();
	delete tagimage; tagimage = NULL;
	delete threshold;
	Shape *shapes = new Shape[config->MAX_SHAPES];
	Shape *anchor = new Shape(config);
	Border* border = new Border(config, shapes, anchor);
	int nshapes = border->findShapes();
	delete border;
	if( nshapes >= 12  ){
		Pattern* pattern = new Pattern(config, shapes, nshapes, anchor);
		pattern->findCodeInternal(tag);
		delete pattern;
	}
	delete anchor;
	delete [] shapes;
	return true;
}
Beispiel #2
0
//called more than once in video frame processing
bool
Decoder::processFrame(unsigned char *data, int width, int height)
{
	assert(data != NULL) ;
	assert( (data+(width*height)) != NULL) ;

	//1. Skip frame 
	if(fuzzy->selectFrame(config->V_SKIP_FRAMES) == false) {
		if(fuzzy->tagIsActive()) markCode(data, width, height, 0);
		return false;
	}

	//2.Check Motion 
	if(fuzzy->motionDetect(data, width, height) == false) { 
		if(fuzzy->tagIsActive()) markCode(data, width, height, 0);
		return false;
	}

	//3. Process Tag
	config->V_GRID_WIDTH = width;
	config->V_GRID_HEIGHT = height;
	//config->setDebugPixmap(new Pixmap("debug.jpg"));
	for(int i=0; i<12; i++) tag[i] = -1;
	Threshold* threshold = new Threshold(config, data, width, height);
	threshold->computeEdgemap();
	delete threshold;
	resetVMap(width*height);
	Shape *shapes = new Shape[config->MAX_SHAPES];
	Shape *anchor = new Shape(config);
	Border* border = new Border(config, shapes, anchor);
	int nshapes = border->findShapes();
	delete border;
	if( nshapes >= 12  ){
		Pattern* pattern = new Pattern(config, shapes, nshapes, anchor);
		pattern->findCodeExternal(tag);
		delete pattern;
	}
		
	delete anchor;
	delete [] shapes;
	bool tagvalidity = fuzzy->validateTag(tag);
	if(tagvalidity) markCode(data, width, height, 1);
	return tagvalidity;
}