Exemplo n.º 1
0
moCalibrationModule::moCalibrationModule() : moModule(MO_MODULE_INPUT | MO_MODULE_OUTPUT | MO_MODULE_GUI){

	MODULE_INIT();

	// declare input/output

	this->input = NULL;
	this->output = new moDataStream("trackedblob");
	this->declareInput(0, &this->input, new moDataStreamInfo(
			"data", "trackedblob", "Data stream with type of 'trackedblob'"));
	this->declareOutput(0, &this->output, new moDataStreamInfo(
			"data", "trackedblob", "Data stream with type of 'trackedblob'"));

	this->properties["rows"] = new moProperty(3);
	this->properties["rows"]->setMin(2);
	this->properties["rows"]->addCallback(mocalibrationmodule_update_size, this);
	this->properties["cols"] = new moProperty(3);
	this->properties["cols"]->setMin(2);
	this->properties["cols"]->addCallback(mocalibrationmodule_update_size, this);
	this->properties["screenPoints"] = new moProperty(moPointList());
	this->properties["surfacePoints"] = new moProperty(moPointList());
	this->properties["surfacePoints"]->addCallback(mocalibrationmodule_triangulate, this);
	this->properties["calibrate"] = new moProperty(false);
	this->properties["calibrate"]->addCallback(mocalibrationmodule_activate_calibration, this);
	// Minimum frames that the user has to press a calibration point
	this->properties["duration_per_point"] = new moProperty(50);
	this->properties["duration_per_point"]->addCallback(mocalibrationmodule_activate_calibration, this);

	this->retriangulate = false;
	this->rect = cvRect(0, 0, 5000, 5000);
	this->storage = cvCreateMemStorage(0);
	this->active_point = 0;
	this->last_id = -1;
	this->last_finished_id = -1;
	this->current_duration = 0;
	this->current_touch = NULL;
	this->calibrated = false;

	this->subdiv = NULL;

	this->buildScreenPoints();
}
Exemplo n.º 2
0
static moPointList convertToPointList(moPropertyType type, void *val) {
	moPointList output = moPointList();
	switch ( type ) {
		case MO_PROPERTY_STRING: {
			CASTEDGET(std::string);
			std::vector<std::string> points = tokenize(value, ";");
			std::vector<std::string>::iterator it;
			for ( it = points.begin(); it != points.end(); it++ ) {
				std::vector<std::string> point = tokenize((*it), ",");
				moPoint p;

				// it's an error, not 2 points. just forget it.
				if ( point.size() != 2 )
					continue;

				// push the point into the list
				p.x = atof(point[0].c_str());
				p.y = atof(point[1].c_str());
				output.push_back(p);
			}

			return output;
		}

		case MO_PROPERTY_POINTLIST: {
			CASTEDGET(moPointList);
			return value;
		}

		// we can't do anything for other type.
		default:
			return output;
	}

	return output;
}