TEST(FilteredRegionPositiveDisp, FilteredRegion)
{
	const int width = 55;
	const int disparity = 10;
	std::vector<region_interval> input {region_interval(1,10, 50), region_interval(2,10, 51), region_interval(3,45,60), region_interval(4,10, 35)};
	std::vector<region_interval> expected {region_interval(1,10,45), region_interval(2,10,45), region_interval(4,10,35)};

	std::vector<region_interval> actual = filtered_region(width, input, disparity);

	EXPECT_EQ(expected.size(), actual.size());

	EXPECT_TRUE(std::equal(expected.begin(), expected.end(), actual.begin(), actual.end()));
}
예제 #2
0
TEST(Interval, Simple3)
{
	std::vector<region_interval> base  {region_interval(0, 319, 329), region_interval(1, 318, 329), region_interval(2, 318, 329), region_interval(4, 318,329), region_interval(5, 318,329), region_interval(11, 317,318), region_interval(12, 317,318)};
	std::vector<region_interval> match {region_interval(0, 327, 328), region_interval(1, 326, 328), region_interval(2, 322, 328), region_interval(4, 321,322), region_interval(4, 323,328)};
	std::vector<region_interval> difference;
	//std::vector<RegionInterval> intersection;

	std::vector<region_interval> difference_desired {region_interval(0,319,327), region_interval(0,328,329), region_interval(1, 318, 326), region_interval(1,328,329), region_interval(2,318,322), region_interval(2,328,329), region_interval(4, 318,321), region_interval(4, 322,323), region_interval(4, 328,329), region_interval(5, 318,329), region_interval(11, 317,318), region_interval(12, 317,318)};
	std::vector<region_interval> intersection_desired {region_interval(0, 327, 328), region_interval(1, 326, 328), region_interval(2, 322, 328), region_interval(4, 321,322), region_interval(4, 323,328)};

	/*intervals::intersection(base.begin(), base.end(), match.begin(), match.end(), 0, std::back_inserter(intersection), std::back_inserter(difference));

	std::cout << std::endl << "--intersections--" << std::endl;
	std::copy(intersection.begin(), intersection.end(), std::ostream_iterator<RegionInterval>(std::cout, " "));*/

	/*std::cout << std::endl << "--difference--" << std::endl;
	std::copy(difference.begin(), difference.end(), std::ostream_iterator<RegionInterval>(std::cout, " "));
	std::cout << std::endl;*/

	//std::cout << "difference" << std::endl;
	EXPECT_TRUE(mismatch_output(difference.begin(), difference.end(), difference_desired.begin()));

	/*std::cout << "intersection" << std::endl;
	if(!mismatch_output(intersection.begin(), intersection.end(), intersection_desired.begin()))
		return false;

	std::vector<RegionInterval> diff_test;
	intervals::difference(base.begin(), base.end(), match.begin(), match.end(), 0, std::back_inserter(diff_test), true);


	std::cout << "difference2" << std::endl;
	if(!mismatch_output(diff_test.begin(), diff_test.end(), difference_desired.begin()))
		return false;*/
}
예제 #3
0
TEST(SplitRegionTest, Basic2)
{
	//rectangular case
	region_descriptor test3 = create_rectangle(cv::Rect(10,15, 10,20));
	std::vector<region_descriptor> res3;
	int ret3 = split_region(test3, 4, std::back_inserter(res3));
	EXPECT_EQ(ret3, 4);
	EXPECT_EQ(res3.size(), 4);
	EXPECT_EQ(res3[0].size(), 50);
	EXPECT_EQ(res3[1].size(), 50);
	EXPECT_EQ(res3[2].size(), 50);
	EXPECT_EQ(res3[3].size(), 50);

	//to small case (one direction)
	std::vector<region_descriptor> res4;
	int ret4 = split_region(test3, 10, std::back_inserter(res4));
	EXPECT_EQ(ret4, 2);
	EXPECT_EQ(res4.size(), 2);
	EXPECT_EQ(res4[0].size(), 100);
	EXPECT_EQ(res4[1].size(), 100);

	//irregular shaped case
	region_descriptor test5 = test3;
	test5.lineIntervals.push_back(region_interval(30,15,40));
	test5.bounding_box.width = 25;
	test5.bounding_box.height += 1;
	std::vector<region_descriptor> res5;
	int ret5 = split_region(test5, 5, std::back_inserter(res5));
	EXPECT_EQ(ret5, 4);
	EXPECT_EQ(res5.size(), 4);
}
예제 #4
0
region_descriptor create_rectangle(cv::Rect rect)
{
	region_descriptor result;
	for(int i = 0; i < rect.height; ++i)
		result.lineIntervals.push_back(region_interval(i+rect.y, rect.x, rect.x + rect.width));

	result.bounding_box = rect;
	result.m_size = rect.area();

	return result;
}
예제 #5
0
TEST(Interval, Simple1)
{
	std::vector<region_interval> base {region_interval(0, 2, 6), region_interval(0, 10, 19), region_interval(0,22,29), region_interval(0,30,36), region_interval(1,2,6), region_interval(2,4,9)};
	std::vector<region_interval> match {region_interval(0, 3,5), region_interval(0,9,13), region_interval(0,15,21), region_interval(0,23,26), region_interval(0,36, 41), region_interval(2,5,7)};
	std::vector<region_interval> difference;
	//std::vector<RegionInterval> intersection;

	std::vector<region_interval> difference_desired {region_interval(0,2,3), region_interval(0,5,6), region_interval(0, 13, 15), region_interval(0,22,23), region_interval(0,26,29), region_interval(0,30,36), region_interval(1,2,6), region_interval(2,4,5),region_interval(2, 7, 9)};
	//std::vector<RegionInterval> intersection_desired {RegionInterval(0,3,5), RegionInterval(0,10,13), RegionInterval(0,15,19), RegionInterval(0,23,26), RegionInterval(2,5,7)};

	//intervals::intersection(base.begin(), base.end(), match.begin(), match.end(), 0, std::back_inserter(intersection), std::back_inserter(difference));

	//std::cout << std::endl << "--intersections--" << std::endl;
	//std::copy(intersection.begin(), intersection.end(), std::ostream_iterator<RegionInterval>(std::cout, " "));

	/*std::cout << std::endl << "--difference--" << std::endl;
	std::copy(difference.begin(), difference.end(), std::ostream_iterator<RegionInterval>(std::cout, " "));
	std::cout << std::endl;

	std::cout << "difference" << std::endl;*/
	EXPECT_TRUE(mismatch_output(difference.begin(), difference.end(), difference_desired.begin()));

	/*std::cout << "intersection" << std::endl;
	if(!mismatch_output(intersection.begin(), intersection.end(), intersection_desired.begin()))
		return false;*/
}
예제 #6
0
void convert_minima_ranges(const cv::Mat_<value_type>& values, InserterIterator inserter, value_type threshold)
{
	auto factory = [&](std::size_t y, std::size_t lower, std::size_t upper, value_type value) {
		if(value < threshold)
		{
			*inserter = region_interval(y,lower,upper);
			++inserter;
		}
	};

	auto cmp_func = [=](value_type last, value_type current) {
		return (last > threshold && current > threshold) || (last <= threshold && current <= threshold);
	};

	intervals::convert_generic<value_type>(values, factory, cmp_func);
}