Merge remote-tracking branch 'upstream/master' into rho
This commit is contained in:
@@ -256,7 +256,6 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
||||
*out_corner_count = 0;
|
||||
|
||||
IplImage _img;
|
||||
int check_chessboard_result;
|
||||
int quad_count = 0, group_idx = 0, dilations = 0;
|
||||
|
||||
img = cvGetMat( img, &stub );
|
||||
@@ -302,7 +301,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
|
||||
if( flags & CV_CALIB_CB_FAST_CHECK)
|
||||
{
|
||||
cvGetImage(img, &_img);
|
||||
check_chessboard_result = cvCheckChessboard(&_img, pattern_size);
|
||||
int check_chessboard_result = cvCheckChessboard(&_img, pattern_size);
|
||||
if(check_chessboard_result <= 0)
|
||||
{
|
||||
return 0;
|
||||
@@ -1144,7 +1143,6 @@ icvCleanFoundConnectedQuads( int quad_count, CvCBQuad **quad_group, CvSize patte
|
||||
{
|
||||
double min_box_area = DBL_MAX;
|
||||
int skip, min_box_area_index = -1;
|
||||
CvCBQuad *q0, *q;
|
||||
|
||||
// For each point, calculate box area without that point
|
||||
for( skip = 0; skip < quad_count; skip++ )
|
||||
@@ -1166,12 +1164,12 @@ icvCleanFoundConnectedQuads( int quad_count, CvCBQuad **quad_group, CvSize patte
|
||||
cvClearMemStorage( temp_storage );
|
||||
}
|
||||
|
||||
q0 = quad_group[min_box_area_index];
|
||||
CvCBQuad *q0 = quad_group[min_box_area_index];
|
||||
|
||||
// remove any references to this quad as a neighbor
|
||||
for( i = 0; i < quad_count; i++ )
|
||||
{
|
||||
q = quad_group[i];
|
||||
CvCBQuad *q = quad_group[i];
|
||||
for( j = 0; j < 4; j++ )
|
||||
{
|
||||
if( q->neighbors[j] == q0 )
|
||||
|
||||
@@ -118,7 +118,6 @@ static CvStatus icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints,
|
||||
int count = 0, converged = 0;
|
||||
float inorm, jnorm, invInorm, invJnorm, invScale, scale = 0, inv_Z = 0;
|
||||
float diff = (float)criteria.epsilon;
|
||||
float inv_focalLength = 1 / focalLength;
|
||||
|
||||
/* Check bad arguments */
|
||||
if( imagePoints == NULL )
|
||||
@@ -139,6 +138,7 @@ static CvStatus icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints,
|
||||
return CV_BADFACTOR_ERR;
|
||||
|
||||
/* init variables */
|
||||
float inv_focalLength = 1 / focalLength;
|
||||
int N = pObject->N;
|
||||
float *objectVectors = pObject->obj_vecs;
|
||||
float *invMatrix = pObject->inv_matr;
|
||||
|
||||
@@ -285,7 +285,7 @@ In addition to the class members, the following operations on rectangles are imp
|
||||
|
||||
* ``rect = rect1 & rect2`` (rectangle intersection)
|
||||
|
||||
* ``rect = rect1 | rect2`` (minimum area rectangle containing ``rect2`` and ``rect3`` )
|
||||
* ``rect = rect1 | rect2`` (minimum area rectangle containing ``rect1`` and ``rect2`` )
|
||||
|
||||
* ``rect &= rect1, rect |= rect1`` (and the corresponding augmenting operations)
|
||||
|
||||
|
||||
@@ -634,18 +634,12 @@ sub-matrices.
|
||||
Mat M = Mat(3, 3, CV_64F, m).inv();
|
||||
@endcode
|
||||
.
|
||||
Partial yet very common cases of this *user-allocated data* case are conversions from CvMat and
|
||||
IplImage to Mat. For this purpose, there are special constructors taking pointers to CvMat or
|
||||
IplImage and the optional flag indicating whether to copy the data or not. Backward conversion from
|
||||
Mat to CvMat or IplImage is provided via cast operators Mat::operator CvMat() const and
|
||||
Mat::operator IplImage(). The operators do NOT copy the data.
|
||||
@code
|
||||
IplImage* img = cvLoadImage("greatwave.jpg", 1);
|
||||
Mat mtx(img); // convert IplImage* -> Mat
|
||||
CvMat oldmat = mtx; // convert Mat -> CvMat
|
||||
CV_Assert(oldmat.cols == img->width && oldmat.rows == img->height &&
|
||||
oldmat.data.ptr == (uchar*)img->imageData && oldmat.step == img->widthStep);
|
||||
@endcode
|
||||
Partial yet very common cases of this *user-allocated data* case are conversions from CvMat and
|
||||
IplImage to Mat. For this purpose, there is function cv::cvarrToMat taking pointers to CvMat or
|
||||
IplImage and the optional flag indicating whether to copy the data or not.
|
||||
@dontinclude samples/cpp/image.cpp
|
||||
@skip Ptr<IplImage> iplimg
|
||||
@until is converted, while the data is shared
|
||||
|
||||
- Use MATLAB-style array initializers, zeros(), ones(), eye(), for example:
|
||||
@code
|
||||
|
||||
@@ -356,7 +356,7 @@ In addition to the class members, the following operations on rectangles are imp
|
||||
certain amount)
|
||||
- rect += point, rect -= point, rect += size, rect -= size (augmenting operations)
|
||||
- rect = rect1 & rect2 (rectangle intersection)
|
||||
- rect = rect1 | rect2 (minimum area rectangle containing rect2 and rect3 )
|
||||
- rect = rect1 | rect2 (minimum area rectangle containing rect1 and rect2 )
|
||||
- rect &= rect1, rect |= rect1 (and the corresponding augmenting operations)
|
||||
- rect == rect1, rect != rect1 (rectangle comparison)
|
||||
|
||||
|
||||
@@ -846,7 +846,7 @@ static bool ocl_repeat(InputArray _src, int ny, int nx, OutputArray _dst)
|
||||
|
||||
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type),
|
||||
rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1,
|
||||
kercn = std::min(ocl::predictOptimalVectorWidth(_src, _dst), 4);
|
||||
kercn = ocl::predictOptimalVectorWidth(_src, _dst);
|
||||
|
||||
ocl::Kernel k("repeat", ocl::core::repeat_oclsrc,
|
||||
format("-D T=%s -D nx=%d -D ny=%d -D rowsPerWI=%d -D cn=%d",
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
|
||||
#ifndef WIN32
|
||||
|
||||
@@ -1629,18 +1630,110 @@ CV_IMPL const char* cvGetWindowName( void* window_handle )
|
||||
return window_name;
|
||||
}
|
||||
|
||||
static GtkFileFilter* icvMakeGtkFilter(const char* name, const char* patterns, GtkFileFilter* images)
|
||||
{
|
||||
GtkFileFilter* filter = gtk_file_filter_new();
|
||||
gtk_file_filter_set_name(filter, name);
|
||||
|
||||
while(patterns[0])
|
||||
{
|
||||
gtk_file_filter_add_pattern(filter, patterns);
|
||||
gtk_file_filter_add_pattern(images, patterns);
|
||||
patterns += strlen(patterns) + 1;
|
||||
}
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
static void icvShowSaveAsDialog(GtkWidget* widget, CvWindow* window)
|
||||
{
|
||||
if (!window || !widget)
|
||||
return;
|
||||
|
||||
CvImageWidget* image_widget = CV_IMAGE_WIDGET(window->widget);
|
||||
if (!image_widget || !image_widget->original_image)
|
||||
return;
|
||||
|
||||
GtkWidget* dialog = gtk_file_chooser_dialog_new("Save As...",
|
||||
GTK_WINDOW(widget),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
|
||||
|
||||
cv::String sname = gtk_window_get_title(GTK_WINDOW(window->frame));
|
||||
sname = sname.substr(sname.find_last_of("\\/") + 1) + ".png";
|
||||
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), sname.c_str());
|
||||
|
||||
GtkFileFilter* filter_all = gtk_file_filter_new();
|
||||
gtk_file_filter_set_name(filter_all, "All Files");
|
||||
gtk_file_filter_add_pattern(filter_all, "*");
|
||||
|
||||
GtkFileFilter* filter_images = gtk_file_filter_new();
|
||||
gtk_file_filter_set_name(filter_images, "All Images");
|
||||
|
||||
GtkFileFilter* file_filters[] = {
|
||||
icvMakeGtkFilter("Portable Network Graphics files (*.png)", "*.png\0", filter_images),
|
||||
icvMakeGtkFilter("JPEG files (*.jpeg;*.jpg;*.jpe)", "*.jpeg\0*.jpg\0*.jpe\0", filter_images),
|
||||
icvMakeGtkFilter("Windows bitmap (*.bmp;*.dib)", "*.bmp\0*.dib\0", filter_images),
|
||||
icvMakeGtkFilter("TIFF Files (*.tiff;*.tif)", "*.tiff\0*.tif\0", filter_images),
|
||||
icvMakeGtkFilter("JPEG-2000 files (*.jp2)", "*.jp2\0", filter_images),
|
||||
icvMakeGtkFilter("WebP files (*.webp)", "*.webp\0", filter_images),
|
||||
icvMakeGtkFilter("Portable image format (*.pbm;*.pgm;*.ppm;*.pxm;*.pnm)", "*.pbm\0*.pgm\0*.ppm\0*.pxm\0*.pnm\0", filter_images),
|
||||
icvMakeGtkFilter("OpenEXR Image files (*.exr)", "*.exr\0", filter_images),
|
||||
icvMakeGtkFilter("Radiance HDR (*.hdr;*.pic)", "*.hdr\0*.pic\0", filter_images),
|
||||
icvMakeGtkFilter("Sun raster files (*.sr;*.ras)", "*.sr\0*.ras\0", filter_images),
|
||||
filter_images,
|
||||
filter_all
|
||||
};
|
||||
|
||||
for (size_t idx = 0; idx < sizeof(file_filters)/sizeof(file_filters[0]); ++idx)
|
||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), file_filters[idx]);
|
||||
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter_images);
|
||||
|
||||
cv::String filename;
|
||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
char* fname = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
||||
filename = fname;
|
||||
g_free(fname);
|
||||
}
|
||||
gtk_widget_destroy(dialog);
|
||||
|
||||
if (!filename.empty())
|
||||
{
|
||||
cv::Mat bgr;
|
||||
cv::cvtColor(cv::cvarrToMat(image_widget->original_image), bgr, cv::COLOR_RGB2BGR);
|
||||
cv::imwrite(filename, bgr);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (GTK_VERSION3)
|
||||
#define GDK_Escape GDK_KEY_Escape
|
||||
#define GDK_Return GDK_KEY_Return
|
||||
#define GDK_Linefeed GDK_KEY_Linefeed
|
||||
#define GDK_Tab GDK_KEY_Tab
|
||||
#define GDK_s GDK_KEY_s
|
||||
#define GDK_S GDK_KEY_S
|
||||
#endif //GTK_VERSION3
|
||||
|
||||
static gboolean icvOnKeyPress( GtkWidget * /*widget*/,
|
||||
GdkEventKey* event, gpointer /*user_data*/ )
|
||||
static gboolean icvOnKeyPress(GtkWidget* widget, GdkEventKey* event, gpointer user_data)
|
||||
{
|
||||
int code = 0;
|
||||
|
||||
if ( (event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK && (event->keyval == GDK_s || event->keyval == GDK_S))
|
||||
{
|
||||
try
|
||||
{
|
||||
icvShowSaveAsDialog(widget, (CvWindow*)user_data);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
// suppress all exceptions here
|
||||
}
|
||||
}
|
||||
|
||||
switch( event->keyval )
|
||||
{
|
||||
case GDK_Escape:
|
||||
|
||||
@@ -1840,7 +1840,6 @@ cvDestroyAllWindows(void)
|
||||
|
||||
static void showSaveDialog(CvWindow* window)
|
||||
{
|
||||
#ifndef HAVE_OPENGL
|
||||
if (!window || !window->image)
|
||||
return;
|
||||
|
||||
@@ -1884,9 +1883,6 @@ static void showSaveDialog(CvWindow* window)
|
||||
cv::Mat tmp; cv::flip(cv::Mat(sz.cy, sz.cx, CV_8UC(channels), data), tmp, 0);
|
||||
cv::imwrite(szFileName, tmp);
|
||||
}
|
||||
#else
|
||||
(void)window;
|
||||
#endif // HAVE_OPENGL
|
||||
}
|
||||
|
||||
CV_IMPL int
|
||||
|
||||
@@ -15,6 +15,7 @@ import operator
|
||||
import functools
|
||||
import numpy as np
|
||||
import cv2
|
||||
import argparse
|
||||
|
||||
# Python 3 moved urlopen to urllib.requests
|
||||
try:
|
||||
@@ -24,9 +25,21 @@ except ImportError:
|
||||
|
||||
class NewOpenCVTests(unittest.TestCase):
|
||||
|
||||
# path to local repository folder containing 'samples' folder
|
||||
repoPath = None
|
||||
# github repository url
|
||||
repoUrl = 'https://raw.github.com/Itseez/opencv/master'
|
||||
|
||||
def get_sample(self, filename, iscolor = cv2.IMREAD_COLOR):
|
||||
if not filename in self.image_cache:
|
||||
filedata = urlopen("https://raw.github.com/Itseez/opencv/master/" + filename).read()
|
||||
filedata = None
|
||||
if NewOpenCVTests.repoPath is not None:
|
||||
candidate = NewOpenCVTests.repoPath + '/' + filename
|
||||
if os.path.isfile(candidate):
|
||||
with open(candidate, 'rb') as f:
|
||||
filedata = f.read()
|
||||
if filedata is None:
|
||||
filedata = urlopen(NewOpenCVTests.repoUrl + '/' + filename).read()
|
||||
self.image_cache[filename] = cv2.imdecode(np.fromstring(filedata, dtype=np.uint8), iscolor)
|
||||
return self.image_cache[filename]
|
||||
|
||||
@@ -133,6 +146,15 @@ class Hackathon244Tests(NewOpenCVTests):
|
||||
self.assertLessEqual(abs(mr - mr0), 5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='run OpenCV python tests')
|
||||
parser.add_argument('--repo', help='use sample image files from local git repository (path to folder), '
|
||||
'if not set, samples will be downloaded from github.com')
|
||||
parser.add_argument('--data', help='<not used> use data files from local folder (path to folder), '
|
||||
'if not set, data files will be downloaded from docs.opencv.org')
|
||||
args, other = parser.parse_known_args()
|
||||
print("Testing OpenCV", cv2.__version__)
|
||||
print("Local repo path:", args.repo)
|
||||
NewOpenCVTests.repoPath = args.repo
|
||||
random.seed(0)
|
||||
unittest.main()
|
||||
unit_argv = [sys.argv[0]] + other;
|
||||
unittest.main(argv=unit_argv)
|
||||
|
||||
Reference in New Issue
Block a user