mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 20:09:23 +08:00
All tests writing temporary files are updated to use cv::tempfile() function
This commit is contained in:
parent
ec3a7665b0
commit
d9c74f63e1
@ -473,20 +473,59 @@ string format( const char* fmt, ... )
|
||||
|
||||
string tempfile( const char* suffix )
|
||||
{
|
||||
char buf[L_tmpnam];
|
||||
char* name = 0;
|
||||
#ifdef ANDROID
|
||||
strcpy(buf, "/sdcard/__opencv_temp_XXXXXX");
|
||||
name = mktemp(buf);
|
||||
#else
|
||||
name = tmpnam(buf);
|
||||
#endif
|
||||
if (*name == '\\')
|
||||
++name;
|
||||
string n(name);
|
||||
if (suffix != 0)
|
||||
n += (n[n.size()-1] == '.' && suffix[0] == '.' ? suffix + 1 : suffix);
|
||||
return n;
|
||||
#if defined WIN32 || defined _WIN32
|
||||
char temp_dir[MAX_PATH + 1] = { 0 };
|
||||
char temp_file[MAX_PATH + 1] = { 0 };
|
||||
|
||||
::GetTempPathA(sizeof(temp_dir), temp_dir);
|
||||
if(0 != ::GetTempFileNameA(temp_dir, "__opencv_temp.", 0, temp_file))
|
||||
return string();
|
||||
|
||||
string name = temp_file;
|
||||
if(suffix)
|
||||
{
|
||||
if (suffix[0] != '.')
|
||||
return name + "." + suffix;
|
||||
else
|
||||
return name + suffix;
|
||||
}
|
||||
else
|
||||
return name;
|
||||
# else
|
||||
# ifdef ANDROID
|
||||
//char defaultTemplate[] = "/mnt/sdcard/__opencv_temp.XXXXXX";
|
||||
char defaultTemplate[] = "/data/local/tmp/__opencv_temp.XXXXXX";
|
||||
# else
|
||||
char defaultTemplate[] = "/tmp/__opencv_temp.XXXXXX";
|
||||
# endif
|
||||
|
||||
string fname;
|
||||
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
|
||||
if(temp_dir == 0 || temp_dir[0] == 0)
|
||||
fname = defaultTemplate;
|
||||
else
|
||||
{
|
||||
fname = temp_dir;
|
||||
char ech = fname[fname.size() - 1];
|
||||
if(ech != '/' && ech != '\\')
|
||||
fname += "/";
|
||||
fname += "__opencv_temp.XXXXXX";
|
||||
}
|
||||
|
||||
const int fd = mkstemp((char*)fname.c_str());
|
||||
if(fd == -1) return "";
|
||||
close(fd);
|
||||
remove(fname.c_str());
|
||||
|
||||
if(suffix)
|
||||
{
|
||||
if (suffix[0] != '.')
|
||||
fname = fname + "." + suffix;
|
||||
else
|
||||
fname += suffix;
|
||||
}
|
||||
return fname;
|
||||
# endif
|
||||
}
|
||||
|
||||
static CvErrorCallback customErrorCallback = 0;
|
||||
|
@ -560,7 +560,7 @@ static void inRange(const Mat& src, const Mat& lb, const Mat& rb, Mat& dst)
|
||||
NAryMatIterator it(arrays, planes);
|
||||
size_t total = planes[0].total();
|
||||
size_t i, nplanes = it.nplanes;
|
||||
int depth = src.depth(), cn = src.channels();
|
||||
int depth = src.depth(), cn = src.channels();
|
||||
|
||||
for( i = 0; i < nplanes; i++, ++it )
|
||||
{
|
||||
@ -608,7 +608,7 @@ static void inRangeS(const Mat& src, const Scalar& lb, const Scalar& rb, Mat& ds
|
||||
NAryMatIterator it(arrays, planes);
|
||||
size_t total = planes[0].total();
|
||||
size_t i, nplanes = it.nplanes;
|
||||
int depth = src.depth(), cn = src.channels();
|
||||
int depth = src.depth(), cn = src.channels();
|
||||
union { double d[4]; float f[4]; int i[4];} lbuf, rbuf;
|
||||
int wtype = CV_MAKETYPE(depth <= CV_32S ? CV_32S : depth, cn);
|
||||
scalarToRawData(lb, lbuf.d, wtype, cn);
|
||||
@ -903,7 +903,7 @@ static void exp(const Mat& src, Mat& dst)
|
||||
NAryMatIterator it(arrays, planes);
|
||||
size_t j, total = planes[0].total()*src.channels();
|
||||
size_t i, nplanes = it.nplanes;
|
||||
int depth = src.depth();
|
||||
int depth = src.depth();
|
||||
|
||||
for( i = 0; i < nplanes; i++, ++it )
|
||||
{
|
||||
@ -932,7 +932,7 @@ static void log(const Mat& src, Mat& dst)
|
||||
NAryMatIterator it(arrays, planes);
|
||||
size_t j, total = planes[0].total()*src.channels();
|
||||
size_t i, nplanes = it.nplanes;
|
||||
int depth = src.depth();
|
||||
int depth = src.depth();
|
||||
|
||||
for( i = 0; i < nplanes; i++, ++it )
|
||||
{
|
||||
@ -1022,7 +1022,7 @@ static void cartToPolar(const Mat& mx, const Mat& my, Mat& mmag, Mat& mangle, bo
|
||||
NAryMatIterator it(arrays, planes);
|
||||
size_t j, total = planes[0].total();
|
||||
size_t i, nplanes = it.nplanes;
|
||||
int depth = mx.depth();
|
||||
int depth = mx.depth();
|
||||
double scale = angleInDegrees ? 180/CV_PI : 1;
|
||||
|
||||
for( i = 0; i < nplanes; i++, ++it )
|
||||
@ -1364,7 +1364,7 @@ TEST_P(ElemWiseTest, accuracy)
|
||||
|
||||
double maxErr = op->getMaxErr(depth);
|
||||
vector<int> pos;
|
||||
ASSERT_PRED_FORMAT2(cvtest::MatComparator(maxErr, op->context), dst0, dst) << "\nsrc[0] ~ " << cvtest::MatInfo(!src.empty() ? src[0] : Mat()) << "\ntestCase #" << testIdx << "\n";
|
||||
ASSERT_PRED_FORMAT2(cvtest::MatComparator(maxErr, op->context), dst0, dst) << "\nsrc[0] ~ " << cvtest::MatInfo(!src.empty() ? src[0] : Mat()) << "\ntestCase #" << testIdx << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,8 @@ protected:
|
||||
{
|
||||
try
|
||||
{
|
||||
FileStorage fs("test.xml", FileStorage::WRITE);
|
||||
string fname = cv::tempfile(".xml");
|
||||
FileStorage fs(fname, FileStorage::WRITE);
|
||||
vector<int> mi, mi2, mi3, mi4;
|
||||
vector<Mat> mv, mv2, mv3, mv4;
|
||||
Mat m(10, 9, CV_32F);
|
||||
@ -403,7 +404,7 @@ protected:
|
||||
fs << "mv3" << mv3;
|
||||
fs << "empty" << empty;
|
||||
fs.release();
|
||||
fs.open("test.xml", FileStorage::READ);
|
||||
fs.open(fname, FileStorage::READ);
|
||||
fs["mi"] >> mi2;
|
||||
fs["mv"] >> mv2;
|
||||
fs["mi3"] >> mi4;
|
||||
@ -439,7 +440,7 @@ protected:
|
||||
int N = 1000, M = 1200000;
|
||||
Mat mat(M, N, CV_32F);
|
||||
rng.fill(mat, RNG::UNIFORM, 0, 1);
|
||||
FileStorage fs("test.xml", FileStorage::WRITE);
|
||||
FileStorage fs(cv::tempfile(".xml"), FileStorage::WRITE);
|
||||
fs << "mat" << mat;
|
||||
fs.release();
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ public:
|
||||
float patternScale = 22.0f,
|
||||
int nOctaves = 4,
|
||||
const vector<int>& selectedPairs = vector<int>());
|
||||
FREAK( const FREAK& rhs );
|
||||
FREAK( const FREAK& rhs );
|
||||
FREAK& operator=( const FREAK& );
|
||||
|
||||
virtual ~FREAK();
|
||||
@ -349,20 +349,20 @@ public:
|
||||
vector<int> selectPairs( const vector<Mat>& images, vector<vector<KeyPoint> >& keypoints,
|
||||
const double corrThresh = 0.7, bool verbose = true );
|
||||
|
||||
AlgorithmInfo* info() const;
|
||||
AlgorithmInfo* info() const;
|
||||
|
||||
enum
|
||||
{
|
||||
NB_SCALES = 64, NB_PAIRS = 512, NB_ORIENPAIRS = 45
|
||||
};
|
||||
enum
|
||||
{
|
||||
NB_SCALES = 64, NB_PAIRS = 512, NB_ORIENPAIRS = 45
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
|
||||
void buildPattern();
|
||||
uchar meanIntensity( const Mat& image, const Mat& integral, const float kp_x, const float kp_y,
|
||||
void buildPattern();
|
||||
uchar meanIntensity( const Mat& image, const Mat& integral, const float kp_x, const float kp_y,
|
||||
const unsigned int scale, const unsigned int rot, const unsigned int point ) const;
|
||||
|
||||
bool orientationNormalized; //true if the orientation is normalized, false otherwise
|
||||
bool orientationNormalized; //true if the orientation is normalized, false otherwise
|
||||
bool scaleNormalized; //true if the scale is normalized, false otherwise
|
||||
double patternScale; //scaling of the pattern
|
||||
int nOctaves; //number of octaves
|
||||
@ -372,28 +372,28 @@ protected:
|
||||
int nOctaves0;
|
||||
vector<int> selectedPairs0;
|
||||
|
||||
struct PatternPoint
|
||||
{
|
||||
float x; // x coordinate relative to center
|
||||
float y; // x coordinate relative to center
|
||||
float sigma; // Gaussian smoothing sigma
|
||||
};
|
||||
struct PatternPoint
|
||||
{
|
||||
float x; // x coordinate relative to center
|
||||
float y; // x coordinate relative to center
|
||||
float sigma; // Gaussian smoothing sigma
|
||||
};
|
||||
|
||||
struct DescriptionPair
|
||||
{
|
||||
uchar i; // index of the first point
|
||||
uchar j; // index of the second point
|
||||
};
|
||||
struct DescriptionPair
|
||||
{
|
||||
uchar i; // index of the first point
|
||||
uchar j; // index of the second point
|
||||
};
|
||||
|
||||
struct OrientationPair
|
||||
{
|
||||
uchar i; // index of the first point
|
||||
uchar j; // index of the second point
|
||||
int weight_dx; // dx/(norm_sq))*4096
|
||||
int weight_dy; // dy/(norm_sq))*4096
|
||||
};
|
||||
struct OrientationPair
|
||||
{
|
||||
uchar i; // index of the first point
|
||||
uchar j; // index of the second point
|
||||
int weight_dx; // dx/(norm_sq))*4096
|
||||
int weight_dy; // dy/(norm_sq))*4096
|
||||
};
|
||||
|
||||
vector<PatternPoint> patternLookup; // look-up table for the pattern points (position+sigma of all points at all scales and orientation)
|
||||
vector<PatternPoint> patternLookup; // look-up table for the pattern points (position+sigma of all points at all scales and orientation)
|
||||
int patternSizes[NB_SCALES]; // size of the pattern at a specific scale (used to check if a point is within image boundaries)
|
||||
DescriptionPair descriptionPairs[NB_PAIRS];
|
||||
OrientationPair orientationPairs[NB_ORIENPAIRS];
|
||||
@ -641,8 +641,8 @@ protected:
|
||||
class CV_EXPORTS AdjusterAdapter: public FeatureDetector
|
||||
{
|
||||
public:
|
||||
/** pure virtual interface
|
||||
*/
|
||||
/** pure virtual interface
|
||||
*/
|
||||
virtual ~AdjusterAdapter() {}
|
||||
/** too few features were detected so, adjust the detector params accordingly
|
||||
* \param min the minimum number of desired features
|
||||
@ -682,7 +682,7 @@ public:
|
||||
/** \param adjuster an AdjusterAdapter that will do the detection and parameter adjustment
|
||||
* \param max_features the maximum desired number of features
|
||||
* \param max_iters the maximum number of times to try to adjust the feature detector params
|
||||
* for the FastAdjuster this can be high, but with Star or Surf this can get time consuming
|
||||
* for the FastAdjuster this can be high, but with Star or Surf this can get time consuming
|
||||
* \param min_features the minimum desired features
|
||||
*/
|
||||
DynamicAdaptedFeatureDetector( const Ptr<AdjusterAdapter>& adjuster, int min_features=400, int max_features=500, int max_iters=5 );
|
||||
@ -693,8 +693,8 @@ protected:
|
||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||
|
||||
private:
|
||||
DynamicAdaptedFeatureDetector& operator=(const DynamicAdaptedFeatureDetector&);
|
||||
DynamicAdaptedFeatureDetector(const DynamicAdaptedFeatureDetector&);
|
||||
DynamicAdaptedFeatureDetector& operator=(const DynamicAdaptedFeatureDetector&);
|
||||
DynamicAdaptedFeatureDetector(const DynamicAdaptedFeatureDetector&);
|
||||
|
||||
int escape_iters_;
|
||||
int min_features_, max_features_;
|
||||
@ -792,7 +792,7 @@ public:
|
||||
virtual bool empty() const;
|
||||
|
||||
protected:
|
||||
virtual void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
|
||||
virtual void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
|
||||
|
||||
Ptr<DescriptorExtractor> descriptorExtractor;
|
||||
};
|
||||
@ -962,7 +962,7 @@ class CV_EXPORTS_W DescriptorMatcher : public Algorithm
|
||||
public:
|
||||
virtual ~DescriptorMatcher();
|
||||
|
||||
/*
|
||||
/*
|
||||
* Add descriptors to train descriptor collection.
|
||||
* descriptors Descriptors to add. Each descriptors[i] is a descriptors set from one image.
|
||||
*/
|
||||
@ -1078,7 +1078,7 @@ protected:
|
||||
static bool isMaskedOut( const vector<Mat>& masks, int queryIdx );
|
||||
|
||||
static Mat clone_op( Mat m ) { return m.clone(); }
|
||||
void checkMasks( const vector<Mat>& masks, int queryDescriptorsCount ) const;
|
||||
void checkMasks( const vector<Mat>& masks, int queryDescriptorsCount ) const;
|
||||
|
||||
// Collection of descriptors from train images.
|
||||
vector<Mat> trainDescCollection;
|
||||
|
@ -529,7 +529,7 @@ GPU_PERF_TEST(VideoWriter, cv::gpu::DeviceInfo, std::string)
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1));
|
||||
std::string outputFile = inputFile.substr(0, inputFile.find('.')) + "_test.avi";
|
||||
std::string outputFile = cv::tempfile(".avi");
|
||||
|
||||
cv::VideoCapture reader(inputFile);
|
||||
ASSERT_TRUE( reader.isOpened() );
|
||||
|
@ -338,7 +338,7 @@ GPU_PERF_TEST(VideoWriter, cv::gpu::DeviceInfo, std::string)
|
||||
const double FPS = 25.0;
|
||||
|
||||
std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1));
|
||||
std::string outputFile = inputFile.substr(0, inputFile.find('.')) + "_test.avi";
|
||||
std::string outputFile = cv::tempfile(".avi");
|
||||
|
||||
cv::VideoCapture reader(inputFile);
|
||||
ASSERT_TRUE( reader.isOpened() );
|
||||
|
@ -687,7 +687,7 @@ PARAM_TEST_CASE(VideoWriter, cv::gpu::DeviceInfo, std::string)
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "video/" + inputFile;
|
||||
outputFile = inputFile.substr(0, inputFile.find('.')) + "_test.avi";
|
||||
outputFile = cv::tempfile(".avi");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
ts->printf(cvtest::TS::LOG, "finish reading big image\n");
|
||||
if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
|
||||
ts->printf(cvtest::TS::LOG, "start writing big image\n");
|
||||
imwrite(string(ts->get_data_path()) + "readwrite/write.png", img);
|
||||
imwrite(cv::tempfile(".png"), img);
|
||||
ts->printf(cvtest::TS::LOG, "finish writing big image\n");
|
||||
}
|
||||
catch(...)
|
||||
@ -72,10 +72,14 @@ public:
|
||||
|
||||
string ext_from_int(int ext)
|
||||
{
|
||||
#ifdef HAVE_PNG
|
||||
if (ext == 0) return ".png";
|
||||
#endif
|
||||
if (ext == 1) return ".bmp";
|
||||
if (ext == 2) return ".pgm";
|
||||
#ifdef HAVE_TIFF
|
||||
if (ext == 3) return ".tiff";
|
||||
#endif
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -92,16 +96,21 @@ public:
|
||||
for (int k = 1; k <= 5; ++k)
|
||||
{
|
||||
for (int ext = 0; ext < 4; ++ext) // 0 - png, 1 - bmp, 2 - pgm, 3 - tiff
|
||||
{
|
||||
if(ext_from_int(ext).empty())
|
||||
continue;
|
||||
for (int num_channels = 1; num_channels <= 3; num_channels+=2)
|
||||
{
|
||||
ts->printf(ts->LOG, "image type depth:%d channels:%d ext: %s\n", CV_8U, num_channels, ext_from_int(ext).c_str());
|
||||
Mat img(img_r * k, img_c * k, CV_MAKETYPE(CV_8U, num_channels), Scalar::all(0));
|
||||
circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), cv::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255));
|
||||
ts->printf(ts->LOG, "writing image : %s\n", string(string(ts->get_data_path()) + "readwrite/test" + ext_from_int(ext)).c_str());
|
||||
imwrite(string(ts->get_data_path()) + "readwrite/test" + ext_from_int(ext), img);
|
||||
ts->printf(ts->LOG, "reading test image : %s\n", string(string(ts->get_data_path()) + "readwrite/test" + ext_from_int(ext)).c_str());
|
||||
|
||||
Mat img_test = imread(string(ts->get_data_path()) + "readwrite/test" + ext_from_int(ext), CV_LOAD_IMAGE_UNCHANGED);
|
||||
string img_path = cv::tempfile(ext_from_int(ext).c_str());
|
||||
ts->printf(ts->LOG, "writing image : %s\n", img_path.c_str());
|
||||
imwrite(img_path, img);
|
||||
|
||||
ts->printf(ts->LOG, "reading test image : %s\n", img_path.c_str());
|
||||
Mat img_test = imread(img_path, CV_LOAD_IMAGE_UNCHANGED);
|
||||
|
||||
if (img_test.empty()) ts->set_failed_test_info(ts->FAIL_MISMATCH);
|
||||
|
||||
@ -115,14 +124,17 @@ public:
|
||||
ts->set_failed_test_info(ts->FAIL_MISMATCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
for (int num_channels = 1; num_channels <= 3; num_channels+=2)
|
||||
{
|
||||
// jpeg
|
||||
ts->printf(ts->LOG, "image type depth:%d channels:%d ext: %s\n", CV_8U, num_channels, ".jpg");
|
||||
Mat img(img_r * k, img_c * k, CV_MAKETYPE(CV_8U, num_channels), Scalar::all(0));
|
||||
circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), cv::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255));
|
||||
string filename = string(ts->get_data_path() + "readwrite/test_" + char(k + 48) + "_c" + char(num_channels + 48) + "_.jpg");
|
||||
|
||||
string filename = cv::tempfile(".jpg");
|
||||
imwrite(filename, img);
|
||||
img = imread(filename, CV_LOAD_IMAGE_UNCHANGED);
|
||||
|
||||
@ -142,14 +154,17 @@ public:
|
||||
ts->set_failed_test_info(ts->FAIL_MISMATCH);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIFF
|
||||
for (int num_channels = 1; num_channels <= 3; num_channels+=2)
|
||||
{
|
||||
// tiff
|
||||
ts->printf(ts->LOG, "image type depth:%d channels:%d ext: %s\n", CV_16U, num_channels, ".tiff");
|
||||
Mat img(img_r * k, img_c * k, CV_MAKETYPE(CV_16U, num_channels), Scalar::all(0));
|
||||
circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), cv::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255));
|
||||
string filename = string(ts->get_data_path() + "readwrite/test.tiff");
|
||||
|
||||
string filename = cv::tempfile(".tiff");
|
||||
imwrite(filename, img);
|
||||
ts->printf(ts->LOG, "reading test image : %s\n", filename.c_str());
|
||||
Mat img_test = imread(filename, CV_LOAD_IMAGE_UNCHANGED);
|
||||
@ -171,6 +186,7 @@ public:
|
||||
ts->set_failed_test_info(ts->FAIL_MISMATCH);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch(const cv::Exception & e)
|
||||
@ -205,9 +221,7 @@ public:
|
||||
TEST(Highgui_Image, write_big) { CV_GrfmtWriteBigImageTest test; test.safe_run(); }
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PNG) && defined(HAVE_TIFF) && defined(HAVE_JPEG)
|
||||
TEST(Highgui_Image, write_imageseq) { CV_GrfmtWriteSequenceImageTest test; test.safe_run(); }
|
||||
#endif
|
||||
|
||||
TEST(Highgui_Image, read_bmp_rle8) { CV_GrfmtReadBMPRLE8Test test; test.safe_run(); }
|
||||
|
||||
|
@ -155,7 +155,7 @@ void CV_HighGuiTest::ImageTest(const string& dir)
|
||||
for(size_t i = 0; i < ext_num; ++i)
|
||||
{
|
||||
string ext = exts[i];
|
||||
string full_name = "img." + ext;
|
||||
string full_name = cv::tempfile(ext.c_str());
|
||||
ts->printf(ts->LOG, " full_name : %s\n", full_name.c_str());
|
||||
|
||||
imwrite(full_name, image);
|
||||
@ -225,7 +225,7 @@ void CV_HighGuiTest::ImageTest(const string& dir)
|
||||
void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt)
|
||||
{
|
||||
string src_file = dir + "../cv/shared/video_for_test.avi";
|
||||
string tmp_name = format("video_%s.%s", cvtest::fourccToString(fmt.fourcc).c_str(), fmt.ext.c_str());
|
||||
string tmp_name = cv::tempfile((cvtest::fourccToString(fmt.fourcc) + "." + fmt.ext).c_str());
|
||||
|
||||
ts->printf(ts->LOG, "reading video : %s and converting it to %s\n", src_file.c_str(), tmp_name.c_str());
|
||||
|
||||
@ -291,8 +291,8 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
|
||||
if (psnr < thresDbell)
|
||||
{
|
||||
printf("Too low psnr = %gdb\n", psnr);
|
||||
imwrite("img.png", img);
|
||||
imwrite("img1.png", img1);
|
||||
// imwrite("img.png", img);
|
||||
// imwrite("img1.png", img1);
|
||||
ts->set_failed_test_info(ts->FAIL_MISMATCH);
|
||||
break;
|
||||
}
|
||||
@ -323,7 +323,7 @@ void CV_HighGuiTest::SpecificImageTest(const string& dir)
|
||||
|
||||
stringstream s_digit; s_digit << i;
|
||||
|
||||
string full_name = "img_"+s_digit.str()+".bmp";
|
||||
string full_name = cv::tempfile((s_digit.str() + ".bmp").c_str());
|
||||
ts->printf(ts->LOG, " full_name : %s\n", full_name.c_str());
|
||||
|
||||
imwrite(full_name, image);
|
||||
@ -395,7 +395,7 @@ void CV_HighGuiTest::SpecificVideoTest(const string& dir, const cvtest::VideoFor
|
||||
int fourcc = fmt.fourcc;
|
||||
|
||||
string fourcc_str = cvtest::fourccToString(fourcc);
|
||||
const string video_file = "video_" + fourcc_str + "." + ext;
|
||||
const string video_file = cv::tempfile((fourcc_str + "." + ext).c_str());
|
||||
|
||||
Size frame_size(968 & -2, 757 & -2);
|
||||
VideoWriter writer(video_file, fourcc, 25, frame_size, true);
|
||||
|
@ -65,13 +65,11 @@ public:
|
||||
|
||||
string getFilename(const cvtest::VideoFormat& fmt)
|
||||
{
|
||||
return format("test_video_%s.%s", cvtest::fourccToString(fmt.fourcc).c_str(), fmt.ext.c_str());
|
||||
return cv::tempfile((cvtest::fourccToString(fmt.fourcc) + "." + fmt.ext).c_str());
|
||||
}
|
||||
|
||||
bool CreateTestVideo(const cvtest::VideoFormat& fmt, int framecount)
|
||||
bool CreateTestVideo(const cvtest::VideoFormat& fmt, int framecount, string filename)
|
||||
{
|
||||
string filename = getFilename(fmt);
|
||||
|
||||
VideoWriter writer(filename, fmt.fourcc, 25, framesize, true);
|
||||
if( !writer.isOpened() )
|
||||
return false;
|
||||
@ -96,7 +94,7 @@ public:
|
||||
string filename = getFilename(fmt);
|
||||
ts->printf(ts->LOG, "\nFile: %s\n", filename.c_str());
|
||||
|
||||
if( !CreateTestVideo(fmt, n_frames) )
|
||||
if( !CreateTestVideo(fmt, n_frames, filename) )
|
||||
{
|
||||
ts->printf(ts->LOG, "\nError: cannot create video file");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
@ -145,8 +143,8 @@ public:
|
||||
idx1, idx);
|
||||
ts->printf(ts->LOG, "Saving both frames ...\n");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
imwrite("opencv_test_highgui_postest_actual.png", img);
|
||||
imwrite("opencv_test_highgui_postest_expected.png", img0);
|
||||
// imwrite("opencv_test_highgui_postest_actual.png", img);
|
||||
// imwrite("opencv_test_highgui_postest_expected.png", img0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -164,8 +162,8 @@ public:
|
||||
ts->printf(ts->LOG, "The frame read after positioning to %d is incorrect (PSNR=%g)\n", idx, err);
|
||||
ts->printf(ts->LOG, "Saving both frames ...\n");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
imwrite("opencv_test_highgui_postest_actual.png", img);
|
||||
imwrite("opencv_test_highgui_postest_expected.png", img0);
|
||||
// imwrite("opencv_test_highgui_postest_actual.png", img);
|
||||
// imwrite("opencv_test_highgui_postest_expected.png", img0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ protected:
|
||||
|
||||
// Write out
|
||||
|
||||
string filename = tempfile() + ".xml";
|
||||
string filename = cv::tempfile(".xml");
|
||||
{
|
||||
FileStorage fs = FileStorage(filename, FileStorage::WRITE);
|
||||
try
|
||||
|
@ -527,7 +527,7 @@ protected:
|
||||
firstResult.at<int>(i) = static_cast<int>(em.predict(samples.row(i))[1]);
|
||||
|
||||
// Write out
|
||||
string filename = tempfile() + ".xml";
|
||||
string filename = cv::tempfile(".xml");
|
||||
{
|
||||
FileStorage fs = FileStorage(filename, FileStorage::WRITE);
|
||||
try
|
||||
|
@ -86,9 +86,6 @@ void CV_InpaintTest::run( int )
|
||||
inpaint( test, mask1ch, res1, 5, CV_INPAINT_NS );
|
||||
inpaint( test, mask1ch, res2, 5, CV_INPAINT_TELEA );
|
||||
|
||||
imwrite("d:/exp1.png", res1);
|
||||
imwrite("d:/exp2.png", res2);
|
||||
|
||||
Mat diff1, diff2;
|
||||
absdiff( orig, res1, diff1 );
|
||||
absdiff( orig, res2, diff2 );
|
||||
|
@ -37,8 +37,6 @@ for l in open("%s/api" % sys.argv[1]):
|
||||
# Validation: check that any optional arguments are last
|
||||
had_error = False
|
||||
for (f, args, ty, flags) in api:
|
||||
if f == 'PolarToCart':
|
||||
print f, [(a.init != None) for a in args]
|
||||
has_init = [(a.init != None) for a in args if not 'O' in a.flags]
|
||||
if True in has_init and not all(has_init[has_init.index(True):]):
|
||||
print 'Error in definition for "%s", optional arguments must be last' % f
|
||||
|
@ -250,7 +250,7 @@ class RunInfo(object):
|
||||
self.adb = "adb"
|
||||
if options.adb_serial:
|
||||
self.adb = [self.adb, "-s", options.adb_serial]
|
||||
else:
|
||||
else:
|
||||
self.adb = [self.adb]
|
||||
try:
|
||||
output = Popen(self.adb + ["shell", "ls"], stdout=PIPE, stderr=PIPE).communicate()
|
||||
@ -653,10 +653,11 @@ class RunInfo(object):
|
||||
elif self.targetos == "android":
|
||||
hostlogpath = ""
|
||||
usercolor = [a for a in args if a.startswith("--gtest_color=")]
|
||||
if len(userlog) == 0 and _stdout.isatty() and hostos != "nt":
|
||||
if len(usercolor) == 0 and _stdout.isatty() and hostos != "nt":
|
||||
args.append("--gtest_color=yes")
|
||||
try:
|
||||
andoidcwd = "/data/bin/" + getpass.getuser().replace(" ","") + "_" + self.options.mode +"/"
|
||||
tempdir = "/data/local/tmp/"
|
||||
andoidcwd = tempdir + getpass.getuser().replace(" ","") + "_" + self.options.mode +"/"
|
||||
exename = os.path.basename(exe)
|
||||
androidexe = andoidcwd + exename
|
||||
#upload
|
||||
@ -692,6 +693,9 @@ class RunInfo(object):
|
||||
return
|
||||
#rm log
|
||||
Popen(self.adb + ["shell", "rm " + andoidcwd + logfile], stdout=_stdout, stderr=_stderr).wait()
|
||||
|
||||
# clean temporary files
|
||||
Popen(self.adb + ["shell", "rm " + tempdir + "__opencv_temp.*"], stdout=_stdout, stderr=_stderr).wait()
|
||||
except OSError:
|
||||
pass
|
||||
if os.path.isfile(hostlogpath):
|
||||
@ -709,6 +713,17 @@ class RunInfo(object):
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
# clean temporary files
|
||||
temp_path = os.environ.get('OPENCV_TEMP_PATH')
|
||||
if not temp_path:
|
||||
if hostos == "nt":
|
||||
temp_path = tempfile.gettempdir()
|
||||
else:
|
||||
temp_path = "/tmp"
|
||||
|
||||
for filename in glob.glob(os.path.join(temp_path, "__opencv_temp.*")) :
|
||||
os.remove( filename )
|
||||
|
||||
logpath = os.path.join(workingDir, logfile)
|
||||
if os.path.isfile(logpath):
|
||||
return logpath
|
||||
|
Loading…
Reference in New Issue
Block a user