<commit_before>//utils.cpp

#include "utils.h"




cv::Mat util::crop(cv::Mat matImage, cv::RotatedRect rRect){


	//It's a rotatedrect, so first get the bounding box

	cv::Rect rBounding = rRect.boundingRect();

	//Crop this off, and clone (because we rotate later)

	cv::Mat matBound = matImage(rBounding).clone();

	//Now move the rotatedrect back by the part we have cropped off due to the bounding rect
	//cv::RotatedRect rRectSmall = rRect - Point2f(2,2);//rBounding.tl();
	
	rRect.center = rRect.center - cv::Point2f(rBounding.x, rBounding.y); //add +0.5? or -0.5? or?

	float angle = rRect.angle;

	//Rotate around center
	rotate(matBound, angle, matBound);
	//imwrite("matBoundRot.png", matBound);

	cv::Size rect_size = rRect.size;
	
	//Account for rotation
	if (rRect.angle < -45.) {
		angle += 90.0;
		swap(rect_size.width, rect_size.height);
	} else  if (rRect.angle > 45.) {
		angle -= 90.0;
		swap(rect_size.width, rect_size.height);
	}

<commit_msg>Small fix in crop<commit_after>//utils.cpp

#include "utils.h"




cv::Mat util::crop(cv::Mat matImage, cv::RotatedRect rRect){


	//It's a rotatedrect, so first get the bounding box

	cv::Rect rBounding = rRect.boundingRect();

	//Constrain it
	rBounding = constrainRectInSize(rBounding, matImage.size());

	//Crop this off, and clone (because we rotate later)

	cv::Mat matBound = matImage(rBounding).clone();

	//Now move the rotatedrect back by the part we have cropped off due to the bounding rect
	//cv::RotatedRect rRectSmall = rRect - Point2f(2,2);//rBounding.tl();
	
	rRect.center = rRect.center - cv::Point2f(rBounding.x, rBounding.y); //add +0.5? or -0.5? or?

	float angle = rRect.angle;

	//Rotate around center
	rotate(matBound, angle, matBound);
	//imwrite("matBoundRot.png", matBound);

	cv::Size rect_size = rRect.size;
	
	//Account for rotation
	if (rRect.angle < -45.) {
		angle += 90.0;
		swap(rect_size.width, rect_size.height);
	} else  if (rRect.angle > 45.) {
		angle -= 90.0;
		swap(rect_size.width, rect_size.height);
	}


{'fraction_non_alphanumeric': 0.15101838052657726, 'fraction_numerical': 0.01788375558867362, 'mean_word_length': 3.772511848341232, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2694112', 'n_tokens_mistral': 801, 'n_tokens_neox': 730, 'n_words': 196}