ColorValidator::ColorValidator( rapidxml::xml_node<> *node, std::string name, bool debug ):
		Validator(name, debug)
{
	std::string colorspace( node->first_node("colorspace")->value() );
	_conversionFlag = ( colorspace=="hsv" )? CV_BGR2HSV : -1;

	rapidxml::xml_node<> *areaP = node->first_node("areaPercentage");
	_minAreaThershold = atof(areaP->first_node("min")->value());
	_maxAreaThershold = atof(areaP->first_node("max")->value());

	rapidxml::xml_node<> *ranges = node->first_node("range");
	for( ; ranges; ranges = ranges->next_sibling("range") )
	{
		double* minRange = new double[3]();
		rapidxml::xml_node<> *minR = ranges->first_node("minRange");
		minRange[0] = atof(minR->first_node("ch0")->value());
		minRange[1] = atof(minR->first_node("ch1")->value());
		minRange[2] = atof(minR->first_node("ch2")->value());

		double* maxRange = new double[3]();
		rapidxml::xml_node<> *maxR = ranges->first_node("maxRange");
		maxRange[0] = atof(maxR->first_node("ch0")->value());
		maxRange[1] = atof(maxR->first_node("ch1")->value());
		maxRange[2] = atof(maxR->first_node("ch2")->value());

		_ranges.push_back(std::make_pair(minRange, maxRange));
	}
}
Esempio n. 2
0
static void displayinfo(int level, unsigned char data[]){
	static const char *kind[] = {"ALPHACOLORSELECTED", "ALPHACOLORMASKED", "SPOTCHANNEL"};
	const char *indent = tabs(level);

	if(xml){
		fprintf(xml, "%s<%s>\n", indent, kind[data[12]]);
		colorspace(level+1, peek2B(data), data+2);
		fprintf(xml, "\t%s<OPACITY>%d</OPACITY>\n", indent, peek2B(data+10));
		// kind values seem to be:
		// 0 = alpha channel, colour indicates selected areas
		// 1 = alpha channel, colour indicates masked areas
		// 2 = spot colour channel
		//fprintf(xml, "\t%s<KIND>%d</KIND>\n", indent, data[12]);
		fprintf(xml, "%s</%s>\n", indent, kind[data[12]]);
	}
}