|
|
|
@ -48,6 +48,16 @@ |
|
|
|
|
|
|
|
|
|
PARAM_TEST_CASE(GlBuffer, cv::Size, MatType) |
|
|
|
|
{ |
|
|
|
|
static void SetUpTestCase() |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void TearDownTestCase() |
|
|
|
|
{ |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cv::Size size; |
|
|
|
|
int type; |
|
|
|
|
|
|
|
|
@ -60,83 +70,57 @@ PARAM_TEST_CASE(GlBuffer, cv::Size, MatType) |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, Constructor1) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf(size.height, size.width, type); |
|
|
|
|
cv::GlBuffer buf(size.height, size.width, type, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
EXPECT_EQ(size.height, buf.rows()); |
|
|
|
|
EXPECT_EQ(size.width, buf.cols()); |
|
|
|
|
EXPECT_EQ(type, buf.type()); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, Constructor2) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf(size, type); |
|
|
|
|
cv::GlBuffer buf(size, type, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
EXPECT_EQ(size.height, buf.rows()); |
|
|
|
|
EXPECT_EQ(size.width, buf.cols()); |
|
|
|
|
EXPECT_EQ(type, buf.type()); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, ConstructorFromMat) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf(gold); |
|
|
|
|
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::Mat bufData; |
|
|
|
|
buf.copyTo(bufData); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, bufData, 0); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, ConstructorFromGpuMat) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type); |
|
|
|
|
cv::gpu::GpuMat d_gold(gold); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf(d_gold); |
|
|
|
|
cv::GlBuffer buf(d_gold, cv::GlBuffer::ARRAY_BUFFER); |
|
|
|
|
|
|
|
|
|
cv::Mat bufData; |
|
|
|
|
buf.copyTo(bufData); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, bufData, 0); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
d_gold.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, ConstructorFromGlBuffer) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
cv::GlBuffer buf_gold(size, type, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf_gold(size, type); |
|
|
|
|
cv::GlBuffer buf(buf_gold); |
|
|
|
|
|
|
|
|
|
EXPECT_EQ(buf_gold.bufId(), buf.bufId()); |
|
|
|
|
EXPECT_EQ(buf_gold.rows(), buf.rows()); |
|
|
|
|
EXPECT_EQ(buf_gold.cols(), buf.cols()); |
|
|
|
|
EXPECT_EQ(buf_gold.type(), buf.type()); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
buf_gold.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, ConstructorFromGlTexture2D) |
|
|
|
@ -147,85 +131,61 @@ TEST_P(GlBuffer, ConstructorFromGlTexture2D) |
|
|
|
|
if (depth != CV_32F || cn == 2) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type, 0, 1.0); |
|
|
|
|
cv::GlTexture2D tex_gold(gold); |
|
|
|
|
cv::GlTexture2D tex_gold(gold, true); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf(tex_gold); |
|
|
|
|
cv::GlBuffer buf(tex_gold, cv::GlBuffer::PIXEL_PACK_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::Mat bufData; |
|
|
|
|
buf.copyTo(bufData); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, bufData, 1e-2); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
tex_gold.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, Create) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf; |
|
|
|
|
buf.create(size.height, size.width, type); |
|
|
|
|
buf.create(size.height, size.width, type, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
EXPECT_EQ(size.height, buf.rows()); |
|
|
|
|
EXPECT_EQ(size.width, buf.cols()); |
|
|
|
|
EXPECT_EQ(type, buf.type()); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, CopyFromMat) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf; |
|
|
|
|
buf.copyFrom(gold); |
|
|
|
|
buf.copyFrom(gold, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::Mat bufData; |
|
|
|
|
buf.copyTo(bufData); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, bufData, 0); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, CopyFromGpuMat) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type); |
|
|
|
|
cv::gpu::GpuMat d_gold(gold); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf; |
|
|
|
|
buf.copyFrom(d_gold); |
|
|
|
|
buf.copyFrom(d_gold, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::Mat bufData; |
|
|
|
|
buf.copyTo(bufData); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, bufData, 0); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
d_gold.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, CopyFromGlBuffer) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type); |
|
|
|
|
cv::GlBuffer buf_gold(gold); |
|
|
|
|
cv::GlBuffer buf_gold(gold, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf; |
|
|
|
|
buf.copyFrom(buf_gold); |
|
|
|
|
buf.copyFrom(buf_gold, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
EXPECT_NE(buf_gold.bufId(), buf.bufId()); |
|
|
|
|
|
|
|
|
@ -233,10 +193,6 @@ TEST_P(GlBuffer, CopyFromGlBuffer) |
|
|
|
|
buf.copyTo(bufData); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, bufData, 0); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
buf_gold.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, CopyFromGlTexture2D) |
|
|
|
@ -247,50 +203,38 @@ TEST_P(GlBuffer, CopyFromGlTexture2D) |
|
|
|
|
if (depth != CV_32F || cn == 2) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type, 0, 1.0); |
|
|
|
|
cv::GlTexture2D tex_gold(gold); |
|
|
|
|
cv::GlTexture2D tex_gold(gold, true); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf; |
|
|
|
|
buf.copyFrom(tex_gold); |
|
|
|
|
buf.copyFrom(tex_gold, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::Mat bufData; |
|
|
|
|
buf.copyTo(bufData); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, bufData, 1e-2); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
tex_gold.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, CopyToGpuMat) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf(gold); |
|
|
|
|
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::gpu::GpuMat dst; |
|
|
|
|
buf.copyTo(dst); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, dst, 0); |
|
|
|
|
|
|
|
|
|
dst.release(); |
|
|
|
|
buf.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, CopyToGlBuffer) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type); |
|
|
|
|
cv::GlBuffer buf(gold); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer dst; |
|
|
|
|
buf.copyTo(dst); |
|
|
|
|
buf.copyTo(dst, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
EXPECT_NE(buf.bufId(), dst.bufId()); |
|
|
|
|
|
|
|
|
@ -298,10 +242,6 @@ TEST_P(GlBuffer, CopyToGlBuffer) |
|
|
|
|
dst.copyTo(bufData); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, bufData, 0); |
|
|
|
|
|
|
|
|
|
dst.release(); |
|
|
|
|
buf.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, CopyToGlTexture2D) |
|
|
|
@ -312,32 +252,26 @@ TEST_P(GlBuffer, CopyToGlTexture2D) |
|
|
|
|
if (depth != CV_32F || cn == 2) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type, 0, 1.0); |
|
|
|
|
cv::GlBuffer buf(gold); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf(gold, cv::GlBuffer::PIXEL_PACK_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::GlTexture2D tex; |
|
|
|
|
buf.copyTo(tex); |
|
|
|
|
buf.copyTo(tex, cv::GlBuffer::PIXEL_PACK_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::Mat texData; |
|
|
|
|
tex.copyTo(texData); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, texData, 1e-2); |
|
|
|
|
|
|
|
|
|
tex.release(); |
|
|
|
|
buf.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, Clone) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type); |
|
|
|
|
cv::GlBuffer buf(gold); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer dst = buf.clone(); |
|
|
|
|
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer dst = buf.clone(cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
EXPECT_NE(buf.bufId(), dst.bufId()); |
|
|
|
|
|
|
|
|
@ -345,35 +279,26 @@ TEST_P(GlBuffer, Clone) |
|
|
|
|
dst.copyTo(bufData); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, bufData, 0); |
|
|
|
|
|
|
|
|
|
dst.release(); |
|
|
|
|
buf.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, MapHostRead) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type); |
|
|
|
|
cv::GlBuffer buf(gold); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::Mat dst = buf.mapHost(cv::GlBuffer::READ_ONLY); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, dst, 0); |
|
|
|
|
|
|
|
|
|
buf.unmapHost(); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, MapHostWrite) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type); |
|
|
|
|
cv::GlBuffer buf(size, type); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf(size, type, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::Mat dst = buf.mapHost(cv::GlBuffer::WRITE_ONLY); |
|
|
|
|
gold.copyTo(dst); |
|
|
|
@ -384,26 +309,19 @@ TEST_P(GlBuffer, MapHostWrite) |
|
|
|
|
buf.copyTo(bufData); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, bufData, 0); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlBuffer, MapDevice) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type); |
|
|
|
|
cv::GlBuffer buf(gold); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::gpu::GpuMat dst = buf.mapDevice(); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, dst, 0); |
|
|
|
|
|
|
|
|
|
buf.unmapDevice(); |
|
|
|
|
|
|
|
|
|
buf.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(OpenGL, GlBuffer, testing::Combine(DIFFERENT_SIZES, ALL_TYPES)); |
|
|
|
@ -413,6 +331,16 @@ INSTANTIATE_TEST_CASE_P(OpenGL, GlBuffer, testing::Combine(DIFFERENT_SIZES, ALL_ |
|
|
|
|
|
|
|
|
|
PARAM_TEST_CASE(GlTexture2D, cv::Size, MatType) |
|
|
|
|
{ |
|
|
|
|
static void SetUpTestCase() |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void TearDownTestCase() |
|
|
|
|
{ |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cv::Size size; |
|
|
|
|
int type; |
|
|
|
|
int depth; |
|
|
|
@ -432,213 +360,147 @@ PARAM_TEST_CASE(GlTexture2D, cv::Size, MatType) |
|
|
|
|
|
|
|
|
|
TEST_P(GlTexture2D, Constructor1) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::GlTexture2D tex(size.height, size.width, format); |
|
|
|
|
cv::GlTexture2D tex(size.height, size.width, format, true); |
|
|
|
|
|
|
|
|
|
EXPECT_EQ(size.height, tex.rows()); |
|
|
|
|
EXPECT_EQ(size.width, tex.cols()); |
|
|
|
|
EXPECT_EQ(format, tex.format()); |
|
|
|
|
|
|
|
|
|
tex.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlTexture2D, Constructor2) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::GlTexture2D tex(size, format); |
|
|
|
|
cv::GlTexture2D tex(size, format, true); |
|
|
|
|
|
|
|
|
|
EXPECT_EQ(size.height, tex.rows()); |
|
|
|
|
EXPECT_EQ(size.width, tex.cols()); |
|
|
|
|
EXPECT_EQ(format, tex.format()); |
|
|
|
|
|
|
|
|
|
tex.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlTexture2D, ConstructorFromMat) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1); |
|
|
|
|
|
|
|
|
|
cv::GlTexture2D tex(gold); |
|
|
|
|
cv::GlTexture2D tex(gold, true); |
|
|
|
|
|
|
|
|
|
cv::Mat texData; |
|
|
|
|
tex.copyTo(texData, depth); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, texData, 1e-2); |
|
|
|
|
|
|
|
|
|
tex.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlTexture2D, ConstructorFromGpuMat) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1); |
|
|
|
|
cv::gpu::GpuMat d_gold(gold); |
|
|
|
|
|
|
|
|
|
cv::GlTexture2D tex(d_gold); |
|
|
|
|
cv::GlTexture2D tex(d_gold, true); |
|
|
|
|
|
|
|
|
|
cv::Mat texData; |
|
|
|
|
tex.copyTo(texData, depth); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, texData, 1e-2); |
|
|
|
|
|
|
|
|
|
tex.release(); |
|
|
|
|
d_gold.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlTexture2D, ConstructorFromGlBuffer) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1); |
|
|
|
|
cv::GlBuffer buf_gold(gold); |
|
|
|
|
cv::GlBuffer buf_gold(gold, cv::GlBuffer::PIXEL_UNPACK_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::GlTexture2D tex(buf_gold); |
|
|
|
|
cv::GlTexture2D tex(buf_gold, true); |
|
|
|
|
|
|
|
|
|
cv::Mat texData; |
|
|
|
|
tex.copyTo(texData, depth); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, texData, 1e-2); |
|
|
|
|
|
|
|
|
|
tex.release(); |
|
|
|
|
buf_gold.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlTexture2D, ConstructorFromGlTexture2D) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::GlTexture2D tex_gold(size, format); |
|
|
|
|
cv::GlTexture2D tex_gold(size, format, true); |
|
|
|
|
cv::GlTexture2D tex(tex_gold); |
|
|
|
|
|
|
|
|
|
EXPECT_EQ(tex_gold.texId(), tex.texId()); |
|
|
|
|
EXPECT_EQ(tex_gold.rows(), tex.rows()); |
|
|
|
|
EXPECT_EQ(tex_gold.cols(), tex.cols()); |
|
|
|
|
EXPECT_EQ(tex_gold.format(), tex.format()); |
|
|
|
|
|
|
|
|
|
tex.release(); |
|
|
|
|
tex_gold.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlTexture2D, Create) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::GlTexture2D tex; |
|
|
|
|
tex.create(size.height, size.width, format); |
|
|
|
|
tex.create(size.height, size.width, format, true); |
|
|
|
|
|
|
|
|
|
EXPECT_EQ(size.height, tex.rows()); |
|
|
|
|
EXPECT_EQ(size.width, tex.cols()); |
|
|
|
|
EXPECT_EQ(format, tex.format()); |
|
|
|
|
|
|
|
|
|
tex.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlTexture2D, CopyFromMat) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1); |
|
|
|
|
|
|
|
|
|
cv::GlTexture2D tex; |
|
|
|
|
tex.copyFrom(gold); |
|
|
|
|
tex.copyFrom(gold, true); |
|
|
|
|
|
|
|
|
|
cv::Mat texData; |
|
|
|
|
tex.copyTo(texData, depth); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, texData, 1e-2); |
|
|
|
|
|
|
|
|
|
tex.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlTexture2D, CopyFromGpuMat) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1); |
|
|
|
|
cv::gpu::GpuMat d_gold(gold); |
|
|
|
|
|
|
|
|
|
cv::GlTexture2D tex; |
|
|
|
|
tex.copyFrom(d_gold); |
|
|
|
|
tex.copyFrom(d_gold, true); |
|
|
|
|
|
|
|
|
|
cv::Mat texData; |
|
|
|
|
tex.copyTo(texData, depth); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, texData, 1e-2); |
|
|
|
|
|
|
|
|
|
tex.release(); |
|
|
|
|
d_gold.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlTexture2D, CopyFromGlBuffer) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1); |
|
|
|
|
cv::GlBuffer buf_gold(gold); |
|
|
|
|
cv::GlBuffer buf_gold(gold, cv::GlBuffer::PIXEL_UNPACK_BUFFER, true); |
|
|
|
|
|
|
|
|
|
cv::GlTexture2D tex; |
|
|
|
|
tex.copyFrom(buf_gold); |
|
|
|
|
tex.copyFrom(buf_gold, true); |
|
|
|
|
|
|
|
|
|
cv::Mat texData; |
|
|
|
|
tex.copyTo(texData, depth); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, texData, 1e-2); |
|
|
|
|
|
|
|
|
|
tex.release(); |
|
|
|
|
buf_gold.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlTexture2D, CopyToGpuMat) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1); |
|
|
|
|
|
|
|
|
|
cv::GlTexture2D tex(gold); |
|
|
|
|
cv::GlTexture2D tex(gold, true); |
|
|
|
|
|
|
|
|
|
cv::gpu::GpuMat dst; |
|
|
|
|
tex.copyTo(dst, depth); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, dst, 1e-2); |
|
|
|
|
|
|
|
|
|
dst.release(); |
|
|
|
|
tex.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(GlTexture2D, CopyToGlBuffer) |
|
|
|
|
{ |
|
|
|
|
cv::namedWindow("test", cv::WINDOW_OPENGL); |
|
|
|
|
|
|
|
|
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1); |
|
|
|
|
|
|
|
|
|
cv::GlTexture2D tex(gold); |
|
|
|
|
cv::GlTexture2D tex(gold, true); |
|
|
|
|
|
|
|
|
|
cv::GlBuffer dst; |
|
|
|
|
tex.copyTo(dst, depth); |
|
|
|
|
tex.copyTo(dst, depth, true); |
|
|
|
|
|
|
|
|
|
cv::Mat bufData; |
|
|
|
|
dst.copyTo(bufData); |
|
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(gold, bufData, 1e-2); |
|
|
|
|
|
|
|
|
|
dst.release(); |
|
|
|
|
tex.release(); |
|
|
|
|
cv::destroyAllWindows(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(OpenGL, GlTexture2D, testing::Combine(DIFFERENT_SIZES, testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4))); |
|
|
|
|