faster X/Y matrix creation
Hi!
Is there more efficient way in OpenCV to create a MxN CV_32FC2 matrix than this?
// create XY 2D array
// (((0, 0), (1, 0), (2, 0), ...),
// ((0, 1), (1, 1), (2, 1), ...),
// ...)
cv::Mat xy(img_size, CV_32FC2);
float *pxy = (float*)xy.data;
for (int y = 0; y < img_size.height; y++)
for (int x = 0; x < img_size.width; x++)
{
*pxy++ = x;
*pxy++ = y;
}
I need it as a base for cv::perspectiveTransform() (see this post). Any speedup is welcome.
Thanks.
just curious, read the blogpost, so how long does the whole procedure take ? i got the impression, that all of it is pretty much constant, and might need run only once .
The whole perspective_to_maps() function takes less then 2 seconds on BeagleBone Black for a 1280x720 matrix. The shooting target project is very sensitive to short response times (shooters are very impatient people) and the camera position might be variable in the future. So I'm looking for every bit of time which might be spared.
hmm the camera position /direction does not matter, the only input to your function are the persp. matrix and the img size.