so this main function shouldn't exist here and it might mess things up. Remove this and take all this code that *uses* the factory and create unit tests - make a test for each kind of conversion (ie CV_8U to double etc.) you might want to automate this or automatically generate this code.