I have an optical flow algorithm which uses Updatemotionhistory but it runs on CPU. I want to check the performance of this algorithm on GPU. So i plan to use UMat. Here is a snippet
UMat gpu_motion_mask,gpu_motion_history;
motion_mask.copyTo(gpu_motion_mask);
motion_history.copyTo(gpu_motion_history);
updateMotionHistory(gpu_motion_mask, gpu_motion_history, timestamp, MHI_DURATION);
calcMotionGradient(gpu_motion_history, mg_mask, mg_orient, MIN_TIME_DELTA, MAX_TIME_DELTA, 3);
segmentMotion(gpu_motion_history, seg_mask, seg_bounds, timestamp, 32);
In the above code i converted Mat into UMat to use it in the functions. But after this i need to access the pixels in the UMat gpu_motion_history and gpu_motion_mask using at<float>.
for(int i=0; i< motion_history.cols; i++)
{
for(int j=0; j< motion_history.rows ; j++)
{
float a = motion_history.at<float>(j,i);
// cout << (a-timestamp-MHI_DURATION)/MHI_DURATION << endl;
if((a-timestamp-MHI_DURATION)/MHI_DURATION <= -5)
vis1.at<uchar>(j,i) = 0;
else
vis1.at<uchar>(j,i) = (a-timestamp-MHI_DURATION)/MHI_DURATION;
}
Issue is it thorws an error saying cv::UMat has no member named "at". Is there any way i can access the pixels in UMat?