/* data DataManager handles the input and ouput of this module */ void AddListItemModule::run( DataManager& data) const { using namespace cv; // select input list dependend on the type if (data.hasInputData("stringList") || data.hasInputData("string")) { data.setOutputData("stringList", addItemToList<String, string>(data, "stringList", "string")); } if (data.hasInputData("integerList") || data.hasInputData("integer")) { data.setOutputData("integerList", addItemToList<Integer, int>(data, "integerList", "integer")); } if (data.hasInputData("floatList") || data.hasInputData("float")) { data.setOutputData("floatList", addItemToList<Float, float>(data, "floatList", "float")); } if (data.hasInputData("boolList") || data.hasInputData("bool")) { data.setOutputData("boolList", addItemToList<Bool, bool>(data, "boolList", "bool")); } if (data.hasInputData("imageList") || data.hasInputData("image")) { data.setOutputData("imageList", addItemToList<Matrix, Mat>(data, "imageList", "image")); } }
/* data DataManager handles the input and ouput of this module */ void SplitChannelsModule::run( DataManager& data) const { using namespace cv; // get a pointers to the input data Matrix::c_ptr pImage = data.getInputData<Matrix>("image"); // get the actual opencv matrix of the input data Mat image = pImage->getContent(); // split image into channels vector<Mat> channels; split(image, channels); // convert channels into abstract type std::list<Matrix::ptr> list; for(auto it = channels.begin(); it != channels.end(); ++it) { list.push_back(Matrix::ptr(new Matrix(*it))); } // set the result (output) on the datamanager data.setOutputData("channels", new List<Matrix>(list)); }
void LoadImageModule::run( DataManager& data) const { using namespace cv; Mat image; std::string strFilename = data.getParam<std::string>("filename",""); // check whether to load the image in grayscale mode, defaults to color if (data.getParam<std::string>("mode","color").compare("grayscale") == 0) { image = imread (strFilename.c_str (), CV_LOAD_IMAGE_GRAYSCALE); // Read the file } else { image = imread (strFilename.c_str (), CV_LOAD_IMAGE_COLOR); // Read the file } if (!image.data)// Check for invalid input { throw ErrorException(string("Could not open or find the image: ") + strFilename); } data.setOutputData("image",new Matrix(image)); }