mirror of
https://github.com/opencv/opencv.git
synced 2026-09-25 04:09:57 +03:00
Merge pull request #29867 from vrabaud:min_empty
Fix infinite loop in warpAffine
This commit is contained in:
@@ -336,6 +336,8 @@ static inline int borderInterpolate_fast( int p, int len, int borderType )
|
|||||||
p = p < 0 ? 0 : len - 1;
|
p = p < 0 ? 0 : len - 1;
|
||||||
else if( borderType == BORDER_REFLECT || borderType == BORDER_REFLECT_101 )
|
else if( borderType == BORDER_REFLECT || borderType == BORDER_REFLECT_101 )
|
||||||
{
|
{
|
||||||
|
if( len == 1 )
|
||||||
|
return 0;
|
||||||
int delta = borderType == BORDER_REFLECT_101;
|
int delta = borderType == BORDER_REFLECT_101;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,6 +43,10 @@
|
|||||||
#include "opencv2/ts/ts_gtest.h"
|
#include "opencv2/ts/ts_gtest.h"
|
||||||
#include "test_precomp.hpp"
|
#include "test_precomp.hpp"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <future>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace opencv_test { namespace {
|
namespace opencv_test { namespace {
|
||||||
|
|
||||||
class CV_ImgWarpBaseTest : public cvtest::ArrayTest
|
class CV_ImgWarpBaseTest : public cvtest::ArrayTest
|
||||||
@@ -1199,5 +1203,31 @@ TEST(Imgproc_Warping, DISABLED_playground)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Imgproc_Warping, infinite_loop)
|
||||||
|
{
|
||||||
|
std::promise<void> promise;
|
||||||
|
auto future = promise.get_future();
|
||||||
|
|
||||||
|
std::thread worker([&promise]() {
|
||||||
|
cv::Mat src(1, 10, CV_8UC1, cv::Scalar(128));
|
||||||
|
cv::Mat dst;
|
||||||
|
cv::Matx23f M(1.f, 0.f, 0.f, 0.f, 1.f, 0.f);
|
||||||
|
|
||||||
|
cv::warpAffine(src, dst, M, cv::Size(10, 10), cv::INTER_CUBIC,
|
||||||
|
cv::BORDER_REFLECT_101);
|
||||||
|
promise.set_value();
|
||||||
|
});
|
||||||
|
|
||||||
|
auto status = future.wait_for(std::chrono::seconds(1));
|
||||||
|
if (status == std::future_status::ready) {
|
||||||
|
worker.join();
|
||||||
|
} else {
|
||||||
|
worker.detach();
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ(status, std::future_status::ready)
|
||||||
|
<< "cv::warpAffine hung in an infinite loop!";
|
||||||
|
}
|
||||||
|
|
||||||
}} // namespace
|
}} // namespace
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
|||||||
Reference in New Issue
Block a user