<commit_before>// main.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "Utilities.h"

// Functions to load in a single image or all images
Mat loadImage(char* location, char* file);
Mat* loadImages(int numberOfImages, char* location, char** files);

// A function which temporarily resizes images before showing them
void showImage(char* name, Mat image);

// "Sign" functions - used to detect bus stop signs
Mat findSign(Mat image);
Mat binaryImage(Mat image);
Mat backProjection(Mat image, Mat yellow);
Mat getHue(Mat image);
Mat templateMatching(Mat image, Mat templateImage);

// "Number" function - used to detect the stop number from the sign
int digitRecognition(Mat image);

int _tmain(int argc, _TCHAR* argv[])
{
	cout << "Using OpenCV " << CV_VERSION << endl;
	char* testLocation = "Media/Test Images/";	// Location of bus stop sign images
	
	// Bus stop sign images
	char* testFiles[] = {
		"2809 a.jpg",
		"2809 b.jpg",
		"2830 a.jpg",
		"2830 b.jpg",
		"2838 a.jpg",
		"2838 b.jpg",
		"2838 c.jpg",
		"2838 d.jpg",
		"2839 a.jpg",
		"2839 b.jpg",
		"2839 c.jpg",
		"2839 d.jpg"
	};

	char* templateLocation = "Media/Templates/";	// Location of sample stop sign images

	// Sample stop sign images
	char* templateFiles[] = {
		"stop.png",
		"stop&no.png",
		"stop2.png",
		"stop&no2.png",
		"yellow.png"
	};

	Mat sign = loadImage(testLocation, testFiles[6]);
	Mat templateSign = loadImage(templateLocation, templateFiles[2]);
	Mat yellow = loadImage(templateLocation, templateFiles[4]);

	showImage("Bus Stop Sign", sign);
	/*Mat hsvSign = findSign(sign);
	Mat binary = binaryImage(sign);
	Mat backProjSign = backProjection(sign, yellow);
	//Mat templateMatch = templateMatching(sign, templateSign);
	Mat templateMatch = templateMatching(sign, yellow);

	showImage("HSV", hsvSign);
	showImage("Binary", binary);
	showImage("Back Projection", backProjSign);
	showImage("Template Matching", templateMatch);
	waitKey(0);*/

	Mat backProjSign = backProjection(sign, yellow);
	//showImage("Back Projection", backProjSign);
	//waitKey(0);

	int stopNumber = digitRecognition(backProjSign);

	/*int numberOfTestImages = sizeof(testFiles) / sizeof(testFiles[0]);
	Mat* busStops = loadImages(numberOfTestImages, testLocation, testFiles);
	int numberOfTemplateImages = sizeof(templateFiles) / sizeof(templateFiles[0]);
	Mat* templates = loadImages(numberOfTemplateImages, templateLocation, templateFiles);

	for (int i = 0; i < numberOfTestImages; i++) {
		cout << "Processing image " << (i + 1) << endl;
		showImage("Sign", busStops[i]);
		Mat hsvSign = findSign(busStops[i]);
		Mat binary = binaryImage(busStops[i]);
		Mat backProjSign = backProjection(busStops[i], templates[4]);
		Mat templateMatch;
		if (i == 0 || i == 1) {
			// templates[0] or templates[1]
			templateMatch = templateMatching(busStops[i], templates[0]);

		}
		else {
			// templates[2] or templates[3]
			templateMatch = templateMatching(busStops[i], templates[2]);

		}
<commit_msg>added opening to binary sign image<commit_after>// main.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "Utilities.h"

// Functions to load in a single image or all images
Mat loadImage(char* location, char* file);
Mat* loadImages(int numberOfImages, char* location, char** files);

// A function which temporarily resizes images before showing them
void showImage(char* name, Mat image);

// "Sign" functions - used to detect bus stop signs
Mat findSign(Mat image);
Mat binaryImage(Mat image);
Mat backProjection(Mat image, Mat yellow);
Mat getHue(Mat image);
Mat templateMatching(Mat image, Mat templateImage);

// "Number" function - used to detect the stop number from the sign
int digitRecognition(Mat image);

int _tmain(int argc, _TCHAR* argv[])
{
	cout << "Using OpenCV " << CV_VERSION << endl;
	char* testLocation = "Media/Test Images/";	// Location of bus stop sign images
	
	// Bus stop sign images
	char* testFiles[] = {
		"2809 a.jpg",
		"2809 b.jpg",
		"2830 a.jpg",
		"2830 b.jpg",
		"2838 a.jpg",
		"2838 b.jpg",
		"2838 c.jpg",
		"2838 d.jpg",
		"2839 a.jpg",
		"2839 b.jpg",
		"2839 c.jpg",
		"2839 d.jpg"
	};

	char* templateLocation = "Media/Templates/";	// Location of sample stop sign images

	// Sample stop sign images
	char* templateFiles[] = {
		"stop.png",
		"stop&no.png",
		"stop2.png",
		"stop&no2.png",
		"yellow.png"
	};

	Mat sign = loadImage(testLocation, testFiles[6]);
	Mat templateSign = loadImage(templateLocation, templateFiles[2]);
	Mat yellow = loadImage(templateLocation, templateFiles[4]);

	showImage("Bus Stop Sign", sign);
	/*Mat hsvSign = findSign(sign);
	Mat binary = binaryImage(sign);
	Mat backProjSign = backProjection(sign, yellow);
	//Mat templateMatch = templateMatching(sign, templateSign);
	Mat templateMatch = templateMatching(sign, yellow);

	showImage("HSV", hsvSign);
	showImage("Binary", binary);
	showImage("Back Projection", backProjSign);
	showImage("Template Matching", templateMatch);
	waitKey(0);*/

	Mat backProjSign = backProjection(sign, yellow);
	/*erode(backProjSign, backProjSign, getStructuringElement(MORPH_ELLIPSE, Size(15, 15)));
	dilate(backProjSign, backProjSign, getStructuringElement(MORPH_ELLIPSE, Size(15, 15)));*/

	/*erode(backProjSign, backProjSign, getStructuringElement(MORPH_ELLIPSE, Size(7, 7)));
	dilate(backProjSign, backProjSign, getStructuringElement(MORPH_ELLIPSE, Size(7, 7)));*/

	erode(backProjSign, backProjSign, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)));
	dilate(backProjSign, backProjSign, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)));

	showImage("Back Projection", backProjSign);
	waitKey(0);

	//int stopNumber = digitRecognition(backProjSign);

	/*int numberOfTestImages = sizeof(testFiles) / sizeof(testFiles[0]);
	Mat* busStops = loadImages(numberOfTestImages, testLocation, testFiles);
	int numberOfTemplateImages = sizeof(templateFiles) / sizeof(templateFiles[0]);
	Mat* templates = loadImages(numberOfTemplateImages, templateLocation, templateFiles);

	for (int i = 0; i < numberOfTestImages; i++) {
		cout << "Processing image " << (i + 1) << endl;
		showImage("Sign", busStops[i]);
		Mat hsvSign = findSign(busStops[i]);
		Mat binary = binaryImage(busStops[i]);
		Mat backProjSign = backProjection(busStops[i], templates[4]);
		Mat templateMatch;
		if (i == 0 || i == 1) {
			// templates[0] or templates[1]
			templateMatch = templateMatching(busStops[i], templates[0]);

		}
		else {
			// templates[2] or templates[3]
			templateMatch = templateMatching(busStops[i], templates[2]);

		}

{'fraction_non_alphanumeric': 0.14013709063214014, 'fraction_numerical': 0.023153084539223153, 'mean_word_length': 5.01833180568286, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '316639', 'n_tokens_mistral': 2359, 'n_tokens_neox': 2190, 'n_words': 595}