mirror of
https://github.com/opencv/opencv.git
synced 2026-07-25 05:13:04 +04:00
Compare commits
56 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d0210f510e | |||
| 34aa4e4578 | |||
| 447b8bf58a | |||
| e9539061db | |||
| ba7bf1ef68 | |||
| 5a53f41622 | |||
| 80844fd554 | |||
| a96a6bf149 | |||
| b7c9aaa471 | |||
| 00d9f690f6 | |||
| ae79fe10dc | |||
| 62fc342d35 | |||
| 36924d6dbb | |||
| e49e75da06 | |||
| 1d40946959 | |||
| 2598392295 | |||
| 17cc5e2c40 | |||
| 4b14400976 | |||
| 4704a254f7 | |||
| 7708e9882e | |||
| fe1bd0cc2f | |||
| a752f25944 | |||
| a984da911b | |||
| df55be3c3d | |||
| 55339de684 | |||
| f08dd510fa | |||
| d308ed3712 | |||
| 6d0f8aa893 | |||
| bea98bd22a | |||
| 4539607ab1 | |||
| b320138dba | |||
| 95ea12588e | |||
| bcd08b5d18 | |||
| 19298ae3cb | |||
| 5e06da3050 | |||
| 17ac18a7b9 | |||
| c259590b26 | |||
| 3f3ca85103 | |||
| 05ddc16eaa | |||
| 2ba77614aa | |||
| ef347aa6a4 | |||
| b1cdb91139 | |||
| a09ad35d98 | |||
| 1b5835cd35 | |||
| 9932bbad3a | |||
| 39ac84ff04 | |||
| fcbefaff86 | |||
| bf2256fb89 | |||
| b0b2fc9e3f | |||
| 1ccd64e102 | |||
| 23bf3e337a | |||
| 3cf265992f | |||
| 67635c6d65 | |||
| a26e496d00 | |||
| d579d3e596 | |||
| 5a77176654 |
@@ -1,8 +1,51 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*****************************************************************************************************
|
||||
USAGE:
|
||||
./opencv_annotation -images <folder location> -annotations <ouput file>
|
||||
|
||||
Created by: Puttemans Steven
|
||||
Created by: Puttemans Steven - February 2015
|
||||
*****************************************************************************************************/
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
@@ -12,6 +55,12 @@ Created by: Puttemans Steven
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
@@ -176,8 +225,33 @@ int main( int argc, const char** argv )
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the folder actually exists
|
||||
// If -1 is returned then the folder actually exists, and thus you can continue
|
||||
// In all other cases there was a folder creation and thus the folder did not exist
|
||||
#if defined(_WIN32)
|
||||
if(_mkdir(image_folder.c_str()) != -1){
|
||||
// Generate an error message
|
||||
cerr << "The image folder given does not exist. Please check again!" << endl;
|
||||
// Remove the created folder again, to ensure a second run with same code fails again
|
||||
_rmdir(image_folder.c_str());
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
if(mkdir(image_folder.c_str(), 0777) != -1){
|
||||
// Generate an error message
|
||||
cerr << "The image folder given does not exist. Please check again!" << endl;
|
||||
// Remove the created folder again, to ensure a second run with same code fails again
|
||||
remove(image_folder.c_str());
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Create the outputfilestream
|
||||
ofstream output(annotations.c_str());
|
||||
if ( !output.is_open() ){
|
||||
cerr << "The path for the output file contains an error and could not be opened. Please check again!" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Return the image filenames inside the image folder
|
||||
vector<String> filenames;
|
||||
@@ -191,6 +265,12 @@ int main( int argc, const char** argv )
|
||||
// Read in an image
|
||||
Mat current_image = imread(filenames[i]);
|
||||
|
||||
// Check if the image is actually read - avoid other files in the folder, because glob() takes them all
|
||||
// If not then simply skip this iteration
|
||||
if(current_image.empty()){
|
||||
continue;
|
||||
}
|
||||
|
||||
// Perform annotations & generate corresponding output
|
||||
stringstream output_stream;
|
||||
get_annotations(current_image, &output_stream);
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#define CV_VERSION_EPOCH 2
|
||||
#define CV_VERSION_MAJOR 4
|
||||
#define CV_VERSION_MINOR 12
|
||||
#define CV_VERSION_REVISION 0
|
||||
#define CV_VERSION_REVISION 1
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
|
||||
|
||||
@@ -1372,6 +1372,49 @@ void CV_GetQuadSubPixTest::prepare_to_validation( int /*test_case_idx*/ )
|
||||
dst.convertTo(dst0, dst0.depth());
|
||||
}
|
||||
|
||||
////////////////////////////// resizeArea /////////////////////////////////
|
||||
|
||||
template <typename T>
|
||||
static void check_resize_area(const Mat& expected, const Mat& actual, double tolerance = 1.0)
|
||||
{
|
||||
ASSERT_EQ(actual.type(), expected.type());
|
||||
ASSERT_EQ(actual.size(), expected.size());
|
||||
|
||||
Mat diff;
|
||||
absdiff(actual, expected, diff);
|
||||
|
||||
Mat one_channel_diff = diff; //.reshape(1);
|
||||
|
||||
Size dsize = actual.size();
|
||||
bool next = true;
|
||||
for (int dy = 0; dy < dsize.height && next; ++dy)
|
||||
{
|
||||
const T* eD = expected.ptr<T>(dy);
|
||||
const T* aD = actual.ptr<T>(dy);
|
||||
|
||||
for (int dx = 0; dx < dsize.width && next; ++dx)
|
||||
if (fabs(static_cast<double>(aD[dx] - eD[dx])) > tolerance)
|
||||
{
|
||||
cvtest::TS::ptr()->printf(cvtest::TS::SUMMARY, "Inf norm: %f\n", static_cast<float>(norm(actual, expected, NORM_INF)));
|
||||
cvtest::TS::ptr()->printf(cvtest::TS::SUMMARY, "Error in : (%d, %d)\n", dx, dy);
|
||||
|
||||
const int radius = 3;
|
||||
int rmin = MAX(dy - radius, 0), rmax = MIN(dy + radius, dsize.height);
|
||||
int cmin = MAX(dx - radius, 0), cmax = MIN(dx + radius, dsize.width);
|
||||
|
||||
std::cout << "Abs diff:" << std::endl << diff << std::endl;
|
||||
std::cout << "actual result:\n" << actual(Range(rmin, rmax), Range(cmin, cmax)) << std::endl;
|
||||
std::cout << "expected result:\n" << expected(Range(rmin, rmax), Range(cmin, cmax)) << std::endl;
|
||||
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_EQ(norm(one_channel_diff, cv::NORM_INF), 0);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TEST(Imgproc_cvWarpAffine, regression)
|
||||
{
|
||||
IplImage* src = cvCreateImage(cvSize(100, 100), IPL_DEPTH_8U, 1);
|
||||
@@ -1496,41 +1539,45 @@ TEST(Imgproc_resize_area, regression)
|
||||
|
||||
cv::resize(src, actual, cv::Size(), 0.3, 0.3, INTER_AREA);
|
||||
|
||||
ASSERT_EQ(actual.type(), expected.type());
|
||||
ASSERT_EQ(actual.size(), expected.size());
|
||||
check_resize_area<ushort>(expected, actual, 1.0);
|
||||
}
|
||||
|
||||
Mat diff;
|
||||
absdiff(actual, expected, diff);
|
||||
TEST(Imgproc_resize_area, regression_half_round)
|
||||
{
|
||||
static uchar input_data[32 * 32];
|
||||
for(int i = 0; i < 32 * 32; ++i)
|
||||
input_data[i] = (uchar)(i % 2 + 253 + i / (16 * 32));
|
||||
|
||||
Mat one_channel_diff = diff; //.reshape(1);
|
||||
static uchar expected_data[16 * 16];
|
||||
for(int i = 0; i < 16 * 16; ++i)
|
||||
expected_data[i] = (uchar)(254 + i / (16 * 8));
|
||||
|
||||
float elem_diff = 1.0f;
|
||||
Size dsize = actual.size();
|
||||
bool next = true;
|
||||
for (int dy = 0; dy < dsize.height && next; ++dy)
|
||||
{
|
||||
ushort* eD = expected.ptr<ushort>(dy);
|
||||
ushort* aD = actual.ptr<ushort>(dy);
|
||||
cv::Mat src(32, 32, CV_8UC1, input_data);
|
||||
cv::Mat expected(16, 16, CV_8UC1, expected_data);
|
||||
cv::Mat actual(expected.size(), expected.type());
|
||||
|
||||
for (int dx = 0; dx < dsize.width && next; ++dx)
|
||||
if (fabs(static_cast<float>(aD[dx] - eD[dx])) > elem_diff)
|
||||
{
|
||||
cvtest::TS::ptr()->printf(cvtest::TS::SUMMARY, "Inf norm: %f\n", static_cast<float>(norm(actual, expected, NORM_INF)));
|
||||
cvtest::TS::ptr()->printf(cvtest::TS::SUMMARY, "Error in : (%d, %d)\n", dx, dy);
|
||||
cv::resize(src, actual, cv::Size(), 0.5, 0.5, INTER_AREA);
|
||||
|
||||
const int radius = 3;
|
||||
int rmin = MAX(dy - radius, 0), rmax = MIN(dy + radius, dsize.height);
|
||||
int cmin = MAX(dx - radius, 0), cmax = MIN(dx + radius, dsize.width);
|
||||
check_resize_area<uchar>(expected, actual, 0.5);
|
||||
}
|
||||
|
||||
std::cout << "Abs diff:" << std::endl << diff << std::endl;
|
||||
std::cout << "actual result:\n" << actual(Range(rmin, rmax), Range(cmin, cmax)) << std::endl;
|
||||
std::cout << "expected result:\n" << expected(Range(rmin, rmax), Range(cmin, cmax)) << std::endl;
|
||||
TEST(Imgproc_resize_area, regression_quarter_round)
|
||||
{
|
||||
static uchar input_data[32 * 32];
|
||||
for(int i = 0; i < 32 * 32; ++i)
|
||||
input_data[i] = (uchar)(i % 2 + 253 + i / (16 * 32));
|
||||
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
static uchar expected_data[8 * 8];
|
||||
for(int i = 0; i < 8 * 8; ++i)
|
||||
expected_data[i] = 254;
|
||||
|
||||
ASSERT_EQ(norm(one_channel_diff, cv::NORM_INF), 0);
|
||||
cv::Mat src(32, 32, CV_8UC1, input_data);
|
||||
cv::Mat expected(8, 8, CV_8UC1, expected_data);
|
||||
cv::Mat actual(expected.size(), expected.type());
|
||||
|
||||
cv::resize(src, actual, cv::Size(), 0.25, 0.25, INTER_AREA);
|
||||
|
||||
check_resize_area<uchar>(expected, actual, 0.5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -777,7 +777,8 @@ cvGetTrainSamples( const CvMat* train_data, int tflag,
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
int i, j, var_count, sample_count, s_step, v_step;
|
||||
int i, j, var_count, sample_count;
|
||||
size_t s_step, v_step, s;
|
||||
bool copy_data;
|
||||
const float* data;
|
||||
const int *s_idx, *v_idx;
|
||||
@@ -815,7 +816,7 @@ cvGetTrainSamples( const CvMat* train_data, int tflag,
|
||||
{
|
||||
samples[0] = (float*)(samples + sample_count);
|
||||
if( tflag != CV_ROW_SAMPLE )
|
||||
CV_SWAP( s_step, v_step, i );
|
||||
CV_SWAP( s_step, v_step, s );
|
||||
|
||||
for( i = 0; i < sample_count; i++ )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user