Commit cbfee83b authored by marina.kolpakova's avatar marina.kolpakova

test: GFF same as cpu greedy implementation

parent 49062223
...@@ -91,7 +91,7 @@ namespace { ...@@ -91,7 +91,7 @@ namespace {
int height = image.rows; int height = image.rows;
for (int j = 0; j < image.rows; ++j) for (int j = 0; j < image.rows; ++j)
for(int i = 0; i < image.cols; ++i) for (int i = 0; i < image.cols; ++i)
{ {
if (dist_labels[j * pitch + i] != -1) continue; if (dist_labels[j * pitch + i] != -1) continue;
...@@ -130,6 +130,23 @@ namespace { ...@@ -130,6 +130,23 @@ namespace {
delete[] stack; delete[] stack;
} }
void checkCorrectness(cv::Mat gpu)
{
cv::Mat diff = gpu - _labels;
int outliers = 0;
for (int j = 0; j < image.rows; ++j)
for (int i = 0; i < image.cols; ++i)
{
if ( (_labels.at<int>(j,i) == gpu.at<int>(j,i + 1)) && (diff.at<int>(j, i) != diff.at<int>(j,i + 1)))
{
outliers++;
// std::cout << j << " " << i << " " << _labels.at<int>(j,i) << " " << gpu.at<int>(j,i + 1) << " " << diff.at<int>(j, i) << " " << diff.at<int>(j,i + 1) << std::endl;
}
}
ASSERT_FALSE(outliers);
}
cv::Mat image; cv::Mat image;
cv::Mat _labels; cv::Mat _labels;
}; };
...@@ -161,10 +178,6 @@ TEST_P(Labeling, ConnectedComponents) ...@@ -161,10 +178,6 @@ TEST_P(Labeling, ConnectedComponents)
GreedyLabeling host(image); GreedyLabeling host(image);
host(host._labels); host(host._labels);
double minVal, maxVal;
cv::minMaxLoc(host._labels, &minVal, &maxVal);
std::cout << minVal << " " << maxVal << std::endl;
cv::gpu::GpuMat mask; cv::gpu::GpuMat mask;
mask.create(image.rows, image.cols, CV_8UC1); mask.create(image.rows, image.cols, CV_8UC1);
...@@ -175,25 +188,7 @@ TEST_P(Labeling, ConnectedComponents) ...@@ -175,25 +188,7 @@ TEST_P(Labeling, ConnectedComponents)
ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components)); ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components));
for (int j = 0; j + 32 < components.rows; j += 32) host.checkCorrectness(cv::Mat(components));
for (int i = 0; i + 32 < components.cols; i += 32)
{
std::cout << "Tile: " << i << " " << j << std::endl;
std::cout << cv::Mat(image, cv::Rect(i,j,32,32)) << std::endl;
std::cout << cv::Mat(host._labels, cv::Rect(i,j,32,32)) << std::endl;
// std::cout << cv::Mat(cv::Mat(components), cv::Rect(i,j,32,32)) << std::endl;
}
// for debug
// cv::imshow("test", image);
// cv::waitKey(0);
// cv::imshow("test", host._labels * 5);
// cv::waitKey(0);
// // cv::imshow("test", cv::Mat(mask) * 10);
// // cv::waitKey(0);
// cv::imshow("test", cv::Mat(components) * 2);
// cv::waitKey(0);
} }
INSTANTIATE_TEST_CASE_P(ConnectedComponents, Labeling, ALL_DEVICES); INSTANTIATE_TEST_CASE_P(ConnectedComponents, Labeling, ALL_DEVICES);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment