How to crop a portion of my image based on color

Hey guys… I am writing a game in UE4, and want to capture a portion of my screen, crop it, to be later stored and uploaded to a server, etc.

I have made some considerable progress using the c++ version of OpenCV and doing some screen capture manipulation. That being said I feel my approach will not ultimately succeed.

My goal here is to capture only the white portion of the screen and crop it out. My solution doesn’t work because it’s screen ratio dependent.

Could anyone suggest a different approach I could pursue? Again I just want to capture the white portion of the screen and create a new image out of it

Here’s what I have accomplished so far…

`

Here’s my method …

void USBGameInstance::OnScreenCap(int32 Width, int32 Height, const TArray<FColor>& Bitmap)
{
	cv::Mat image(Height, Width, CV_8UC3); // these are reversed according to docs I have seen.

	for (int i = 0; i < Width; i++)
	{
		for (int j = 0; j < Height; j++)
		{
			cv::Vec3b px(Bitmap[i + (j*Width)].B, Bitmap[i + (j * Width)].G, Bitmap[i + (j * Width)].R);
			image.at<cv::Vec3b>(j, i) = px;
		}
	}

	float zoom = .8;
	float origWH = (float)Width / 2;
	float origHH = (float)Height / 2;
	float zoomWH = origHH * zoom * 1.2; // capture is almost box, just a bit wider
	float zoomHH = origHH * zoom;
	float xOffset = origWH * .05;
	image = image(cv::Rect(origWH-zoomWH-xOffset, origHH - zoomHH, zoomWH*2, zoomHH*2));

	cv::imshow("Window",image);

	UGameViewportClient::OnScreenshotCaptured().Remove(ocv::delegateHandle);
}