cv::MatExpr evaluates expression when we perform task/compare rather then when we evaluate (Bug #1816)
Description
cv::MatExpr evaluates expression when we perform task/compare rather then when we actually evaluate the expression,
Example,
cv::Mat depth_map(VIDEO_FRAME_HEIGHT, VIDEO_FRAME_WIDTH, CV_8UC1, 1);
cv::Mat dist_trans(VIDEO_FRAME_HEIGHT, VIDEO_FRAME_WIDTH, CV_32FC1);
cv::circle(depth_map, cv::Point2i(320, 240), 40, cvScalar(255,255,255), 10);
cv::MatExpr mask_fg = depth_map > 1;
cv::MatExpr mask_bg = depth_map <= 1;
depth_map.setTo(0, mask_fg);
depth_map.setTo(255, mask_bg);
double min_value, max_value;
cv::minMaxLoc(depth_map, &min_value, &max_value);
std::cout<<"\nmin_value: "<<min_value<<"\tmax_value: "<<max_value; //Output: min_value: 255 max_value: 255
I am not sure if that is desire behavior, however I feel odd even if that is desire behavior.
Associated revisions
Merge pull request #1816 from SpecLad:no-more-epoch
History
Updated by Andrey Kamaev almost 13 years ago
- Priority changed from Blocker to Low
- Category set to core
Updated by Vadim Pisarevsky almost 13 years ago
MatExpr is a proxy class. It should not be used explicitly.
replace
cv::MatExpr mask_fg = depth_map > 1; cv::MatExpr mask_bg = depth_map <= 1;
with
cv::Mat mask_fg = depth_map > 1; cv::Mat mask_bg = depth_map <= 1;
and it will work as expected
- Status changed from Open to Cancelled
- Assignee set to Vadim Pisarevsky
Updated by Andrey Kamaev almost 13 years ago
- Target version set to 2.4.1