예제 #1
0
// Display the count images in bgr and compute their HSV histograms.
// Then compare each histogram to the first one and report results.
//
static void showHistogramComparisons(int count,
                                     const char *name[],
                                     const cv::Mat bgr[])
{
    std::vector<cv::Mat> hsv(count);
    std::vector<cv::Mat> histogram(count);
    for (int i = 0; i < count; ++i) {
        makeWindow(name[i], bgr[i]);
        cv::cvtColor(bgr[i], hsv[i], cv::COLOR_BGR2HSV);
    }
    for (int i = 0; i < histogram.size(); ++i) {
        histogram[i] = calculateHistogram(hsv[i]);
    }
    compareHistograms(histogram, name);
    std::cout << "Press a key to quit." << std::endl;
    cv::waitKey(0);
}
예제 #2
0
std::string letterRecognition(cv::Mat image){
	std::string letters[27] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "*" };
	cv::Mat imgDivide = image.clone();
	imgDivide = removeNoise(image);
	imgDivide = resizeImage(imgDivide);
	int letterInt = compareHistograms(imgDivide);
	//make sure its an M or an N
	if (letterInt == 13 && image.cols >= 55){
		return "M";
	}
	else if (letterInt == 12 && image.cols < 55){
		return "N";
	}
	if (letterInt == 1337)
	{
		return "Error";
	}
	return letters[letterInt];
}