mirror of
https://github.com/opencv/opencv.git
synced 2024-12-04 08:49:14 +08:00
42 lines
982 B
C++
42 lines
982 B
C++
// This file is part of OpenCV project.
|
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
// of this distribution and at http://opencv.org/license.html
|
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
namespace opencv_test
|
|
{
|
|
using namespace perf;
|
|
|
|
typedef perf::TestBaseWithParam<std::string> PNG;
|
|
|
|
PERF_TEST(PNG, decode)
|
|
{
|
|
String filename = getDataPath("perf/2560x1600.png");
|
|
|
|
FILE *f = fopen(filename.c_str(), "rb");
|
|
fseek(f, 0, SEEK_END);
|
|
long len = ftell(f);
|
|
fseek(f, 0, SEEK_SET);
|
|
vector<uchar> file_buf((size_t)len);
|
|
EXPECT_EQ(len, (long)fread(&file_buf[0], 1, (size_t)len, f));
|
|
fclose(f); f = NULL;
|
|
|
|
TEST_CYCLE() imdecode(file_buf, IMREAD_UNCHANGED);
|
|
|
|
SANITY_CHECK_NOTHING();
|
|
}
|
|
|
|
PERF_TEST(PNG, encode)
|
|
{
|
|
String filename = getDataPath("perf/2560x1600.png");
|
|
cv::Mat src = imread(filename);
|
|
|
|
vector<uchar> buf;
|
|
TEST_CYCLE() imencode(".png", src, buf);
|
|
|
|
SANITY_CHECK_NOTHING();
|
|
}
|
|
|
|
} // namespace
|