paralleization wip
This commit is contained in:
		
							parent
							
								
									f5dad284e6
								
							
						
					
					
						commit
						b3c2d585ae
					
				
					 5 changed files with 230 additions and 237 deletions
				
			
		|  | @ -31,11 +31,12 @@ void InteligentRoi::slideRectToPoint(cv::Rect& rect, const cv::Point2i& point) | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| cv::Rect InteligentRoi::maxRect(const cv::Size2i& imageSize, std::vector<std::pair<cv::Point2i, int>> mustInclude) | ||||
| cv::Rect InteligentRoi::maxRect(bool& incompleate, const cv::Size2i& imageSize, std::vector<std::pair<cv::Point2i, int>> mustInclude) | ||||
| { | ||||
| 	int radius = std::min(imageSize.height, imageSize.width)/2; | ||||
| 	incompleate = false; | ||||
| 	int diameter = std::min(imageSize.height, imageSize.width); | ||||
| 	cv::Point2i point(imageSize.width/2, imageSize.height/2); | ||||
| 	cv::Rect candiate(point.x-radius, point.y-radius, radius*2, radius*2); | ||||
| 	cv::Rect candiate(point.x-diameter/2, point.y-diameter/2, diameter, diameter); | ||||
| 
 | ||||
| 	std::sort(mustInclude.begin(), mustInclude.end(), | ||||
| 		[&point](const std::pair<cv::Point2i, int>& a, const std::pair<cv::Point2i, int>& b){return compPointPrio(a, b, point);}); | ||||
|  | @ -43,8 +44,9 @@ cv::Rect InteligentRoi::maxRect(const cv::Size2i& imageSize, std::vector<std::pa | |||
| 	while(true) | ||||
| 	{ | ||||
| 		cv::Rect includeRect = rectFromPoints(mustInclude); | ||||
| 		if(includeRect.width-2 > radius || includeRect.height-2 > radius) | ||||
| 		if(includeRect.width-2 > diameter || includeRect.height-2 > diameter) | ||||
| 		{ | ||||
| 			incompleate = true; | ||||
| 			slideRectToPoint(candiate, mustInclude.back().first); | ||||
| 			mustInclude.pop_back(); | ||||
| 			Log(Log::DEBUG)<<"cant fill"; | ||||
|  | @ -52,7 +54,9 @@ cv::Rect InteligentRoi::maxRect(const cv::Size2i& imageSize, std::vector<std::pa | |||
| 				Log(Log::DEBUG)<<mipoint.first<<' '<<pointDist(mipoint.first, point)<<' '<<mipoint.second; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	for(const std::pair<cv::Point2i, int>& includePoint : mustInclude) | ||||
|  | @ -75,34 +79,30 @@ InteligentRoi::InteligentRoi(const Yolo& yolo) | |||
| 	personId = yolo.getClassForStr("person"); | ||||
| } | ||||
| 
 | ||||
| cv::Rect InteligentRoi::getCropRectangle(const std::vector<Yolo::Detection>& detections, const cv::Size2i& imageSize) | ||||
| bool InteligentRoi::getCropRectangle(cv::Rect& out, const std::vector<Yolo::Detection>& detections, const cv::Size2i& imageSize) | ||||
| { | ||||
| 	if(!detections.empty()) | ||||
| 	std::vector<std::pair<cv::Point2i, int>> corners; | ||||
| 	for(size_t i = 0; i < detections.size(); ++i) | ||||
| 	{ | ||||
| 		std::vector<std::pair<cv::Point2i, int>> corners; | ||||
| 		for(size_t i = 0; i < detections.size(); ++i) | ||||
| 		int priority = detections[i].priority; | ||||
| 		if(detections[i].class_id == personId) | ||||
| 		{ | ||||
| 			int priority = detections[i].priority; | ||||
| 			if(detections[i].class_id == personId) | ||||
| 			{ | ||||
| 				corners.push_back({detections[i].box.tl()+cv::Point2i(detections[i].box.width/2, 0), priority+2}); | ||||
| 				corners.push_back({detections[i].box.tl(), priority+1}); | ||||
| 				corners.push_back({detections[i].box.br(), priority}); | ||||
| 				corners.push_back({detections[i].box.tl()+cv::Point2i(detections[i].box.width, 0), priority+1}); | ||||
| 				corners.push_back({detections[i].box.br()+cv::Point2i(0-detections[i].box.width, 0), priority}); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				corners.push_back({detections[i].box.tl(), priority}); | ||||
| 				corners.push_back({detections[i].box.br(), priority}); | ||||
| 				corners.push_back({detections[i].box.tl()+cv::Point2i(detections[i].box.width, 0), priority}); | ||||
| 				corners.push_back({detections[i].box.br()+cv::Point2i(0-detections[i].box.width, 0), priority}); | ||||
| 			} | ||||
| 			corners.push_back({detections[i].box.tl()+cv::Point2i(detections[i].box.width/2, 0), priority+2}); | ||||
| 			corners.push_back({detections[i].box.tl(), priority+1}); | ||||
| 			corners.push_back({detections[i].box.br(), priority}); | ||||
| 			corners.push_back({detections[i].box.tl()+cv::Point2i(detections[i].box.width, 0), priority+1}); | ||||
| 			corners.push_back({detections[i].box.br()+cv::Point2i(0-detections[i].box.width, 0), priority}); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			corners.push_back({detections[i].box.tl(), priority}); | ||||
| 			corners.push_back({detections[i].box.br(), priority}); | ||||
| 			corners.push_back({detections[i].box.tl()+cv::Point2i(detections[i].box.width, 0), priority}); | ||||
| 			corners.push_back({detections[i].box.br()+cv::Point2i(0-detections[i].box.width, 0), priority}); | ||||
| 		} | ||||
| 
 | ||||
| 		return maxRect(imageSize, corners); | ||||
| 	} | ||||
| 
 | ||||
| 	Log(Log::DEBUG)<<"Using center crop as there are no detections"; | ||||
| 	return maxRect(imageSize); | ||||
| 	bool incompleate; | ||||
| 	out = maxRect(incompleate, imageSize, corners); | ||||
| 	return incompleate; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue